:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #666666;
  --border: #dddddd;
  --accent: #2f6fed;
  --accent-fg: #ffffff;
  --card-bg: #f7f7f8;
  --danger: #c0392b;
  --confused: #b8860b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --fg: #eaeaea;
    --muted: #9a9a9a;
    --border: #33363c;
    --accent: #5b8cff;
    --accent-fg: #0c0c0c;
    --card-bg: #1d1f24;
    --danger: #e07a6d;
    --confused: #e0b04d;
  }
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  margin: 0;
  line-height: 1.5;
}

header.app-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

header.app-header .brand {
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--fg);
}

header.app-header nav a {
  color: var(--muted);
  text-decoration: none;
  margin-right: 1rem;
  font-size: 0.95rem;
}

header.app-header nav a:hover,
header.app-header nav a.active {
  color: var(--accent);
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; margin-top: 2rem; }

.muted { color: var(--muted); }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.card-list { display: flex; flex-direction: column; gap: 0.5rem; }

a.card-link {
  text-decoration: none;
  color: inherit;
  display: block;
}
a.card-link:hover { border-color: var(--accent); }

.term-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.term-card-header h3 { flex: 1; }
.term-card h3 { margin: 0 0 0.25rem; }
.term-card .badge {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  margin-left: 0.5rem;
}
.term-card .tag-confused {
  color: var(--confused);
  font-size: 0.85rem;
}

.relation-line { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
form.relation-form { margin: 0.75rem 0 0; }
form.relation-form input { flex: 1 1 200px; }

.term-actions { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }
.term-actions .badge { margin-left: auto; }

button.sm { padding: 0.25rem 0.55rem; font-size: 0.8rem; font-weight: 500; }

button.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1;
  flex-shrink: 0;
}
button.icon-btn:hover { background: var(--danger); color: var(--accent-fg); opacity: 1; }
button.icon-btn:focus-visible { outline: 2px solid var(--danger); outline-offset: 1px; }

form.inline-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: flex-start;
  margin: 1rem 0;
}

input, select, textarea, button {
  font: inherit;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
}

textarea { width: 100%; min-height: 4rem; }

button {
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  cursor: pointer;
  font-weight: 600;
}
button:hover { opacity: 0.9; }
button.secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}
button.danger { background: var(--danger); }

.error-text { color: var(--danger); font-size: 0.9rem; }

.field { display: flex; flex-direction: column; gap: 0.25rem; }
.field label { font-size: 0.85rem; color: var(--muted); }

.level-section { margin-bottom: 1.5rem; }

.term-toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0; align-items: center; }
.term-toolbar input[type="search"] { flex: 1 1 240px; }

.pass-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
button.pass-chip {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
button.pass-chip.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.level-jump { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.85rem; margin-bottom: 1rem; }
.level-jump a { color: var(--muted); text-decoration: none; }
.level-jump a:hover { color: var(--accent); }

.progress-summary { margin: 1rem 0 1.5rem; }
.progress-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--border); }
.progress-bar .seg { height: 100%; }
.progress-bar .seg.recognition, .progress-legend .swatch.recognition { background: #8a8f98; }
.progress-bar .seg.recall, .progress-legend .swatch.recall { background: var(--accent); }
.progress-bar .seg.application, .progress-legend .swatch.application { background: #d9a441; }
.progress-bar .seg.mastered, .progress-legend .swatch.mastered { background: #2e7d32; }
.progress-legend { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.progress-legend .swatch {
  display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 2px;
  margin-right: 0.35rem; vertical-align: middle;
}

.session-progress { font-size: 0.8rem; margin-bottom: 0.4rem; }
.habit-line { font-size: 0.85rem; margin-top: 0.15rem; }

/* Signed-in identity in the page header (hidden in single-user mode). */
.auth-box {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent, #2563eb);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
}
