:root {
  color-scheme: light dark;
  --door: #f2f0ec;
  --panel: #fbfaf8;
  --ink: #1f2a22;
  --on-ink: #fff;
  --muted: #6b6f68;
  --button: #fff;
  --border: #c9c6bf;
  --line: #e3e0da;
  --hover: #efede8;
  --plus: #b5b3ad;
  --danger: #a1261b;
  --offline: #ffe0dc;
  --today: #fff4de;
  --late: #ffe7e4;
  --note-ink: #1f2a22;   /* sticky notes stay bright, so their text stays dark */
  --pink: #f4a9bd;
  --lightblue: #bfe0e8;
  --green: #c3dd8e;
  --blue: #45b4e0;
  --orange: #f78a3c;
  --yellow: #f6cf6a;
  --hand: "Segoe Print", "Noteworthy", "Bradley Hand", "Comic Sans MS", cursive;
}
@media (prefers-color-scheme: dark) {
  :root {
    --door: #171a17;
    --panel: #222621;
    --ink: #ecebe4;
    --on-ink: #171a17;
    --muted: #a6aba0;
    --button: #2e332d;
    --border: #4d534a;
    --line: #373c35;
    --hover: #30352f;
    --plus: #686e64;
    --danger: #ff9d90;
    --offline: #55261f;
    --today: #48360f;
    --late: #4e211c;
  }
  .note, .head, .title-note { filter: brightness(.93); }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--door);
  color: var(--ink);
  font: 16px/1.4 system-ui, "Segoe UI", sans-serif;
  padding: 0 max(16px, env(safe-area-inset-right)) 90px max(16px, env(safe-area-inset-left));
}
h1, h2, .note .title, .note .detail { font-family: var(--hand); }
h1, h2 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.25rem; }
header, main { max-width: 1400px; margin: 0 auto; }
header {
  display: flex; flex-wrap: wrap; gap: 12px 24px;
  align-items: center; justify-content: space-between; padding: 18px 0;
}
.title-note {
  background: var(--yellow); color: var(--note-ink); padding: 6px 22px; text-align: center;
  transform: rotate(-1deg); box-shadow: 0 3px 8px rgb(0 0 0 / .14);
}
.title-note p { margin: 0; font-family: var(--hand); font-size: .9rem; }

