:root {
  --paper: #f6f1e7; --card: #fffcf5; --ink: #1f1b16; --ink2: #3d362d; --muted: #675e52; --line: #e4dccd; --rule: #ebe3d3;
  --tomato: #e2482f; --tomato-ink: #b8321c; --ok: #276b43; --tight: #8a5a00; --late: #a92f19;
  --ok-bg: #e7f2ea; --tight-bg: #fbf0d9; --late-bg: #fbe5df; --hl: #fff1a8;
  --radius: 14px; --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@font-face { font-family: "Fraunces"; src: url("fonts/fraunces-latin.woff2") format("woff2"); font-weight: 400 800; font-display: swap; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 16px/1.55 var(--sans); min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); font-weight: 400; }
h2 { font: 600 13px/1.2 var(--sans); margin: 28px 0 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }

/* header */
.top { display: flex; align-items: center; gap: 22px; padding: 16px 32px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); }
.mark { width: 38px; height: 38px; flex: none; }
.word { font: 700 27px/1 var(--serif); letter-spacing: -.02em; }
.tag { margin: 0; font: italic 500 17px/1.2 var(--serif); color: var(--ink2); }
.privacy { margin: 0 0 0 auto; font-size: 13px; color: var(--muted); }
.lock { color: var(--ok); font-size: 9px; vertical-align: 2px; margin-right: 4px; }

.grid { display: grid; grid-template-columns: minmax(320px, 430px) 1fr; gap: 32px; padding: 28px 32px; flex: 1; max-width: 1280px; width: 100%; margin: 0 auto; }
.col { min-width: 0; }

/* input: a sheet of ruled paper */
.paper { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 12px; box-shadow: 0 1px 0 rgba(0,0,0,.03), 0 12px 30px -18px rgba(60,40,10,.25); }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.label-row label { font-weight: 650; }
.label-row .muted { font-size: 13px; margin-left: 4px; }
.small-actions { display: flex; gap: 12px; white-space: nowrap; }
textarea#list { width: 100%; resize: vertical; border: 0; outline: 0; background: transparent; padding: 0 2px; font: 16px/32px var(--mono); color: var(--ink);
  background-image: linear-gradient(transparent 31px, var(--rule) 31px); background-size: 100% 32px; background-attachment: local; min-height: 288px; }
textarea#list:focus-visible { box-shadow: 0 0 0 3px rgba(226,72,47,.18); border-radius: 6px; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

