@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Inter:wght@300;400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:      #09090f;
  --deep:     #0e0e1a;
  --surface:  #13131f;
  --card:     #1a1a2e;
  --rim:      #2a2a45;
  --subtle:   #3a3655;
  --gold:     #c9a84c;
  --gold-dim: #8a6e2f;
  --ember:    #e8531a;
  --green:    #4caf7d;
  --text:     #e8e4d9;
  --muted:    #7a7590;
  --radius:   8px;
}

html, body {
  background: var(--ink);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── TYPOGRAPHY ── */
h1, h2, h3 { font-family: 'Cinzel', serif; line-height: 1.15; }
h1 { font-size: 1.8rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 600; }
h3 { font-size: 1rem;   font-weight: 600; }
p  { color: var(--muted); font-size: 0.9rem; }

/* ── LAYOUT ── */
.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* ── TOPBAR ── */
.topbar {
  grid-column: 1 / -1;
  height: 56px;
  background: var(--deep);
  border-bottom: 1px solid var(--rim);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-logo {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-decoration: none;
  margin-right: auto;
}
.topbar-user {
  font-size: 0.8rem;
  color: var(--muted);
}
.topbar-btn {
  font-size: 0.75rem;
  color: var(--muted);
  background: none;
  border: 1px solid var(--rim);
  border-radius: 4px;
  padding: 5px 12px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  font-family: 'Inter', sans-serif;
}
.topbar-btn:hover { color: var(--text); border-color: var(--subtle); }

/* ── SIDEBAR ── */
.sidebar {
  background: var(--deep);
  border-right: 1px solid var(--rim);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}
.sidebar-section {
  padding: 6px 16px 4px;
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--subtle);
  font-weight: 600;
  margin-top: 8px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: 'Inter', sans-serif;
}
.sidebar-link:hover { background: var(--surface); color: var(--text); }
.sidebar-link.active { background: var(--surface); color: var(--gold); border-left: 2px solid var(--gold); }
.sidebar-link .icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

/* ── MAIN CONTENT ── */
.main {
  padding: 32px;
  overflow-y: auto;
  max-width: 900px;
}

/* ── CARDS ── */
.card {
  background: var(--card);
  border: 1px solid var(--rim);
  border-radius: var(--radius);
  padding: 24px;
}
.card + .card { margin-top: 16px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 5px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.18s;
  text-decoration: none;
}
.btn-primary {
  background: var(--gold);
  color: var(--ink);
}
.btn-primary:hover { background: #e0bd6a; }
.btn-primary:disabled { background: var(--gold-dim); cursor: not-allowed; opacity: 0.6; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--rim);
}
.btn-secondary:hover { border-color: var(--subtle); background: var(--card); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--rim);
}
.btn-ghost:hover { color: var(--text); border-color: var(--subtle); }

.btn-danger {
  background: transparent;
  color: #e05555;
  border: 1px solid #4a2020;
}
.btn-danger:hover { background: #2a1010; }

.btn-sm { padding: 6px 14px; font-size: 0.78rem; }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: 5px;
  padding: 10px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.18s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--gold-dim);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--muted); }
