/* Mobile-first: base rules target ~375px, scaled up via min-width query. */

* { box-sizing: border-box; }

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1b1f28;
  --text-muted: #5a6270;
  --border: #dde1e7;
  --accent: #2f5fd6;
  --accent-text: #ffffff;
  --error: #b3261e;
  --error-bg: #fdecea;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---- Auth pages (login / onboard / invalid) ---- */

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: 12px;
  padding: 28px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.auth-card h1 {
  font-size: 1.3rem;
  margin: 0 0 4px;
}

.auth-sub {
  color: var(--text-muted);
  margin: 0 0 20px;
  font-size: 0.9rem;
}

.auth-form { display: flex; flex-direction: column; gap: 6px; }

.auth-form label { font-size: 0.85rem; font-weight: 600; margin-top: 10px; }

.auth-form input {
  padding: 12px;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
}

.auth-form button {
  margin-top: 18px;
  padding: 14px;
  min-height: 44px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}

.auth-form button:disabled { opacity: 0.6; cursor: default; }

.auth-hint { font-size: 0.8rem; color: var(--text-muted); margin: 2px 0 0; }

.auth-note { font-size: 0.8rem; color: var(--text-muted); margin-top: 20px; text-align: center; }

.error {
  color: var(--error);
  background: var(--error-bg);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin: 0 0 12px;
}

/* ---- App shell ---- */

.shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-toggle {
  min-width: 44px;
  min-height: 44px;
  font-size: 1.2rem;
  background: none;
  border: none;
  cursor: pointer;
}

.topbar-title { font-weight: 600; flex: 1; }

.logout-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 10px;
}

.sidebar {
  display: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.sidebar.is-open { display: block; }

.nav-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  width: 100%;
  text-align: left;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 0.95rem;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
}

.nav-item.is-active {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.content { padding: 20px 16px 40px; flex: 1; }

.content h2 { margin-top: 0; font-size: 1.15rem; }

.coming-soon { color: var(--text-muted); }

.panel-sub { color: var(--text-muted); font-size: 0.9rem; margin-top: -4px; }

.key-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin: 16px 0;
  font-size: 0.9rem;
}

.key-state p { margin: 4px 0; }

.key-account { color: var(--text-muted); }

.key-saved-at { color: var(--text-muted); font-size: 0.8rem; }

.key-form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }

.key-form label { font-size: 0.85rem; font-weight: 600; }

.key-form input {
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
}

.key-form button {
  margin-top: 10px;
  padding: 14px;
  min-height: 44px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  align-self: flex-start;
  min-width: 180px;
}

.key-form button:disabled { opacity: 0.6; cursor: default; }

.key-status { font-size: 0.9rem; margin-top: 10px; min-height: 1.2em; }

.key-status.is-error { color: var(--error); }

.key-status.is-success { color: #1a7a3a; }

/* ---- Scale up: sidebar becomes a permanent rail, hamburger disappears ---- */

@media (min-width: 768px) {
  .nav-toggle { display: none; }

  .shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: 52px 1fr;
    grid-template-areas:
      "top top"
      "side main";
    height: 100vh;
  }

  .topbar { grid-area: top; position: sticky; }

  .sidebar {
    grid-area: side;
    display: block !important;
    border-right: 1px solid var(--border);
    border-bottom: none;
    min-height: 0;
  }

  .nav-list { padding: 20px 12px; }

  .content {
    grid-area: main;
    padding: 32px 40px;
    max-width: 720px;
    overflow-y: auto;
  }
}
