:root {
  --bg: #f6f6f4;
  --card: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e2e2de;
  --accent: #0b6bcb;
  --accent-fg: #ffffff;
  --warn: #9a5b00;
  --error: #c0362c;
  --ok: #1d7a3a;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --card: #1c1c1c;
    --fg: #ededed;
    --muted: #9a9a9a;
    --line: #2e2e2e;
    --accent: #5aa9f5;
    --accent-fg: #0b1a2a;
    --warn: #e6a844;
    --error: #f0776c;
    --ok: #5cc27e;
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); overflow-anchor: none; color-scheme: light dark; }
body { margin: 0; color: var(--fg); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
/* Present for password managers, invisible to people (display:none fields are often ignored). */
.pm-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* Top spacing is padding on the containers, not a collapsing h1 margin
   (iOS Safari mishandled the scroll top with the collapsed margin). */
h1 { font-size: 1.8rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
a { color: var(--accent); }
.muted { color: var(--muted); font-weight: normal; }
.center { text-align: center; }
.lede { color: var(--muted); margin: 0 0 1.5rem; }
.narrow { max-width: 34rem; margin: 0 auto; padding: 2.5rem 16px 3rem; }
.wide { max-width: 62rem; margin: 0 auto; padding: 1.5rem 16px 3rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
label { display: block; margin-bottom: .9rem; font-size: .9rem; font-weight: 600; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: normal; }
/* Fields are 16px: iOS zooms the page in (and stays zoomed) when a smaller field gets focus. */
input:not([type=checkbox]) { display: block; width: 100%; margin-top: .3rem; padding: .6rem .7rem; font: inherit; font-size: 1rem; font-weight: normal; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.keyrow { display: flex; gap: .4rem; align-items: center; margin-top: .3rem; }
.keyrow input { margin-top: 0; font-family: ui-monospace, Menlo, monospace; min-width: 0; }

button { font: inherit; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; white-space: nowrap; }
button:disabled { opacity: .6; cursor: progress; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
form > button.primary { width: 100%; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
form > button.link { display: block; margin: .75rem auto 0; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; margin: .75rem 0; }
.row button { flex: 1; }

.error { color: var(--error); font-size: .9rem; }
.warn { color: var(--warn); }
.landing { max-width: 46rem; margin: 0 auto; padding: 2.5rem 16px 4rem; }
.landing .lede { font-size: 1.25rem; color: var(--fg); font-weight: 600; margin: 0 0 .15rem; }
.landing .sublede { font-size: 1.05rem; color: var(--fg); opacity: .8; font-weight: 600; margin: 0 0 .5rem; }
.info p.more-link { margin: .9rem 0 0; font-weight: 600; }
.landing .intro { color: var(--muted); margin: 0 0 1.5rem; }
.info { margin-top: 2.5rem; }
.info h2 { font-size: 1.15rem; margin-bottom: .6rem; }
.info p { margin: 0; color: var(--muted); }
.uses { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .75rem; }
.uses li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; color: var(--muted); font-size: .95rem; }
.uses strong { display: block; color: var(--fg); margin-bottom: .15rem; }
.steps { margin: 0; padding-left: 1.4rem; color: var(--muted); }
.steps li { margin-bottom: .5rem; padding-left: .2rem; }
.steps strong, .notes strong { color: var(--fg); }
.notes { margin: 0; padding-left: 1.2rem; color: var(--muted); }
.notes li { margin-bottom: .6rem; }

header { display: flex; align-items: center; gap: .75rem; padding: .75rem 16px; border-bottom: 1px solid var(--line); background: var(--card); }
header .muted { flex: 1; font-family: ui-monospace, Menlo, monospace; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.list-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-top: 2rem; }
.list-head h2 { margin: 0; }
#links { list-style: none; padding: 0; margin: 0; }
.link-item { display: grid; grid-template-columns: 76px 1fr; gap: 1rem; align-items: start; }
.link-item .qr-thumb { width: 76px; height: 76px; padding: 0; border: 1px solid var(--line); background: #fff; border-radius: 6px; overflow: hidden; }
.link-item .qr-thumb svg { display: block; width: 100%; height: 100%; }
.link-item h3 { font-size: 1rem; margin: 0 0 .2rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.dest { margin: 0; font-size: .9rem; word-break: break-all; }
.dest.pending { color: var(--warn); }
.dest.old { color: var(--muted); text-decoration: line-through; }
.chip { font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; border: 1px solid currentColor; }
.chip.live { color: var(--ok); }
.chip.pending { color: var(--warn); }
.chip.off { color: var(--muted); }
.link-item .row { margin: .6rem 0 0; }
.link-item .row button { flex: 0 0 auto; padding: .35rem .7rem; font-size: .85rem; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--fg); padding: 0; width: min(30rem, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog-body { padding: 1.25rem; }
.qr-big { background: #fff; padding: 12px; border-radius: 8px; }
.qr-big svg { display: block; width: 100%; height: auto; }
.url { font-size: .8rem; word-break: break-all; }

@media (max-width: 480px) {
  .link-item { grid-template-columns: 56px 1fr; gap: .75rem; }
  .link-item .qr-thumb { width: 56px; height: 56px; }
}
.nowrap { white-space: nowrap; }
label.form-title { font-size: 1.1rem; font-weight: 700; }
.batch summary { cursor: pointer; font-weight: 600; }
.batch[open] summary { margin-bottom: .75rem; }
.batch form > p { margin: 0 0 .75rem; font-size: .92rem; }
.batch-fields { display: grid; grid-template-columns: 8rem 1fr; gap: .75rem; align-items: end; }
.batch-fields label { margin-bottom: .4rem; }
.batch-result { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.batch-result p { margin: 0 0 .6rem; }
.small { font-size: .85rem; }
.row.tight { margin: 0; flex-wrap: wrap; }
.row.tight button { flex: 0 0 auto; }
.history .qr-thumb { padding: 0; border: 1px solid var(--line); background: #fff; border-radius: 6px; overflow: hidden; }
.history .qr-thumb svg { display: block; width: 100%; height: 100%; }
.history h2 { font-size: 1.1rem; margin-top: 2rem; }
.history .url { font-size: .8rem; word-break: break-all; margin: .3rem 0 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 1rem 0 0; font-size: .92rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; word-break: break-all; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1.1rem .75rem; }
.timeline li::before { content: ""; position: absolute; left: calc(-1rem - 6px); top: .45rem; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline .when { font-size: .85rem; color: var(--muted); }
.timeline .what { font-weight: 600; margin: .1rem 0; }
.timeline .dest { font-size: .92rem; }
.footer-note { margin-top: 2.5rem; text-align: center; }

.kind { border: 0; padding: 0; margin: 0 0 .9rem; }
.kind legend { font-size: .9rem; font-weight: 600; padding: 0; margin-bottom: .35rem; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { flex: 1; margin: 0; font-weight: 500; }
.seg input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; margin: 0; }
.seg span { display: block; text-align: center; padding: .5rem .4rem; cursor: pointer; font-size: .9rem; }
.seg label + label span { border-left: 1px solid var(--line); }
.seg input:checked + span { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
textarea { display: block; width: 100%; margin-top: .3rem; padding: .6rem .7rem; font: inherit; font-size: 1rem; font-weight: normal; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
input[type=file] { display: block; margin-top: .4rem; font: inherit; font-weight: normal; font-size: .9rem; max-width: 100%; }
.photo-preview { display: flex; align-items: center; gap: .75rem; margin: -.3rem 0 .9rem; }
.photo-preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
dialog { max-height: calc(100dvh - 32px); }
.dest.note { word-break: normal; overflow-wrap: anywhere; }
.history h1 { margin-bottom: 1.25rem; }
code { font-family: ui-monospace, Menlo, monospace; font-size: .85em; }
.import-preview p { margin: .5rem 0; }
.import-rows { list-style: none; margin: 0 0 .5rem; padding: 0; max-height: 14rem; overflow-y: auto; font-size: .85rem; }
.import-rows li { padding: .2rem 0; overflow-wrap: anywhere; }
.import-rows .chip { font-size: .68rem; }
.import-create .chip, .import-update .chip { color: var(--ok); }
.import-error .chip { color: var(--error); }
.import-skip .chip { color: var(--muted); }
.info ol + p { margin-top: .9rem; }
.button-link { display: inline-block; padding: .6rem 1.1rem; border-radius: 8px; background: var(--accent); color: var(--accent-fg); font-weight: 600; text-decoration: none; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.compare { width: 100%; border-collapse: collapse; font-size: .92rem; }
.compare th, .compare td { text-align: left; vertical-align: top; padding: .55rem .5rem; border-bottom: 1px solid var(--line); }
.compare thead th { font-size: .85rem; color: var(--muted); }
.compare tbody th { font-weight: 600; width: 30%; }
.compare td:nth-child(2) { color: var(--fg); }
.compare td:nth-child(3) { color: var(--muted); }
.faq h3 { font-size: 1rem; margin: 1.2rem 0 .3rem; }
.site-footer { margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; justify-content: center; font-size: .9rem; }

.tip { margin: 1rem 0 0; padding: .8rem 1rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: .92rem; }
.tip strong { color: var(--fg); }
.tip a { white-space: nowrap; }
.info .tip em { color: var(--fg); font-style: normal; }

.chip.locked { color: var(--accent); }
.link-item.clickable { cursor: pointer; }
/* Mouse only: on touch screens :hover sticks to the last card touched (even when scrolling). */
@media (hover: hover) and (pointer: fine) { .link-item.clickable:hover { border-color: var(--muted); } }
label.switch { display: flex; align-items: center; gap: .65rem; font-weight: 600; cursor: pointer; margin-bottom: .9rem; }
input.switch-input { appearance: none; -webkit-appearance: none; flex: none; margin: 0; width: 2.75rem; height: 1.6rem; border-radius: 999px;
  background: var(--line); position: relative; cursor: pointer; transition: background .15s; }
input.switch-input::before { content: ""; position: absolute; top: 3px; left: 3px; width: calc(1.6rem - 6px); height: calc(1.6rem - 6px);
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .3); transition: transform .15s; }
input.switch-input:checked { background: var(--accent); }
input.switch-input:checked::before { transform: translateX(1.15rem); }
input.switch-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.link:disabled { opacity: .5; text-decoration: none; }

.header-btn { font-size: .85rem; padding: .3rem .65rem; border-radius: 6px; flex: none; }

.phrase-box { margin: 0 0 1rem; }
.phrase-box summary { cursor: pointer; font-weight: 600; }
.phrase-box[open] summary { margin-bottom: .5rem; }
/* A grid, not CSS columns or list markers: iOS printing ignored the columns
   and clipped the numbers. Numbers are spans (see fillPhrase). */
.phrase { display: grid; grid-auto-flow: column; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(8, auto);
  gap: .15rem 1rem; list-style: none; margin: .5rem 0 1rem; padding: 0; font-family: ui-monospace, Menlo, monospace; font-size: .9rem; }
.phrase .n { display: inline-block; min-width: 2.2em; text-align: right; margin-right: .5em; color: var(--muted); }
@media (max-width: 480px) { .phrase { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(12, auto); } }
#phrase-row { margin: -.25rem 0 .5rem; }
#key-phrase-box { margin: .75rem 0 1.25rem; }

/* Recovery sheet: printing it hides everything else. */
@media print {
  @page { margin: .75in; }
  body.print-sheet { background: #fff; }
  body.print-sheet > :not(#print-sheet) { display: none !important; }
  body.print-sheet #print-sheet { display: block !important; color: #000; background: #fff; font-size: 11pt; line-height: 1.4; }
  #print-sheet h1 { font-size: 18pt; margin: 0 0 .3em; }
  #print-sheet h2 { font-size: 12pt; margin: 1.2em 0 .4em; }
  #print-sheet p { margin: .4em 0; }
  #print-sheet .phrase { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(8, auto); gap: .35em 1.5em; font-size: 13pt; margin: .5em 0; }
  #print-sheet .phrase .n { color: #555; }
  #print-sheet .mono { word-break: break-all; font-size: 10pt; }
  #print-sheet, #print-sheet * { break-inside: avoid; }
}

/* More options (options.js) */
.advanced { margin: 0 0 1rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.advanced summary { cursor: pointer; font-weight: 600; font-size: .95rem; }
.advanced[open] summary { margin-bottom: .75rem; }
.advanced .opt { padding: .75rem 0; border-bottom: 1px solid var(--line); }
.advanced .opt:last-of-type { border-bottom: 0; }
.advanced .opt p { margin: 0 0 .6rem; }
.advanced .opt label.switch { margin-bottom: .4rem; }
.advanced .opt-title { font-weight: 600; font-size: .9rem; }
.time-rule { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .75rem .75rem; margin: 0 0 .75rem; min-width: 0; }
.time-rule legend { font-size: .85rem; font-weight: 600; padding: 0 .25rem; }
.days { display: flex; flex-wrap: wrap; gap: .25rem .6rem; margin-bottom: .6rem; }
label.day { display: flex; align-items: center; gap: .25rem; margin: 0; font-weight: normal; font-size: .9rem; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.pair label { min-width: 0; }
.extras { margin: .2rem 0 0; }
.advanced button.link { white-space: normal; text-align: left; }
@media (max-width: 480px) { .pair.dates { grid-template-columns: 1fr; gap: 0; } }
.facts-row { display: contents; }
/* iOS gives date and time fields a built-in minimum width and centered text,
   so they spilled out of their columns. */
input[type=date], input[type=time], input[type=datetime-local] { -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; min-height: 2.75rem; text-align: left; }
input::-webkit-date-and-time-value { text-align: left; }
select { display: block; width: 100%; max-width: 100%; margin-top: .3rem; padding: .6rem .7rem; font: inherit; font-size: 1rem; font-weight: normal; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.hint { display: block; margin-top: .35rem; font-weight: normal; }
.time-rule .hint { margin: -.4rem 0 .8rem; }
.button-link.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.test-print { margin-top: 1.5rem; }
.test-print .row { margin: .75rem 0; }
.test-print .button-link { flex: 1 1 12rem; text-align: center; }

/* Signed-in header: a link styled like its buttons. */
a.header-btn { border: 1px solid var(--line); background: var(--card); color: var(--fg); text-decoration: none; white-space: nowrap; }
@media (max-width: 480px) {
  header { flex-wrap: wrap; gap: .4rem; }
  header strong { margin-right: auto; }
  header .muted { flex-basis: 100%; order: 5; }
  .header-btn { font-size: .8rem; padding: .3rem .5rem; }
}

/* Your links: list or table. */
.view-toggle { flex: none; margin-left: auto; }
.view-toggle span { padding: .3rem .8rem; font-size: .85rem; }
.list-head .row.tight { margin-left: 0; }
/* position: relative keeps the hidden header labels inside the scroll box (else they widen the page). */
.table-scroll { position: relative; overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.links-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.links-table th, .links-table td { text-align: left; vertical-align: middle; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
.links-table tbody tr:last-child td { border-bottom: 0; }
.links-table th { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.links-table th button { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.links-table th button[aria-sort] { color: var(--fg); font-weight: 700; }
.links-table td.dest-cell { max-width: 22rem; overflow-wrap: anywhere; }
.links-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 480px) { .links-table td.dest-cell { min-width: 12rem; } }
.links-table .qr-mini { width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); background: #fff; border-radius: 4px; overflow: hidden; display: block; }
.links-table .qr-mini svg { display: block; width: 100%; height: 100%; }
.links-table .actions { white-space: nowrap; }
.links-table .actions button { padding: .25rem .55rem; font-size: .8rem; }
.links-table .name { font-weight: 600; }

/* Four destination kinds: two rows of two on phones. */
@media (max-width: 480px) {
  .destination .kind .seg { flex-wrap: wrap; }
  .destination .kind .seg label { flex: 1 1 50%; }
  .destination .kind .seg label + label span { border-left: 0; }
  .destination .kind .seg label:nth-child(even) span { border-left: 1px solid var(--line); }
  .destination .kind .seg label:nth-child(n+3) span { border-top: 1px solid var(--line); }
}

/* QR design (QR dialog) */
#design-dialog { width: min(34rem, calc(100vw - 32px)); }
#design-preview { max-width: 18rem; margin: 0 auto 1rem; }
.design-group { border: 0; border-top: 1px solid var(--line); margin: 0 0 .5rem; padding: .75rem 0 0; min-width: 0; }
.design-group legend { font-weight: 700; font-size: .95rem; padding: 0; margin-bottom: .5rem; }
.design-group .seg { margin-bottom: .9rem; }
.design-group .seg span { font-size: .85rem; padding: .45rem .3rem; white-space: nowrap; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr)); gap: .35rem; margin-bottom: .9rem; }
.icon-grid button { aspect-ratio: 1; padding: .35rem; display: grid; place-items: center; border-radius: 8px; font-size: .7rem; }
.icon-grid button svg { width: 100%; height: 100%; }
.icon-grid button[aria-checked=true] { border-color: var(--accent); outline: 2px solid var(--accent); }
#qr-customize { width: 100%; margin-bottom: .75rem; }
#design-dialog .wide-btn { width: 100%; margin-top: .25rem; }
#design-size { padding: 0; }
#design-size-note:empty { display: none; }
.colors input[type=color] { display: block; width: 100%; height: 2.5rem; margin-top: .3rem; padding: .15rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.design-notes { margin: 0 0 .5rem; }
.design-notes p { margin: 0 0 .4rem; }
.design-notes:empty { display: none; }
.qr-big.checker { background: repeating-conic-gradient(#ddd 0% 25%, #fff 0% 50%) 50% / 16px 16px; }

.uses button.link { font: inherit; vertical-align: baseline; }

.app-footer { margin-top: 2.5rem; }

/* Link type tags */
.chip.linktype { color: var(--muted); white-space: nowrap; }
.chip.linktype-page { color: #7a4fc4; }
.chip.linktype-contact { color: #0f7f8a; }
.chip.linktype-event { color: #b5561e; }
@media (prefers-color-scheme: dark) {
  .chip.linktype-page { color: #b79cf0; }
  .chip.linktype-contact { color: #5fc7d0; }
  .chip.linktype-event { color: #f0a070; }
}
/* Table actions: two per row instead of one wide row. */
.links-table td.actions { white-space: normal; }
.links-table .actions-grid { display: grid; grid-template-columns: repeat(2, max-content); gap: .3rem; }

/* Draft links prepared by AI assistants */
.draft-note { margin: 0 0 1rem; padding: .7rem .9rem; border-radius: 8px; border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); font-size: .92rem; }
.draft-note button.link { margin-left: .25rem; }
