/* Did I?: soft rose with calm pastel tiles. Deliberately no dark green or teal, and no red alarms. */
:root {
  --bg: #fcf7f8;
  --card: #ffffff;
  --ink: #33252a;
  --ink-2: #6b545b;
  --rule: #efdde2;
  --accent: #b23a5e;        /* buttons: white text on this is 5.9:1 */
  --accent-ink: #ffffff;
  --accent-soft: #fbe3ea;
  --focus: #b23a5e;
  --shadow: 0 1px 2px rgb(51 37 42 / .06), 0 8px 24px rgb(51 37 42 / .07);
  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* tile colours: soft fill + edge */
  --rose: #fde4ea;  --rose-edge: #e98aa0;
  --sky: #e1effb;   --sky-edge: #7fb3e0;
  --sun: #fdf1c9;   --sun-edge: #dcb23a;
  --mint: #e0f3dd;  --mint-edge: #8cc98a;
  --lilac: #ece6fb; --lilac-edge: #a995e6;
  --peach: #fde6d6; --peach-edge: #eea77c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1719;
    --card: #282023;
    --ink: #f6ecef;
    --ink-2: #d3bfc5;
    --rule: #43363a;
    --accent: #f2a1b6;
    --accent-ink: #2a1219;
    --accent-soft: #452c34;
    --focus: #f2a1b6;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .3);
    --rose: #3d2830;  --sky: #23303d;  --sun: #3a3322;
    --mint: #25332a;  --lilac: #2f2a40; --peach: #3d2d24;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1.0625rem/1.55 var(--font);
  padding-inline: clamp(16px, 4vw, 40px);
}
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top { max-width: 1080px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-block: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.25rem; }
.brand img { border-radius: 9px; }
.home-link { text-decoration: none; font-weight: 700; font-size: .95rem; padding: 8px 14px; border: 1px solid var(--rule); border-radius: 999px; background: var(--card); white-space: nowrap; }

main { max-width: 1080px; margin: 0 auto; display: grid; gap: 18px; padding-bottom: 28px; }
.lead { margin: 4px 0 0; font-size: clamp(1.1rem, 2.4vw, 1.3rem); max-width: 60ch; }
.hint { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); max-width: 60ch; }
.card { background: var(--card); border: 1px solid var(--rule); border-radius: 18px; padding: 18px 20px; box-shadow: var(--shadow); }
.help { margin: 6px 0 14px; color: var(--ink-2); }

.btn {
  font: 700 1rem/1.2 var(--font); color: var(--ink); background: var(--card);
  border: 2px solid var(--rule); border-radius: 12px; padding: 10px 16px; min-height: 48px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.quiet { color: var(--ink-2); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.file-btn { display: inline-flex; align-items: center; }
input[type=text], input[type=time], select {
  font: 400 1.05rem/1.3 var(--font); color: var(--ink); background: var(--bg);
  border: 2px solid var(--rule); border-radius: 12px; padding: 9px 12px; min-height: 48px;
}
input:focus, select:focus { border-color: var(--accent); outline: none; }
label > span { display: block; font-weight: 700; font-size: .92rem; margin-bottom: 4px; }

/* The buttons you tap */
.items { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 14px; }
.item {
  --fill: var(--rose); --edge: var(--rose-edge);
  position: relative; display: flex; flex-direction: column;
  background: var(--fill); border: 2px solid color-mix(in oklab, var(--edge) 55%, transparent); border-radius: 20px;
}
.item[data-color="sky"]   { --fill: var(--sky);   --edge: var(--sky-edge); }
.item[data-color="sun"]   { --fill: var(--sun);   --edge: var(--sun-edge); }
.item[data-color="mint"]  { --fill: var(--mint);  --edge: var(--mint-edge); }
.item[data-color="lilac"] { --fill: var(--lilac); --edge: var(--lilac-edge); }
.item[data-color="peach"] { --fill: var(--peach); --edge: var(--peach-edge); }
.tap {
  flex: 1; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; align-items: start;
  padding: 18px 18px 8px; border: 0; background: none; color: inherit; text-align: start; font: inherit; cursor: pointer; border-radius: 18px;
}
.tap:hover .ico { transform: scale(1.06); }
.ico {
  grid-row: span 3; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.8rem; line-height: 1; background: var(--card); border: 2px solid color-mix(in oklab, var(--edge) 60%, transparent);
  transition: transform .15s ease;
}
.name { font-weight: 700; font-size: 1.2rem; line-height: 1.25; overflow-wrap: anywhere; }
.last { color: var(--ink-2); font-size: .98rem; font-variant-numeric: tabular-nums; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 4px; font-size: .92rem; }
.state { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 14px; font-weight: 700; max-width: 100%; text-wrap: balance; }
.state.done { background: var(--card); }
.state.done::before { content: ""; width: .8em; height: .45em; border-inline-start: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; transform: translateY(-.12em) rotate(-45deg); }
:root[dir="rtl"] .state.done::before { transform: translateY(-.12em) rotate(45deg); }
.state.todo { border: 2px dashed color-mix(in oklab, var(--edge) 70%, transparent); color: var(--ink-2); }
.count { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.hist {
  align-self: flex-end; margin: 0 10px 10px; padding: 6px 12px; min-height: 40px;
  font: 700 .92rem var(--font); color: var(--ink); background: color-mix(in oklab, var(--card) 70%, transparent);
  border: 1px solid color-mix(in oklab, var(--edge) 50%, transparent); border-radius: 999px; cursor: pointer;
}
.hist:hover { background: var(--card); }
@media (prefers-reduced-motion: no-preference) {
  .item.just { animation: pulse .7s ease-out; }
  @keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--edge) 70%, transparent); } 100% { box-shadow: 0 0 0 16px transparent; } }
}

