:root {
  color-scheme: light;
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-strong: #eef7f5;
  --text: #18212f;
  --muted: #647084;
  --line: rgba(24, 33, 47, 0.12);
  --primary: #0f8b8d;
  --primary-strong: #075f72;
  --accent: #f45d48;
  --gold: #f4b740;
  --shadow: 0 18px 50px rgba(18, 36, 54, 0.12);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101722;
  --surface: #172232;
  --surface-strong: #102d34;
  --text: #edf5fb;
  --muted: #a7b4c5;
  --line: rgba(237, 245, 251, 0.14);
  --primary: #48c7bd;
  --primary-strong: #81e5dc;
  --accent: #ff806d;
  --gold: #ffd166;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(72, 199, 189, 0.18), transparent 28rem),
    linear-gradient(135deg, rgba(15, 139, 141, 0.10), transparent 38rem),
    var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

.app-header,
.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: var(--shadow);
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
}

.theme-toggle {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(18, 36, 54, 0.08);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logout-button,
.login-button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(15, 139, 141, 0.2);
}

.logout-button {
  padding: 0 16px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 24px;
  align-items: stretch;
  padding: 36px 0 24px;
}

.hero-copy {
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(15, 139, 141, 0.12), rgba(244, 93, 72, 0.08)),
    var(--surface);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 14px;
  font-size: clamp(2rem, 6vw, 4.6rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.hero-panel {
  display: grid;
  align-content: center;
  gap: 8px;
  min-height: 220px;
  padding: 28px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--primary-strong), #243b6b);
  color: #fff;
  box-shadow: var(--shadow);
}

.hero-panel span,
.hero-panel small {
  color: rgba(255, 255, 255, 0.78);
}

.hero-panel strong {
  font-size: 4rem;
  line-height: 1;
}

.controls {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 12px 0 20px;
  background: linear-gradient(to bottom, var(--bg) 72%, transparent);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 12px 32px rgba(18, 36, 54, 0.08);
}

.search-box span {
  color: var(--primary);
  font-size: 1.4rem;
  font-weight: 800;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding: 4px 0 48px;
}

.topic-card {
  display: grid;
  min-height: 190px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(18, 36, 54, 0.09);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.topic-card:hover,
.topic-card:focus-visible {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--primary) 52%, var(--line));
  box-shadow: var(--shadow);
  outline: 0;
}

.topic-card .tag {
  width: fit-content;
  margin-bottom: 18px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.topic-card h2 {
  margin-bottom: 10px;
  font-size: 1.25rem;
  line-height: 1.2;
}

.topic-card p {
  margin-bottom: 22px;
  color: var(--muted);
  line-height: 1.55;
}

.topic-card .open-link {
  align-self: end;
  color: var(--accent);
  font-weight: 800;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 34px;
  border: 1px dashed color-mix(in srgb, var(--primary) 45%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--primary-strong);
  font-size: 1.8rem;
}

.empty-state p {
  max-width: 580px;
  margin: 0 auto;
  color: var(--muted);
  line-height: 1.65;
}

.is-hidden {
  display: none !important;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 460px);
}

.login-card {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(15, 139, 141, 0.12), rgba(244, 93, 72, 0.08)),
    var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 30px;
}

.login-copy h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 8vw, 3.5rem);
}

.login-copy p:last-child {
  color: var(--muted);
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

.login-form label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.login-form input {
  min-height: 48px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  padding: 0 14px;
}

.login-form input:focus {
  border-color: var(--primary);
  outline: 3px solid color-mix(in srgb, var(--primary) 24%, transparent);
}

.login-error {
  margin: 6px 0 0;
  color: var(--accent);
  font-weight: 800;
}

.login-button {
  margin-top: 10px;
  width: 100%;
}

@media (max-width: 820px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    min-height: 150px;
  }

  .topic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 580px) {
  .app-header,
  .page-shell {
    width: min(100% - 24px, 1120px);
  }

  .hero-copy {
    padding: 24px;
  }

  .topbar {
    align-items: flex-start;
  }

  .nav-actions {
    flex-shrink: 0;
  }

  .logout-button {
    min-height: 44px;
    padding: 0 12px;
  }

  h1 {
    font-size: 2.45rem;
  }

  .topic-grid {
    grid-template-columns: 1fr;
  }
}
