:root {
  color-scheme: light;
  --ink: #19211f;
  --muted: #66716d;
  --line: #d8ded9;
  --paper: #f8faf7;
  --panel: #ffffff;
  --primary: #18332f;
  --primary-soft: #e4efeb;
  --accent: #b84a3b;
  --accent-soft: #fae9e5;
  --gold: #d8aa37;
  --shadow: 0 14px 34px rgba(30, 44, 39, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    linear-gradient(180deg, rgba(24, 51, 47, 0.08), transparent 240px),
    var(--paper);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(940px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px 16px 86px;
}

.auth-gate {
  width: min(760px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 36px) 16px 36px;
  display: grid;
  align-items: center;
}

.auth-card h1 {
  margin: 0;
  font-size: 42px;
  line-height: 1.05;
  letter-spacing: 0;
}

.auth-lead {
  margin: 14px 0 22px;
  color: var(--muted);
  font-size: 17px;
}

[hidden] {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(env(safe-area-inset-top) + 8px) 0 18px;
}

.topbar h1,
.view h2,
.section-head h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 28px;
  line-height: 1.08;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 760;
}

.status-pill {
  min-width: 64px;
  border: 1px solid rgba(24, 51, 47, 0.18);
  border-radius: 999px;
  padding: 8px 11px;
  background: var(--panel);
  color: var(--primary);
  font-size: 13px;
  font-weight: 740;
  text-align: center;
}

main {
  display: grid;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 14px;
}

.section-head.compact {
  margin-top: 0;
}

.section-head h2 {
  font-size: 22px;
}

.auth-panel .section-head h2 {
  font-size: 22px;
}

.section-head h3 {
  font-size: 18px;
}

#parseHint,
.quiz-surface p,
.settings-list span,
#authStatus,
#accountStatus {
  color: var(--muted);
}

.auth-message {
  min-height: 22px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.raw-input,
.preview-panel,
.quiz-surface,
.settings-list,
.auth-panel,
.card-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.raw-input {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  padding: 16px;
  outline: 0;
  line-height: 1.5;
}

.raw-input:focus,
input:focus,
textarea:focus {
  border-color: rgba(24, 51, 47, 0.58);
  box-shadow: 0 0 0 4px rgba(24, 51, 47, 0.09);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 760;
}

.primary-button {
  background: var(--primary);
  color: white;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--primary-soft);
  color: var(--primary);
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.preview-panel {
  margin-top: 18px;
  padding: 16px;
}

.candidate-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 12px;
  background: #fbfcfa;
}

.candidate-panel p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 720;
}

.candidate-list {
  display: grid;
  gap: 8px;
}

.candidate-button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
}

.candidate-button.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.candidate-button span {
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

label.wide {
  grid-column: 1 / -1;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 88px;
  resize: vertical;
  padding: 12px;
}

.search-input {
  width: min(260px, 48vw);
  background: var(--panel);
}

.card-list {
  display: grid;
  gap: 10px;
}

.card-item {
  padding: 14px;
}

.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title-row h3 {
  margin: 0;
  font-size: 20px;
}

.card-item p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
}

.icon-button {
  min-width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #f2f5f2;
  color: var(--muted);
}

.quiz-surface,
.settings-list {
  padding: 18px;
}

.auth-panel {
  margin: 14px 0;
  padding: 16px;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quiz-surface h2 {
  min-height: 74px;
  margin-top: 8px;
  font-size: 30px;
}

.quiz-answer {
  border-left: 4px solid var(--gold);
  margin-top: 14px;
  padding: 12px 14px;
  background: #fff8de;
  line-height: 1.55;
}

.settings-list {
  display: grid;
  gap: 14px;
}

.settings-list div {
  display: grid;
  gap: 4px;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: min(940px, 100%);
  margin: 0 auto;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  border-top: 1px solid var(--line);
  background: rgba(248, 250, 247, 0.94);
  backdrop-filter: blur(12px);
}

.tab {
  min-height: 46px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 780;
}

.tab.is-active {
  background: var(--primary);
  color: #fff;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 30px 16px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 620px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .topbar h1 {
    font-size: 24px;
  }

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

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

  .candidate-button {
    grid-template-columns: 1fr;
  }

  .quiz-surface h2 {
    font-size: 25px;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    flex: 1 1 auto;
  }
}
