html, body { height: 100%; }
body { overflow: hidden; }
.muted { color: var(--muted); }
.small-text { font-size: .85rem; }
.wide { width: 100%; }
.stack { display: grid; gap: 12px; }
.row-gap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-gap.end { justify-content: flex-end; }
.error { color: var(--red); font-size: .9rem; margin: 0; }
.danger { color: var(--red) !important; border-color: var(--red) !important; }
kbd, code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .82em; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 4px; padding: 1px 5px; }
.icon-btn { background: none; border: 0; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 1.3rem; line-height: 1; color: var(--muted); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--red-soft); color: var(--ink); }
.pro-tag { font-size: .68rem; font-weight: 700; color: var(--red); border: 1px solid var(--red); border-radius: 4px; padding: 0 4px; margin-left: 4px; vertical-align: 1px; }

.boot { height: 100%; display: grid; place-items: center; font-size: 1.4rem; }

/* Auth */
.auth { height: 100%; overflow: auto; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); background: var(--paper-2); border: 2px solid var(--ink); border-radius: 16px; padding: 28px; display: grid; gap: 14px; }
.auth-card h1 { font-size: 1.7rem; margin: 6px 0 0; letter-spacing: -.02em; }
.auth-card p { margin: 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.or { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: .85rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.auth-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.auth-card hr { border: 0; border-top: 1px solid var(--rule); width: 100%; margin: 4px 0; }
.fine { font-size: .8rem; }

/* Shell */
.shell { height: 100%; display: grid; grid-template-columns: 260px minmax(0, 1fr) auto; }
.sidebar { background: var(--paper-2); border-right: 1.5px solid var(--rule); display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 16px 12px; gap: 16px; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.views { display: grid; gap: 2px; }
.views button { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; font-weight: 500; }
.views button:hover { background: var(--paper); }
.views button[aria-current="page"] { background: var(--red-soft); color: var(--ink); font-weight: 600; }
.views .ico { width: 18px; text-align: center; color: var(--muted); font-weight: 700; }
.views .shame .ico { color: var(--red); font-family: var(--font-pen); }
.views .count { margin-left: auto; font-size: .8rem; color: var(--muted); }
.views.small button { font-size: .95rem; padding: 6px 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin: 0 4px; }
.side-section { display: grid; gap: 6px; }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 0 6px 0 10px; }
.side-head h2 { font-size: .8rem; font-weight: 700; color: var(--muted); margin: 0; letter-spacing: .02em; }
.side-foot { margin-top: auto; display: grid; gap: 8px; }
.plan-chip { background: var(--paper); border: 1.5px dashed var(--rule); border-radius: 10px; padding: 10px 12px; text-align: left; cursor: pointer; font-size: .88rem; line-height: 1.35; }
.plan-chip strong { display: block; font-size: .95rem; }
.plan-chip.pro { border-color: var(--red); border-style: solid; }

.main { min-width: 0; min-height: 0; overflow-y: auto; position: relative; }
/* The page itself. On wide screens it becomes a centered sheet on a desk (see below). */
.sheet {
  --mx: clamp(36px, 5vw, 70px);
  min-height: 100%; position: relative; padding: 0 clamp(16px, 4vw, 48px) 80px clamp(56px, 7vw, 96px);
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, transparent calc(var(--mx) - 1px), var(--margin) calc(var(--mx) - 1px) calc(var(--mx) + 1px), transparent calc(var(--mx) + 1px)),
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px) var(--line));
  background-attachment: local;
}
.topbar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 12px; padding: 18px 0 12px; background: var(--paper); }
.topbar h1 { font-size: 1.7rem; margin: 0; letter-spacing: -.02em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search { width: min(260px, 40vw); }
.search .input { padding: 8px 12px; }

.quick-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 6px 0 18px; position: sticky; top: 72px; z-index: 2; background: var(--paper); padding-bottom: 8px; }
.quick-add .input { border-color: var(--ink); font-size: 1.02rem; padding: 12px 14px; }
.chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; }
.chips span { font-size: .8rem; background: var(--hl); color: var(--ink); border-radius: 999px; padding: 2px 10px; font-weight: 600; }

.banner { background: var(--paper-2); border: 1.5px dashed var(--red); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: .92rem; }
.banner p { margin: 0; }

