@font-face { font-family: "Instrument Sans"; src: url(/fonts/instrument-sans.woff2) format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url(/fonts/source-serif-4.woff2) format("woff2"); font-weight: 200 900; font-display: swap; }

:root {
  --ground: #F3F4F1;
  --sheet: #FFFFFF;
  --ink: #232B33;
  --ink-2: #4A535C;
  --muted: #7A838B;
  --rule: #E3E6E2;
  --rule-strong: #D3D7D2;
  --night: #24406B;
  --night-soft: #E9EEF5;
  --dealt: #2F6B4F;
  --dealt-soft: #E8F1EC;
  --warn: #9A5B13;
  --warn-soft: #FBF3E6;
  --danger: #A33A3A;
  --own: #A7ADB2;

  --sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", ui-serif, Georgia, serif;

  --r-sm: 6px;
  --r-md: 10px;
  --sheet-pad: clamp(16px, 4vw, 32px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-optical-sizing: auto;
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--night); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--ground) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.bar-in {
  max-width: 1120px; margin: 0 auto;
  display: flex; align-items: center; gap: 28px;
  padding: 12px var(--sheet-pad);
  padding-top: max(12px, env(safe-area-inset-top));
}
.mark {
  display: flex; align-items: center; gap: 10px;
  font: 500 19px/1 var(--serif); letter-spacing: -0.01em; text-decoration: none;
}
.mark svg { width: 22px; height: 22px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  text-decoration: none; color: var(--ink-2);
  padding: 6px 10px; border-radius: var(--r-sm); font-weight: 500;
}
.nav a:hover { color: var(--ink); background: #E9EBE7; }
.nav a[aria-current="page"] { color: var(--ink); background: #E4E7E2; }
.who { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.who button { background: none; border: 0; padding: 4px 0; color: var(--ink-2); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule-strong); }
.who button:hover { color: var(--ink); text-decoration-color: currentColor; }

/* ---------- page ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 28px var(--sheet-pad) 80px; }
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; align-items: start; }

/* night list */
.nights { position: sticky; top: 76px; }
.nights h2 { font: 500 13px/1 var(--sans); color: var(--muted); margin: 0 0 10px 10px; }
.nights ol { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 130px); overflow: auto; }
.nights a {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 8px;
  padding: 8px 10px; border-radius: var(--r-sm); text-decoration: none;
}
.nights a:hover { background: #E9EBE7; }
.nights a[aria-current="page"] { background: var(--sheet); box-shadow: 0 0 0 1px var(--rule); }
.nights .d { font-weight: 600; }
.nights .c { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nights .s { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.nights .s.open { color: var(--ink-2); }
.nights .s.done { color: var(--dealt); }
.nights .s.draft { color: var(--warn); }

.strip { display: none; }

/* headline */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 {
  margin: 0; font: 500 clamp(32px, 5vw, 44px)/1.05 var(--serif); letter-spacing: -0.025em; font-optical-sizing: auto;
}
.head .date { display: block; font: 400 15px/1.4 var(--sans); color: var(--muted); letter-spacing: 0; margin-top: 8px; }
.step { display: flex; gap: 6px; }

/* the tally: one tick per bochur, filled when dealt with */
.tally { display: flex; align-items: center; gap: 14px; margin: 0 0 22px; color: var(--ink-2); font-size: 14px; }
.ticks { display: flex; gap: 3px; flex-wrap: wrap; }
.ticks i { width: 6px; height: 18px; border-radius: 2px; background: var(--rule-strong); }
.ticks i.on { background: var(--dealt); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.seg { display: inline-flex; background: #E7E9E5; border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 6px; cursor: pointer; color: var(--ink-2); font-weight: 500; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--sheet); color: var(--ink); box-shadow: 0 1px 2px rgba(35, 43, 51, .12); }

/* ---------- the report sheet ---------- */
.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); }
.entry { padding: 18px var(--sheet-pad) 16px; border-top: 1px solid var(--rule); }
.entry:first-child { border-top: 0; }
.entry-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.entry-top .name { min-width: 0; }
.entry-top > :last-child { flex: none; }
.name { font-weight: 700; font-size: 16px; text-decoration: none; }
.name:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.items { list-style: none; margin: 8px 0 0; padding: 0; }
.item { display: grid; grid-template-columns: 5.2em 14px minmax(0, 1fr) auto; align-items: baseline; gap: 0 8px; padding: 3px 0; min-height: 30px; }
.item .edit { width: 26px; height: 22px; margin: -2px 0; align-self: center; }
.t { font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.t small { font-size: 12px; color: var(--muted); margin-right: 3px; }
.dot {
  width: 8px; height: 8px; border-radius: 50%; align-self: center;
  background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 16%, transparent);
}
.dot.own { background: transparent; box-shadow: inset 0 0 0 1.5px var(--own); }
.what .extra { color: var(--muted); }
.item .edit { visibility: hidden; }
.item:hover .edit, .item:focus-within .edit { visibility: visible; }
@media (hover: none) { .item .edit { visibility: visible; } }

.entry.is-dealt .name, .entry.is-dealt .what { color: var(--ink-2); }

.status { font-size: 14px; color: var(--muted); white-space: nowrap; }
.status.dealt { color: var(--dealt); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.status.dealt svg { width: 15px; height: 15px; }
.dealt-info { margin: 10px 0 0; padding: 10px 12px; background: var(--dealt-soft); border-radius: var(--r-sm); font-size: 14px; color: #24543E; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dealt-info p { margin: 0; }
.dealt-info .note { color: var(--ink); white-space: pre-wrap; }
.dealt-info .acts { display: flex; gap: 12px; }

.deal-form { margin-top: 12px; padding: 16px; border: 1px solid var(--rule); border-radius: var(--r-md); background: #FAFBFA; display: grid; gap: 14px; }
.deal-form textarea.in { min-height: 60px; }
.opt { color: var(--muted); font-weight: 400; margin-left: 4px; }
.deal-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.deal-row .acts { display: flex; gap: 8px; }
.deal-row .btn { height: 38px; }
.amount {
  display: flex; align-items: stretch; height: 38px; width: 280px; max-width: 100%;
  border: 1px solid var(--rule-strong); border-radius: 8px; background: #fff; overflow: hidden;
}
.amount:focus-within { border-color: var(--night); box-shadow: 0 0 0 3px var(--night-soft); }
.amount select {
  appearance: none; -webkit-appearance: none; border: 0; border-right: 1px solid var(--rule);
  background: #F4F5F3 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237A838B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 11px center;
  padding: 0 30px 0 12px; font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer;
}
.amount select:focus { outline: none; background-color: #ECEEEA; }
.amount .cur { display: flex; align-items: center; padding: 0 2px 0 12px; color: var(--muted); font-size: 15px; }
.amount input { flex: 1; min-width: 0; border: 0; outline: none; padding: 0 12px 0 4px; font-size: 15px; font-variant-numeric: tabular-nums; background: transparent; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--rule-strong); background: var(--sheet); color: var(--ink);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; font-size: 14px;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #BFC4BE; background: #FAFBFA; }
.btn.primary { background: var(--night); border-color: var(--night); color: #fff; }
.btn.primary:hover { background: #1C3458; }
.btn.deal { border-color: var(--rule-strong); }
.btn.deal:hover { border-color: var(--dealt); color: var(--dealt); }
.btn.quiet { border-color: transparent; background: none; color: var(--ink-2); padding-left: 8px; padding-right: 8px; }
.btn.quiet:hover { background: #ECEEEA; color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.icon:hover { background: #EEF0EC; color: var(--ink); }
.icon svg { width: 16px; height: 16px; }
.link { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); font-size: inherit; }
.link:hover { text-decoration-color: currentColor; }

label.f { display: grid; gap: 5px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.in, select.in, textarea.in {
  width: 100%; border: 1px solid var(--rule-strong); background: #fff; border-radius: 7px;
  padding: 8px 10px; font-size: 15px; line-height: 1.35;
}
.in:focus { outline: none; border-color: var(--night); box-shadow: 0 0 0 3px var(--night-soft); }
::placeholder { color: #A9B0B5; opacity: 1; }
textarea.in { resize: vertical; min-height: 64px; }

/* ---------- notices ---------- */
.notice { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--r-md); margin-bottom: 18px; font-size: 14px; }
.notice.draft { background: var(--warn-soft); color: #6B4210; border: 1px solid #F0DFC2; }
.notice.pub { background: transparent; color: var(--muted); padding: 0; margin: -8px 0 18px; }

.attn { margin-bottom: 22px; }
.attn h2, .sec h2 { font: 500 20px/1.2 var(--serif); margin: 0 0 4px; letter-spacing: -0.01em; }
.attn > p, .sec > p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.fix { padding: 14px var(--sheet-pad); border-top: 1px solid var(--rule); display: grid; gap: 10px; }
.fix:first-child { border-top: 0; }
.fix q { quotes: "“" "”"; font-weight: 500; }
.fix .err { color: var(--danger); font-size: 13px; }
.fix .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fix select.in { width: auto; min-width: 200px; }

details.texts { margin-top: 28px; }
details.texts summary { cursor: pointer; color: var(--ink-2); font-size: 14px; }
details.texts ol { margin: 12px 0 0; padding: 0; list-style: none; }
details.texts li { display: grid; grid-template-columns: 5.2em 1fr auto; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--rule); font-size: 14px; }
details.texts li .t { color: var(--muted); }

.empty { padding: 56px var(--sheet-pad); text-align: center; color: var(--muted); }
.empty h2 { font: 400 24px/1.2 var(--serif); color: var(--ink); margin: 0 0 6px; }
.empty p { margin: 0 auto; max-width: 42ch; }

/* ---------- bochurim ---------- */
.narrow { max-width: 760px; }
.search { max-width: 320px; }
.roster { list-style: none; margin: 0; padding: 0; }
.roster a { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: baseline; padding: 12px var(--sheet-pad); border-top: 1px solid var(--rule); text-decoration: none; }
.roster li:first-child a { border-top: 0; }
.roster a:hover { background: #FAFBFA; }
.roster .n { font-weight: 600; }
.roster .m { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.roster .o { font-size: 13px; color: var(--night); font-weight: 600; min-width: 9em; text-align: right; }
.roster .o.none { color: transparent; }

.back { display: inline-block; margin-bottom: 14px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--ink); }
.summary { color: var(--ink-2); margin: -6px 0 22px; }
.night-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.night-h a { font-weight: 600; text-decoration: none; }
.night-h a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- settings ---------- */
.sec { margin-bottom: 40px; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sec-h h2 { margin: 0; }
.sec-h h2 a { text-decoration: none; }
.sec-h h2 a:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.rows .tag { white-space: nowrap; }
.rows > div { display: flex; align-items: center; gap: 12px; padding: 12px var(--sheet-pad); border-top: 1px solid var(--rule); flex-wrap: wrap; }
.rows > div:first-child { border-top: 0; }
.rows .grow { flex: 1; min-width: 160px; }
.rows .sub { color: var(--muted); font-size: 13px; }
.rows .off { opacity: .5; }
.rows .in { max-width: 100%; }
.addrow { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px var(--sheet-pad); border-top: 1px solid var(--rule); background: #FAFBFA; border-radius: 0 0 var(--r-md) var(--r-md); }
.addrow .in { flex: 1; min-width: 140px; }
.choice { display: flex; gap: 10px; align-items: center; padding: 12px var(--sheet-pad); border-top: 1px solid var(--rule); cursor: pointer; }
.choice:first-child { border-top: 0; }
.choice input { accent-color: var(--night); width: 16px; height: 16px; }
.choice .in { width: auto; padding: 4px 8px; }

.swatch { width: 22px; height: 22px; border-radius: 50%; border: 0; cursor: pointer; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 16%, transparent); flex: none; }
.palette { display: flex; flex-wrap: wrap; gap: 10px; padding: 6px 0; }
.palette .swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c); }

.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #EDEFEB; color: var(--ink-2); font-weight: 500; }
.tag.error { background: #F7E7E7; color: var(--danger); }
.tag.pending { background: var(--warn-soft); color: var(--warn); }
.what .tag { margin-left: 6px; vertical-align: 1px; }

/* ---------- dialog ---------- */
dialog {
  border: 0; padding: 0; border-radius: 14px; width: min(480px, calc(100vw - 24px));
  box-shadow: 0 24px 60px rgba(25, 32, 40, .22), 0 0 0 1px rgba(25, 32, 40, .06);
  color: var(--ink);
}
dialog::backdrop { background: rgba(28, 36, 44, .34); }
dialog form { padding: 22px 22px 18px; display: grid; gap: 14px; }
dialog h2 { margin: 0; font: 500 22px/1.2 var(--serif); }
dialog .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
dialog .foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 4px; }
dialog .foot .left { margin-right: auto; }
dialog .presetpick { display: grid; gap: 2px; max-height: 260px; overflow: auto; border: 1px solid var(--rule-strong); border-radius: 8px; padding: 4px; }
dialog .presetpick label { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 14px; }
dialog .presetpick label:hover { background: #F3F5F2; }
dialog .presetpick input { position: absolute; opacity: 0; pointer-events: none; }
dialog .presetpick label:has(input:checked) { background: var(--night-soft); }
dialog .presetpick label:has(input:focus-visible) { outline: 2px solid var(--night); }
.formerr { color: var(--danger); font-size: 14px; margin: 0; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth form { width: min(360px, 100%); display: grid; gap: 14px; }
.auth .mark { font-size: 28px; margin-bottom: 4px; }
.auth .mark svg { width: 30px; height: 30px; }
.auth p { margin: 0 0 6px; color: var(--muted); }
.auth .btn { padding: 10px; font-size: 15px; }

/* password show/hide */
.pw { position: relative; display: block; }
.pw .in { padding-right: 44px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 32px; border: 0; background: none; color: var(--muted); border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.pw-toggle:hover { color: var(--ink); background: #F1F2EF; }
.pw-toggle svg { width: 18px; height: 18px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--danger); }

.loading { padding: 60px 0; text-align: center; color: var(--muted); }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; gap: 0; }
  .nights { display: none; }
  .strip {
    display: flex; gap: 6px; overflow-x: auto; margin: -8px calc(-1 * var(--sheet-pad)) 18px; padding: 2px var(--sheet-pad) 6px;
    scrollbar-width: none;
  }
  .strip::-webkit-scrollbar { display: none; }
  .strip a {
    flex: none; text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 500;
    background: #E7E9E5; color: var(--ink-2);
  }
  .strip a[aria-current="page"] { background: var(--ink); color: #fff; }
  .strip a.draft:not([aria-current]) { box-shadow: inset 0 0 0 1px #E7C99A; background: var(--warn-soft); }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .bar-in { gap: 14px; }
  .nav a { padding: 6px 8px; }
  .who .uname { display: none; }
  .page { padding-top: 22px; }
  .item { grid-template-columns: 4.6em 12px minmax(0, 1fr) auto; gap: 0 6px; }
  .amount { width: 100%; }
  .deal-row .acts { width: 100%; justify-content: flex-end; }
  .roster a { grid-template-columns: 1fr auto; }
  .roster .m { grid-column: 1; grid-row: 2; }
  .roster .o { grid-row: 1 / 3; align-self: center; min-width: 0; }
  .roster .o.none { display: none; }
  dialog .two { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .mark span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
