/*
 * habit-chain styles.
 *
 * One rule: the shell is greyscale and only chains carry colour. Habit colours
 * are the user's, so UI colour would fight them. The lone exception is --break,
 * a red used only where a chain snapped.
 */

:root {
  /* Warm graphite. A blue-leaning near-black was deliberately avoided. */
  --bg: #131211;
  --panel: #1b1a18;
  --panel-2: #232120;
  --line: #302d2b;
  --line-soft: #262423;
  --text: #ede9e4;
  --muted: #9a938c;
  --break: #e2503c;

  --radius: 14px;
  --gutter: 32px;
  --cell: 40px;
  --gap: 5px;

  /* Hangul stays on the system font; Archivo takes only Latin and digits. */
  --sans: "Archivo", "Pretendard Variable", "Pretendard", ui-sans-serif, system-ui,
          -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f1f1ef;
    --panel: #fbfbfa;
    --panel-2: #eaeae7;
    --line: #dedcd8;
    --line-soft: #e8e7e3;
    --text: #1a1917;
    --muted: #6f6c68;
    --break: #c8371f;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }

#app { max-width: 620px; margin: 0 auto; padding: 0 16px 64px; }

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

:where(button, a, input, select, summary):focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* ── Top bar ──────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 16px 0 12px;
  background: linear-gradient(var(--bg) 72%, transparent);
}
.wordmark {
  margin: 0;
  display: flex; align-items: center; gap: 9px;
  font-size: 12px; text-transform: uppercase;
  font-variation-settings: "wdth" 112, "wght" 650;
  letter-spacing: .16em;
  color: var(--muted);
}
.wordmark svg { color: var(--text); flex: none; }

/* A write takes 1.5-2s; this shows something is happening meanwhile. */
#progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  overflow: hidden; z-index: 20; pointer-events: none;
  opacity: 0; transition: opacity .18s ease;
}
#progress.on { opacity: 1; }
#progress::after {
  content: ""; display: block; height: 100%; width: 38%;
  background: var(--text);
  animation: sweep 1.05s cubic-bezier(.6, 0, .4, 1) infinite;
}
@keyframes sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(360%); }
}

/* ── Buttons ──────────────────────────────────────── */
button {
  font: inherit; cursor: pointer; border-radius: 10px;
  border: 1px solid var(--line); padding: 9px 14px;
  background: var(--panel-2); color: var(--text); font-weight: 600;
  transition: background .14s ease, color .14s ease, border-color .14s ease, transform .08s ease;
}
button:hover { border-color: var(--muted); }
button:active { transform: scale(.98); }
button[disabled] { cursor: default; opacity: .5; }

button.primary { background: var(--text); color: var(--bg); border-color: transparent; }
button.primary:hover { filter: brightness(1.12); }
button.ghost, a.ghost {
  background: transparent; color: var(--muted); font-weight: 500;
  font-size: 13px; padding: 8px 12px; border-radius: 9px;
  border: 1px solid var(--line); text-decoration: none;
  display: inline-flex; align-items: center;
}
button.ghost:hover, a.ghost:hover { color: var(--text); border-color: var(--muted); }
button.danger { color: var(--break); border-color: color-mix(in oklab, var(--break) 40%, var(--line)); }
button.danger:hover { background: var(--break); color: var(--bg); border-color: transparent; }

.icon-btn {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  width: 34px; height: 34px; padding: 0; display: grid; place-content: center;
}
.icon-btn:hover { color: var(--text); }

