/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface2: #1a1a1a;
  --border: #2a2a2a;
  --border-bright: #444;
  --text: #f0f0f0;
  --text-dim: #888;
  --text-dimmer: #555;
  --accent: #ffffff;
  --accent-dim: #cccccc;
  --green: #4cff91;
  --red: #ff4c4c;
  --yellow: #ffd54c;
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'Courier New', Courier, monospace;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--text-dim); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--text); }

.hidden { display: none !important; }

/* ===== GATE SCREEN ===== */
#gate-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#gate-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#gate-logo {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -2px;
  color: var(--accent);
}

#gate-sub {
  font-size: 12px;
  color: var(--text-dimmer);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

#gate-desc {
  color: var(--text-dim);
  font-size: 14px;
}

#gate-error {
  color: var(--red);
  font-size: 13px;
}

/* ===== HEADER ===== */
#main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

#header-left { display: flex; align-items: center; gap: 12px; }

#header-logo {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -1px;
  color: var(--accent);
}

#header-tagline {
  font-size: 12px;
  color: var(--text-dimmer);
  display: none;
}

@media (min-width: 500px) {
  #header-tagline { display: block; }
}

#header-right { display: flex; align-items: center; gap: 16px; }

.header-link {
  font-size: 13px;
  color: var(--text-dim);
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.header-link:hover {
  color: var(--text);
  border-color: var(--border-bright);
  background: var(--surface2);
}

.discord-link { color: #7289da; border-color: #7289da33; }
.discord-link:hover { background: #7289da18; border-color: #7289da; color: #7289da; }

/* ===== NAV ===== */
#main-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 24px;
  overflow-x: auto;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  font-family: var(--font);
  padding: 14px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-btn:hover { color: var(--text); }
.nav-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== CC BANNER ===== */
#cc-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  flex-wrap: wrap;
}

#cc-banner span:first-child { color: var(--text-dim); }

#cc-display {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: bold;
  color: var(--accent);
  letter-spacing: 2px;
  background: var(--surface);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

#cc-copy-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

#cc-copy-btn:hover { color: var(--text); border-color: var(--border-bright); }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-left: auto;
  flex-shrink: 0;
}

.status-dot.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.disconnected { background: var(--red); }
.status-dot.connecting { background: var(--yellow); animation: pulse 1s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ===== MAIN CONTENT ===== */
#main-content {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px;
}

.section { display: flex; flex-direction: column; gap: 16px; }
.section.hidden { display: none; }

/* ===== INFO BOX ===== */
.info-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--yellow);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-dim);
}

/* ===== CHAT ===== */
#chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 4px 0;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 85%;
}

.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.arena { align-self: flex-start; align-items: flex-start; }

.chat-msg-role {
  font-size: 11px;
  color: var(--text-dimmer);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.chat-msg-bubble {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.user .chat-msg-bubble {
  background: var(--surface);
  border-color: var(--border-bright);
}

.chat-msg-time { font-size: 10px; color: var(--text-dimmer); }

#chat-input-area {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 12px 16px;
  resize: none;
  transition: border-color 0.2s;
  outline: none;
}

#chat-input:focus { border-color: var(--border-bright); }

#chat-send-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 12px 22px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}

#chat-send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
#chat-send-btn:not(:disabled):hover { opacity: 0.85; }

/* ===== FILES ===== */
#files-livefeed {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

#livefeed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}

#livefeed-status { font-size: 12px; color: var(--text-dim); font-weight: 400; }

#livefeed-log {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 14px 16px;
  min-height: 80px;
  max-height: 180px;
  overflow-y: auto;
  line-height: 1.8;
}

.log-line { display: flex; gap: 10px; }
.log-line .log-time { color: var(--text-dimmer); flex-shrink: 0; }
.log-line .log-text.found { color: var(--green); }
.log-line .log-text.info { color: var(--text-dim); }
.log-line .log-text.done { color: var(--accent); font-weight: bold; }
.log-line .log-text.error { color: var(--red); }

#files-list-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 80px;
}

#files-empty { color: var(--text-dimmer); font-size: 13px; text-align: center; padding: 20px 0; }

#files-list { display: flex; flex-direction: column; gap: 8px; }

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  gap: 10px;
}

.file-item-name {
  font-family: var(--mono);
  color: var(--text);
  flex: 1;
}

.file-item-size { color: var(--text-dimmer); font-size: 11px; }

.file-item-preview-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.file-item-preview-btn:hover { color: var(--text); border-color: var(--border-bright); }

#files-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

#project-name-input {
  flex: 1;
  min-width: 160px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
}

#project-name-input:focus { border-color: var(--border-bright); }

#download-zip-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}

#download-zip-btn:hover { opacity: 0.85; }

/* ===== FILE MODAL ===== */
#file-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#file-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#file-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

#file-modal-title { font-family: var(--mono); font-size: 14px; font-weight: bold; }

#file-modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
}

#file-modal-close:hover { color: var(--text); }

#file-modal-content {
  overflow-y: auto;
  padding: 16px 18px;
}

#file-modal-content pre {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ===== BOOKMARKLET ===== */
.bm-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bm-block h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.bm-block p, .bm-block li {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.7;
}

#bm-guide {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#bm-guide strong { color: var(--text); }

/* BM Visual Preview */
#bm-visual-preview {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}

.bm-preview-ui {
  background: #0d0d0d;
  border: 1px solid #333;
  border-radius: 12px;
  width: 280px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.bm-preview-header {
  background: #1a1a1a;
  border-bottom: 1px solid #2a2a2a;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
}

.bm-preview-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bm-preview-status {
  font-size: 12px;
  color: var(--red);
}

.bm-preview-input {
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  color: #888;
  font-size: 13px;
  padding: 8px 10px;
  width: 100%;
  outline: none;
}

.bm-preview-btn {
  background: #fff;
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 9px;
  font-weight: 700;
  font-size: 13px;
  cursor: default;
  width: 100%;
}

.bm-preview-log {
  font-size: 11px;
  color: #555;
  font-family: var(--mono);
}

/* BM Code Preview */
#bm-code-preview-wrap {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 200px;
}

#bm-code-preview {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
}

#bm-copy-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s;
  align-self: flex-start;
}

#bm-copy-btn:hover { opacity: 0.85; }

#bm-copy-confirm {
  font-size: 13px;
  color: var(--green);
  align-self: center;
}

/* ===== FOOTER ===== */
#main-footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 12px;
  color: var(--text-dimmer);
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

#main-footer a { color: var(--text-dim); }
#main-footer a:hover { color: var(--text); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #666; }
