:root {
  --bg: #0b1117;
  --surface: #121b24;
  --surface-2: #182430;
  --border: #253545;
  --text: #edf2f7;
  --muted: #93a4b7;
  --primary: #34d399;
  --primary-ink: #052e23;
  --accent: #38bdf8;
  --danger: #f87171;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

h1, h2, h3 {
  margin: 0 0 0.65rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 0.4rem; }

.muted { color: var(--muted); font-size: 0.92rem; }
.small { font-size: 0.85rem; }

/* Auth */
.auth-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.brand-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

/* App Shell */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: 76px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 17, 23, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.logo-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.7);
}

.topbar-sub {
  font-size: 0.76rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.main-content {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  flex: 1;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.tab-panel.active {
  display: flex;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 1rem;
}

.grid-two-asym {
  display: grid;
  grid-template-columns: minmax(290px, 380px) 1fr;
  gap: 1rem;
}

@media (max-width: 840px) {
  .grid-two-asym {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  font: inherit;
  font-size: 0.95rem;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(52, 211, 153, 0.45);
  border-color: var(--primary);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.68rem 1rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.08s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-accent { background: var(--accent); color: #082032; }
.btn-danger { background: rgba(248, 113, 113, 0.16); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.4); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.82rem; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.pill-ok {
  color: var(--primary);
  border-color: rgba(52, 211, 153, 0.45);
}

.box, .markdown-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  white-space: pre-wrap;
  font-size: 0.92rem;
}

.error-box {
  background: rgba(248, 113, 113, 0.14);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: #fecaca;
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  font-size: 0.88rem;
}

.status-msg {
  margin-top: 0.6rem;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.35);
  font-size: 0.88rem;
}

.sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.9rem 0;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.checkbox-row input {
  width: auto;
}

/* Voice meter */
.voice-meter {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.metric {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}

.metric-label {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
}

.level-bar-wrap {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.7rem;
}

.level-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.08s linear;
}

/* Chat */
.chat-card {
  display: flex;
  flex-direction: column;
  min-height: 460px;
}

.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 440px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.msg {
  max-width: 88%;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  font-size: 0.94rem;
  white-space: pre-wrap;
}

.msg-user {
  align-self: flex-end;
  background: rgba(52, 211, 153, 0.16);
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.msg-assistant {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.msg-meta {
  font-size: 0.73rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  align-items: flex-end;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: rgba(11, 17, 23, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 0.35rem 0.35rem calc(0.35rem + env(safe-area-inset-bottom));
  gap: 0.25rem;
}

.nav-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 10px;
  padding: 0.6rem 0.25rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.nav-btn.active {
  background: rgba(52, 211, 153, 0.14);
  color: var(--primary);
}

.item-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.12rem 0.35rem;
  border-radius: 6px;
  font-size: 0.84em;
}