/* Panels */
.panel summary { font-weight: 700; cursor: pointer; font-size: 1.1rem; min-height: 32px; }
.edit-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
.edit-row {
  display: grid; grid-template-columns: 5.5rem minmax(0, 1fr) auto; gap: 10px; align-items: end;
  padding: 12px; border: 1px solid var(--rule); border-radius: 14px; background: var(--bg);
}
.edit-row select.icon-pick { font-size: 1.4rem; width: 100%; }
.edit-row input[type=text] { width: 100%; }
.edit-row .opts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end; }
.edit-row .moves { display: flex; gap: 6px; }
.edit-row .moves .btn, .edit-row .rm { min-height: 44px; padding: 6px 12px; }
.swatches { display: flex; gap: 6px; border: 0; margin: 0; padding: 0; }
.swatches legend { font-weight: 700; font-size: .92rem; margin-bottom: 4px; padding: 0; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch span { display: block; width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 2px var(--rule); }
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--ink); }
.swatch input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 3px; }

.foot { max-width: 1080px; margin: 0 auto; padding-block: 18px 32px; color: var(--ink-2); font-size: .92rem; border-top: 1px solid var(--rule); }
.foot p { margin: 0 0 8px; }

/* History sheet */
.sheet {
  border: 0; border-radius: 22px; padding: 22px clamp(16px, 4vw, 30px); width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  background: var(--card); color: var(--ink); box-shadow: 0 30px 80px rgb(0 0 0 / .35);
}
.sheet::backdrop { background: rgb(51 37 42 / .5); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.sheet h2 { margin: 0; font-size: 1.35rem; display: flex; gap: 10px; align-items: center; overflow-wrap: anywhere; }
.sheet h3 { margin: 18px 0 6px; font-size: 1rem; color: var(--ink-2); }
.hlist { list-style: none; margin: 0; padding: 0; }
.hlist li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--rule); font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.hlist .x { min-height: 40px; min-width: 40px; border: 1px solid var(--rule); background: none; color: var(--ink-2); border-radius: 10px; cursor: pointer; font: 700 1.1rem var(--font); }
.hlist .x:hover { border-color: var(--accent); color: var(--ink); }
.sheet .none, .sheet .older { margin: 4px 0; color: var(--ink-2); }
.past { margin-top: 18px; padding-top: 4px; border-top: 2px solid var(--rule); }
.past h3 { color: var(--ink); }
.msg { min-height: 1.4em; margin: 6px 0 0; font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; display: flex; gap: 14px; align-items: center;
  box-shadow: var(--shadow); z-index: 30; max-width: calc(100vw - 32px); font-weight: 700;
}
.toast-btn { font: 700 1rem var(--font); background: transparent; color: var(--accent-soft); border: 2px solid currentColor; border-radius: 10px; padding: 4px 12px; cursor: pointer; min-height: 40px; }

@media (max-width: 480px) {
  .edit-row { grid-template-columns: 4.5rem minmax(0, 1fr); }
  .edit-row .rm { grid-column: 1 / -1; justify-self: start; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* English | العربية */
:root[lang="ar"] { --font: 'IBM Plex Sans Arabic', 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif; }
.fb-lang { order: -1; flex-basis: 100%; display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: .95rem; color: var(--rule); }
.fb-lang button { font: inherit; font-weight: 700; color: var(--ink-2); background: none; border: 0; border-radius: 999px; padding: 4px 12px; min-height: 36px; cursor: pointer; }
.fb-lang button[lang="ar"] { font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; font-size: 1.05rem; }
.fb-lang button[lang="en"] { font-family: 'Atkinson Hyperlegible', system-ui, sans-serif; }
.fb-lang button[aria-pressed="true"] { color: var(--ink); background: color-mix(in oklab, var(--accent) 16%, transparent); }
.fb-lang button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.fb-suggest { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 0 0 4px; padding: 12px 16px; border: 1px solid var(--rule); border-radius: 14px; background: var(--card); }
.fb-suggest p { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.fb-suggest [lang="ar"] { font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; font-weight: 700; }
.fb-suggest [lang="en"] { font-family: 'Atkinson Hyperlegible', system-ui, sans-serif; color: var(--ink-2); }
.fb-suggest-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-suggest button { font-weight: 700; padding: 8px 16px; border-radius: 999px; cursor: pointer; min-height: 40px; }
.fb-suggest .fb-ar { background: var(--accent); color: var(--accent-ink); border: 0; font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; }
.fb-suggest .fb-en { background: transparent; color: var(--ink); border: 2px solid var(--rule); }