.form-textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.form-select option { background: var(--card); }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.badge-active   { background: rgba(201,168,76,0.15); color: var(--gold); border: 1px solid var(--gold-dim); }
.badge-complete { background: rgba(76,175,125,0.15); color: var(--green); border: 1px solid #2a6e50; }
.badge-pending  { background: rgba(120,115,144,0.15); color: var(--muted); border: 1px solid var(--subtle); }
.badge-session  { background: rgba(232,83,26,0.12); color: var(--ember); border: 1px solid #6a2a10; }

/* ── STATUS DOT ── */
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-active   { background: var(--gold); box-shadow: 0 0 6px rgba(201,168,76,0.5); }
.dot-complete { background: var(--green); }
.dot-pending  { background: var(--subtle); }

/* ── DIVIDERS ── */
.divider {
  border: none;
  border-top: 1px solid var(--rim);
  margin: 20px 0;
}

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}
.page-header-left h1 { margin-bottom: 4px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-family: 'Cinzel', serif; color: var(--subtle); margin-bottom: 8px; font-size: 1rem; }
.empty-state p { font-size: 0.85rem; margin-bottom: 20px; }

/* ── LOADING ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--rim);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 24px;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ── TOAST ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}
.toast {
  background: var(--card);
  border: 1px solid var(--rim);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 0.85rem;
  color: var(--text);
  max-width: 320px;
  animation: slideIn 0.2s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--ember); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── MODAL ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}
.modal {
  background: var(--card);
  border: 1px solid var(--rim);
  border-radius: 10px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.modal-title {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  margin-bottom: 20px;
  color: var(--text);
}
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ── AUTH PAGE ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--rim);
  border-radius: 12px;
  padding: 40px;
}
.auth-logo {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.12em;
  text-align: center;
  margin-bottom: 8px;
}
.auth-tagline {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 32px;
}
.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 0.82rem;
  color: var(--muted);
}
.auth-switch a {
  color: var(--gold);
  text-decoration: none;
  cursor: pointer;
}
.auth-switch a:hover { text-decoration: underline; }

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ── CAMPAIGN CARD ── */
.campaign-card {
  background: var(--card);
  border: 1px solid var(--rim);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  text-decoration: none;
  display: block;
}
.campaign-card:hover { border-color: var(--gold-dim); transform: translateY(-2px); }
.campaign-card-name {
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.campaign-card-meta { font-size: 0.78rem; color: var(--muted); }

/* ── SESSION LIST ITEM ── */
.session-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.18s;
  margin-bottom: 8px;
}
.session-item:hover { border-color: var(--subtle); }
.session-item-number {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  color: var(--gold);
  letter-spacing: 0.1em;
  flex-shrink: 0;
  width: 60px;
}
.session-item-title { font-size: 0.9rem; font-weight: 500; color: var(--text); flex: 1; }
.session-item-date  { font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }

/* ── AI PROCESSING ── */
.ai-processing {
  background: var(--surface);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
}
.ai-processing .spinner { width: 32px; height: 32px; margin-bottom: 16px; }
.ai-processing p { font-size: 0.88rem; }
.ai-processing .ai-step {
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-top: 8px;
}

/* ── NOTES OUTPUT ── */
.notes-section { margin-bottom: 28px; }
.notes-section-title {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.notes-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rim);
}
.notes-narrative {
  font-size: 0.9rem;
  color: #a09c92;
  line-height: 1.8;
}
.notes-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.notes-list li {
  font-size: 0.87rem;
  color: var(--text);
  padding: 10px 14px;
  background: var(--surface);
  border-radius: 5px;
  border-left: 2px solid var(--gold-dim);
  line-height: 1.5;
}

/* ── QUEST ITEM ── */
.quest-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: border-color 0.18s;
}
.quest-row:hover { border-color: var(--subtle); }
.quest-row-body { flex: 1; }
.quest-row-name { font-size: 0.9rem; font-weight: 500; color: var(--text); margin-bottom: 3px; }
.quest-row-desc { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }
.quest-row-meta { font-size: 0.72rem; color: var(--subtle); margin-top: 4px; }

/* ── ENTITY CHIPS ── */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s;
}
.chip:hover { border-color: var(--gold-dim); color: var(--text); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ── TAG EDITOR ── */
.tag-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 28px;
}
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 10px;
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: 20px;
  font-size: 0.72rem;
  color: var(--muted);
  transition: border-color 0.15s;
}
.tag-pill:hover { border-color: var(--subtle); }
.tag-pill-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  padding: 0 1px;
  transition: color 0.15s;
}
.tag-pill-remove:hover { color: var(--ember); }
.tag-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: none;
  border: 1px dashed var(--subtle);
  border-radius: 20px;
  font-size: 0.72rem;
  color: var(--subtle);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: 'Inter', sans-serif;
}
.tag-add-btn:hover { border-color: var(--gold-dim); color: var(--gold); }
.tag-input-inline {
  background: var(--surface);
  border: 1px solid var(--gold-dim);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.72rem;
  color: var(--text);
  outline: none;
  width: 100px;
  font-family: 'Inter', sans-serif;
}

