:root {
  color-scheme: light;
  --paper: #FDF6B2;
  --box: #FFFBD9;
  --ink: #1F2A44;
  --ink-soft: #4A5570;
  --strip: #7A2424;
  --strip-edge: #5C1A1A;
  --line: #9DC3E6;
  --margin: #D9534F;
  --late: #A11D1D;
  --ready-ink: #1F4E8C;
  --check-bg: #FFFDF0;
  --photo-bg: #DCE3EC;
  --cols: 28px minmax(0, 1fr) minmax(64px, 120px) minmax(64px, 120px) minmax(80px, 120px) 64px 72px;
  --mcol: 28px;
  --rowh: 52px;
  --hand: 'Kalam', 'Comic Sans MS', cursive;
  --sans: 'Work Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); }
body { min-height: 100vh; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font-family: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ready-ink); outline-offset: 2px; }

.strip {
  background: var(--strip); border-bottom: 4px solid var(--strip-edge); color: var(--paper);
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px));
  font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
}
.loading { font-family: var(--hand); font-size: 20px; text-align: center; margin-top: 60px; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 20px 12px 110px; }

/* Menu */
.menu { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; margin-bottom: 18px; }
.box {
  flex: 1 1 220px; display: flex; flex-direction: column; gap: 1px;
  border: 1.5px solid var(--ink); border-radius: 4px; padding: 6px 12px; background: var(--box);
}
.label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.job-select { font-family: var(--hand); font-size: 18px; background: transparent; border: none; padding: 0; min-height: 36px; cursor: pointer; width: 100%; }
.user-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 8px; min-height: 36px; }
.user-email { font-size: 15px; overflow-wrap: anywhere; }
.user-right { display: flex; align-items: center; gap: 8px; }
.role-tag { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 3px; background: var(--ink); color: var(--paper); }
.linkish { background: none; border: none; padding: 6px 2px; font-size: 13px; font-weight: 600; text-decoration: underline; cursor: pointer; min-height: 32px; }

.btn {
  min-height: 44px; padding: 0 16px; border: 1.5px solid var(--ink); border-radius: 4px; background: var(--box);
  font-size: 15px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
}
.btn.dark { background: var(--ink); color: var(--paper); }
.btn.plain { background: transparent; }
.btn.small { min-height: 36px; font-size: 13px; padding: 0 10px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.count { font-size: 12px; padding: 1px 7px; border-radius: 999px; background: var(--ink); color: var(--paper); }
.btn.dark .count { background: var(--paper); color: var(--ink); }
.ico { display: inline-flex; line-height: 0; }
.ico svg { width: 18px; height: 18px; }

/* Heading */
.title-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; padding-left: var(--mcol); margin-bottom: 6px; }
h1 { margin: 0; font-family: var(--hand); font-weight: 700; font-size: 30px; line-height: 1.2; }
h2 { margin: 0; font-family: var(--hand); font-weight: 700; font-size: 24px; line-height: 1.2; }
.sub { font-size: 14px; }

