/* Ambition & Desire PWA — one column on the phone, nav + main + agenda rail on the desktop; two skins for the time views. */
:root {
  --bg: #f3ead9; --paper: #fbf6ec; --ink: #2b2118; --muted: #7a6a58; --line: #d9ccb6; --accent: #8b3a2f; --accent-ink: #fff;
  --player: #e4d6bd; --gm: #fbf6ec; --warn: #b8762a; --ok: #3f7a4a; --gap: #c9b7a0; --now: #f0c36a; --shadow: 0 1px 3px rgba(43, 33, 24, .15);
  --font: Georgia, "Times New Roman", serif; --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --rail-w: 340px; --nav-w: 180px; --topbar-h: 48px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1d1813; --paper: #272019; --ink: #ece2d0; --muted: #a8988a; --line: #4a3e33; --player: #3a2f25; --gm: #272019; --gap: #4a3e33; --now: #7a5b16; --shadow: 0 1px 3px rgba(0,0,0,.5); }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; }
button, input, select, textarea { font: inherit; color: inherit; }
/* form controls follow the theme: the UA otherwise paints a light dropdown list with the dark theme's text colour */
:root { color-scheme: light dark; }
select, input, textarea { background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
option { color: var(--ink); background: var(--paper); }
a { color: inherit; }
.muted { color: var(--muted); } .small { font-size: .85em; } .neg { color: var(--accent); } .pos { color: var(--ok); } .error { color: var(--accent); }
code { font-family: ui-monospace, Menlo, monospace; font-size: .9em; }
.app { display: grid; height: 100%; width: 100%; max-width: 100vw; overflow: hidden; grid-template-rows: var(--topbar-h) 1fr; grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
.topbar { grid-area: top; display: flex; align-items: center; gap: 8px; padding: 0 8px; background: var(--ink); color: var(--bg); font-family: var(--ui); position: sticky; top: 0; z-index: 20; }
.iconbtn { background: transparent; border: 0; color: inherit; font-size: 20px; padding: 6px 10px; cursor: pointer; }
.status { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; }
.status-part + .status-part::before { content: " · "; color: var(--muted); }
.nav { grid-area: nav; display: none; flex-direction: column; background: var(--paper); border-right: 1px solid var(--line); padding: 8px; font-family: var(--ui); }
.navlink { display: flex; gap: 10px; align-items: center; padding: 10px 12px; text-decoration: none; border-radius: 8px; }
.navlink.active { background: var(--player); font-weight: 600; }
.navicon { width: 1.4em; text-align: center; }
.main { grid-area: main; min-width: 0; overflow: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
.rail { grid-area: rail; display: none; overflow: auto; background: var(--paper); border-left: 1px solid var(--line); padding: 8px; font-family: var(--ui); font-size: 12px; }
@media (min-width: 900px) {
  .app { grid-template-columns: var(--nav-w) minmax(0, 1fr) var(--rail-w); grid-template-areas: "top top top" "nav main rail"; }
  .nav, .rail { display: flex; flex-direction: column; }
  #btn-menu, #btn-agenda { display: none; }
  .strip { display: none; }
}
@media (max-width: 899px) {
  body.nav-open .nav { display: flex; position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: 240px; z-index: 30; box-shadow: var(--shadow); }
  body.rail-open .rail { display: block; position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: min(92vw, 420px); z-index: 30; box-shadow: var(--shadow); }
  .main { padding: 8px; }
}
body.offline .topbar::after { content: "⚡"; color: var(--warn); }

/* cards and tiles */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 8px; font-size: 1.05em; font-family: var(--ui); } .card h3 { margin: 10px 0 4px; font-size: .95em; font-family: var(--ui); color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; } .tiles.small { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.tile { background: var(--bg); border-radius: 8px; padding: 8px 10px; } .tile-label { font-family: var(--ui); font-size: .78em; color: var(--muted); } .tile-value { font-size: 1.1em; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92em; } .tbl td, .tbl th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; } .tbl thead:empty, .tbl th:empty { display: none; }
.bar { display: inline-block; width: 90px; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; vertical-align: middle; } .bar-fill { display: block; height: 100%; background: var(--ok); } .bar.warn .bar-fill { background: var(--warn); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.npc { cursor: pointer; } .npc-head { display: flex; justify-content: space-between; align-items: baseline; } .chip { font-family: var(--ui); font-size: .72em; background: var(--line); border-radius: 10px; padding: 1px 8px; }
.dims { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; margin: 6px 0; font-family: var(--ui); font-size: .8em; } .dim { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.skill { display: grid; grid-template-columns: 1fr 90px 36px; align-items: center; gap: 8px; padding: 2px 0; } .skill.leaf { padding-left: 16px; } .skill-rating { text-align: right; font-variant-numeric: tabular-nums; }
.track { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; align-items: center; padding: 2px 0; }
.search { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.facts li, .notes .note { margin-bottom: 6px; } .note { padding: 6px 0; border-bottom: 1px solid var(--line); }
.prose p { margin: 0 0 .7em; } .prose p:last-child { margin-bottom: 0; } .prose blockquote { margin: .4em 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
.prose h3, .prose h4, .prose h5 { font-family: var(--ui); margin: .6em 0 .3em; font-size: 1em; } .dice { font-family: ui-monospace, Menlo, monospace; font-size: .85em; background: var(--bg); border-radius: 4px; padding: 0 4px; }
.btn { font-family: var(--ui); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; } .btn.small { padding: 4px 10px; font-size: .85em; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); } .btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
dl dt { font-family: var(--ui); color: var(--muted); font-size: .8em; margin-top: 6px; } dl dd { margin: 0; }
.roles .role { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line); font-family: var(--ui); font-size: .9em; } .roles input, .roles select { padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }

/* Play */
.play { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 24px); }
.thread { flex: 1; overflow: auto; padding: 4px 2px; }
.day-sep { text-align: center; font-family: var(--ui); font-size: .8em; color: var(--muted); margin: 14px 0 6px; }
.scene-head { font-family: var(--ui); font-size: .78em; color: var(--muted); margin: 10px 0 4px; padding: 2px 8px; border-left: 3px solid var(--line); cursor: pointer; } .scene-head.flash { background: var(--now); }
.entry { margin: 6px 0; } .entry.live .bubble { opacity: .95; }
.bubble { max-width: 46em; overflow-wrap: anywhere; padding: 10px 14px; border-radius: 14px; box-shadow: var(--shadow); white-space: pre-wrap; } .bubble.gm { white-space: normal; background: var(--gm); border: 1px solid var(--line); }
.bubble.player { background: var(--player); margin-left: auto; border-bottom-right-radius: 4px; font-family: var(--ui); font-size: .95em; }
.sms .bubble.gm { font-family: ui-monospace, Menlo, monospace; font-size: .9em; background: #e8f0e0; max-width: 24em; }
.engine-line { font-family: var(--ui); font-size: .85em; color: var(--muted); padding: 2px 10px; }
.tools { font-family: var(--ui); font-size: .8em; color: var(--muted); padding: 2px 10px; } .tool-line.err { color: var(--accent); }
.st-aborted .bubble { border-style: dashed; } .warnline { font-family: var(--ui); font-size: .8em; color: var(--warn); }
.composer-wrap { border-top: 1px solid var(--line); padding-top: 6px; background: var(--bg); }
.composer { display: flex; gap: 8px; align-items: flex-end; } .composer textarea { flex: 1; resize: none; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); max-height: 200px; }
.answering { font-family: var(--ui); font-size: .85em; color: var(--muted); padding: 2px 4px 6px; } .spinner { display: inline-block; width: 10px; height: 10px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }
.more-btn { align-self: center; margin-bottom: 6px; }
.proposals { font-family: var(--ui); font-size: .9em; } .proposal { background: var(--paper); border: 1px dashed var(--warn); border-radius: 10px; padding: 8px 10px; margin: 6px 0; } .proposal-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
textarea.json { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: .85em; }

/* the mobile strip */
.strip { display: flex; gap: 4px; overflow-x: auto; padding: 2px 0 6px; font-family: var(--ui); }
@media (min-width: 900px) { .strip { display: none; } }
.daychip { flex: 1 0 44px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 4px 2px; font-size: 11px; line-height: 1.2; cursor: pointer; } .daychip.today { background: var(--now); } .daychip.warn { border-color: var(--warn); } .daychip.gap { border-style: dashed; } .daychip .dots { color: var(--muted); letter-spacing: -1px; }
.day-sheet .day-slot { padding: 6px 8px; border-left: 4px solid var(--line); margin-bottom: 6px; border-radius: 6px; } .day-slot.now { background: var(--now); } .slot-name { font-family: var(--ui); font-weight: 600; font-size: .9em; }

/* agenda rail */
.rail-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.rail-grid { display: grid; grid-template-columns: 44px repeat(7, 1fr); gap: 2px; }
.rg-corner, .pg-corner { } .rg-day, .pg-day { text-align: center; padding: 2px 0; border-bottom: 1px solid var(--line); } .rg-day.today, .pg-day.today { background: var(--now); border-radius: 6px 6px 0 0; }
.rg-slot, .pg-slot { font-size: 10px; color: var(--muted); writing-mode: vertical-rl; transform: rotate(180deg); text-align: center; padding: 2px 0; }
.rg-cell { min-height: 44px; background: var(--bg); border-radius: 4px; padding: 2px; cursor: pointer; overflow: hidden; border: 1px solid transparent; }
.rg-cell.now, .pg-cell.now { box-shadow: inset 0 0 0 2px var(--now); animation: pulse 2s ease-in-out infinite; } @keyframes pulse { 50% { box-shadow: inset 0 0 0 2px transparent; } }
.cov-played { border-left: 3px solid var(--ok) !important; } .cov-montaged { border-left: 3px solid var(--muted) !important; } .cov-routine { border-left: 3px solid #6a8caf !important; } .cov-elided { background: repeating-linear-gradient(45deg, var(--gap) 0 3px, transparent 3px 8px) !important; } .cov-future { }
.rg-cell.warn, .pg-cell.warn { outline: 1px solid var(--warn); }
.item { display: flex; gap: 3px; align-items: center; font-size: 11px; line-height: 1.25; padding: 1px 2px; border-radius: 3px; background: var(--paper); margin-bottom: 1px; overflow: hidden; white-space: nowrap; }
.item .icon { flex: 0 0 auto; color: var(--muted); } .item-text { overflow: hidden; text-overflow: ellipsis; }
.item.st-done { text-decoration: line-through; color: var(--muted); } .item.st-partial { text-decoration: underline dotted; } .item.st-skipped, .item.st-no_record { opacity: .6; } .item.src-gm_suggest { border: 1px dashed var(--line); } .item.src-routine { color: #4b6a8a; }
.item .x { margin-left: auto; border: 0; background: transparent; cursor: pointer; color: var(--muted); padding: 0 2px; }
.pip { width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--muted); display: inline-block; } .pip.main.on, .item .pip.main { background: var(--accent); border-color: var(--accent); } .pip.side { background: var(--muted); }
.more { font-size: 10px; color: var(--muted); }

/* planner */
.tabs { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; font-family: var(--ui); overflow-x: auto; white-space: nowrap; } .tab { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 6px 10px; cursor: pointer; } .tab.active { border-bottom-color: var(--accent); font-weight: 600; } .skin-select { margin-left: auto; }
.weeknav { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; font-family: var(--ui); }
.plan-grid { display: grid; grid-template-columns: 28px repeat(7, 1fr); gap: 3px; font-family: var(--ui); }
.pg-cell { min-height: 92px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 3px; position: relative; } .pg-cell.over { background: var(--now); }
.addline { display: flex; align-items: center; gap: 2px; border-top: 1px dashed var(--line); margin-top: 2px; }
.pg-cell .free { flex: 1; min-width: 0; border: 0; border-radius: 0; background: transparent; font-size: 11px; padding: 2px; }
.pg-cell .plus { border: 1px solid var(--line); background: var(--bg); border-radius: 50%; width: 20px; height: 20px; line-height: 1; padding: 0; cursor: pointer; font-size: 14px; color: var(--muted); }
body.placing .pg-cell { outline: 2px dashed var(--now); cursor: copy; }
.capline { display: flex; gap: 4px; align-items: center; font-size: 10px; color: var(--muted); margin-top: 2px; } .pips { letter-spacing: 1px; }
.tray { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0; font-family: var(--ui); }
.chip-item { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 3px 10px; font-size: .85em; cursor: grab; } .chip-item.sel { background: var(--now); } .chip-item .icon { color: var(--muted); margin-right: 4px; }
@media (max-width: 899px) { .plan-grid { grid-template-columns: 22px repeat(7, minmax(78px, 1fr)); overflow-x: auto; } .planner-body { overflow-x: auto; } }

/* the long calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; font-family: var(--ui); }
.cal-head { text-align: center; font-size: .8em; color: var(--muted); padding: 4px 0; } .cal-head.sun { color: var(--accent); }
.cal-cell { min-height: 72px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px; font-size: 11px; cursor: pointer; overflow: hidden; } .cal-cell.empty { background: transparent; border-color: transparent; cursor: default; }
.cal-cell.sun .cal-num { color: var(--accent); } .cal-cell.today { background: var(--now); } .cal-num { font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; gap: 4px; } .cal-num .nameday { font-weight: 400; color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .cal-item.kind-deadline { color: var(--accent); } .cal-item.kind-occasion { color: #8a4b8a; } .cal-item.kind-automation { color: var(--muted); } .cal-routines { color: #4b6a8a; font-size: 9px; }
.month-title { font-size: 1.1em; }

/* skins (13-time-and-planning.md §4): the Polish paper wall calendar of 1999, the school diary */
[data-skin="wall"] .rail, [data-skin="wall"] .plan-grid, [data-skin="wall"] .cal-grid { font-family: "Arial Narrow", "Helvetica Neue", Arial, sans-serif; }
[data-skin="wall"] .cal-grid { background: #fffdf5; border: 2px solid #b8102e; border-radius: 4px; padding: 6px; } [data-skin="wall"] .cal-cell { border-radius: 0; border-color: #e6d9c0; } [data-skin="wall"] .cal-cell.sun .cal-num, [data-skin="wall"] .cal-head.sun { color: #b8102e; font-weight: 700; }
[data-skin="wall"] .month-title { color: #b8102e; text-transform: uppercase; letter-spacing: .08em; } [data-skin="wall"] .rg-day.today, [data-skin="wall"] .pg-day.today { background: #ffd9d9; } [data-skin="wall"] .nameday { font-size: 9px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-skin="diary"] .plan-grid, [data-skin="diary"] .rail-grid { background: repeating-linear-gradient(transparent 0 23px, rgba(90,120,200,.25) 23px 24px); font-family: "Comic Sans MS", "Segoe Print", cursive; } [data-skin="diary"] .pg-cell { border: 1px solid #9fb2e0; border-radius: 0; background: rgba(255,255,255,.6); } [data-skin="diary"] .rg-cell { background: rgba(255,255,255,.5); }
[data-skin="diary"] .pg-day, [data-skin="diary"] .rg-day { border-bottom: 2px solid #9fb2e0; } [data-skin="diary"] .item { background: transparent; } [data-skin="diary"] .cal-grid { font-family: "Comic Sans MS", "Segoe Print", cursive; }

/* review */
.st-done { color: var(--ok); } .st-skipped, .st-no_record { color: var(--accent); } .st-partial, .st-moved { color: var(--warn); }
.cal-list li { margin-bottom: 4px; }

/* sheets, toasts, login */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { background: var(--paper); color: var(--ink); width: min(100%, 720px); max-height: 85vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 14px 16px 24px; position: relative; font-family: var(--font); }
@media (min-width: 900px) { .sheet { align-items: center; } .sheet-body { border-radius: 14px; } }
.sheet-close { position: absolute; top: 8px; right: 10px; border: 0; background: transparent; font-size: 22px; cursor: pointer; } .sheet-body h2 { margin: 0 24px 10px 0; font-family: var(--ui); font-size: 1.05em; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 6px; font-family: var(--ui); }
.toast { background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: .9em; transition: opacity .4s; } .toast.error { background: var(--accent); color: #fff; } .toast.out { opacity: 0; }
.login { position: fixed; inset: 0; background: var(--bg); z-index: 60; display: flex; align-items: center; justify-content: center; }
.login form { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 24px 28px; display: flex; flex-direction: column; gap: 12px; min-width: 280px; } .login h1 { margin: 0 0 6px; font-size: 1.4em; } .login label { display: flex; flex-direction: column; gap: 4px; font-family: var(--ui); font-size: .9em; } .login input { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); } .login button { padding: 10px; background: var(--accent); color: #fff; border: 0; border-radius: 8px; cursor: pointer; }