/* Lists */
.group-title { font-size: .95rem; font-weight: 700; margin: 22px 0 4px; display: flex; gap: 8px; align-items: baseline; }
.group-title .muted { font-weight: 500; font-size: .85rem; }
.group-title.overdue { color: var(--red); }
ul.tasks { list-style: none; margin: 0; padding: 0; }
li.task { position: relative; padding: 8px 6px 10px; border-radius: 8px; cursor: pointer; }
li.task:hover { background: color-mix(in srgb, var(--paper-2) 70%, transparent); }
li.task.selected { background: var(--paper-2); box-shadow: inset 3px 0 0 var(--red); }
li.task.dragging { opacity: .4; }
li.task.drop-above { box-shadow: inset 0 3px 0 var(--red); }
.row { display: flex; gap: 12px; align-items: flex-start; }
.check { appearance: none; -webkit-appearance: none; width: 22px; height: 22px; margin: 2px 0 0; border: 2px solid var(--p4); border-radius: 50%; flex: none; cursor: pointer; background: var(--paper-2); position: relative; }
.check.p1 { border-color: var(--p1); background: color-mix(in srgb, var(--p1) 12%, var(--paper-2)); }
.check.p2 { border-color: var(--p2); background: color-mix(in srgb, var(--p2) 12%, var(--paper-2)); }
.check.p3 { border-color: var(--p3); background: color-mix(in srgb, var(--p3) 12%, var(--paper-2)); }
.check:checked { background: var(--ink); border-color: var(--ink); }
.check:checked::after { content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px; border: solid var(--paper); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.check:hover:not(:checked)::after { content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px; border: solid var(--faint); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.t-body { flex: 1; min-width: 0; }
.t-title { font-size: 1.04rem; line-height: 1.4; word-break: break-word; }
.t-title mark { background: linear-gradient(transparent 55%, var(--hl) 55%); color: inherit; padding: 0 2px; }
.help-chip { margin-left: 8px; padding: 1px 9px; border: 1px solid var(--red); border-radius: 999px; background: transparent; color: var(--red); font-size: .78rem; font-weight: 600; line-height: 1.5; vertical-align: 2px; cursor: pointer; white-space: nowrap; }
.help-chip:hover:not(:disabled) { background: var(--red-soft); }
.help-chip:disabled { opacity: .7; cursor: default; }
li.task.done .t-title { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2px; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .8rem; color: var(--muted); margin-top: 2px; }
.meta .due.overdue { color: var(--red); font-weight: 600; }
.meta .due.today { color: #2E8B57; font-weight: 600; }
.meta .proj { display: inline-flex; align-items: center; gap: 4px; }
.roast-note { font-family: var(--font-pen); color: var(--red); font-size: 1.08rem; line-height: 1.35; margin: 4px 0 0 34px; transform: rotate(-.5deg); transform-origin: left; }
.roast-note.writing { animation: ink .9s ease-out; }
.roast-note.kind { color: var(--p3); }
@keyframes ink { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.roast-note.pending { opacity: .6; }

.empty { padding: 40px 0; }
.empty p { font-family: var(--font-pen); color: var(--red); font-size: 1.35rem; margin: 0 0 6px; }
.empty .muted { font-family: var(--font-body); font-size: .95rem; color: var(--muted); }

/* Report card */
.report { max-width: 640px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 14px; padding: 24px; margin-top: 16px; position: relative; }
.report .big-grade { position: absolute; top: 14px; right: 20px; font-family: var(--font-pen); color: var(--red); font-size: 4rem; font-weight: 700; line-height: 1; transform: rotate(8deg); }
.report h2 { margin: 0 0 16px; font-size: 1.3rem; }
.report table { width: 100%; border-collapse: collapse; }
.report td { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.report td:last-child { text-align: right; font-weight: 600; }
.teacher { font-family: var(--font-pen); color: var(--red); font-size: 1.25rem; line-height: 1.4; margin: 18px 0 10px; min-height: 1.4em; }

/* Drawer */
.drawer { width: min(420px, 100vw); overflow: hidden; background: var(--paper-2); border-left: 1.5px solid var(--rule); display: flex; flex-direction: column; min-height: 0; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.drawer-body { padding: 16px 18px 40px; overflow-y: auto; overflow-x: hidden; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; }
.d-title-row { display: flex; gap: 10px; align-items: flex-start; }
.d-title { flex: 1; border: 0; background: none; resize: none; font-size: 1.25rem; font-weight: 600; line-height: 1.35; padding: 0; overflow: hidden; }
.d-title:focus { outline: none; box-shadow: 0 2px 0 var(--rule); }
.drawer .roast-note { margin-left: 32px; }
.d-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.drawer .input { min-width: 0; }
.subtasks { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.subtasks li { display: flex; align-items: center; gap: 10px; }
.subtasks li.done span { text-decoration: line-through; color: var(--faint); }
.subtasks .check { width: 18px; height: 18px; margin: 0; }
.subtasks .check:checked::after { left: 4px; top: 1px; width: 5px; height: 9px; }
.subtasks .icon-btn { width: 26px; height: 26px; font-size: 1rem; margin-left: auto; }
.sub-form { display: flex; gap: 8px; }
.sub-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.d-subtasks { padding: 12px; border: 1.5px solid var(--rule); border-radius: 10px; background: var(--paper); }
.sub-progress { height: 4px; border-radius: 999px; background: var(--rule); overflow: hidden; }
.sub-progress span { display: block; height: 100%; background: #2E8B57; transition: width .3s ease; }
/* "Next step" line in the list */
.next-step { display: flex; align-items: flex-start; gap: 8px; margin: 2px 0 0 34px; font-size: .9rem; }
.next-step .check.mini { width: 16px; height: 16px; margin: 2px 0 0; flex: none; }
.next-step .check.mini:checked::after, .next-step .check.mini:hover:not(:checked)::after { left: 4px; top: 1px; width: 4px; height: 8px; }
.ns-body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.ns-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #2E8B57; }
.ns-text { color: var(--ink); }
.ns-count { font-size: .75rem; color: var(--faint); }
.next-step .sub-acts { display: inline-flex; }
/* Help is advice, not a roast, so it's written in blue ink */
.help-note { font-family: var(--font-pen); color: var(--p3); font-size: 1.02rem; line-height: 1.35; margin: 0; }
.sub-form .input { flex: 1; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; margin-top: 8px; }

/* Dialogs */
.dlg { border: 2px solid var(--ink); border-radius: 16px; padding: 0; background: var(--paper-2); color: var(--ink); width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); }
.dlg.small { width: min(440px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(20, 27, 43, .45); }
.dlg-inner { padding: 20px 22px 24px; display: grid; gap: 14px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h2 { margin: 0; font-size: 1.3rem; }
.set-group { display: grid; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--rule); }
.set-group h3 { margin: 0; font-size: 1rem; }
.set-group p { margin: 0; }
.set-group .seg, .field .seg, .set-group > .btn { justify-self: start; }
.toggle { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--red); }
.plan-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tier { display: grid; gap: 8px; }
.tier h3 { margin: 6px 0 0; font-size: 1.15rem; }
.tier h3 .pen { font-size: 1rem; font-weight: 400; margin-left: 6px; }
.tier p { margin: 0; }
/* Coach action links under a subtask */
.sub-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.sub-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.sub-act { font: inherit; font-size: .8rem; font-weight: 600; color: var(--p3); background: none; border: 1px solid var(--rule); border-radius: 999px; padding: 1px 9px; text-decoration: none; cursor: pointer; }
.sub-act:hover { border-color: var(--p3); }
.plan-opt { display: grid; gap: 2px; padding: 16px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); cursor: pointer; text-align: left; }
.plan-opt strong { font-size: 1.5rem; }
.plan-opt span { color: var(--muted); font-size: .9rem; }
.plan-opt.best { border-color: var(--red); }
.plan-opt:disabled { opacity: .5; cursor: wait; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatches button[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--paper-2) inset; }
table.help { border-collapse: collapse; width: 100%; font-size: .92rem; }
table.help td { padding: 6px 4px; border-bottom: 1px solid var(--rule); }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 12px; display: flex; gap: 14px; align-items: center; max-width: calc(100vw - 24px); box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast .linkish { color: var(--hl); font-weight: 600; }

/* Wide screens: the app is one centered group on a desk. Sidebar and sheet sit
   side by side; the task drawer opens as a third card and the group re-centers. */
@media (min-width: 1240px) {
  .shell {
    display: flex; justify-content: center; gap: 16px; padding: 24px 20px 0;
    background-color: var(--desk);
    background-image: radial-gradient(var(--desk-dot) 1px, transparent 1.2px);
    background-size: 22px 22px;
  }
  .sidebar, .main, .drawer {
    border: 0; border-radius: 8px 8px 0 0;
    box-shadow: 0 1px 2px rgba(31,42,68,.08), 0 10px 30px -8px rgba(31,42,68,.18);
  }
  .sidebar { flex: 0 0 260px; }
  .main { flex: 0 1 880px; background: var(--paper); }
  .drawer { flex: 0 0 400px; }
  .sheet { --mx: 64px; padding: 0 44px 80px 92px; }
}

/* Responsive */
.only-mobile { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(20,27,43,.4); z-index: 9; }
@media (max-width: 1100px) {
  .shell { grid-template-columns: 240px minmax(0, 1fr); }
  .drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 10; box-shadow: -8px 0 24px rgba(0,0,0,.15); padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
}
@media (max-width: 760px) {
  .only-mobile { display: inline-grid; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(290px, 85vw); z-index: 10; transform: translateX(-105%); transition: transform .2s ease; padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
  .sidebar.open { transform: none; }
  .sheet { padding-left: 44px; padding-right: 14px; --mx: 26px; }
  .topbar h1 { font-size: 1.35rem; }
  .search { width: 38vw; }
  .quick-add { top: 64px; }
  .d-grid { grid-template-columns: 1fr; }
  .plan-pick { grid-template-columns: 1fr; }
}
