/* The Unwoven — melancholic, low-fantasy palette. Plain CSS, no framework. */
:root {
  --bg:        #14131a;   /* near-black violet, the keep at night */
  --bg-2:      #1c1b24;
  --panel:     #211f2b;
  --panel-2:   #2a2735;
  --ink:       #d8d2c4;   /* parchment text */
  --ink-dim:   #8a8478;
  --ink-faint: #5b5648;
  --line:      #3a3647;
  --gold:      #c9a24b;   /* highborn / royal accent */
  --gold-dim:  #8a6f33;
  --blood:     #8c3b3b;   /* heat / danger */
  --rot:       #6f8a3b;   /* poison / the green */
  --chill:     #4b7a8c;
  --arc:       #7a5b8c;
  --thread:    #b8a878;   /* a revealed thread */
  --thread-hid:#46424f;   /* a hidden/locked thread */
  --shadow: 0 2px 0 #0c0b10, 0 8px 24px rgba(0,0,0,.45);
  --mono: "Iosevka", "Cascadia Code", "Consolas", ui-monospace, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", "Georgia", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, #1d1b26, var(--bg)) fixed;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; flex-direction: column; min-height: 100vh; max-width: 1180px; margin: 0 auto; }

/* status strip (always visible, top) */
#strip {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(#1b1a23, #161520);
  position: sticky; top: 0; z-index: 20;
}
#title { font-family: var(--mono); letter-spacing: .26em; color: var(--gold); font-size: 12px; white-space: nowrap; }
#title .ver { color: var(--ink-faint); font-size: 10px; letter-spacing: .1em; }
#status { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; flex: 1; }
.chip { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.chip .label { font-family: var(--mono); font-size: 9px; letter-spacing: .12em; color: var(--ink-faint); text-transform: uppercase; }
.chip .val { font-family: var(--mono); font-size: 13px; color: var(--ink); white-space: nowrap; }
.chip.wide { min-width: 150px; }
.chip .meter { height: 4px; background: var(--thread-hid); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.chip .meter > i { display: block; height: 100%; background: var(--gold); transition: width .2s linear; }
.chip.nerve .meter > i { background: var(--chill); }
.chip.heat .meter > i { background: var(--blood); }
.chip .warn { color: var(--blood); }
.chip .contract { font-family: var(--serif); font-size: 12px; color: var(--ink-dim); font-style: italic; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#day-control { display: flex; gap: 6px; }
#day-control .act { padding: 6px 10px; }
#day-control .act.primary { border-color: var(--gold-dim); color: var(--gold); }
#journal-toggle {
  background: var(--panel-2); color: var(--ink-dim); border: 1px solid var(--line);
  border-radius: 4px; padding: 6px 12px; cursor: pointer; font-family: var(--mono); font-size: 11px; letter-spacing: .06em;
}
#journal-toggle:hover { color: var(--gold); border-color: var(--gold-dim); }
#journal-toggle.flagged { color: var(--gold); border-color: var(--gold-dim); }

/* tabs */
#tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 18px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
#tabs button {
  background: transparent; color: var(--ink-dim); border: 1px solid transparent;
  padding: 6px 14px; border-radius: 4px; cursor: pointer; font-family: var(--mono);
  font-size: 12px; letter-spacing: .04em;
}
#tabs button:hover { color: var(--ink); background: var(--panel); }
#tabs button.active { color: var(--gold); border-color: var(--gold-dim); background: var(--panel); }

/* the workspace (one full-width tab at a time) */
#workspace { flex: 1; padding: 16px 18px; }
.work-grid { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.work-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .work-grid, .work-cols { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 16px; }
h2.head { font-family: var(--mono); font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold-dim); margin: 0 0 12px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
h3 { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; color: var(--ink-dim); margin: 14px 0 6px; }
h3:first-child { margin-top: 0; }

/* generic list rows / buttons */
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.row:hover { background: var(--panel-2); }
.row.sel { background: var(--panel-2); outline: 1px solid var(--gold-dim); }
.row .name { color: var(--ink); }
.row .sub { font-size: 11px; color: var(--ink-faint); font-family: var(--mono); }
.tag { font-family: var(--mono); font-size: 9px; letter-spacing: .08em; padding: 1px 5px; border-radius: 3px; border: 1px solid var(--line); color: var(--ink-dim); text-transform: uppercase; }
.tag.target { color: var(--blood); border-color: var(--blood); }
.tag.ally   { color: var(--rot); border-color: var(--gold-dim); }

button.act {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 4px; padding: 6px 10px; cursor: pointer; font-family: var(--mono); font-size: 12px;
}
button.act:hover:not(:disabled) { border-color: var(--gold-dim); color: var(--gold); }
button.act:disabled { opacity: .4; cursor: not-allowed; }
button.act .cost { color: var(--ink-faint); margin-left: 6px; font-size: 11px; }

/* a brief, quiet acknowledgement that a click landed (replaces the old particle VFX) */
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(201,162,75,.5); } 100% { box-shadow: 0 0 0 8px rgba(201,162,75,0); } }
.flash { animation: pulse .5s ease-out; }
@keyframes pulse-blood { 0% { box-shadow: 0 0 0 0 rgba(140,59,59,.6); } 100% { box-shadow: 0 0 0 10px rgba(140,59,59,0); } }
.flash-blood { animation: pulse-blood .55s ease-out; }

