/* The dialogs: Edit (a list of every daily with a checkbox, and a form to add your own) and the home-screen sheet. */

.editor {
  border: 0; padding: 0; border-radius: 24px;
  background: var(--paper); color: var(--ink); font-family: var(--font);
  width: min(440px, calc(100vw - 32px)); max-height: min(720px, calc(100dvh - 48px));
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
/* The dialog only has a max-height, so its height comes from its content. Form and list must start
   from their content height and shrink (flex: 1 1 auto), not from 0 (flex: 1, i.e. a 0% basis):
   older Safari engines (iPad, iOS) take that 0% literally, collapse the dialog to nothing and show
   only the backdrop. min-height: 0 lets the list shrink below its content and scroll. */
.editor[open] { display: flex; flex-direction: column; }
.editor:focus { outline: none; }
.editor::backdrop { background: rgba(10, 12, 20, .6); }
html:has(.editor[open]) { overflow: hidden; } /* the page behind stays put while the list scrolls */

.editor form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; margin: 0; }
.editor header { padding: 22px 24px 12px; }
.editor h2 { margin: 0; font-size: 21px; letter-spacing: -.01em; }
.editor header p { margin: 6px 0 0; color: var(--ink-muted); font-size: 14px; line-height: 1.4; }
.editor footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 24px 20px; border-top: 1px solid var(--line); }

.editor-list { list-style: none; margin: 0; padding: 4px 10px; overflow: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; contain: content; }
.editor-list:focus-visible { outline: 2px solid var(--deep); outline-offset: -2px; border-radius: 8px; }
.editor .icon { width: 30px; height: 30px; }
.editor strong { display: block; font-size: 15px; }
.editor small { display: block; color: var(--ink-muted); font-size: 13px; line-height: 1.35; }

/* ---- The home-screen sheet: the steps for browsers without an install prompt */

.sheet {
  border: 0; padding: 22px 24px 20px; border-radius: 24px;
  background: var(--paper); color: var(--ink); font-family: var(--font);
  width: min(400px, calc(100vw - 32px));
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
.sheet::backdrop { background: rgba(10, 12, 20, .6); }
.sheet form { margin: 0; }
.sheet h2 { margin: 0; font-size: 21px; letter-spacing: -.01em; }
.sheet-steps { margin: 16px 0 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 14px; }
.sheet-steps li { counter-increment: step; display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; font-size: 15px; line-height: 1.45; }
.sheet-steps li::before { content: counter(step); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--deep); color: var(--paper); font-size: 14px; font-weight: 700; }
.sheet footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---- Buttons */

.button { font: inherit; font-size: 14px; white-space: nowrap; border-radius: 999px; padding: 9px 18px; cursor: pointer; border: 1px solid var(--line); background: transparent; color: var(--ink); }
.button-primary { background: var(--deep); border-color: var(--deep); color: var(--paper); font-weight: 600; }
.button:disabled { opacity: .4; cursor: default; }

/* ---- One row per daily, under their own heading like the sections below */

.editor-section h3, .editor-add h3 { margin: 0 0 10px; font-size: 15px; }
.editor-section { padding: 12px 12px 0; }
.editor-section h3 { margin-bottom: 4px; }

.editor-row { display: flex; align-items: center; gap: 4px; border-radius: 12px; }
.editor-pick { flex: 1; min-width: 0; display: grid; grid-template-columns: 20px 30px 1fr; gap: 12px; align-items: center; padding: 9px 12px; border-radius: 12px; cursor: pointer; }
.editor-pick strong { overflow-wrap: anywhere; }
.editor-pick > span { min-width: 0; } /* a grid cell, so the note field can take its full width */
.editor-pick input[type="checkbox"] { accent-color: var(--deep); width: 18px; height: 18px; margin: 0; }
.editor-remove { flex: none; width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--ink-muted); cursor: pointer; }
.editor-remove svg { width: 18px; height: 18px; }

/* The optional note under a daily of one's own (#46): looks like a description, or a quiet link
   while there's none; tapping it turns it into a field. */
.editor-note { display: block; max-width: 100%; margin: 0; padding: 2px 0; border: 0; background: none; font: inherit; font-size: 13px; line-height: 1.35; text-align: left; color: var(--ink-muted); cursor: text; overflow-wrap: anywhere; }
.editor-note.is-empty { color: var(--deep); font-weight: 600; cursor: pointer; }
.editor-note:focus-visible { outline: 2px solid var(--deep); outline-offset: 2px; border-radius: 4px; }
.editor-note-input { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 16px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); }
.editor-note-input:focus { outline: 2px solid var(--deep); outline-offset: 1px; }

/* A daily that was just added lights up briefly (#17). */
.editor-row.is-new { animation: just-added 1.6s ease-out; }
@keyframes just-added { from { background: color-mix(in srgb, var(--deep) 16%, transparent); } }
@media (hover: hover) {
  .editor-pick:hover, .editor-remove:hover { background: var(--line); }
  .editor-remove:hover { color: var(--ink); }
}

/* ---- Add your own */

.editor-add { margin: 10px 2px 8px; padding: 16px 10px 4px; border-top: 1px solid var(--line); }
.editor-add-name { display: flex; gap: 8px; align-items: stretch; }
.editor-add-name .button { flex: none; white-space: nowrap; min-width: 84px; }
.editor-name { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--ink); }
.editor-name:focus { outline: 2px solid var(--deep); outline-offset: 1px; }
.editor-icons { border: 0; margin: 12px 0 10px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.editor-icons legend { font-size: 13px; color: var(--ink-muted); margin-bottom: 8px; padding: 0; }
.editor-icons label { position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: 12px; border: 1.5px solid transparent; cursor: pointer; color: var(--ink-muted); }
.editor-icons input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.editor-icons .icon { width: 26px; height: 26px; }
.editor-icons label:has(input:checked) { border-color: var(--deep); background: var(--line); color: var(--ink); }
.editor-icons label:has(input:focus-visible) { outline: 2px solid var(--deep); outline-offset: 2px; }

/* ---- Quote of the day: one row per collection, like the dailies but without an icon */

.editor-quotes > small { display: block; margin: -6px 0 6px; }
.editor-quotes ul { list-style: none; margin: 0 -10px 6px; padding: 0; }
.editor-quote { grid-template-columns: 20px 1fr; }

/* Short screens (phones in landscape): give the list the room. */
@media (prefers-reduced-motion: reduce) {
  .editor-row.is-new { animation: none; }
}

@media (max-height: 480px) {
  .editor { max-height: calc(100dvh - 16px); }
  .editor header { padding: 14px 20px 6px; }
  .editor header p { display: none; }
  .editor-pick { padding: 6px 12px; }
  .editor footer { padding: 10px 20px 12px; }
}

/* The narrowest phones (320px): keep "Reset to defaults" and "Done" on one line. */
@media (max-width: 360px) {
  .editor footer { padding-inline: 16px; }
  .editor footer .button { padding-inline: 14px; }
}
