:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-hover: #181818;
  --border: #2a2a2a;
  --border-strong: #3c3c3c;
  --text: #ffffff;
  --text-muted: #aaaaaa;
  --text-dim: #767676;
  --error: #e05252;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#root { height: 100vh; display: flex; flex-direction: column; }

/* ─── AUTH ─────────────────────────────────────────────────────────────────── */
.auth-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-height: 100vh;
}

.auth-box {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.auth-logo img { width: 38px; height: 38px; }

.auth-logo span {
  font-family: 'Times New Roman', Times, serif;
  font-size: 22px;
  font-weight: 700;
}

.auth-title { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }

.auth-sub { font-size: 14px; color: var(--text-muted); line-height: 1.5; }
.auth-sub strong { color: var(--text); }

form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 15px;
  font-size: 15px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.input:focus { border-color: #444; }
.input::placeholder { color: var(--text-dim); }

.btn-primary {
  width: 100%;
  background: #fff;
  color: #000;
  border: none;
  border-radius: 10px;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover:not(:disabled) { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-link {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s;
}

.btn-link:hover:not(:disabled) { color: var(--text-muted); }
.btn-link:disabled { opacity: 0.4; cursor: not-allowed; }

.form-error { font-size: 13px; color: var(--error); min-height: 16px; text-align: left; }

/* OTP */
.otp-wrap { display: flex; gap: 8px; justify-content: center; margin: 6px 0; }

.otp-input {
  width: 48px;
  height: 58px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  caret-color: transparent;
}

.otp-input:focus { border-color: #444; }

/* ─── APP SHELL ─────────────────────────────────────────────────────────────── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ─── SIDEBAR ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: 56px;
  background: #111;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  flex-shrink: 0;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar.open { width: 180px; align-items: flex-start; }

.hamburger {
  width: 36px;
  height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  border-radius: 8px;
  border: none;
  background: transparent;
  flex-shrink: 0;
  transition: background 0.15s;
  margin-bottom: 12px;
  margin-left: 10px;
}

.hamburger:hover { background: #1a1a1a; }

.hamburger span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: #707070;
  border-radius: 2px;
  transition: background 0.15s;
}

.hamburger:hover span { background: #aaa; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  margin-bottom: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s 0.08s;
  white-space: nowrap;
}

.sidebar.open .sidebar-logo { opacity: 1; pointer-events: auto; }
.sidebar-logo img { width: 24px; height: 24px; flex-shrink: 0; }

.sidebar-logo span {
  font-family: 'Times New Roman', Times, serif;
  font-size: 14px;
  font-weight: 700;
}

.nav-group { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 0 10px; }

.nav-item {
  height: 38px;
  display: flex;
  align-items: center;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  color: #707070;
  padding: 0 9px;
  gap: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  background: transparent;
  border: none;
  font-family: inherit;
  text-align: left;
  width: 100%;
}

.nav-item:hover { background: #1a1a1a; color: #b0b0b0; }
.nav-item.active { background: #1e1e1e; color: #fff; }

.nav-item svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.7;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.nav-item .label {
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.12s 0.04s;
  pointer-events: none;
}

.sidebar.open .nav-item .label { opacity: 1; }
.sidebar .spacer { flex: 1; }

.sidebar-footer { padding: 0 10px; width: 100%; display: flex; align-items: center; gap: 9px; }

.avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  background: #222;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: #888;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.avatar:hover { background: #2e2e2e; color: #bbb; }

.avatar-label {
  font-size: 11px;
  color: #666666;
  opacity: 0;
  transition: opacity 0.12s 0.04s;
  white-space: nowrap;
}

.sidebar.open .avatar-label { opacity: 1; }

/* ─── MAIN ──────────────────────────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.page-title {
  font-family: 'Times New Roman', Times, serif;
  font-size: 17px;
  font-weight: 700;
}

.user-tag {
  font-size: 11px;
  color: #888;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.content { flex: 1; overflow-y: auto; padding: 20px; }

/* ─── HUB CONTENT ───────────────────────────────────────────────────────────── */
.section-sub { font-size: 12px; color: var(--text-dim); margin-bottom: 20px; }

.cat-label {
  font-size: 9px;
  font-weight: 600;
  color: #666666;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 8px;
  margin-top: 20px;
}

.cat-label:first-of-type { margin-top: 0; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.card:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.card .icon { font-size: 20px; margin-bottom: 2px; }
.card .name { font-size: 12px; font-weight: 600; color: #eeeeee; line-height: 1.3; }
.card .desc { font-size: 11px; color: var(--text-dim); line-height: 1.4; }

.card.soon { opacity: 0.3; cursor: default; }
.card.soon:hover { border-color: var(--border); background: var(--surface); }
.soon-tag { font-size: 10px; color: #666666; }

/* Videos */
.video-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}

.video-card:not(.soon):hover { border-color: var(--border-strong); }
.video-card.soon { opacity: 0.25; cursor: default; }

.video-thumb {
  height: 80px;
  background: #161616;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-thumb svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: #2a2a2a;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.video-info { padding: 10px 12px; }
.video-title { font-size: 11px; font-weight: 600; color: #bbb; margin-bottom: 3px; }
.video-meta { font-size: 10px; color: var(--text-dim); }

/* Conversations */
.conv-list { display: flex; flex-direction: column; gap: 8px; }

.conv-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  transition: border-color 0.15s;
}

.conv-item:hover { border-color: var(--border-strong); }
.conv-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

.conv-body { flex: 1; min-width: 0; }
.conv-tool { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 3px; }

.conv-preview {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-time { font-size: 10px; color: #666666; flex-shrink: 0; white-space: nowrap; }

/* ─── TOOL / CHAT ────────────────────────────────────────────────────────────── */
.tool-header { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.tool-desc { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.back-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.back-btn:hover { background: #1a1a1a; }

.back-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: #555;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-new-chat {
  font-size: 12px;
  font-weight: 500;
  color: #888;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-new-chat:hover { background: #fff; color: #000; border-color: #fff; }

.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  transition: background 0.15s;
}

.chat-area.drag-over {
  background: #161616;
  outline: 2px dashed #2a2a2a;
  outline-offset: -8px;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
  text-align: center;
}

.chat-empty-icon { font-size: 44px; opacity: 0.4; }
.chat-empty p { font-size: 14px; }

.messages { display: flex; flex-direction: column; gap: 16px; }

.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.msg-assistant { justify-content: flex-start; }

.bubble {
  max-width: 76%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}

.msg-user .bubble {
  background: #fff;
  color: #000;
  border-radius: 12px 12px 2px 12px;
  white-space: pre-wrap;
}

.msg-assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: #ddd;
  border-radius: 12px 12px 12px 2px;
}

.msg-assistant .bubble p { margin: 0 0 4px; }
.msg-assistant .bubble b, .msg-assistant .bubble strong { color: #fff; font-weight: 600; }
.msg-assistant .bubble code { background: #1a1a1a; border-radius: 4px; padding: 1px 5px; font-family: monospace; font-size: 13px; color: #bbb; }
.msg-assistant .bubble pre { background: #1a1a1a; border-radius: 8px; padding: 12px; overflow-x: auto; margin: 6px 0; }
.msg-assistant .bubble pre code { padding: 0; background: none; }
.msg-assistant .bubble hr { border: none; border-top: 1px solid #2a2a2a; margin: 10px 0; }
.msg-assistant .bubble .md-h1 { font-size: 15px; font-weight: 700; color: #fff; }
.msg-assistant .bubble .md-h2 { font-size: 14px; font-weight: 600; color: #eee; }
.msg-assistant .bubble .md-h3 { font-size: 13px; font-weight: 600; color: #ddd; }
.msg-assistant .bubble ul, .msg-assistant .bubble ol { padding-left: 18px; margin: 4px 0; }
.msg-assistant .bubble li { margin-bottom: 3px; }
.bubble.error { color: var(--error) !important; }

.chat-input-wrap {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.attach-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.attach-btn:hover { background: #1a1a1a; border-color: var(--border-strong); }

.attach-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: #555;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mic-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.mic-btn:hover { background: #1a1a1a; border-color: var(--border-strong); }

.mic-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: #555;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mic-btn.listening {
  border-color: #e05252;
  animation: mic-pulse 1.2s ease-in-out infinite;
}

.mic-btn.listening svg { stroke: #e05252; }

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 82, 82, 0.3); }
  50%       { box-shadow: 0 0 0 6px rgba(224, 82, 82, 0); }
}

.image-preview {
  display: none;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.image-preview img {
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  max-width: 120px;
}

.remove-img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #2a2a2a;
  border: none;
  color: #888;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.remove-img:hover { background: #3a3a3a; color: #ccc; }

.msg-image {
  max-width: 200px;
  border-radius: 8px;
  display: block;
  margin-bottom: 6px;
}

.chat-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  resize: none;
  transition: border-color 0.15s;
  max-height: 160px;
  overflow-y: auto;
  line-height: 1.5;
}

.chat-input:focus { border-color: #333; }
.chat-input::placeholder { color: var(--text-dim); }

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.send-btn:hover:not(:disabled) { opacity: 0.88; }
.send-btn:disabled { opacity: 0.25; cursor: not-allowed; }

.send-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: #000;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ─── SCROLLBAR ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #252525; border-radius: 2px; }