/* ── Today ────────────────────────────────────────── */
.day {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 2px 2px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.day-date { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.day-date small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.day-tally { display: flex; align-items: center; gap: 10px; }
.day-links { display: flex; gap: 3px; flex-wrap: wrap; }
.day-links i {
  width: 16px; height: 9px; border-radius: 5px;
  border: 1.5px solid var(--habit); background: transparent;
}
.day-links i.on { background: var(--habit); }
.day-count { margin: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.day-count b {
  color: var(--text); font-variant-numeric: tabular-nums;
  font-variation-settings: "wdth" 108, "wght" 700;
}
.day.all-done .day-count b { color: var(--text); }

/* ── Calendar page (/@owner/name) ─────────────────── */
/* 내 다른 달력으로 건너가는 지름길. 프로필이 있는 브라우저에서만 보인다. */
.cal-switch { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 4px; }
.cal-switch[hidden] { display: none; }
.cal-chip {
  font-size: 12px; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); text-decoration: none;
}
a.cal-chip:hover { color: var(--text); border-color: var(--muted); }
.cal-chip.now {
  color: var(--text); border-color: var(--muted);
  background: var(--panel-2); font-weight: 600;
}

.public-head { padding: 14px 2px 22px; }
.public-title {
  margin: 0; font-size: 24px; letter-spacing: -.02em;
  font-variation-settings: "wdth" 108, "wght" 700;
  overflow-wrap: anywhere;
}
.public-desc {
  margin: 7px 0 0; font-size: 14px; color: var(--muted);
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65;
  max-width: 52ch;
}
.public-desc:empty { display: none; }
.public-db { margin: 9px 0 0; font-size: 12px; }
.public-db a { color: var(--muted); text-decoration-color: var(--line); text-underline-offset: 2px; }
.public-db a:hover { color: var(--text); }
/* The footer speaks to visitors; the owner already knows what this is. */
.public-foot {
  display: none;
  margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line-soft);
  font-size: 12.5px; color: var(--muted); text-align: center;
}
body.viewer .public-foot { display: block; }
.public-foot p { margin: 0; }
.public-foot a { color: var(--text); text-decoration-color: var(--muted); text-underline-offset: 2px; }

/* A browser without this calendar's token can look but not write. */
body.viewer .add-form { display: none; }

/* Read-only grid: the chain shows, but nothing invites a press. */
.grid.ro .cell { cursor: default; }
.grid.ro .cell:hover { border-color: transparent; }

/* ── Calendar picker (home with several saved) ────── */
.picker-list { display: grid; gap: 8px; margin-top: 16px; text-align: left; }
.picker-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 15px; text-decoration: none; color: var(--text);
}
.picker-item:hover { border-color: var(--muted); }
.picker-item code { font-size: 13.5px; background: transparent; padding: 0; }
.picker-item small { font-size: 11.5px; color: var(--muted); flex: none; }
.picker > p { margin-top: 14px; font-size: 12.5px; }

