/* Seven Envelopes - ledger-green paper, kraft envelopes, banknote green cash and a red rubber stamp. */
:root {
  --bg: #eef0e8; --bg-2: #e2e6da; --card: #fbfbf6; --ink: #1b2620; --ink-2: #4b564f; --line: #cdd3c4;
  --accent: #1f5c45; --accent-ink: #ffffff;
  --kraft: #d7b37a; --kraft-2: #c49a5a; --kraft-ink: #3d2a10; --flap: #c9a265;
  --cash: #5f9a6c; --cash-2: #3f7a50; --stamp: #b3261e; --empty: #f4ece0;
  --ly-tin: #c49a5a; --ly-instant: #3f8a5c; --ly-notice: #3c6e8f; --ly-longer: #6b5a8e; --band: rgba(31, 92, 69, 0.13); --band-line: #1f5c45;
  --v-exposed: #9b1c1c; --v-thin: #8a4b05; --v-ready: #1d5d3c; --v-ink: #ffffff;
  --w-week: #9b1c1c; --w-month: #8a4b05; --w-q: #2f5d82;
  --warn-bg: #fbe9e7; --warn-ink: #8a1c1c; --note-bg: #fbf1dc; --note-ink: #6b3d05; --ok-bg: #e6f2ea; --ok-ink: #1d5640;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Rockwell", "Roboto Slab", "Clarendon", "Georgia", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1411; --bg-2: #18201b; --card: #151c18; --ink: #e8ece4; --ink-2: #aeb8af; --line: #2c3730;
  --accent: #7fcca4; --accent-ink: #0b1a12;
  --kraft: #76572e; --kraft-2: #5f451f; --kraft-ink: #fff3dc; --flap: #8a6a3c;
  --cash: #5fae78; --cash-2: #3f8a57; --stamp: #ff8a80; --empty: #232a25;
  --ly-tin: #b08a52; --ly-instant: #4fa274; --ly-notice: #5b8fb3; --ly-longer: #8f7bb8; --band: rgba(127, 204, 164, 0.14); --band-line: #7fcca4;
  --v-exposed: #ffb4ab; --v-thin: #ffd08a; --v-ready: #8fe0b4; --v-ink: #14110f;
  --w-week: #ffb4ab; --w-month: #ffd08a; --w-q: #a8cdf0;
  --warn-bg: #3a1716; --warn-ink: #ffcdc7; --note-bg: #352812; --note-ink: #ffdca3; --ok-bg: #12301f; --ok-ink: #b9ecd0;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); overflow-x: hidden; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); line-height: 1.2; overflow-wrap: anywhere; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: 0.88rem; }
.muted { color: var(--ink-2); }
.mono { font-family: var(--mono); }

/* Header */
.bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--card); flex-wrap: wrap; }
.back { color: var(--ink-2); text-decoration: none; font-size: 0.9rem; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; flex: 1; min-width: 0; font-family: var(--display); }
.logo { width: 28px; height: 28px; flex: none; }
.lg-note { fill: var(--cash); stroke: var(--cash-2); stroke-width: 1; }
.lg-env { fill: var(--kraft); stroke: var(--kraft-2); stroke-width: 1.2; }
.lg-flap { fill: none; stroke: var(--kraft-ink); stroke-width: 1.4; stroke-linejoin: round; }
.session { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Buttons */
.pill { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 6px; padding: 6px 14px; font: 600 0.88rem var(--sans); cursor: pointer; text-decoration: none; }
.pill:hover:not(:disabled) { border-color: var(--accent); }
.pill.solid { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill.ghost { cursor: default; }
.pill.big { padding: 10px 22px; font-size: 1rem; }
.pill.tiny { padding: 3px 10px; font-size: 0.8rem; }
.pill:disabled { opacity: 0.55; cursor: not-allowed; }
.chip { border: 1px dashed var(--accent); background: transparent; color: var(--ink); border-radius: 6px; padding: 5px 12px; font: 0.86rem var(--sans); cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-style: solid; }

/* Layout */
main { max-width: 1180px; margin: 0 auto; padding: 0 16px 40px; }
.hero { padding: 22px 0 8px; }
.kicker { font-size: 0.86rem; color: var(--ink-2); margin: 0 0 8px; max-width: 780px; }
.note-src { font-style: italic; }
.hero h1 { font-size: clamp(1.6rem, 4.4vw, 2.6rem); margin: 4px 0 10px; max-width: 860px; }
.lede { max-width: 780px; margin: 0 0 12px; }
.samples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; margin-top: 16px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-top: 16px; min-width: 0; }
.layout .panel { margin-top: 0; }
.ph { font-size: 1.2rem; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.step-no { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 4px; background: var(--kraft); color: var(--kraft-ink); font: 700 0.9rem var(--sans); flex: none; }
.lbl { display: block; font-size: 0.82rem; font-weight: 600; margin: 8px 0 4px; color: var(--ink-2); }
input, select, textarea { width: 100%; font: 0.95rem var(--sans); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; min-width: 0; }
textarea { font-family: var(--mono); font-size: 0.86rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.fmt { margin: 6px 0; }
.drop { border: 1px dashed var(--line); border-radius: 6px; padding: 8px; margin-top: 6px; }
.drop.over { border-color: var(--accent); background: var(--bg-2); }
.filelbl { color: var(--accent); text-decoration: underline; cursor: pointer; }
.note { background: var(--note-bg); color: var(--note-ink); border-radius: 6px; padding: 6px 10px; }
.gate { background: var(--note-bg); color: var(--note-ink); border-radius: 6px; padding: 8px 10px; }
.runrow { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 12px; }

/* Envelopes */
.env-host { margin: 6px 0 4px; }
.env-empty { color: var(--ink-2); font-style: italic; padding: 30px 0; text-align: center; }
.env-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: start; }
.env { margin: 0; min-width: 0; }
.env-pocket { position: relative; height: 150px; }
.env-cash { position: absolute; left: 12%; right: 12%; bottom: 70px; background: transparent; display: flex; flex-direction: column; justify-content: flex-end; z-index: 1; }
.env-bill { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--cash) 0 10px, var(--cash-2) 10px 11px); border: 1px solid var(--cash-2); border-radius: 2px; }
.env-bill.b2 { position: absolute; left: 10%; right: -8%; top: 8px; bottom: 0; transform: rotate(4deg); opacity: 0.85; height: auto; }
.env-front { position: absolute; left: 0; right: 0; bottom: 0; height: 92px; background: var(--kraft); border: 1px solid var(--kraft-2); border-radius: 3px; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 4px 2px 6px; color: var(--kraft-ink); clip-path: polygon(0 0, 50% 34%, 100% 0, 100% 100%, 0 100%); }
.env-flap { position: absolute; left: 0; right: 0; bottom: 92px; height: 30px; background: var(--flap); clip-path: polygon(0 100%, 50% 0, 100% 100%); z-index: 0; opacity: 0.9; }
.env-day { font: 700 0.9rem var(--display); }
.env-need { font: 700 0.95rem var(--mono); }
.env-cov { font-size: 0.72rem; line-height: 1.2; text-align: center; }
.env.st-dry .env-front, .env.st-after .env-front { background: var(--empty); color: var(--ink); border-style: dashed; border-color: var(--ink-2); }
.env.st-dry .env-flap, .env.st-after .env-flap { opacity: 0.35; }
.env.st-nothing .env-front { opacity: 0.75; }
.stamp { position: absolute; z-index: 3; left: 50%; top: 52%; transform: translate(-50%, -50%) rotate(-14deg); border: 2px solid var(--stamp); color: var(--stamp); font: 800 0.78rem var(--sans); letter-spacing: 0.08em; text-transform: uppercase; padding: 1px 6px; border-radius: 3px; background: var(--card); }
.env-lines { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.slip { display: block; font-size: 0.72rem; line-height: 1.25; background: var(--bg-2); color: var(--ink); border-left: 3px solid var(--kraft-2); padding: 2px 4px; border-radius: 2px; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
.slip.trimmed { text-decoration: line-through; text-decoration-color: var(--stamp); border-left-color: var(--stamp); }
.legend { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; flex: none; }
.sw-full { background: var(--cash); }
.sw-part { background: linear-gradient(0deg, var(--cash) 50%, var(--kraft) 50%); }
.sw-dry { background: var(--empty); border: 1px dashed var(--ink-2); }

/* Strata */
.layer-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.strata { display: grid; grid-template-columns: 46px 74px minmax(0, 1fr); gap: 10px; align-items: stretch; }
.st-axis { position: relative; height: 280px; }
.st-tick { position: absolute; right: 0; transform: translateY(50%); font: 600 0.75rem var(--mono); color: var(--accent); white-space: nowrap; }
.st-col { position: relative; height: 280px; border-left: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); background: var(--bg); }
.st-band { position: absolute; left: 0; right: 0; background: var(--band); border-top: 2px dashed var(--band-line); border-bottom: 2px dashed var(--band-line); }
.st-stack { position: absolute; left: 10px; right: 10px; top: 0; bottom: 0; display: flex; flex-direction: column-reverse; }
.st-layer { flex: none; border-top: 1px solid rgba(0, 0, 0, 0.25); }
.ly-tin { background: var(--ly-tin); } .ly-instant { background: var(--ly-instant); } .ly-notice { background: var(--ly-notice); } .ly-longer { background: var(--ly-longer); }
.st-key { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.st-key li { display: flex; gap: 8px; align-items: flex-start; }
.st-key .sw { margin-top: 4px; }
.st-txt { display: flex; flex-direction: column; min-width: 0; }
.st-total { flex-direction: column; gap: 0 !important; border-top: 1px solid var(--line); padding-top: 6px; }

/* Badges */
.badge { display: inline-block; border-radius: 4px; padding: 3px 10px; font: 700 0.82rem var(--sans); background: var(--line); color: var(--ink); white-space: nowrap; }
.badge.v-exposed { background: var(--v-exposed); color: var(--v-ink); }
.badge.v-thin { background: var(--v-thin); color: var(--v-ink); }
.badge.v-ready { background: var(--v-ready); color: var(--v-ink); }

/* Progress */
.progress h3 { margin: 0 0 8px; }
.steps { list-style: none; padding: 0; margin: 0; }
.step { color: var(--ink-2); padding: 2px 0; }
.step.active { color: var(--ink); font-weight: 600; }
.step.done { color: var(--ok-ink); }
.step-ic { font-family: var(--mono); display: inline-block; width: 1em; }
.raw { white-space: pre-wrap; font-family: var(--mono); font-size: 0.82rem; max-height: 340px; overflow: auto; }

/* Result */
.res-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.res-head h2 { margin: 0; font-size: 1.4rem; min-width: 0; }
.summary { font-size: 1.05rem; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols h3, .result h3 { font-size: 1.05rem; margin: 16px 0 6px; }
.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.trims li { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.trims .slip { display: inline-block; font-size: 0.85rem; }
.trims .how { flex-basis: 100%; font-size: 0.9rem; }
.none { color: var(--ink-2); font-style: italic; list-style: none; }
.tiers { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tier { border: 1px solid var(--line); border-top-width: 5px; border-radius: 6px; padding: 8px 10px; background: var(--bg); min-width: 0; }
.ly-edge-tin { border-top-color: var(--ly-tin); } .ly-edge-instant { border-top-color: var(--ly-instant); } .ly-edge-notice { border-top-color: var(--ly-notice); } .ly-edge-longer { border-top-color: var(--ly-longer); }
.tier-head { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.tier .role { color: var(--ink-2); margin: 6px 0 4px; }
.tier .advice { margin: 0; }
.moves { padding-left: 1.4em; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.move p { margin: 2px 0 0; }
.move-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.when { font: 700 0.76rem var(--sans); text-transform: uppercase; letter-spacing: 0.04em; border: 1.5px solid currentColor; border-radius: 3px; padding: 0 6px; }
.when-this-week { color: var(--w-week); } .when-this-month { color: var(--w-month); } .when-next-3-months { color: var(--w-q); } .when-none { color: var(--ink-2); }
.recon { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.recon li { border-radius: 6px; padding: 6px 10px; background: var(--ok-bg); color: var(--ok-ink); font-size: 0.9rem; }
.recon li.warn { background: var(--warn-bg); color: var(--warn-ink); }
.recon li.note { background: var(--note-bg); color: var(--note-ink); }
.recon li.none { font-style: normal; }
.exports, .cardrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* History */
.hist { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 8px; }
.hrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.hinfo { display: flex; flex-direction: column; flex: 1; min-width: 0; }

/* Footer, toasts */
.foot { max-width: 1180px; margin: 0 auto; padding: 10px 16px 40px; color: var(--ink-2); font-size: 0.86rem; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 6px; padding: 8px 12px; font-size: 0.9rem; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); transition: opacity 0.5s; }
.toast.err { border-left-color: var(--stamp); }
.toast.gone { opacity: 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .layer-grid { grid-template-columns: minmax(0, 1fr); }
  .tiers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .env-row { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 14px; }
  .three { grid-template-columns: 1fr 1fr; }
  .cols { grid-template-columns: minmax(0, 1fr); }
  .tiers { grid-template-columns: minmax(0, 1fr); }
  .strata { grid-template-columns: 40px 60px minmax(0, 1fr); }
  .slip { font-size: 0.66rem; padding: 2px 3px; }
  .bar { gap: 8px; }
}
@media print {
  .bar, .samples, .askbox, .histbox, .exports, .toasts, .foot { display: none !important; }
  body { background: #fff; }
}
.move .tick { width: 18px; height: 18px; margin: 0; accent-color: var(--ok-ink); cursor: pointer; }
.move.done p { text-decoration: line-through; }
.cmp-up { font-weight: 700; }
.cmp-down { font-weight: 700; font-style: italic; }