/* Table */
.scroller { overflow-x: auto; border-top: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
.table { min-width: 0; }
.row { display: grid; grid-template-columns: var(--cols); min-height: var(--rowh); border-bottom: 1px solid var(--line); background: var(--paper); }
.row.ready { background: var(--box); }
.row.head { min-height: 40px; background: var(--ink); color: var(--paper); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; border-bottom: none; }
.row.simple { grid-template-columns: var(--mcol) minmax(0, 1fr); }
.cell { display: flex; align-items: center; padding: 0 6px; font-size: 14px; white-space: nowrap; min-width: 0; }
.cell.center { justify-content: center; padding: 0 2px; }
.cell.col { flex-direction: column; align-items: flex-start; justify-content: center; }
.mcell { border-right: 3px double var(--margin); }
.head .mcell { border-right-color: #E8807C; }
.head .tcell { padding: 0 10px; }
.tcell { flex-direction: column; align-items: stretch; justify-content: center; gap: 2px; padding: 8px 8px 6px 10px; white-space: normal; }
.task-text {
  display: block; width: 100%; padding: 0; border: none; background: transparent; text-align: left; cursor: pointer;
  font-family: var(--hand); font-size: 19px; line-height: 1.25; overflow-wrap: anywhere;
}
.archived .task-text { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.empty-text { font-family: var(--hand); font-size: 19px; padding: 6px 12px; display: flex; align-items: center; }
.ready-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.ready-note { font-size: 12px; font-weight: 600; color: var(--ready-ink); }
.late { color: var(--late); font-weight: 600; }
.late-tag { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--late); }
.done-date { font-weight: 600; }

.pill { display: inline-block; padding: 2px 6px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; border: 1.5px solid var(--ink); }
.pill.urgent { background: var(--ink); color: var(--paper); }
.pill.high { background: #F2A65A; border-color: #C9772E; }
.pill.normal { background: transparent; }
.pill.low { background: transparent; color: var(--ink-soft); border-color: #8A93A8; }

.check { width: 44px; height: 44px; border: none; background: transparent; padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.check .sq { width: 26px; height: 26px; border: 2px solid var(--ink); border-radius: 3px; background: var(--check-bg); display: flex; align-items: center; justify-content: center; }
.check .sq svg { width: 20px; height: 20px; }

.thumb {
  position: relative; width: 44px; height: 40px; border: 1.5px solid var(--ink); border-radius: 4px; padding: 0;
  background: var(--photo-bg); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 3px; display: block; }
.thumb .badge {
  position: absolute; top: -7px; right: -7px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center;
}
.addpic { width: 44px; height: 40px; border: 1.5px dashed var(--ink-soft); border-radius: 4px; background: transparent; color: var(--ink-soft); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.addpic svg { width: 20px; height: 20px; }
.restore { width: 44px; height: 40px; border: 1.5px solid var(--ink); border-radius: 4px; background: transparent; padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* Forms */
.add-form { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; padding: 16px 0 0 var(--mcol); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.grow { flex: 1 1 240px; }
.field.date { flex: 0 1 170px; }
.field.sel { flex: 0 1 150px; }
.hand-input {
  font-family: var(--hand); font-size: 18px; background: transparent; border: none; border-bottom: 2px solid var(--ink);
  padding: 4px 2px; min-height: 44px; width: 100%; border-radius: 0;
}
.box-input {
  font-size: 15px; background: var(--box); border: 1.5px solid var(--ink); border-radius: 4px; padding: 6px 8px; min-height: 44px; width: 100%;
}
textarea.hand-input { resize: vertical; min-height: 70px; line-height: 1.3; }
.form-msg { font-size: 14px; flex-basis: 100%; }
.form-msg.err { color: var(--late); font-weight: 600; }

/* Undo and notices */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  width: min(640px, calc(100% - 20px)); display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: #fff; border-radius: 6px; padding: 6px 6px 6px 14px; box-shadow: 0 6px 18px rgba(31, 42, 68, 0.3); z-index: 30;
}
.toast .msg { flex: 1 1 auto; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast .btn { background: transparent; color: #fff; border-color: #fff; }
.toast.notice { padding: 12px 16px; }

/* Task detail */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 26, 40, 0.82); display: flex; align-items: flex-start; justify-content: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 12px 24px; overflow-y: auto; z-index: 40;
}
.sheet { width: 100%; max-width: 760px; background: var(--paper); border-radius: 8px; padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.sheet-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.close { flex: 0 0 auto; width: 44px; height: 44px; border: 1.5px solid var(--ink); border-radius: 4px; background: transparent; padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px 0; }
.facts .label { margin-right: 4px; }
.edit-grid { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.photo-grid figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; }
.photo-grid figcaption { font-size: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.danger { color: var(--late); border-color: var(--late); background: transparent; }

/* People */
.panel { margin-top: 22px; }
.panel h2 { padding-left: var(--mcol); margin-bottom: 8px; }
.people-row { display: grid; grid-template-columns: var(--mcol) minmax(0, 1fr) auto; min-height: var(--rowh); border-bottom: 1px solid var(--line); align-items: center; }
.people-row .who { padding: 6px 10px; overflow-wrap: anywhere; font-size: 15px; }
.people-row .ctrls { display: flex; gap: 8px; align-items: center; padding: 4px 4px 4px 0; flex-wrap: wrap; justify-content: flex-end; }
.people-row .mcell { align-self: stretch; }
.people-row select { min-height: 40px; }
.hint { font-size: 14px; padding-left: var(--mcol); margin: 6px 0 0; max-width: 70ch; }

/* Sign in */
.signin { max-width: 440px; margin: 36px auto 0; padding: 0 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.signin p { margin: 0; font-size: 15px; line-height: 1.45; }
.code-input { font-family: var(--sans); letter-spacing: 0.3em; font-size: 22px; text-align: center; }

.phone-only { display: none; }

/* Phones, upright and sideways */
@media (max-width: 900px) {
  :root { --cols: 20px minmax(240px, 1fr) 62px 66px 72px 50px 56px; --mcol: 20px; --rowh: 44px; }
  .table { min-width: 570px; }
  .stick { position: sticky; left: 0; z-index: 1; background: inherit; }
  .stick2 { left: 20px; }
  .tcell { padding: 0 8px 0 10px; }
  .task-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 18px; line-height: 44px; min-height: 44px; }
  .desk-only { display: none !important; }
  .phone-only { display: inline; }
  .strip { padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top, 0px)); }
  .wrap { padding: 10px 10px 100px; }
  .menu { margin-bottom: 10px; }
  .box { padding: 3px 10px; }
  .job-select { min-height: 30px; }
  .user-line { min-height: 30px; }
  h1 { font-size: 22px; }
  .row.head { min-height: 32px; font-size: 10px; }
  .check .sq { width: 24px; height: 24px; }
  .thumb, .addpic, .restore { width: 40px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