.scoreboards { display: flex; flex-wrap: wrap; gap: 12px; }
.scorecard { background: var(--panel); border-radius: 12px; padding: 8px 12px 10px; text-align: center; }
.scorecard h2 { font-size: 1rem; margin-bottom: 4px; }
.versus { display: flex; align-items: center; gap: 8px; }
.side { display: grid; min-width: 88px; padding: 2px 8px; border-radius: 4px; }
.side small { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.side b { font-family: var(--hand); font-size: 1.5rem; line-height: 1.2; }
.side.lead { background: var(--yellow); color: var(--note-ink); transform: rotate(-1.2deg); box-shadow: 0 3px 7px rgb(0 0 0 / .18); }
.side.lead small { color: var(--note-ink); }

button, input, select, textarea { font: inherit; color: inherit; }
button {
  min-height: 40px; padding: 6px 14px; cursor: pointer;
  background: var(--button); border: 1px solid var(--border); border-radius: 8px;
}
button.primary, .filter button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
button.danger { color: var(--danger); }
:focus-visible { outline: 3px solid #1565c0; outline-offset: 2px; }

.offline { max-width: 1400px; margin: 0 auto 12px; padding: 10px 14px; background: var(--offline); border-radius: 8px; }

.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.filter { display: flex; flex-wrap: wrap; gap: 6px; }
.toolbar input {
  flex: 0 1 300px; min-width: 200px; min-height: 40px; font-size: 16px; padding: 6px 12px;
  background: var(--button); border: 1px solid var(--border); border-radius: 8px;
}

.reminders { background: var(--panel); border-radius: 12px; padding: 14px 16px; margin-bottom: 22px; }
.reminder-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.reminder {
  text-align: left; border-left: 8px solid #8a8d86; display: grid;
}
.reminder small { color: var(--muted); }
.reminder.today { border-left-color: #e08a00; background: var(--today); }
.reminder.late { border-left-color: #c22a1d; background: var(--late); }
.empty { color: var(--muted); margin: 4px 0; }

.columns { display: grid; gap: 24px; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.head {
  color: var(--note-ink); display: inline-block; padding: 6px 16px; margin-bottom: 14px;
  box-shadow: 0 2px 6px rgb(0 0 0 / .12); transform: rotate(-.8deg);
}
.pink { background: var(--pink); }
.lightblue { background: var(--lightblue); }
.green { background: var(--green); }
.blue { background: var(--blue); }
.orange { background: var(--orange); }
.yellow { background: var(--yellow); }
.columns section { border-top: 6px solid var(--yellow); padding-top: 14px; }

.notes { display: grid; gap: 18px 14px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.note {
  color: var(--note-ink); position: relative; display: flex; flex-direction: column; min-height: 170px;
  box-shadow: 0 6px 12px -4px rgb(0 0 0 / .28); transform: rotate(-.7deg);
}
.note:nth-child(even) { transform: rotate(.8deg); }
.note::before {
  content: ""; position: absolute; top: -9px; left: 25%; width: 50%; height: 18px;
  background: rgb(255 255 255 / .5); border: 1px solid rgb(0 0 0 / .05);
}
.note .body {
  flex: 1; min-height: 0; background: none; border: 0; border-radius: 0;
  text-align: left; padding: 16px 12px 8px; display: flex; flex-direction: column; gap: 4px;
  overflow-wrap: anywhere; hyphens: auto;
}
.note .title { font-weight: 600; font-size: 1.02rem; }
.note .detail { font-size: .9rem; }
.note .meta { margin-top: auto; display: flex; flex-wrap: wrap; gap: 4px; font-size: .8rem; }
.chip { background: rgb(255 255 255 / .75); border-radius: 20px; padding: 1px 8px; }
.chip.who { background: var(--note-ink); color: #fff; font-weight: 600; }
.chip.late { background: #c22a1d; color: #fff; }
.chip.today { background: #7a4a00; color: #fff; }
.ticks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 6px; }
.ticks button {
  padding: 4px 2px; font-size: .82rem; background: rgb(255 255 255 / .62); border-color: transparent;
}
.ticks button:hover { background: #fff; }
.ticks .both { grid-column: 1 / -1; }

.outings { margin-top: 34px; border-top: 6px solid var(--yellow); padding-top: 14px; }
.section-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.section-bar select { min-height: 40px; border-radius: 8px; }

.bottom { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 34px; align-items: start; }
.weight, .done { background: var(--panel); border-radius: 12px; padding: 14px 16px; }
.side-lists { display: grid; gap: 24px; }
.trash summary { font-family: var(--hand); font-size: 1.25rem; font-weight: 700; cursor: pointer; min-height: 32px; }
.trash li span { text-decoration: none !important; }
table { width: 100%; border-collapse: collapse; margin: 10px 0; table-layout: fixed; }
th, td { border: 2px solid var(--ink); border-width: 0 0 2px; padding: 2px; vertical-align: middle; }
th:first-child, td:first-child { width: 58px; font-family: var(--hand); text-align: left; }
th { font-family: var(--hand); font-size: 1.1rem; }
th button { display: block; width: 100%; font: .78rem/1.3 system-ui, sans-serif; color: var(--muted); border: 0; background: none; min-height: 32px; }
td button { width: 100%; min-height: 52px; border: 0; background: none; display: flex; gap: 8px; align-items: center; justify-content: center; }
td button:hover { background: var(--hover); }
.sticker { font-size: 1.6rem; }
.cell-text { display: grid; font-size: .85rem; text-align: left; }
.cell-text small { color: var(--muted); }
.plus { color: var(--plus); }

.done ul { list-style: none; margin: 10px 0 0; padding: 0; max-height: 460px; overflow: auto; }
.done li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.done li i { width: 12px; height: 28px; flex: none; }
.done li div { flex: 1; display: grid; }
.done li span { text-decoration: line-through; }
.done li small { color: var(--muted); }

dialog { width: min(440px, calc(100vw - 24px)); border: 0; border-radius: 14px; padding: 18px; box-shadow: 0 20px 60px rgb(0 0 0 / .35); background: var(--panel); color: var(--ink); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog form { display: grid; gap: 10px; }
dialog label { display: grid; gap: 3px; font-size: .9rem; }
dialog input, dialog select, dialog textarea { width: 100%; min-height: 40px; font-size: 16px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--button); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: .9rem; padding: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.swatches label { display: block; }
.swatches input { position: absolute; opacity: 0; width: 1px; min-height: 1px; }
.swatches span { display: block; width: 40px; height: 40px; border-radius: 6px; cursor: pointer; border: 1px solid rgb(0 0 0 / .15); }
.swatches input:checked + span { outline: 3px solid var(--ink); outline-offset: 1px; }
.swatches input:focus-visible + span { outline: 3px solid #1565c0; }
.stickers { display: flex; flex-wrap: wrap; gap: 4px; }
.stickers button { padding: 2px 8px; font-size: 1.3rem; }
.actions { display: flex; gap: 8px; margin-top: 6px; }
.actions span { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; gap: 12px; align-items: center; width: max-content; max-width: calc(100vw - 24px);
  background: var(--ink); color: var(--on-ink); padding: 8px 8px 8px 16px; border-radius: 12px;
}
.toast button { color: var(--ink); white-space: nowrap; }

.login main { display: grid; gap: 28px; justify-items: center; max-width: 360px; padding-top: 12vh; }
.login-card { width: 100%; display: grid; gap: 14px; background: var(--panel); border-radius: 14px; padding: 18px; border-top: 6px solid var(--yellow); }
.login-card label { display: grid; gap: 4px; }
.login-card input, .login-card select { width: 100%; min-height: 44px; font-size: 16px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--button); }
.login-card .offline { margin: 0; }

.account { display: flex; justify-content: flex-end; align-items: center; gap: 10px; max-width: 1400px; margin: 0 auto 10px; color: var(--muted); font-size: .9rem; }
.account button { min-height: 32px; padding: 2px 12px; }

/* Text on a colour of your own */
.on-dark, .on-dark.note, .on-dark.head { color: #fff; }
.strong-ink, .strong-ink.note, .strong-ink.head { color: #000; }
.on-dark .chip:not(.who, .late, .today, .match), .on-dark .ticks button, .on-dark .hearts button { color: var(--note-ink); }

.header-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.dump { display: flex; gap: 8px; margin-bottom: 14px; padding: 12px; background: var(--panel); border-radius: 12px; border-top: 6px solid var(--yellow); }
.dump input, .dump select { min-height: 44px; font-size: 16px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--button); }
.dump input { flex: 1; min-width: 0; }

.inbox { margin-bottom: 22px; }
.sorting { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 6px; }
.sorting small { width: 100%; }
.sorting button { flex: 1 1 44%; min-width: 0; min-height: 34px; padding: 2px 4px; font-size: .8rem; border-color: rgb(0 0 0 / .3); color: var(--note-ink); overflow-wrap: anywhere; }
.sorting button.on-dark { color: #fff; }

.cat-bar { display: flex; align-items: center; gap: 4px; margin-bottom: 14px; }
.cat-bar .head { margin-bottom: 0; overflow-wrap: anywhere; }
.edit-cat { flex: none; min-width: 36px; min-height: 36px; padding: 0 6px; background: none; border-color: transparent; color: var(--muted); }
.section-bar .cat-bar { margin-bottom: 14px; }
.outing-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.outing-tools input { width: 72px; min-height: 40px; font-size: 16px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--button); }

.hearts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 6px 6px 0; }
.hearts button { min-height: 34px; padding: 2px; font-size: .82rem; background: rgb(255 255 255 / .38); border-color: transparent; }
.hearts button[aria-pressed="true"], .on-dark .hearts button[aria-pressed="true"] { background: #fff; color: #a30f3a; font-weight: 700; }
.chip.match { background: #a30f3a; color: #fff; font-weight: 600; }

.surprise { display: grid; gap: 6px; justify-items: center; text-align: center; margin: 14px 0; padding: 22px 16px; font-family: var(--hand); color: var(--note-ink); box-shadow: 0 6px 12px -4px rgb(0 0 0 / .28); transform: rotate(-.8deg); }
.surprise.on-dark { color: #fff; }
.surprise strong { font-size: 1.35rem; }

.swatches input[type="color"] { position: static; opacity: 1; width: 56px; height: 40px; min-height: 40px; padding: 2px; cursor: pointer; }
.swatches label.custom { display: flex; align-items: center; gap: 6px; }

/* Wall mode: bigger, only what is useful from across the room. The class is on
   <html> so that every rem size grows with it. */
html.wall { font-size: 20px; }
.wall body { font-size: 1rem; }
.wall header, .wall main { max-width: none; }
.wall .scoreboards, .wall .outings, .wall .bottom { display: none; }
.wall main { display: flex; flex-direction: column; }
.wall .dump { order: -2; }
.wall .reminders { order: -1; }
.wall button, .wall .dump input, .wall .dump select, .wall .toolbar input { min-height: 52px; }
.wall .dump input, .wall .dump select, .wall .toolbar input { font-size: 1.1rem; }
.wall .columns { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.wall .notes { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.wall .ticks { grid-template-columns: 1fr; }
.wall .ticks button, .wall .sorting button { min-height: 48px; font-size: .85rem; }

#night { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: rgb(0 0 0 / .9); color: #70756d; cursor: pointer; }
#night[open] { display: flex; align-items: center; justify-content: center; }
#night::backdrop { background: transparent; }

@media (max-width: 1000px) {
  .columns, .bottom { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .notes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 10px; }
  .ticks { grid-template-columns: 1fr; }
  .note .body { padding-left: 9px; padding-right: 7px; }
  .note .title { font-size: .86rem; }
  .actions { flex-wrap: wrap; }
  .scoreboards, .scorecard { width: 100%; }
  .versus { justify-content: center; }
  .toolbar input { flex: 1 1 100%; }
  .dump { flex-wrap: wrap; }
  .dump input { order: -1; flex: 1 1 100%; }
  .dump select { flex: 1; }
  .hearts { grid-template-columns: 1fr; }
}
