/* Golden Thread PWA — Mobile-first dark game theme */

:root {
  --bg:        #0d0d1a;
  --surface:   #161628;
  --surface2:  #1e1e35;
  --border:    #2a2a45;
  --text:      #e8e8f0;
  --muted:     #888899;
  --accent:    #4a9eff;
  --green:     #4aff9e;
  --red:       #ff4a6b;
  --gold:      #ffd700;

  --marksman:   #4a9eff;
  --shortblade: #ff6b4a;
  --stealth:    #7b68ee;
  --arcane:     #a8edea;
  --vitality:   #ff4a6b;
  --charisma:   #ffd700;

  --radius:  10px;
  --radius-sm: 6px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
#app { display: flex; flex-direction: column; height: 100%; }

#view {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 80px;
}

/* ── Nav ── */
nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
nav button {
  flex: 1;
  padding: 10px 4px 8px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  transition: color 0.15s;
}
nav button .nav-icon { font-size: 20px; }
nav button.active { color: var(--accent); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ── Character list ── */
.char-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.char-card:last-child { border-bottom: none; }
.char-card:active { background: var(--surface2); }
.char-avatar { font-size: 32px; line-height: 1; width: 44px; text-align: center; }
.char-info h3 { font-size: 16px; font-weight: 600; }
.char-info p  { font-size: 12px; color: var(--muted); }
.char-badge {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.char-badge.pc { border-color: var(--accent); color: var(--accent); }

/* ── Sheet header ── */
.sheet-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.sheet-avatar { font-size: 48px; line-height: 1; }
.sheet-name { font-size: 22px; font-weight: 700; }
.sheet-class { font-size: 13px; color: var(--muted); }
.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 0 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stat-cell {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}
.stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-modifier {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}
.stat-modifier.pos { color: var(--green); }
.stat-modifier.neg { color: var(--red); }
.stat-modifier.zero { color: var(--muted); }
.stat-points { font-size: 11px; color: var(--muted); }

/* ── Token pools ── */
.token-pool {
  margin-bottom: 10px;
}
.token-pool:last-child { margin-bottom: 0; }
.token-pool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.token-label { font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.token-value { font-size: 13px; color: var(--muted); }
.token-bar-bg {
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}
.token-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
  min-width: 2px;
}

/* ── Abilities ── */
.ability-card {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.ability-card:last-child { margin-bottom: 0; }
.ability-info { flex: 1; min-width: 0; }
.ability-name { font-size: 15px; font-weight: 600; }
.ability-desc { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.ability-meta { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.ability-meta span { background: var(--surface); padding: 1px 6px; border-radius: 10px; }
.use-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--accent);
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.use-btn:active { background: rgba(74, 158, 255, 0.15); }
.use-btn:disabled {
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

/* ── Equipment ── */
.equip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.equip-row:last-child { border-bottom: none; }
.equip-name { font-size: 14px; }
.equip-type { font-size: 11px; color: var(--muted); margin-top: 1px; }
.prof-bar { display: flex; align-items: center; gap: 6px; }
.prof-pips { display: flex; gap: 3px; }
.pip {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
}
.pip.filled { background: var(--accent); }

/* ── Marks feed ── */
.mark-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.mark-row:last-child { border-bottom: none; }
.mark-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.mark-name { font-size: 12px; font-weight: 600; color: var(--muted); }
.mark-source {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid;
}
.mark-source.real_world { border-color: var(--green); color: var(--green); }
.mark-source.in_game    { border-color: var(--accent); color: var(--accent); }
.mark-source.starting   { border-color: var(--gold); color: var(--gold); }
.mark-source.equipment_effect { border-color: var(--muted); color: var(--muted); }
.mark-note { font-size: 14px; color: var(--text); }
.mark-via { font-size: 12px; color: var(--muted); }
.mark-stats { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.mark-stat-tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--surface2);
}
.mark-stat-tag.pos { color: var(--green); }
.mark-stat-tag.neg { color: var(--red); }

/* ── Log Action form ── */
.log-form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; flex-direction: column; gap: 4px; }
.form-row label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.form-row select,
.form-row input[type=text],
.form-row textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  width: 100%;
  -webkit-appearance: none;
}
.form-row textarea { min-height: 70px; resize: vertical; }
.form-row select:focus,
.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.stat-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-input-cell { display: flex; flex-direction: column; gap: 3px; }
.stat-input-cell label { font-size: 11px; color: var(--muted); }
.stat-input-cell input[type=number] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 10px;
  font-size: 15px;
  width: 100%;
  -webkit-appearance: none;
}
.submit-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.04em;
}
.submit-btn:active { opacity: 0.85; }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
  max-width: 90vw;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Task search autocomplete ── */
.task-search-wrap { position: relative; }
.task-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  z-index: 50;
  max-height: 220px;
  overflow-y: auto;
}
.task-result-row {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.task-result-row:last-child { border-bottom: none; }
.task-result-row:active { background: var(--surface2); }
.task-result-id   { font-size: 11px; color: var(--muted); }
.task-result-name { font-size: 14px; }
.task-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
}
.task-selected-clear {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 0 0 8px;
  line-height: 1;
}

/* ── Wallet ── */
.wallet-card { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.wallet-balance {
  font-size: 48px; font-weight: 700; color: var(--green);
  letter-spacing: -1px;
}
.loot-toggle {
  background: none; border: 1px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--green); font-size: 13px; padding: 8px; cursor: pointer; width: 100%;
}
.wallet-award { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.award-inputs { display: flex; gap: 10px; }
.award-cell { display: flex; flex-direction: column; align-items: center; flex: 1; gap: 4px; }
.award-cell label { font-size: 11px; font-weight: 700; color: var(--muted); }
.award-cell input { width: 100%; text-align: center; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text);
  padding: 8px 4px; font-size: 22px; }
.gold-tag {
  display: inline-block; font-size: 12px; color: var(--green);
  margin-top: 2px;
}

/* ── Loading / empty ── */
.loading { text-align: center; color: var(--muted); padding: 40px 0; font-size: 20px; }
.empty   { text-align: center; color: var(--muted); padding: 30px 0; font-size: 14px; }
.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 18px 0 8px;
}