/* the four-phase clock on The Day */
.clockrow { display: flex; gap: 6px; margin: 6px 0 10px; }
.phase-pip { flex: 1; text-align: center; padding: 8px 4px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg-2); }
.phase-pip .pn { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; color: var(--ink-dim); text-transform: uppercase; }
.phase-pip .ph { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); }
.phase-pip.now { border-color: var(--gold-dim); background: var(--panel-2); }
.phase-pip.now .pn { color: var(--gold); }
.activities { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* meters in cards */
.bar { height: 5px; background: var(--thread-hid); border-radius: 3px; margin-top: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); transition: width .2s linear; }
.bar.fray { height: 7px; }
.bar.fray > i { background: var(--blood); }

/* skein rings */
.ring { margin: 8px 0; }
.ring .ring-name { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: var(--ink-faint); text-transform: uppercase; }
.threads { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; align-items: center; }
.thread { width: 14px; height: 14px; border-radius: 3px; background: var(--thread-hid); border: 1px solid #0008; }
.thread.on { background: var(--thread); box-shadow: 0 0 6px #b8a87855; }
.thread.knot { border-radius: 50%; background: var(--gold); }
.thread.knot.locked { background: var(--thread-hid); }
.thread.staged { background: var(--gold-dim); box-shadow: 0 0 5px var(--gold-dim); opacity: .85; }

/* the Working */
.workbox { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--gold-dim); border-radius: 5px; background: var(--bg-2); }
.workbox .act { margin: 6px 6px 0 0; }

/* the journal drawer (collapsible, right) */
#journal {
  position: fixed; top: 0; right: 0; height: 100vh; width: 340px; z-index: 40;
  background: linear-gradient(#1b1a23, #161520); border-left: 1px solid var(--gold-dim);
  box-shadow: -8px 0 24px rgba(0,0,0,.5); padding: 16px 18px; overflow-y: auto;
  transition: transform .22s ease;
}
#journal.closed { transform: translateX(100%); }
#journal .codex { color: var(--ink); font-style: italic; line-height: 1.6; margin: 0 0 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
#journal .close-x { float: right; background: none; border: none; color: var(--ink-dim); cursor: pointer; font-family: var(--mono); font-size: 16px; }
#journal .close-x:hover { color: var(--gold); }
#journal .colophon { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 9px; letter-spacing: .06em; color: var(--ink-faint); }

/* save export/import modal */
#save-modal { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; background: rgba(12,11,16,.72); }
.modal-card { position: relative; max-width: 520px; width: 90%; margin: 20px; padding: 22px 24px; background: var(--panel); border: 1px solid var(--gold-dim); border-radius: 8px; box-shadow: var(--shadow); }
.modal-card .close-x { position: absolute; top: 8px; right: 12px; background: none; border: none; color: var(--ink-dim); cursor: pointer; font-family: var(--mono); font-size: 18px; }
.modal-card .close-x:hover { color: var(--gold); }
.save-box { width: 100%; background: var(--bg-2); color: var(--ink); border: 1px solid var(--line); border-radius: 4px; font-family: var(--mono); font-size: 11px; padding: 8px; resize: vertical; word-break: break-all; }

/* opening overlay */
#intro-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(900px 600px at 50% 30%, #1a1822, #0c0b10ee); backdrop-filter: blur(2px); }
.intro-card { max-width: 560px; margin: 20px; padding: 28px 32px; background: var(--panel); border: 1px solid var(--gold-dim);
  border-radius: 8px; box-shadow: var(--shadow); }
.intro-title { font-family: var(--mono); letter-spacing: .3em; color: var(--gold); font-size: 14px; margin-bottom: 4px; }
.intro-sub { font-family: var(--serif); font-style: italic; font-size: 13px; color: var(--ink-dim); margin-bottom: 6px; }
.intro-by { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; color: var(--ink-faint); margin-bottom: 18px; }
.intro-card p { color: var(--ink); line-height: 1.6; margin: 0 0 14px; }
.intro-card p:last-of-type { color: var(--ink-dim); font-style: italic; }
.intro-begin { display: block; margin: 22px auto 0; padding: 8px 28px; }

/* item rarity colors */
.rarity-common { color: var(--ink); }
.rarity-uncommon { color: var(--rot); }
.rarity-rare { color: var(--chill); }
.rarity-epic { color: var(--arc); }

.muted { color: var(--ink-faint); }
.small { font-size: 11px; }
.center { text-align: center; }