/* ── TAG FILTER DROPDOWN ── */
.tag-filter-wrap {
  position: relative;
  display: inline-block;
}
.tag-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: 5px;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s;
  white-space: nowrap;
}
.tag-filter-btn:hover { border-color: var(--subtle); }
.tag-filter-btn.active { border-color: var(--gold-dim); color: var(--gold); }
.tag-filter-chevron { font-size: 0.6rem; opacity: 0.6; }
.tag-filter-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--card);
  border: 1px solid var(--rim);
  border-radius: var(--radius);
  min-width: 200px;
  max-height: 300px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.tag-filter-search {
  padding: 8px 12px;
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--rim);
  font-size: 0.82rem;
  color: var(--text);
  outline: none;
  font-family: 'Inter', sans-serif;
}
.tag-filter-search::placeholder { color: var(--muted); }
.tag-filter-list {
  overflow-y: auto;
  flex: 1;
}
.tag-filter-option {
  display: block;
  padding: 8px 14px;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: 'Inter', sans-serif;
}
.tag-filter-option:hover { background: var(--surface); color: var(--text); }
.tag-filter-option.selected { color: var(--gold); background: rgba(201,168,76,0.06); }

/* ── INPUT METHOD CARDS ── */
.input-method-btn {
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: var(--radius);
  padding: 20px 14px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.18s, background 0.18s, transform 0.18s;
  font-family: 'Inter', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.input-method-btn:hover {
  border-color: var(--gold-dim);
  background: var(--card);
  transform: translateY(-2px);
}
.input-method-icon  { font-size: 1.6rem; }
.input-method-label { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.input-method-sub   { font-size: 0.72rem; color: var(--muted); line-height: 1.4; }

/* ── PLATFORM HINT BUTTONS ── */
.platform-hint-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
  font-family: 'Inter', sans-serif;
}
.platform-hint-btn:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
}

/* ── SESSION PLANNER ── */
.plan-card {
  background: var(--card);
  border: 1px solid var(--rim);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.plan-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.plan-card-title {
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  color: var(--text);
}
.plan-status {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--rim);
  color: var(--muted);
}
.plan-status.has-recap {
  color: var(--gold);
  border-color: var(--gold-dim);
}
.plan-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.plan-tab-btn {
  padding: 5px 14px;
  font-size: 0.78rem;
  cursor: pointer;
  border: 1px solid var(--rim);
  background: var(--surface);
  color: var(--muted);
  border-radius: 4px;
  font-family: 'Inter', sans-serif;
  transition: all 0.15s;
}
.plan-tab-btn.active {
  border-color: var(--gold-dim);
  color: var(--gold);
  background: rgba(201, 168, 76, 0.06);
}
.plan-recap-block {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.7;
}
.plan-recap-block .recap-section-title {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 14px 0 6px;
}
.compare-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rim);
  font-size: 0.85rem;
  line-height: 1.6;
}
.compare-item:last-child { border-bottom: none; }
.compare-icon { flex-shrink: 0; font-size: 0.95rem; margin-top: 1px; }
.compare-text { flex: 1; color: var(--text); }
.compare-copy-btn {
  flex-shrink: 0;
  font-size: 0.72rem;
  padding: 3px 10px;
  border: 1px solid var(--rim);
  background: var(--surface);
  color: var(--gold);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s;
}
.compare-copy-btn:hover { border-color: var(--gold-dim); }
.compare-copy-btn:disabled { opacity: 0.4; cursor: default; }
