/* ---------- Design tokens (strictly dark) ---------- */
:root {
  --bg: #0e0e11;
  --surface: #15151a;
  --surface-hover: #1c1c23;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.28);
  --text: #ececf1;
  --text-muted: #9b9ba6;
  --accent: #8ab4ff;
  --radius: 10px;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(138, 180, 255, 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(138, 180, 255, 0.3); }

/* ---------- Layout ---------- */
#app {
  max-width: 820px;
  margin: 0 auto;
  padding: 72px 24px 48px;
  animation: fade-in 0.35s var(--ease);
}

.page-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.page-head h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

/* ---------- Buttons ---------- */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease);
}

.icon-btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(0.94); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 24px;
  transition: color 0.18s var(--ease);
}
.back-link:hover { color: var(--text); }

/* ---------- Subject tiles (auto-wrapping) ---------- */
.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.tile {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  animation: tile-in 0.45s var(--ease) forwards;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.tile:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.tile:active { transform: translateY(0); }

.tile.last-opened::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 10px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}

/* ---------- Placeholder (subject page, built in Phase 2) ---------- */
.placeholder {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--text-muted);
}

.placeholder h2 { margin: 0 0 8px; color: var(--text); font-size: 20px; }
.placeholder p { margin: 0; }

.empty {
  color: var(--text-muted);
  padding: 32px 0;
}

/* ---------- Accessibility ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.toast {
  padding: 10px 16px;
  background: #1f1f27;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.25s var(--ease);
}

.toast.out { opacity: 0; transform: translateY(6px); transition: all 0.25s var(--ease); }

/* ---------- Animations ---------- */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes tile-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  #app { padding: 40px 16px 32px; }
  .page-head h1 { font-size: 24px; }
}
