:root {
  --bg: #0b1020;
  --surface: #121a2d;
  --surface-2: #1a243b;
  --text: #e6edf8;
  --muted: #95a4c0;
  --accent: #4f8cff;
  --good: #2fb36a;
  --bad: #d55454;
  --gold: #d5a93d;
  --border: #263250;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

.app-header {
  padding: 1rem 1rem 0.5rem;
}
.app-header h1 { margin: 0 0 0.2rem; font-size: 1.4rem; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 0.85rem; }

.app-main {
  padding: 0.5rem 1rem 5.5rem;
  max-width: 760px;
  margin: 0 auto;
}

.tab-view { display: none; }
.tab-view.active { display: block; }

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

.stack > * + * { margin-top: 0.8rem; }
.grid.two {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 1fr;
}

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

input, select, textarea {
  width: 100%;
  margin-top: 0.35rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 0.6rem 0.7rem;
  font: inherit;
}

textarea { resize: vertical; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.segmented button,
.btn,
.tab-nav button,
.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
}

.segmented button.active,
.tab-nav button.active,
.btn.primary,
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn { cursor: pointer; }
.btn.ghost { background: transparent; }
.btn.danger { background: #3a1b1b; border-color: #7d2e2e; color: #ffd2d2; }
.file-btn { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }

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

.chip-group-wrap { margin-top: 0.3rem; }
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.35rem;
}
.chip { padding: 0.4rem 0.6rem; border-radius: 999px; font-size: 0.84rem; }

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.pill {
  border-radius: 999px;
  background: var(--gold);
  color: #2a1e00;
  font-size: 0.76rem;
  padding: 0.2rem 0.55rem;
  font-weight: 600;
}

.hidden { display: none !important; }
.error { color: #ff8f8f; margin: 0; }

.tab-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 16, 32, 0.95);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
  padding: 0.45rem;
}
.tab-nav button {
  font-size: 0.7rem;
  padding: 0.45rem 0.25rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}
.stat-card {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.65rem;
}
.stat-card strong { display: block; font-size: 1.3rem; color: var(--accent); }
.list-card { border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem; background: var(--surface-2); }
.list-card h3 { margin: 0 0 0.45rem; font-size: 1rem; }
.ranked-list { list-style: none; margin: 0; padding: 0; }
.ranked-list li { display: flex; justify-content: space-between; padding: 0.22rem 0; border-bottom: 1px solid rgba(149,164,192,0.12); }
.ranked-list li:last-child { border-bottom: none; }

.journal-item { border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem; background: var(--surface-2); }
.journal-summary { display: flex; justify-content: space-between; gap: 0.5rem; align-items: start; }
.journal-meta { font-size: 0.84rem; color: var(--muted); }
.journal-title { margin: 0.2rem 0 0; font-size: 0.95rem; }
.inline-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.badge { border-radius: 999px; border: 1px solid var(--border); padding: 0.15rem 0.45rem; font-size: 0.75rem; color: var(--muted); }

@media (min-width: 680px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
  .tab-nav button { font-size: 0.82rem; }
}
