/* Vazirmatn, an open font (SIL OFL; see fonts/OFL.txt). One file holds every weight. */
@font-face {
  font-family: "Vazirmatn"; src: url("/fonts/Vazirmatn-wght.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}

/* Three themes: purple (the brand's own), light and dark. All text pairs are at least 4.5:1,
   and the edges of fields and buttons at least 3:1. */
:root, :root[data-theme="purple"] {
  color-scheme: light;
  /* Cream and purple: a warm page, white-warm cards, lavender for the quiet surfaces. */
  --page: linear-gradient(170deg, #f8f1e9 0%, #f4ebf0 45%, #ece3f8 100%);
  --bg: #f6eee6; --card: #fffcf9; --soft: #efe6fb; --text: #1b0a5a; --muted: #56497f; --line: #e5d9ee;
  --accent: #5b2be0; --accent-text: #ffffff; --accent-grad: linear-gradient(135deg, #5b2be0, #b3237f);
  --danger: #b3261e; --warn: #8a4500; --control: #85799f;
  --bar: #5b2be0; --bar-late: #8a4500; --bar-follow: #d6338f;
  --shadow: 0 6px 20px rgb(91 43 224 / .10);
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f6f5fb;
  --bg: #f6f5fb; --card: #ffffff; --soft: #eeebf8; --text: #1d1a2e; --muted: #5d5873; --line: #e4e1ef;
  --control: #837e9c; --shadow: 0 4px 14px rgb(30 20 60 / .08);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: linear-gradient(165deg, #15111f 0%, #1a1429 100%);
  --bg: #15111f; --card: #211a33; --soft: #2b2245; --text: #f3eeff; --muted: #b9aedb; --line: #352b50;
  --accent: #b79cff; --accent-text: #1b0a5a; --accent-grad: linear-gradient(135deg, #b79cff, #ff8fcb);
  --danger: #ff9a90; --warn: #ffc47a; --control: #8a7fb0;
  --bar: #b79cff; --bar-late: #ffc47a; --bar-follow: #ff8fcb;
  --shadow: 0 6px 20px rgb(0 0 0 / .35);
}
/* The light theme keeps the purple accents of the first one. */
:root[data-theme="light"] {
  --accent: #5b2be0; --accent-text: #ffffff; --accent-grad: linear-gradient(135deg, #5b2be0, #b3237f);
  --danger: #b3261e; --warn: #8f4a00; --bar: #5b2be0; --bar-late: #8f4a00; --bar-follow: #d6338f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); background-image: var(--page); background-attachment: fixed; color: var(--text);
  font: 1rem/1.7 Vazirmatn, Tahoma, system-ui, sans-serif;
  padding-bottom: calc(132px + env(safe-area-inset-bottom));
}
header, main { max-width: 640px; margin: 0 auto; padding: 0 16px; }
header { padding-top: 14px; }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.icon-btn { margin-inline-start: auto; width: 44px; padding: 0; display: grid; place-items: center; border-radius: 50%; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
/* The icon names where a tap goes: a sun in the dark, a moon in the day. */
.icon-btn .to-day { display: none; }
:root[data-theme="dark"] .icon-btn .to-day { display: block; }
:root[data-theme="dark"] .icon-btn .to-night { display: none; }
.icon-btn + .avatar { margin-inline-start: 0; }
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.logo-light { display: block; width: 124px; height: auto; }
.logo-dark { display: none; align-items: center; gap: 10px; }
.logo-dark img { width: 40px; height: 40px; border-radius: 12px; box-shadow: var(--shadow); }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: flex; }
.brand-name { font: 700 22px/1 system-ui, sans-serif; letter-spacing: .08em; }
/* The robot comes with a white background: on a light page it blends in, on the dark theme it sits on a card. */
.mascot { width: 104px; height: 104px; object-fit: contain; mix-blend-mode: multiply; }
:root[data-theme="dark"] .mascot { mix-blend-mode: normal; background: #fffcf9; border-radius: 26px; padding: 6px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-grad); color: #fff; font-weight: 700; box-shadow: var(--shadow);
}
h1 { margin: 0; font-size: 1.5rem; line-height: 1.5; }
h2 { margin: 22px 0 8px; font-size: 0.9375rem; color: var(--muted); }
h2.late { color: var(--warn); }
#subtitle { margin: 0 0 14px; color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
button, input, select { min-height: 44px; }
button {
  cursor: pointer; border: 1px solid var(--control); background: var(--card); border-radius: 12px; padding: 4px 14px;
  transition: background-color .12s, opacity .12s;
}
/* Hover only where there is a pointer; a touch screen has none. */
@media (hover: hover) {
  button:hover:not(:disabled) { background-color: color-mix(in srgb, var(--accent) 10%, var(--card)); }
  .primary:hover:not(:disabled) { background-color: transparent; filter: brightness(1.08); }
  nav button:hover:not([aria-current]) { color: var(--text); }
}
summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
/* Pressed feedback that never moves the layout. */
button:active:not(:disabled) { opacity: .7; }
button:disabled { opacity: .55; cursor: progress; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input, select, textarea {
  background: var(--card); border: 1px solid var(--control); border-radius: 12px; padding: 6px 10px; width: 100%;
}
textarea { resize: vertical; }
@media (prefers-reduced-motion: reduce) { button { transition: none; } }
.primary { background: var(--accent-grad); color: var(--accent-text); border-color: transparent; font-weight: 700; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin-bottom: 10px;
  box-shadow: var(--shadow);
}

/* Today: the numbers of the day */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; padding: 12px 4px; background: var(--soft); }
.stats > div + div { border-inline-start: 1px solid var(--line); }
.stats strong { display: block; font-size: 1.625rem; line-height: 1.3; }
.stats span { font-size: 0.875rem; color: var(--muted); }
.stats .late strong { color: var(--warn); }

.quick { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.quick label { flex: 1 0 100%; font-size: 0.875rem; color: var(--muted); }
.quick textarea { flex: 1 1 0; min-width: 0; min-height: 44px; max-height: 40vh; resize: none; overflow-y: hidden; }
.row { display: flex; gap: 8px; }
.row button { white-space: nowrap; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters input { grid-column: 1 / -1; }

/* A task: a coloured edge shows what kind it is; the words beside it say the same */
.task { position: relative; padding-inline-start: 18px; overflow: hidden; }
.task::before { content: ""; position: absolute; inset-block: 10px; inset-inline-start: 0; width: 5px; border-radius: 0 5px 5px 0; background: var(--bar); }
[dir="rtl"] .task::before { border-radius: 5px 0 0 5px; }
.task.late::before { background: var(--bar-late); }
.task.followup::before { background: var(--bar-follow); }
.task.done::before { opacity: .35; }
.task-head { display: flex; gap: 10px; align-items: flex-start; }
.check { min-width: 44px; width: 44px; border-radius: 50%; padding: 0; flex: none; font-size: 1.25rem; }
.task.done .check { background: var(--accent-grad); color: var(--accent-text); border-color: transparent; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.task-title { font-weight: 700; }
.meta { color: var(--muted); font-size: 0.875rem; }
.meta.late { color: var(--warn); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.actions button, .actions select { font-size: 0.875rem; width: auto; flex: 1 1 auto; }
.danger { color: var(--danger); }
.empty { color: var(--muted); text-align: center; padding: 24px 0; display: grid; gap: 12px; justify-items: center; }

/* Messages stay in view above the tab bar, wherever the list is scrolled to. */
#notice {
  position: fixed; inset-inline: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 5;
  max-width: 616px; margin-inline: auto; display: flex; gap: 8px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--accent); border-radius: 14px; padding: 8px 8px 8px 12px;
  box-shadow: 0 4px 16px rgb(0 0 0 / .25);
}
#notice.error { border-color: var(--danger); color: var(--danger); }
#notice span { flex: 1; white-space: pre-line; overflow-wrap: anywhere; padding-top: 8px; }
#notice button { min-width: 44px; padding: 0; border: 0; background: transparent; font-size: 1.25rem; line-height: 1; }
#loading { text-align: center; color: var(--muted); padding: 40px 0; display: grid; gap: 12px; justify-items: center; }
.project { width: 100%; text-align: right; display: block; border: 0; background: transparent; padding: 4px 0; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }

nav {
  position: fixed; inset: auto 0 0 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -6px 20px rgb(0 0 0 / .06);
}
nav button {
  flex: 1; border: 0; border-radius: 0; background: transparent; display: grid; justify-items: center; gap: 2px;
  padding: 8px 4px; color: var(--muted); font-size: 0.8125rem; min-height: 56px;
}
/* A wide screen: the bar follows the width of the content. */
@media (min-width: 700px) {
  nav { max-width: 640px; margin-inline: auto; border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; }
}
/* A phone on its side: a low bar, so the page keeps its height. */
@media (max-height: 480px) and (orientation: landscape) {
  body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  nav button { grid-auto-flow: column; justify-content: center; align-items: center; gap: 8px; min-height: 48px; padding-block: 2px; }
  #notice { bottom: calc(56px + env(safe-area-inset-bottom)); }
}
nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
nav button[aria-current="page"] { color: var(--accent); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }
.ic { width: 1.15em; height: 1.15em; vertical-align: -.2em; margin-inline-end: 6px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.grow { flex: 1; }
.stack { display: grid; gap: 10px; }
.stack label { display: grid; gap: 4px; }
.stack label.inline { display: flex; gap: 8px; align-items: center; }
.stack input[type="checkbox"] { width: 22px; min-height: 22px; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1.4fr 1.2fr; gap: 8px; }
legend { padding: 0; margin-bottom: 4px; }

/* The theme choice */
.themes { display: grid; grid-template-columns: 1fr; gap: 8px; }
.themes label {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; min-height: 56px; cursor: pointer;
  border: 1px solid var(--control); border-radius: 14px; background: var(--card);
}
.themes input { width: 22px; min-height: 22px; accent-color: var(--accent); }
.themes label:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.themes .swatch { width: 40px; height: 40px; border-radius: 12px; flex: none; border: 1px solid var(--control); }
.swatch.s-purple { background: linear-gradient(135deg, #f6eee6 0%, #f6eee6 40%, #5b2be0 40%, #d6338f 100%); }
.swatch.s-auto { background: linear-gradient(90deg, #f6eee6 0 50%, #1f1833 50% 100%); }
.swatch.s-light { background: linear-gradient(135deg, #ffffff, #e9e4fb); }
.swatch.s-dark { background: linear-gradient(135deg, #15111f, #3b2f63); }
.themes small { display: block; color: var(--muted); }

dialog {
  width: min(560px, calc(100% - 24px)); max-height: 90vh; overflow: auto; background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 18px; padding: 16px;
}
dialog::backdrop { background: rgb(15 5 40 / .6); }
dialog h2 { margin: 0; color: var(--text); }
.pre { white-space: pre-line; overflow-wrap: anywhere; }
#record { display: flex; gap: 6px; align-items: center; padding-inline: 12px; }
.link { direction: ltr; text-align: left; font-size: 0.75rem; }
#record.recording { background: var(--danger); color: var(--card); }
#draft textarea { margin: 8px 0; }

/* Importance, checklist */
.task.high::before { background: var(--danger); }
.urgent { color: var(--danger); font-weight: 700; }
.checklist { margin-top: 8px; display: grid; gap: 2px; }
.item { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.item input { width: 24px; height: 24px; min-height: 24px; flex: none; accent-color: var(--accent); }
.item.done span { text-decoration: line-through; color: var(--muted); }

/* The calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; }
.icon-btn.plain { margin: 0; border: 0; background: transparent; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 8px; }
.cal-name { text-align: center; color: var(--muted); font-size: 0.875rem; padding: 4px 0; }
.cal-day {
  min-height: 52px; padding: 2px; border-radius: 12px; border: 1px solid transparent; background: transparent;
  display: grid; align-content: center; justify-items: center; line-height: 1.25;
}
.cal-day .count { font-size: 0.75rem; min-height: 1em; color: var(--accent); font-weight: 700; }
.cal-day.late .count { color: var(--warn); }
.cal-day.today { border-color: var(--accent); }
.cal-day.selected { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.cal-day.selected .count { color: var(--accent-text); }

/* The numbers */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; min-width: 0; }
.bar { width: 100%; max-width: 18px; background: var(--accent-grad); border-radius: 6px 6px 2px 2px; }
.bar-n, .bar-d { font-size: 0.6875rem; color: var(--muted); line-height: 1; }

/* First visit */
.welcome { text-align: center; justify-items: center; }
.welcome ul { text-align: right; margin: 0; padding-inline-start: 20px; }

/* Dragging a task to another day */
.drag-handle {
  position: absolute; top: 4px; inset-inline-end: 4px; width: 44px; min-height: 44px; padding: 0; border: 0;
  background: transparent; color: var(--muted); font-size: 1.5rem; touch-action: none; cursor: grab;
}
.drag-ghost {
  position: fixed; z-index: 20; transform: translate(-50%, -130%); max-width: 70vw; padding: 6px 14px; border-radius: 12px;
  background: var(--accent); color: var(--accent-text); font-weight: 700; pointer-events: none; box-shadow: 0 6px 20px rgb(0 0 0 / .35);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-day.drop { outline: 3px dashed var(--accent); outline-offset: -3px; }
