/*
 * Basic, neutral styling. Proper look & feel comes later.
 *
 * Colors use light-dark(<light>, <dark>). By default they follow the system/browser
 * preference; <html data-theme="light|dark"> (set by the theme toggle) overrides it.
 */

:root {
  color-scheme: light dark;

  --bg: light-dark(#ffffff, #0d1117);
  --text: light-dark(#1f2328, #e6edf3);
  --muted: light-dark(#656d76, #8d96a0);
  --border: light-dark(#d0d7de, #30363d);
  --surface: light-dark(#f6f8fa, #161b22);
  --input-bg: light-dark(#ffffff, #0d1117);
  --accent: light-dark(#0969da, #4493f8);
  --accent-text: light-dark(#ffffff, #0d1117);
  --danger: light-dark(#cf222e, #f85149);
  --danger-bg: light-dark(#ffebe9, #25171c);
  --success: light-dark(#1a7f37, #3fb950);
  --success-bg: light-dark(#dafbe1, #12261e);
  --warning: light-dark(#bf8700, #e3b341);
  --code-bg: light-dark(#eaeef2, #262c36);
  --code-text: light-dark(#953800, #ffa657);
  /* Tags: a light tint of the accent color (until each tag can get its own color). */
  --tag-bg: light-dark(#ddf4ff, #172b45);
  --tag-text: light-dark(#0550ae, #79b8ff);
  /* Selected to-dos in Next and Focus: light grey, in dark mode a little lighter than the page. */
  --selected-bg: light-dark(#eaeef2, #21262d);

  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  color: var(--text);
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* The page is a column at least as tall as the screen (dvh: the visible height on phones, whose address bar
   comes and goes); main takes the leftover space, so the footer sits at the bottom even with little content. */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
}

a { color: var(--accent); }

/* Keyboard focus (Tab): a clear ring in the accent color. Not shown for mouse clicks. */
:where(a, button, input, textarea, select, summary, [contenteditable="true"], [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
:where(input, textarea, [contenteditable="true"]):focus-visible { outline-offset: -1px; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

/* The app's name in Comfortaa (vendor/fonts/README.md), with the tagline hanging under its accent ("do"). */
@font-face {
  font-family: "Comfortaa";
  src: url("/assets/comfortaa/comfortaa-variable-46a9ee6c.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}
.site-header .brand {
  font-family: "Comfortaa", system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.75rem;
  line-height: 1;
  padding-bottom: 0.6em; /* room for the tagline */
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.brand .logo-accent { position: relative; color: var(--accent); }
/* "Beta" next to the logo, at the height of the name (config.x.stage_label) */
.brand-group { display: flex; align-items: flex-start; gap: 0.6rem; }
.stage-label {
  margin-top: 0.15rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.4;
}
.brand .logo-tagline {
  position: absolute;
  top: calc(100% + 0.05em);
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.5em;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.site-header nav { display: flex; align-items: center; gap: 1rem; }
.site-header form { margin: 0; }
.site-header button { white-space: nowrap; }
/* Plain links in the header (Sign in, Sign up). */
.header-link { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); text-decoration: none; }
.header-link:hover { color: var(--text); }

.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  color: var(--text);
}
.theme-toggle svg { width: 1.2rem; height: 1.2rem; }
/* Show the icon of the mode you'd switch to: a moon in light mode, a sun in dark mode. */
.theme-toggle .icon-sun, .theme-toggle .icon-moon { display: none; }
.theme-toggle[data-current="light"] .icon-moon,
.theme-toggle[data-current="dark"] .icon-sun { display: block; }

/* The account menu (layout): a button with your name opens a popover with Settings, Administration and Sign out.
   The popover sits under the button (CSS anchor positioning), or at the top right where browsers lack that. */
.account-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  white-space: nowrap;
  anchor-name: --account-button;
}
.account-chevron { width: 1em; height: 1em; color: var(--muted); }

/* The home link and the feedback bell (left of the account menu); the bell shows the number of tickets with something
   new in a small badge. */
.home-link, .feedback-bell { position: relative; display: inline-flex; align-items: center; padding: 0.35rem; color: var(--text); border-radius: 6px; }
.home-link:hover, .feedback-bell:hover { background: var(--bg); }
.home-link .icon, .feedback-bell .icon { width: 1.2rem; height: 1.2rem; }
.feedback-bell-count {
  position: absolute;
  top: -0.2rem;
  right: -0.35rem;
  min-width: 1.1rem;
  padding: 0 0.3rem;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.1rem;
  text-align: center;
}
.account-menu {
  position-anchor: --account-button;
  inset: auto;
  top: anchor(bottom);
  right: anchor(right);
  margin: 0.35rem 0 0;
  min-width: 12rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 4px 16px light-dark(rgb(0 0 0 / 0.12), rgb(0 0 0 / 0.5));
}
@supports not (anchor-name: --a) {
  .account-menu { top: 3.5rem; right: 0.75rem; }
}
.account-menu ul { list-style: none; margin: 0; padding: 0; }
.account-menu :is(a, button) {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-sizing: border-box;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  text-align: left;
  text-decoration: none;
}
.account-menu :is(a, button):hover { background: var(--surface); }
.account-menu :is(a, button):focus-visible { outline-offset: -2px; }
.account-menu .icon { color: var(--muted); }
.account-menu-sign-out { margin-top: 0.35rem; padding-top: 0.35rem; border-top: 1px solid var(--border); }

main { flex: 1 0 auto; box-sizing: border-box; width: 100%; max-width: 56rem; margin: 2rem auto; padding: 0 1rem; }

/* Full width, like the header: info on the left, links on the right. */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
}
.site-footer p { margin: 0; }
.site-footer nav { display: flex; gap: 1rem; margin-left: auto; } /* stays on the right, also when it wraps */
.site-footer a { color: inherit; }
.site-footer a:hover { color: var(--text); }

/* The maximum of open to-dos (todos/_limit), and whether sign-ups are open (sessions/_signups_notice) */

.limit-notice, .signups-notice {
  margin: 0 0 1rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--warning);
  border-radius: 6px;
  background: var(--surface);
}
.signups-notice { margin-top: 1.5rem; border-left-color: var(--accent); }

/* Administration */

.number-field { max-width: 8rem; }
.table-scroll { max-width: 100%; overflow-x: auto; margin-bottom: 1rem; }
.admin-table { border-collapse: collapse; }
.admin-table :is(th, td) { padding: 0.4rem 0.75rem 0.4rem 0; text-align: left; vertical-align: top; }
.admin-table thead th { border-bottom: 1px solid var(--border); }
.admin-table tbody th { font-weight: 400; }
.admin-table .number-field { width: 6rem; }
.signups-status { margin: 0 0 1rem; }
/* The same width in every box, so the numbers line up from box to box */
.statistics-table { width: 100%; max-width: 22rem; }
.statistics-table td { text-align: right; font-variant-numeric: tabular-nums; padding-right: 0; }

/* FAQ: questions that open one at a time (<details name="faq">) */

.faq-list { border-top: 1px solid var(--border); }
.faq { border-bottom: 1px solid var(--border); }
.faq summary { padding: 0.75rem 0.25rem; font-weight: 600; cursor: pointer; }
.faq summary:hover { color: var(--accent); }
.faq-answer { padding: 0 0.25rem 0.9rem; }

/* Administration: FAQ */

.admin-faqs-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
.admin-faqs { margin: 0.5rem 0 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.admin-faq { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.admin-faq-question { flex: 1; min-width: 12rem; overflow-wrap: anywhere; }
.admin-faq-actions { display: flex; gap: 0.1rem; margin-left: auto; }
.admin-faq-actions form { margin: 0; }
.faq-form { max-width: none; }
.faq-form textarea { min-height: 10rem; resize: vertical; }

/* Feedback: your tickets, a new ticket and one ticket with its thread */

.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
.back-link { margin: 0 0 0.5rem; }
.back-link a { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); text-decoration: none; }
.back-link a:hover { color: var(--text); }

.tickets { margin: 1rem 0 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.ticket-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.1rem 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.ticket-row-link { display: flex; gap: 0.5rem; flex: 1 1 16rem; min-width: 0; color: var(--text); text-decoration: none; }
.tickets-toggle { margin: 1rem 0 0; }
.ticket-row-link:hover .ticket-subject { color: var(--accent); text-decoration: underline; }
.ticket-subject { min-width: 0; overflow-wrap: anywhere; }
/* Unread (something new since you last opened it): a dot in front, and the subject in bold. Every row keeps room for
   the dot, so the numbers line up. */
.ticket-unread .ticket-subject { font-weight: 700; }
.ticket-unread-dot { display: inline-block; flex: none; width: 0.5rem; height: 0.5rem; margin-right: 0.4rem; border-radius: 50%; vertical-align: 0.1em; }
.ticket-row-link .ticket-unread-dot { align-self: center; margin-right: -0.1rem; }
.ticket-unread-dot-on { background: var(--accent); }
.ticket-number { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; }
.ticket-meta { font-size: 0.9rem; }
.ticket-status-open { color: var(--success); }

.ticket-title { margin-bottom: 0.25rem; font-size: 1.5rem; overflow-wrap: anywhere; }
.ticket-title .ticket-number { display: block; font-size: 0.9rem; }
.ticket-page-meta { margin-top: 0; }

.ticket-thread { display: flex; flex-direction: column; gap: 0.75rem; margin: 1.5rem 0; padding: 0; list-style: none; }
.ticket-message { padding: 0.6rem 0.9rem; border: 1px solid var(--border); border-radius: 8px; }
.ticket-message-user { background: var(--surface); }
.ticket-message-admin { border-left: 4px solid var(--accent); }
.ticket-message-header { display: flex; flex-wrap: wrap; gap: 0 0.75rem; margin: 0 0 0.25rem; font-size: 0.9rem; }
/* System lines, such as a category change: small, between the messages. */
.ticket-event { padding: 0 0.9rem; font-size: 0.85rem; text-align: center; overflow-wrap: anywhere; }
/* Plain text: line breaks as typed; long words or links wrap instead of widening the page. */
.ticket-message-body { white-space: pre-wrap; overflow-wrap: anywhere; }

.ticket-form { max-width: 40rem; }
/* The bottom of a ticket page (tickets/_actions): OK, "Close the ticket" and Add reply, or the reply box with Send,
   the checkbox and Cancel. The last button sits on the right. */
.ticket-actions-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; max-width: none; margin: 0; }
.ticket-actions-row form { margin: 0; }
.ticket-actions-row .ticket-actions-end { margin-left: auto; }
.ticket-close-checkbox { display: flex; align-items: center; gap: 0.4rem; }
.ticket-reply { max-width: none; }
.button[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
/* Cancel with something typed: Discard or Keep writing (like the to-do dialog's question). */
.ticket-discard {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.ticket-discard[hidden] { display: none; }
.ticket-discard p { flex: 1 1 12rem; margin: 0; font-weight: 600; }

/* Administration: feedback. Filters side by side, wrapping on a phone; the search box takes the free width. */
.ticket-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 0.75rem; max-width: none; margin-bottom: 0.5rem; }
.ticket-filter { display: flex; flex-direction: column; gap: 0.25rem; }
.ticket-filter-search { flex: 1 1 14rem; }
.ticket-filter-actions { display: flex; gap: 0.5rem; }
.ticket-filters-hint { flex-basis: 100%; font-size: 0.85rem; }
.ticket-person { font-size: 0.9rem; }

/* The admin overview: a table, one line per ticket. The subject takes the free width; the other columns stay as
   narrow as their content. */
.tickets-table { width: 100%; margin-top: 1rem; border-collapse: collapse; }
.tickets-table :is(th, td) { padding: 0.5rem 0.75rem 0.5rem 0; text-align: left; vertical-align: baseline; }
.tickets-table :is(th, td):last-child { padding-right: 0; }
.tickets-table thead th { border-bottom: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; font-weight: 400; white-space: nowrap; }
.tickets-table tbody tr { border-bottom: 1px solid var(--border); }
.tickets-table .ticket-subject { width: 100%; overflow-wrap: anywhere; }
.tickets-table .ticket-number { white-space: nowrap; }
.tickets-table .ticket-subject a { color: var(--text); text-decoration: none; }
.tickets-table .ticket-subject a:hover { color: var(--accent); text-decoration: underline; }
.tickets-table :is(.ticket-category, .ticket-status, .ticket-activity) { white-space: nowrap; font-size: 0.9rem; }
.tickets-table :is(.ticket-category, .ticket-activity) { color: var(--muted); }
.tickets-table :is(.ticket-person, .ticket-account-type, .ticket-waiting-for) { white-space: nowrap; font-size: 0.9rem; }
.tickets-table .ticket-waiting-for-label { display: none; }
.tickets-table .ticket-account-type { color: var(--muted); }
.tickets-table .ticket-person-type { display: none; }
.tickets-table .ticket-person-name { display: inline-block; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
/* Narrower screens: each ticket folds into lines: number and subject, then category · status · time, who it waits
   for, then the person. */
@media (max-width: 45rem) {
  .tickets-table, .tickets-table tbody { display: block; }
  .tickets-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .tickets-table tbody tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.1rem 0.3rem; padding: 0.5rem 0; }
  .tickets-table tbody tr:first-child { border-top: 1px solid var(--border); }
  .tickets-table tbody td { display: block; padding: 0; }
  /* The subject fills the rest of the first line, so the next cells start a new one. */
  .tickets-table .ticket-subject { flex: 1 1 calc(100% - 3.5rem); width: auto; min-width: 0; }
  .tickets-table :is(.ticket-status, .ticket-activity)::before { content: "· "; color: var(--muted); }
  /* "Waiting for: Admin" on a line of its own, under category, status and time; nothing for a closed ticket. */
  .tickets-table .ticket-waiting-for { order: 1; flex-basis: 100%; }
  .tickets-table .ticket-waiting-for:empty { display: none; }
  .tickets-table .ticket-waiting-for-label { display: inline; }
  /* Last line: the person with their account type. */
  .tickets-table .ticket-person { order: 2; flex-basis: 100%; min-width: 0; white-space: normal; }
  .tickets-table .ticket-person-name { display: inline; max-width: none; overflow-wrap: anywhere; }
  .tickets-table .ticket-person-type { display: inline; }
  .tickets-table .ticket-account-type { display: none; }
}
.ticket-badge {
  display: inline-block;
  padding: 0 0.45em;
  border: 1px solid var(--warning);
  border-radius: 999px;
  color: var(--warning);
  font-size: 0.8rem;
  white-space: nowrap;
}
/* Changing the subject or category on the admin ticket page. */
.ticket-change-form { display: flex; flex-direction: column; gap: 0.25rem; max-width: 40rem; margin: 0.5rem 0 0; }
.ticket-change-form label { color: var(--muted); font-size: 0.9rem; }
.ticket-change-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ticket-change-row input[type=text] { flex: 1 1 12rem; min-width: 0; }
.ticket-form textarea { min-height: 7.5rem; max-height: 60vh; resize: vertical; field-sizing: content; }
.character-counter { margin: 0; font-size: 0.85rem; text-align: right; font-variant-numeric: tabular-nums; }
.character-counter-over { color: var(--danger); font-weight: 600; }

/* Text pages (privacy) */

.text-page h2 { font-size: 1.15rem; margin: 1.75rem 0 0.5rem; }
.text-page li { margin-bottom: 0.4rem; }

/* Credits */

.credits-group h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
.credits-list { list-style: none; margin: 0; padding: 0; }
.credits-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.credits-list p { margin: 0; }
.credits-name { font-weight: 600; }
.credits-license {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0 0.4em;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.flash { padding: 0.6rem 0.9rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid; }
.flash-notice { color: var(--success); border-color: currentColor; background: var(--success-bg); }
.flash-alert { color: var(--danger); border-color: currentColor; background: var(--danger-bg); }

.form-errors { color: var(--danger); border: 1px solid currentColor; border-radius: 6px; background: var(--danger-bg); padding: 0 0.9rem; margin-bottom: 1rem; }
/* An error at its field (FieldErrorsHelper): between the label and the field. scroll-margin: some room above
   it when the field-errors controller scrolls it into view. */
.field-error { margin: 0; color: var(--danger); font-size: 0.9rem; font-weight: 600; scroll-margin-top: 0.75rem; }

.auth-form, form { max-width: 24rem; }

/* Sign in, sign up and password reset: one centered column; labels stay left-aligned. */
.auth-page { max-width: 24rem; margin: 0 auto; }
.auth-page .auth-form { max-width: none; }
.field { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 1rem; }
.field_with_errors { display: contents; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--input-bg);
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* .button: a link that looks like a (secondary) button, e.g. Cancel. */
input[type="submit"], button, .button {
  font: inherit;
  color: var(--text);
  padding: 0.45rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

input[type="submit"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
/* Delete and Discard */
.button-danger { color: var(--danger); }
.button-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
/* Deleting your account: the big red button */
:is(.button, button, input[type="submit"]).button-danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--accent-text);
  font-weight: 600;
}
:is(.button, button, input[type="submit"]).button-danger-solid:hover { filter: brightness(1.1); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.account-deletion-facts { padding-left: 1.2rem; }
.account-deletion-facts li { margin-bottom: 0.5rem; }
/* Muted controls (e.g. at the maximum of open to-dos). */
:is(input, textarea, button):disabled { opacity: 0.45; cursor: not-allowed; }
.icon-button:disabled:hover { background: none; color: var(--muted); }
.button { display: inline-block; text-decoration: none; }

.card { border: 1px solid var(--border); border-radius: 8px; padding: 0 1rem; }
.muted { color: var(--muted); }

/* Todos */

.new-todo, .todo form { max-width: none; margin: 0; }
.new-todo { margin-bottom: 1.5rem; }
.new-todo-row { display: flex; gap: 0.5rem; }
.new-todo-row input[type="text"] { flex: 1; min-width: 0; }

.todo-list { display: flex; flex-direction: column; }

.todo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
}

/* The title with the notes icon and the tags right after it; together they take the free width of the row. The tags
   go on the next line when there's no room. */
.todo-main { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; flex: 1; min-width: 0; }
/* Small and muted, like time and energy. */
.todo-has-notes { display: inline-flex; flex-shrink: 0; color: var(--muted); }
.todo-has-notes .icon { width: 0.9rem; height: 0.9rem; }
.todo-title {
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 0.2rem 0.25rem;
  color: var(--text);
  text-decoration: none;
}
/* The title opens the to-do dialog: a light background on hover shows it can be clicked. */
a.todo-title { border-radius: 6px; }
a.todo-title:hover { background: var(--surface); }
.todo-done .todo-title { color: var(--muted); text-decoration: line-through; }
/* Time and energy in the row ("5m med"), muted, right-aligned next to the buttons. */
.todo-details { padding: 0 0.25rem; color: var(--muted); font-size: 0.85rem; white-space: nowrap; word-spacing: 0.25em; }
/* On a phone the title needs the width: time and energy go on a line of their own under it, lined up with the title. */
@media (max-width: 30rem) {
  .todo-details { order: 1; flex-basis: 100%; margin: -0.3rem 0 0.1rem 2.45rem; padding: 0; }
  .todo[role="row"] .todo-details { margin-left: 4rem; } /* after the drag handle in Next and Focus (1.55rem) */
}

/* Tags (docs/tags-design.md): small pills in a light blue tint (--tag-bg, --tag-text), the same after the title,
   in the tag filter above the tabs and as chips in the to-do dialog. Per-tag colors come later. */
.todo-tags { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; min-width: 0; }
.todo-tag, .tag-chip {
  padding: 0 0.5em;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* The filter: toggle buttons. Tags that are off outlined in the tag color, "All tags" plain grey; whatever is on is
   solid in the accent color. (The tint is for tags on to-dos, so the three looks each mean one thing.) On a phone
   one row that scrolls sideways (padding keeps the focus ring visible inside it). */
.tag-filter { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.75rem; }
.tag-filter form { margin: 0; }
.tag-filter-button {
  padding: 0.1rem 0.75rem;
  border-color: var(--tag-text);
  border-radius: 999px;
  background: none;
  color: var(--tag-text);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}
.tag-filter-button:hover { background: var(--tag-bg); }
.tag-filter-all { border-color: var(--border); background: none; color: var(--muted); font-weight: 400; }
.tag-filter-all:hover { border-color: var(--border); background: var(--surface); color: var(--text); }
.tag-filter-button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
@media (max-width: 30rem) {
  .tag-filter { flex-wrap: nowrap; overflow-x: auto; margin-inline: -3px; padding: 3px; scrollbar-width: thin; }
  .tag-filter form { flex: none; }
}

/* The tags field in the to-do dialog: looks like one input, with the chips (tag_input_controller.js) and the
   typing field inside it. */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
}
.tag-input:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -1px; }
.todo-edit .tag-input input[type="text"] { flex: 1 1 6rem; padding: 0.15rem 0.2rem; border: 0; background: none; outline: none; }
.tag-chip { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; }
.tag-chip span { opacity: 0.75; }
.tag-chip:hover { border-color: var(--danger); }
.tag-chip:hover span { color: var(--danger); opacity: 1; }
.todo-edit-field.todo-edit-tags { flex: none; } /* in the dialog's column, not the Time/Energy row */
.todo-edit-tags small { font-size: 0.8rem; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.icon-button:hover { background: var(--surface); color: var(--text); }
.icon-button:focus-visible { outline-offset: 0; color: var(--text); }
/* An icon carrying the button's hover text (icon_with_hint) fills the button, so the hover text shows anywhere on it. */
.icon-button:has(> .icon-hint) { padding: 0; }
.icon-hint { display: flex; padding: 0.35rem; }
.todo-check { color: var(--text); }
.todo-done .todo-check { color: var(--success); }

/* Your own order in Next and Focus (docs/ordering-design.md, todo_order_controller.js). Each part of a row is a grid
   cell. The handle starts a drag at once on touch screens too (touch-action), so the page scrolls only elsewhere on
   the row. Selected rows get a grey background and an accent bar on the left, so it doesn't depend on a slight
   color difference alone; dragged ones are lifted a little. */
.todo-cell { display: flex; }
.todo-handle { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.todo-handle .icon-hint { padding-inline: 0.15rem; }
.todo[role="row"] { padding-left: 0.4rem; } /* room for the selection bar, so it doesn't touch the handle */
.todo[role="row"] [data-cell="details"]:focus-visible { border-radius: 6px; }
.todo[aria-selected="true"] { background: var(--selected-bg); box-shadow: inset 3px 0 0 var(--accent); }
.todo-order-dragging, .todo-order-dragging * { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.todo-dragged { position: relative; z-index: 1; box-shadow: inset 3px 0 0 var(--accent), 0 2px 8px rgb(0 0 0 / 0.2); }

.todo-edit { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 0.75rem; }
.todo-edit input[type="text"] { min-width: 0; }
.todo-edit-title { display: flex; flex-direction: column; gap: 0.35rem; }
.todo-edit-title label { color: var(--muted); font-size: 0.9rem; }
/* Time and energy: side by side under the title, one under the other on a phone. */
.todo-edit-details { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.todo-edit-field { display: flex; flex-direction: column; gap: 0.35rem; flex: 1 1 12rem; min-width: 0; }
.todo-edit-field label { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); font-size: 0.9rem; }
.todo-edit-field label .icon { width: 1rem; height: 1rem; }
.todo-edit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.todo-edit-actions .button-danger { margin-right: auto; }
.todo-edit .form-errors { margin: 0; }
.new-todo .form-errors { margin: 0 0 0.5rem; }
.form-errors p { margin: 0.45rem 0; }
.new-todo .field-error { margin-bottom: 0.25rem; }
/* The field with the error gets a red border, and a red focus ring while you're in it. */
:is(input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"], .notes-editor-invalid .notes-rich-content,
    .tag-input:has([aria-invalid="true"])) {
  border-color: var(--danger);
  outline-color: var(--danger);
}

/* Empty state only while there are no open todos; Done section only once something is done. */
.empty-state { margin: 0.75rem 0; }
.todos-pending:has(.todo) .empty-state { display: none; }
.todos-done:not(:has(.todo)) { display: none; }

.todos-done { margin-top: 1.5rem; }
.todos-done summary { cursor: pointer; color: var(--muted); padding: 0.25rem 0; }

/* The to-do dialog (editing a to-do, lists/_todo_dialog). The header and the question about unsaved changes
   stay in view; the form in between scrolls. On phones it fills the screen. */

.todo-dialog {
  width: min(40rem, calc(100vw - 2rem));
  max-width: none;
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.todo-dialog[open] { display: flex; }
.todo-dialog::backdrop { background: rgb(0 0 0 / 0.5); }
/* The page behind doesn't scroll while the dialog is open. */
html:has(.todo-dialog[open]) { overflow: hidden; }

.todo-dialog-content { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
.todo-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
}
.todo-dialog-header h2 { margin: 0; font-size: 1.05rem; }
.todo-dialog-body { display: block; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1rem; }
.todo-dialog form { max-width: none; margin: 0; }

.todo-dialog-discard {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.todo-dialog-discard[hidden] { display: none; }
.todo-dialog-discard p { flex: 1 1 12rem; margin: 0; font-weight: 600; }

@media (max-width: 30rem) {
  .todo-dialog { width: 100%; height: 100%; max-height: none; margin: 0; border: 0; border-radius: 0; }
  .todo-dialog-discard p { flex-basis: 100%; } /* the buttons together on the next line */
}

/* Settings */

.settings-section { margin-bottom: 1.5rem; padding-bottom: 1rem; }
.settings-section h2 { font-size: 1.15rem; }
/* Tags in Settings: a row per tag with its name to rename, the number of to-dos and Delete; on a phone the number
   and Delete go on a second line. */
.settings-tags { display: flex; flex-direction: column; gap: 0.9rem; margin: 0; padding: 0; list-style: none; }
.settings-tag { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.settings-tag form { margin: 0; }
.settings-tag-form { flex: 1 1 16rem; max-width: 28rem; }
.settings-tag-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.settings-tag-row input[type="text"] { flex: 1 1 8rem; min-width: 0; }
.settings-tag-count { min-width: 4.5em; font-size: 0.9rem; white-space: nowrap; } /* the rows line up */
/* A changed email address waiting for verification. */
.pending-email-address { margin-top: 1.25rem; border-top: 1px solid var(--border); }
.field small { font-size: 0.85rem; }

/* Folders: Inbox, Next and Focus */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.list-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.list-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
}
.list-tab:hover { color: var(--text); }
.list-tab-active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.list-tab-count {
  min-width: 1.4em;
  padding: 0 0.4em;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 400;
  text-align: center;
}

.todo-star:hover { color: var(--warning); }
.todo-starred .todo-star { color: var(--warning); }
.todo-starred .todo-star svg { fill: currentColor; }

.radio-group { border: 0; padding: 0; margin: 0 0 1rem; }
.radio-group legend { padding: 0; margin-bottom: 0.25rem; }
.radio-group label { display: flex; align-items: center; gap: 0.4rem; }

/* Narrow screens (phones): keep the header and folder tabs within the screen width. */
@media (max-width: 30rem) {
  .site-header, .site-footer { padding-inline: 0.75rem; }
  .site-header nav { gap: 0.5rem; }
  .site-header .brand { font-size: 1.5rem; } /* room for the icons, with the tagline still readable */
  /* "Beta" smaller and closer, so the admin header (most icons) fits on a 360 px wide phone */
  .site-header { gap: 0.5rem; }
  .brand-group { gap: 0.35rem; }
  .stage-label { font-size: 0.6rem; padding: 0.05rem 0.3rem; letter-spacing: 0.04em; }
  .admin-table .number-field { width: 4.5rem; } /* the table fits in its card */
  .account-name { /* on a phone only the person icon shows; screen readers still get the name */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .list-tabs { gap: 0; }
  .list-tab { padding-inline: 0.45rem; gap: 0.3rem; }
}

/* Password fields with a show/hide eye button */

.password-field { position: relative; display: flex; }
.password-field input { flex: 1; min-width: 0; padding-right: 2.5rem; }
.password-toggle[hidden] { display: none; }
.password-toggle { position: absolute; top: 50%; right: 0.25rem; transform: translateY(-50%); }
.password-toggle .password-toggle-hide,
.password-toggle[aria-pressed="true"] .password-toggle-show { display: none; }
.password-toggle[aria-pressed="true"] .password-toggle-hide { display: block; }

/* Notes: edited in the to-do's edit form */

.notes-editor { display: flex; flex-direction: column; gap: 0.35rem; }
.notes-editor-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.notes-editor-header label { color: var(--muted); font-size: 0.9rem; }

.notes-modes { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.notes-modes[hidden] { display: none; }
.notes-mode { border: 0; border-radius: 0; padding: 0.15rem 0.65rem; background: none; color: var(--muted); font-size: 0.85rem; }
.notes-mode + .notes-mode { border-left: 1px solid var(--border); }
.notes-mode[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; }
/* Inside the button: the group's overflow: hidden (for the rounded corners) would cut off a ring outside it. */
.notes-mode:focus-visible { outline-offset: -3px; border-radius: 6px; }

.notes-formatting { display: flex; flex-wrap: wrap; gap: 0.1rem; }
.notes-formatting[hidden] { display: none; }
.notes-formatting .icon-button { padding: 0.3rem; }
.notes-formatting .icon-button[aria-pressed="true"] { background: var(--surface); color: var(--accent); }
.notes-hint { margin: 0; font-size: 0.85rem; overflow-wrap: anywhere; }
.notes-counter { margin: 0; font-size: 0.85rem; text-align: right; font-variant-numeric: tabular-nums; }
.notes-counter-over { color: var(--danger); font-weight: 600; }

.notes-editor textarea, .notes-rich-content { min-height: 7.5rem; max-height: 60vh; }
.notes-editor textarea { resize: vertical; field-sizing: content; }
/* While the rich-text editor loads, hide the Markdown underneath it so it doesn't flash. */
.notes-editor[aria-busy="true"] textarea { visibility: hidden; }

.notes-rich-content {
  overflow-y: auto;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  overflow-wrap: anywhere;
}
.notes-preview {
  max-height: 40vh;
  overflow-y: auto;
  padding: 0.45rem 0.6rem;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: var(--surface);
  overflow-wrap: anywhere;
}
.notes-preview-label { margin: 0 0 0.25rem; color: var(--muted); font-size: 0.8rem; }

.notes-rich-content p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  height: 0;
  color: var(--muted);
  pointer-events: none;
}

/* Formatted notes (.formatted-notes) look the same in the list, the rich-text editor and the preview. */
.formatted-notes > :first-child { margin-top: 0; }
.formatted-notes > :last-child { margin-bottom: 0; }
.formatted-notes :is(p, ul, ol, blockquote, pre, table) { margin: 0.4em 0; }
.formatted-notes :is(h1, h2, h3, h4, h5, h6) { margin: 0.75em 0 0.25em; font-size: 1rem; }
.formatted-notes h1 { font-size: 1.2rem; }
.formatted-notes h2 { font-size: 1.1rem; }
.formatted-notes :is(ul, ol) { padding-left: 1.5em; }
.formatted-notes li > :is(p, ul, ol) { margin: 0; }
.formatted-notes blockquote { margin-left: 0; padding-left: 0.75em; border-left: 3px solid var(--border); color: var(--muted); }
.formatted-notes :is(code, pre) {
  border: 1px solid var(--border);
  background: var(--code-bg);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  font-size: 0.875em;
}
.formatted-notes code { padding: 0.1em 0.35em; border-radius: 4px; color: var(--code-text); }
.formatted-notes pre { padding: 0.5em 0.75em; border-radius: 6px; overflow-x: auto; overflow-wrap: normal; }
.formatted-notes pre code { padding: 0; border: 0; background: none; color: inherit; font-size: 1em; }
.formatted-notes hr { border: 0; border-top: 1px solid var(--border); }
.formatted-notes table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.formatted-notes :is(th, td) { padding: 0.25em 0.5em; border: 1px solid var(--border); }

/* Checklists: commonmarker renders <li><input type="checkbox">, Tiptap <ul data-type="taskList">. */
.formatted-notes li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.3em; }
.formatted-notes li > input[type="checkbox"] { margin: 0 0.4em 0 0; vertical-align: -0.1em; }
.notes-rich-content ul[data-type="taskList"] { padding-left: 0.2em; list-style: none; }
.notes-rich-content ul[data-type="taskList"] li { display: flex; gap: 0.4em; }
.notes-rich-content ul[data-type="taskList"] li > label { display: flex; align-items: center; height: 1.5em; flex: none; }
.notes-rich-content ul[data-type="taskList"] li > label input { margin: 0; }
.notes-rich-content ul[data-type="taskList"] li > div { flex: 1; min-width: 0; }
.notes-rich-content ul[data-type="taskList"] li > div > :is(p, ul, ol) { margin: 0; }