.settings { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.field { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 8px 6px 14px; }
.field.check { padding-right: 14px; cursor: pointer; }
.field input[type=date] { border: 0; background: transparent; font-weight: 500; }
.stepper { display: inline-flex; align-items: center; background: var(--paper); border-radius: 999px; }
.stepper input { width: 46px; text-align: center; border: 0; background: transparent; font: 600 15px var(--mono); -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.step { width: 30px; height: 30px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; font-size: 18px; line-height: 1; }
.step:hover { background: var(--line); }
input[type=checkbox] { accent-color: var(--tomato); width: 17px; height: 17px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions button, .btn { border: 1px solid var(--ink); background: transparent; border-radius: 999px; padding: 9px 16px; font-weight: 600; font-size: 14px; cursor: pointer; }
.actions button.primary, .btn.primary { background: var(--ink); color: var(--paper); }
.actions button:disabled { opacity: .35; cursor: default; }
.actions button:not(:disabled):hover, .btn:hover { transform: translateY(-1px); }
.link { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; text-decoration-color: var(--tomato); text-underline-offset: 3px; cursor: pointer; font-size: 14px; font-weight: 600; }
.link.danger { color: var(--muted); text-decoration-color: var(--line); }
.fallback { width: 100%; margin-top: 10px; font: 13px var(--mono); }
:focus-visible { outline: 3px solid rgba(226,72,47,.45); outline-offset: 2px; }

/* plan */
.empty { border: 2px dashed var(--line); border-radius: var(--radius); padding: 48px 28px; text-align: center; }
.empty .big { font: 600 28px/1.2 var(--serif); margin-bottom: 10px; }
.plan-in { animation: rise .35s ease; } @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.today { background: var(--ink); color: var(--paper); border-radius: var(--radius); padding: 20px 24px; display: flex; gap: 18px; align-items: flex-start; }
.today .when { font: 600 12px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: #d9cdb8; margin-bottom: 8px; }
.today .what { font: 600 30px/1.15 var(--serif); letter-spacing: -.01em; }
.today .what .h { color: #f26a50; font-family: var(--mono); font-size: 22px; font-weight: 600; margin-left: 8px; }
.today .more { margin-top: 6px; color: #d9cdb8; font-size: 15px; }
.today .flag { flex: none; width: 46px; height: 46px; }

.verdict { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0 0; padding: 14px 18px; border-radius: var(--radius); font: 600 21px/1.3 var(--serif); }
.verdict small { display: block; font: 400 14.5px/1.45 var(--sans); color: var(--ink2); margin-top: 4px; }
.verdict .dot { flex: none; width: 12px; height: 12px; border-radius: 50%; margin-top: 9px; }
.verdict.ok { background: var(--ok-bg); } .verdict.ok .dot { background: var(--ok); }
.verdict.tight { background: var(--tight-bg); } .verdict.tight .dot { background: var(--tight); }
.verdict.late { background: var(--late-bg); } .verdict.late .dot { background: var(--late); }

/* rescue */
.rescue { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.opt { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.opt.best { border-color: var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.opt .k { font: 600 11px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--tomato-ink); }
.opt .t { font: 600 18px/1.25 var(--serif); }
.opt .d { font-size: 14px; color: var(--ink2); }
.opt .row { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; }
.opt .btn { padding: 6px 12px; font-size: 13px; }
.opt .badge { position: absolute; top: -10px; right: 12px; background: var(--tomato-ink); color: #fff; font: 700 11px/1 var(--sans); letter-spacing: .08em; padding: 5px 8px; border-radius: 999px; text-transform: uppercase; }
.msg { width: 100%; font: 14px/1.5 var(--sans); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--paper); margin-top: 6px; resize: vertical; }

/* the backwards ribbon */
.ribbon { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 6px; overflow-x: auto; }
.ribbon svg { display: block; min-width: 520px; width: 100%; height: auto; }
.ribbon .lbl { font: 600 12.5px var(--sans); fill: var(--ink); }
.ribbon .sub { font: 500 11px var(--mono); fill: var(--muted); }
.ribbon .axis { font: 500 10.5px var(--mono); fill: var(--muted); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); padding: 6px 2px 4px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 18px; height: 8px; border-radius: 4px; margin-right: 6px; vertical-align: 1px; }

/* day by day */
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.day.is-today { border-color: var(--ink); }
.day .d { display: flex; justify-content: space-between; font-weight: 650; font-size: 14px; margin-bottom: 4px; }
.wk { color: var(--muted); font-weight: 500; }
.today-pill { background: var(--tomato-ink); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 12px; }
.block { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; padding: 3px 0; border-top: 1px dashed var(--rule); }
.block .h { font-family: var(--mono); color: var(--ink2); white-space: nowrap; }
.late-block .h { color: var(--late); }
.due { font-size: 13px; color: var(--tomato-ink); padding-top: 4px; }
.due::before { content: "⚑ "; }

table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-family: var(--mono); }
.note { font-size: 12px; color: var(--muted); }
.status { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.status.ok { background: var(--ok-bg); color: var(--ok); } .status.tight { background: var(--tight-bg); color: var(--tight); }
.status.late, .status.past { background: var(--late-bg); color: var(--late); }
.errors { background: var(--tight-bg); border-radius: var(--radius); padding: 10px 16px; font-size: 14px; }
.errors ul { margin: 0; padding-left: 18px; }
code { font-family: var(--mono); font-size: 13px; background: rgba(0,0,0,.05); padding: 1px 5px; border-radius: 5px; }

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 18px 24px 26px; border-top: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; max-width: 92vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; padding: 16px; gap: 20px; }
  .top { flex-wrap: wrap; padding: 12px 16px; gap: 6px 14px; }
  .tag { order: 3; width: 100%; font-size: 15px; }
  .privacy { font-size: 12px; }
  .today .what { font-size: 25px; }
  table { font-size: 13px; } th, td { padding: 8px; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