/* ── Saved calendars inside settings ──────────────── */
.profile-list { display: grid; gap: 6px; margin: 10px 0 14px; }
.profile-list .hint { margin: 0; }
.profile-row { display: flex; align-items: center; gap: 8px; }
.profile-row .profile-open {
  flex: 1; min-width: 0; display: flex; align-items: center;
  justify-content: space-between; gap: 8px;
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px;
  text-decoration: none; color: var(--text); font-size: 13px;
}
.profile-row .profile-open:hover { border-color: var(--muted); }
.profile-row.here .profile-open { border-color: var(--muted); background: var(--panel-2); }
.profile-row .profile-open code {
  background: transparent; padding: 0; font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-row .profile-open small { color: var(--muted); font-size: 11px; flex: none; }
.profile-row button { flex: none; }

/* 하나의 폼이 추가와 수정을 겸한다. 접혀 있다가 필요할 때만 펴진다. */
.profile-form {
  margin-top: 12px; padding: 12px 13px;
  border: 1px solid var(--line); border-radius: 12px;
}
.profile-form[hidden] { display: none; }
.profile-form-title { margin: 0 0 10px; font-size: 12.5px; font-weight: 650; }

/* 공유 주소 한 줄과 복사 버튼 */
.share-row { display: flex; align-items: center; gap: 8px; }
#share-url {
  flex: 1; min-width: 0; overflow-wrap: anywhere;
  font-size: 12px; background: var(--panel-2); border-radius: 7px;
  padding: 7px 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.share-row button { flex: none; }

/* ── Habit cards ──────────────────────────────────── */
.habits { display: grid; gap: 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px 16px;
  position: relative;
  transition: opacity .15s ease;
}
.card.htmx-request { pointer-events: none; opacity: .62; }

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title {
  margin: 0 0 4px; font-size: 15px; letter-spacing: -.01em;
  font-weight: 600; overflow-wrap: anywhere;
}

/* Streak days. The widening figure shows the run growing. */
.streak { display: flex; align-items: baseline; gap: 7px; margin: 0; }
.streak b {
  font-size: 32px; line-height: .9; color: var(--habit);
  font-variant-numeric: tabular-nums;
  font-variation-settings: "wdth" 125, "wght" 700;
  letter-spacing: -.02em;
}
.streak span { font-size: 12.5px; color: var(--muted); }
.streak.dead b { color: var(--muted); }

.card-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.today-btn { padding: 8px 13px; font-size: 13px; white-space: nowrap; }
.today-btn.done {
  background: var(--habit); border-color: transparent;
  color: color-mix(in oklab, var(--habit) 18%, #000);
  font-weight: 700;
}
.today-btn.done:hover { filter: brightness(1.08); }
.del-btn { opacity: .45; }
.card:hover .del-btn, .del-btn:focus-visible { opacity: 1; }

/* Description. Keeps the user's newlines, which is why they stay as text. */
.card-desc {
  margin: 11px 0 0; font-size: 13px; line-height: 1.65;
  color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ── Editing inside the card ──────────────────────
   The form ships folded in every card, so opening is one class, no round trip. */
.card-edit { display: none; }
.card.editing .card-edit { display: block; margin-bottom: 4px; }
.card.editing .card-head, .card.editing .card-desc { display: none; }
.card-edit label { margin-bottom: 0; }
.card-edit input[type=text], .card-edit textarea {
  display: block; width: 100%; margin: 5px 0 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; color: var(--text); font: inherit; outline: none;
}
.card-edit textarea { resize: vertical; min-height: 84px; line-height: 1.6; font-size: 13.5px; }
.card-edit input:focus, .card-edit textarea:focus { border-color: var(--muted); }
/* Swatches sit left, buttons right; narrow cards wrap them onto two lines. */
.edit-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap;
}
.edit-btns { display: flex; gap: 8px; margin-left: auto; }

.card-body {
  display: flex; gap: 22px; align-items: flex-start; flex-wrap: wrap;
  margin-top: 16px;
}

/* ── Chain grid ───────────────────────────────────── */
.grid {
  flex: 1 1 300px; max-width: 430px;
  display: grid;
  grid-template-columns: var(--gutter) repeat(7, minmax(0, 1fr));
  gap: var(--gap);
  align-items: center;
}
.dow {
  font-size: 9.5px; color: var(--muted); text-align: center;
  letter-spacing: .06em; padding-bottom: 3px;
}
.dow.sun { color: color-mix(in oklab, var(--break) 60%, var(--muted)); }
/* Weeks run downward, so month labels sit in the left gutter. */
.mon {
  font-size: 10.5px; color: var(--text); white-space: nowrap;
  letter-spacing: -.02em; opacity: .72;
  font-variation-settings: "wdth" 92, "wght" 600;
}

.cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid transparent;
  padding: 0;
  display: grid; place-content: center;
  color: var(--muted);
  transition: background .14s ease, border-color .14s ease, color .14s ease, transform .08s ease;
}

/* Dates in cells: chain shape alone cannot say which day was checked. Links
   are drawn in the gaps, so the numbers leave the chain intact. A broken cell's
   slash (::after) crosses them, so the number is raised one layer. */
.cell > span {
  position: relative; z-index: 1;
  font-size: 10.5px; line-height: 1;
  font-variant-numeric: tabular-nums;
  font-variation-settings: "wdth" 96, "wght" 550;
  letter-spacing: -.02em;
  pointer-events: none;
}
/* The 1st reads "8/1" — that cell marks the month boundary in the grid. */
.cell.first > span { font-size: 9px; font-variation-settings: "wdth" 88, "wght" 650; letter-spacing: -.04em; }
.cell:hover { border-color: var(--habit); }
.cell.future {
  background: transparent; border: 1px dashed var(--line);
  color: color-mix(in oklab, var(--muted) 42%, transparent);
  cursor: default; pointer-events: none;
}
/* Numbers on filled cells sit on the chain, darkened to stay readable. */
.cell.done {
  background: var(--habit); border-color: transparent;
  color: color-mix(in oklab, var(--habit) 16%, #000);
}
.cell.done > span { font-variation-settings: "wdth" 96, "wght" 650; }
/* Today is marked only while unfilled. A ring kept after filling would cross
   the chain link and make a connected day look broken — and once filled, today
   needs no marker: it is the last cell. */
.cell.today:not(.done) { box-shadow: inset 0 0 0 2px var(--habit); }
/* Today's number stays bold either way — it is the reference point. */
.cell.today { color: var(--text); }
.cell.today.done { color: color-mix(in oklab, var(--habit) 12%, #000); }
.cell.today > span { font-variation-settings: "wdth" 104, "wght" 750; }
/* The in-flight cell: whatever hx-disabled-elt turned off was just pressed. */
.card.htmx-request .cell[disabled]:not(.future) { animation: cellwait .8s ease-in-out infinite; }
@keyframes cellwait { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }

/* Chain links, joining adjacent days into one. */
.cell.done.link-l::before,
.cell.done.link-r::after,
.cell.done.wrap-l::before,
.cell.done.wrap-r::after {
  content: ""; position: absolute; top: 50%; transform: translateY(-50%);
  height: 40%; background: var(--habit);
}
.cell.done.link-l::before { right: 100%; width: calc(var(--gap) + 2px); }
.cell.done.link-r::after { left: 100%; width: calc(var(--gap) + 2px); }
/* Saturday to Sunday: a row change is not a break. */
.cell.done.wrap-r::after {
  left: 100%; width: 9px; border-radius: 0 3px 3px 0;
  -webkit-mask-image: linear-gradient(90deg, #000 55%, transparent);
  mask-image: linear-gradient(90deg, #000 55%, transparent);
}
.cell.done.wrap-l::before {
  right: 100%; width: 9px; border-radius: 3px 0 0 3px;
  -webkit-mask-image: linear-gradient(270deg, #000 55%, transparent);
  mask-image: linear-gradient(270deg, #000 55%, transparent);
}

/* Where the chain last broke — at most one per card. */
.cell.broke::after {
  content: ""; position: absolute; inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(135deg, transparent calc(50% - 1px), var(--break) calc(50% - 1px),
                    var(--break) calc(50% + 1px), transparent calc(50% + 1px));
  opacity: .8;
}

/* ── Card stats ───────────────────────────────────── */
.card-stats {
  margin: 0; flex: 1 1 130px; min-width: 118px;
  display: flex; flex-direction: column; gap: 11px;
}
.card-stats div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.card-stats dt { font-size: 11.5px; color: var(--muted); }
.card-stats dd {
  margin: 0; font-size: 17px; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  font-variation-settings: "wdth" 100, "wght" 650;
}
.card-stats small { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 2px; }

/* ── Empty states and errors ──────────────────────── */
.empty {
  text-align: center; padding: 44px 20px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty h2 { color: var(--text); font-size: 16px; margin: 0 0 8px; letter-spacing: -.01em; }
.empty p { margin: 0 0 4px; font-size: 13.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; margin-top: 16px; }

/* First screen with empty settings: the empty-list shell, plus ordered steps. */
.empty.setup { text-align: left; padding: 30px 24px; }
.empty.setup h2 { text-align: center; }
.empty.setup > p { margin: 0 auto; max-width: 42ch; }
.empty.setup b { color: var(--text); font-weight: 600; }
.setup-steps {
  margin: 16px auto 0; padding-left: 20px; max-width: 42ch;
  font-size: 13px; line-height: 1.75;
}
.setup-steps li { margin: 0 0 3px; }
.setup-steps code, .hint code, .setup-note code {
  font-size: 11.5px; background: var(--panel-2); border-radius: 5px;
  padding: 1px 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.setup-note {
  margin: 14px auto 0; max-width: 42ch;
  font-size: 12.5px; opacity: .85;
}

/* Nothing can be added yet, so hide a form that would only raise a toast. */
#habits:has(.setup) ~ .add-form,
#habits:has(.picker) ~ .add-form { display: none; }
.chip {
  font-size: 12.5px; font-weight: 500; padding: 6px 11px; border-radius: 999px;
  background: transparent; color: var(--muted);
}
.chip:hover { color: var(--text); }

/* ── Skeleton (first load) ────────────────────────── */
.sk { display: grid; gap: 12px; }
.sk div {
  height: 172px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel);
  position: relative; overflow: hidden;
}
.sk div::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--panel-2), transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}
.sk div:nth-child(2)::after { animation-delay: .18s; }
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ── Add form ─────────────────────────────────────── */
.add-form {
  margin-top: 16px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 13px;
  display: grid; gap: 11px;
}
.add-form.htmx-request { opacity: .6; pointer-events: none; }
.add-form input[type=text] {
  width: 100%; background: transparent; border: 0; color: var(--text);
  font: inherit; font-size: 15px; padding: 3px 1px; outline: none;
}
.add-form input[type=text]::placeholder { color: var(--muted); }
/* The description is optional, so it stays quiet and grows downward only. */
.add-form textarea {
  width: 100%; background: transparent; border: 0; color: var(--text);
  font: inherit; font-size: 13.5px; padding: 3px 1px; outline: none;
  resize: vertical; min-height: 42px; line-height: 1.6;
}
.add-form textarea::placeholder { color: var(--muted); }
.add-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* A fixed set instead of the native colour picker: eight is enough, and it
   keeps every colour on screen in agreement. */
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches label { display: block; margin: 0; line-height: 0; }
.swatches input { position: absolute; opacity: 0; width: 0; height: 0; }
.swatches span {
  display: block; width: 20px; height: 20px; border-radius: 999px;
  background: var(--sw); cursor: pointer;
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--sw) 55%, transparent);
  transition: box-shadow .14s ease, transform .1s ease;
}
.swatches span:hover { transform: scale(1.12); }
.swatches input:checked + span {
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--sw);
}
.swatches input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 3px; }

/* ── Toast ────────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30; width: min(440px, calc(100vw - 24px));
}
#toast:empty { display: none; }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--panel); color: var(--text);
  border: 1px solid color-mix(in oklab, var(--break) 45%, var(--line));
  border-radius: 12px; padding: 12px 12px 12px 14px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .28);
  font-size: 13.5px; line-height: 1.5;
  animation: rise .18s ease-out;
}
.toast p { margin: 0; flex: 1; overflow-wrap: anywhere; }
.toast b { display: block; color: var(--break); font-size: 12px; margin-bottom: 2px; }
.toast button { border: 0; background: transparent; color: var(--muted); padding: 0 4px; }
@keyframes rise { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ── Dialogs ──────────────────────────────────────── */
dialog {
  border: 1px solid var(--line); border-radius: 16px; padding: 0;
  background: var(--panel); color: var(--text);
  width: min(520px, calc(100vw - 32px)); max-height: 86vh;
  font: inherit;
}
dialog::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px); }

.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.settings-head h2 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.settings-body { padding: 4px 18px 20px; overflow-y: auto; max-height: calc(86vh - 58px); }

fieldset { border: 0; padding: 15px 0; margin: 0; border-bottom: 1px solid var(--line-soft); }
fieldset:last-child { border-bottom: 0; }
legend { font-size: 12.5px; font-weight: 650; color: var(--text); padding: 0; }
.hint { font-size: 12.5px; color: var(--muted); margin: 8px 0 12px; line-height: 1.6; }
.hint code {
  font-size: 11.5px; background: var(--panel-2); border-radius: 5px;
  padding: 1px 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
/* Links are greyscale too; the browser's blue would be the one loud colour. */
.hint a, .empty a { color: var(--text); text-decoration-color: var(--muted); text-underline-offset: 2px; }
.hint a:hover, .empty a:hover { text-decoration-color: var(--text); }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
label input[type=password], label input[type=text] {
  display: block; width: 100%; margin-top: 5px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; color: var(--text); font: inherit; outline: none;
}
label input:focus { border-color: var(--muted); }
label textarea {
  display: block; width: 100%; margin-top: 5px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; color: var(--text); font: inherit; font-size: 13.5px;
  outline: none; resize: vertical; line-height: 1.6;
}
label textarea:focus { border-color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
#meta-form label { margin-top: 10px; }
#meta-form .row { margin-top: 12px; }

/* The line shown after saving. Its space is always reserved so nothing jumps. */
.set-status {
  margin: 8px 0 0; min-height: 1.4em;
  font-size: 12px; color: var(--muted);
}
.set-status.bad { color: var(--break); }

.confirm { padding: 20px; }
.confirm h2 { margin: 0 0 8px; font-size: 15px; letter-spacing: -.01em; }
.confirm p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.6; }
.confirm-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ── Narrow screens ───────────────────────────────── */
@media (max-width: 480px) {
  :root { --gap: 4px; --gutter: 28px; }
  #app { padding: 0 12px 56px; }
  .card { padding: 14px 13px 15px; }
  .card-body { gap: 16px; margin-top: 14px; }
  .grid { flex-basis: 100%; max-width: none; }
  .card-stats { flex-direction: row; gap: 20px; flex-basis: 100%; }
  .card-stats div { flex-direction: column; align-items: flex-start; gap: 1px; }
  .card-stats dd { font-size: 15px; }
  .streak b { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  #progress::after { width: 100%; opacity: .5; }
}
