:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --line: #e3e1da;
  --accent: #1f6f5f;
  --accent-ink: #ffffff;
  --warn-bg: #fff2cf;
  --warn-ink: #7a5300;
  --danger: #b3261e;
  --radius: 12px;
  /* To-do clusters: visibly a different thing from packing. */
  --task: #a35a00; --task-bg: #fff4e5; --task-ink: #6b3a00;
  /* The compose page and other composing-stage things: indigo, dashed. */
  --pick: #4f46e5; --pick-ink: #ffffff;
  --pick-line: color-mix(in srgb, var(--pick) 45%, var(--line));
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15161a; --card: #1f2126; --text: #ecebe6; --muted: #9c9b94; --line: #2f3238;
    --accent: #3fb59b; --accent-ink: #0d1a16; --warn-bg: #3d2f08; --warn-ink: #ffd77a;
    --task: #e0a35a; --task-bg: #3a2a12; --task-ink: #ffd9a8;
    --pick: #8b85ff; --pick-ink: #0f0d2e;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* 13px base; phone form fields keep 16px so iOS Safari does not zoom on focus. */
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (max-width: 600px) { input, select, textarea { font-size: 16px; } }
/* Desktop renders at 90%, like one Cmd+-. */
@media (min-width: 700px) { body { zoom: 0.9; } }
a { color: var(--accent); }
main { width: 100%; max-width: 720px; margin: 0 auto; padding: 16px 16px 64px; }
@media (min-width: 1000px) { main { max-width: 960px; padding: 24px 24px 64px; } }
main.wide { max-width: none; }
@media (min-width: 1000px) { main.wide { padding: 24px 32px 64px; } }
@media (min-width: 1700px) { main.wide { max-width: 1640px; } }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); }

/* The header runs a quarter larger than the page, so its links stay easy to hit. */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px max(16px, calc((100% - 1640px) / 2 + 16px)); background: var(--card); border-bottom: 1px solid var(--line); font-size: 1.25rem;
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; gap: 18px; align-items: center; }
.topbar nav a { text-decoration: none; color: var(--muted); }
.topbar nav a.active { color: var(--text); font-weight: 600; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 8px 0 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 12px; }
.cards { list-style: none; padding: 0; margin: 0; }
.trip-card { display: flex; justify-content: space-between; align-items: stretch; gap: 12px; }
.trip-link { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.trip-stats { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.trip-card-actions { flex: 0 0 auto; align-self: flex-start; }

.button, button.primary, button.danger {
  display: inline-block; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); text-decoration: none; font: inherit; cursor: pointer; line-height: 1.2;
}
.button.primary, button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.button.small { padding: 5px 10px; font-size: 0.85rem; }
.danger-link { color: var(--danger); }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.inline { display: inline; margin: 0; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 0.85rem; }
.pill.task { background: var(--task-bg); color: var(--task-ink); border-color: transparent; }
/* Stage of a trip on its card, in the colour of the page it is at. */
.pill.stage { font-weight: 700; text-transform: uppercase; font-size: 0.7rem; letter-spacing: .06em; border-color: transparent; }
.pill.stage-pack { background: color-mix(in srgb, var(--accent) 16%, var(--card)); color: var(--accent); }
.pill.stage-compose { background: color-mix(in srgb, var(--pick) 16%, var(--card)); color: var(--pick); border: 1px dashed color-mix(in srgb, var(--pick) 50%, transparent); }
.badge { display: inline-block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; background: var(--warn-bg); color: var(--warn-ink); vertical-align: middle; margin-left: 4px; }

.summary { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 14px; }
/* Native <progress>: no inline style needed, which the CSP forbids. */
.progress { flex: 1 1 140px; height: 8px; border: 0; border-radius: 999px; overflow: hidden; background: var(--line); appearance: none; -webkit-appearance: none; }
.progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
.progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; transition: width .2s; }
.progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.progress.task::-webkit-progress-value { background: var(--task); }
.progress.task::-moz-progress-bar { background: var(--task); }

/* Clusters on both trip pages */
.category { padding: 10px 12px 8px; }
.category-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 2px 4px 8px; }
.category-head h2 { flex: 1 0 auto; }
.category-head [data-group-toggle] { margin-left: auto; text-decoration: none; color: var(--muted); }
.category-head [data-group-toggle]:hover { color: var(--accent); text-decoration: underline; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 4px; border-top: 1px solid var(--line); min-height: 44px; }
.row .name { flex: 1; display: flex; flex-direction: column; }
.row .name small { display: block; }

.pack-form { display: flex; align-items: center; gap: 10px; flex: 1; width: 100%; min-width: 0; }
.pack-label { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; min-height: 28px; min-width: 0; }
.pack-check { width: 20px; height: 20px; margin: 0; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; }
.row.packed .name { color: var(--muted); text-decoration: line-through; }
.remove-form { flex: 0 0 auto; }
.remove-form button { text-decoration: none; padding: 4px 6px; opacity: .5; }
.remove-form button:hover { opacity: 1; color: var(--danger); }
.pack-page .rows { font-size: 0.875rem; }
.pack-page .row { padding: 3px 4px; min-height: 34px; }
.pack-page .category { padding: 8px 10px 6px; margin-bottom: 0; }
.pack-page .category-head { padding: 0 4px 6px; }
.pack-page .category-head h2 { font-size: 0.95rem; }
.clusters { columns: 320px; column-gap: 12px; }
.clusters > .category { break-inside: avoid; display: inline-block; width: 100%; margin: 0 0 12px; }
/* With JS, app.js dealClusters() balances the columns; CSS columns are the fallback. */
.clusters.dealt { columns: auto; display: flex; gap: 12px; align-items: flex-start; }
.clusters.dealt > .col { flex: 1 1 0; min-width: 0; }
.clusters.dealt > .col > .category, .clusters.dealt > .col > .card { display: block; width: auto; margin: 0 0 12px; }
.pack-page .tabs.big { gap: 8px; border-bottom: 2px solid var(--line); margin: 6px 0 14px; }
.pack-page .panel .clusters { margin-bottom: 8px; }
.pack-page .tabs.big .tab { flex: 1 1 0; text-align: center; font-size: 1rem; padding: 10px 14px; margin-bottom: -2px; border: 2px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; background: var(--bg); color: var(--muted); }
.pack-page .tabs.big .tab.active { background: var(--card); color: var(--text); border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.pack-page .tabs.big .tab.tab-task.active { border-color: var(--task); box-shadow: inset 0 3px 0 var(--task); }
.tab-count { display: inline-block; margin-left: 8px; padding: 0 9px; border-radius: 999px; background: var(--line); font-size: 0.8rem; font-weight: 600; color: var(--text); vertical-align: middle; }
.tabs.big .tab.active .tab-count { background: var(--accent); color: var(--accent-ink); }
.tabs.big .tab.tab-task.active .tab-count { background: var(--task); color: #fff; }
@media (max-width: 520px) {
  .pack-page .tabs.big .tab { font-size: 0.95rem; padding: 8px 6px; }
  .pack-page .tabs.big .tab-count { display: block; margin: 4px auto 0; width: max-content; }
}

/* Compose page: the packing list's layout in indigo with dashed cards. */
.headline { font-size: clamp(1.7rem, 4vw, 2.6rem); line-height: 1.1; letter-spacing: -.02em; font-weight: 800; margin: 4px 0 8px; }
.headline .trip-name { color: var(--accent); }
/* Welcome page */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin: 8px 0 14px; }
label.type-card {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 14px 44px 12px 14px; border-radius: var(--radius);
  border: 1px dashed var(--pick-line); background: var(--card); cursor: pointer; user-select: none;
}
label.type-card:hover { border-color: var(--pick); }
label.type-card input { position: absolute; top: 12px; right: 12px; width: 20px; height: 20px; margin: 0; accent-color: var(--pick); cursor: pointer; }
label.type-card:has(input:checked) { border-style: solid; border-color: var(--pick); background: color-mix(in srgb, var(--pick) 10%, var(--card)); }
.type-emoji { font-size: 1.7rem; line-height: 1.1; }
.type-label { font-weight: 700; }
.type-blurb { font-size: 0.9rem; line-height: 1.3; }
.welcome-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 0 0 18px; }
.welcome-form:not(:has(.type-card input:checked)) .welcome-actions .primary { opacity: .45; pointer-events: none; }
.welcome-form:has(.type-card input:checked) .welcome-actions .small { visibility: hidden; }
.welcome-alt { border-style: dashed; }
.welcome-alt p { margin: 0 0 10px; }
.empty-library { border-style: dashed; }
.empty-library p { margin: 0 0 8px; }
.pick-page .headline .trip-name { color: var(--pick); }
.headline .badge { font-size: 0.75rem; vertical-align: middle; }
.pick-page .tabs.big .tab.active, .pick-page .tabs.big .tab.tab-task.active { border-color: var(--pick); box-shadow: inset 0 3px 0 var(--pick); }
.pick-page .tabs.big .tab.active .tab-count { background: var(--pick); color: var(--pick-ink); }
.pick-cluster { border-style: dashed; border-color: var(--pick-line); }
.pick-label { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; min-height: 28px; min-width: 0; }
.pick-label input { width: 20px; height: 20px; margin: 0; flex: 0 0 auto; accent-color: var(--pick); cursor: pointer; }
.pick-row:has(input:checked) .name { font-weight: 600; }
.pick-row:not(:has(input:checked)) .name { color: var(--muted); }
.pick-actions { position: sticky; bottom: 0; z-index: 3; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px -4px 0; padding: 12px 4px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-top: 1px dashed var(--pick-line); }
.welcome-actions .primary, .pick-actions .primary, .step-foot .primary { background: var(--pick); border-color: var(--pick); color: var(--pick-ink); }
.pick-actions .tab-link { text-decoration: none; }
.step-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 12px; }
.step-head h2 { margin: 0; font-size: 1.15rem; }
.step-head .autosave-status { margin-left: auto; }
details.customise { margin-top: 18px; }
details.customise > summary {
  list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 12px 16px;
  border: 1px dashed var(--pick-line); border-radius: var(--radius); background: var(--card);
}
details.customise > summary::-webkit-details-marker { display: none; }
details.customise > summary::before { content: '▸'; color: var(--pick); font-size: 0.9rem; flex: 0 0 auto; transition: transform .15s; }
details.customise[open] > summary::before { transform: rotate(90deg); }
details.customise[open] > summary { border-radius: var(--radius) var(--radius) 0 0; border-bottom-color: transparent; }
details.customise > summary:hover { border-color: var(--pick); }
.customise-title { font-weight: 700; font-size: 1.05rem; }
.customise-body { padding: 12px 16px 0; border: 1px dashed var(--pick-line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
.customise-body .every-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 4px; }
.trip-details { border-style: dashed; border-color: var(--pick-line); }
.trip-details .details-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.trip-details label { margin: 0; }
.trip-details .notes-field { display: block; margin-top: 10px; }
.trip-details textarea { min-height: 2.6em; }
.step-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.autosave-status { min-height: 1.2em; color: var(--muted); }
.autosave-status.error { color: var(--danger); }
.autosave-status.saved { color: var(--pick); }
@media (max-width: 600px) { .trip-details .details-grid { grid-template-columns: 1fr; } }
.pick-page .category-head [data-group-toggle]:hover { color: var(--pick); }
/* The every-trip switches (#show-every, #edit-every), pure CSS via :has(). `label.` / `input[type=checkbox]` for
   specificity over the generic `.form` rules. */
.js label.every-toggle.js-only { display: inline-flex; }
label.every-toggle {
  display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 5px 12px 5px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 0.9rem; font-weight: 500;
  user-select: none;
}
label.every-toggle:hover { border-color: var(--pick); }
label.every-toggle:has(input:checked) { border-color: color-mix(in srgb, var(--pick) 50%, var(--line)); }
label.every-toggle input[type=checkbox] {
  appearance: none; -webkit-appearance: none; position: relative; width: 34px; height: 20px; margin: 0; flex: 0 0 auto;
  border-radius: 999px; border: 0; background: var(--line); cursor: pointer; transition: background .15s;
  vertical-align: middle;
}
label.every-toggle input[type=checkbox]::before {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .35); transition: transform .15s;
}
label.every-toggle input[type=checkbox]:checked { background: var(--pick); }
label.every-toggle input[type=checkbox]:checked::before { transform: translateX(14px); }
label.every-toggle input[type=checkbox]:focus-visible { outline: 2px solid var(--pick); outline-offset: 2px; }
/* Unlocking needs the every-trip items on screen. */
.pick-page:not(:has(#show-every:checked)) label.every-toggle.edit { opacity: .45; pointer-events: none; }
label.every-toggle:has(input:disabled) { cursor: default; }
.pick-page:has(#edit-every:checked) .pick-row.every .pick-label { cursor: pointer; }
.pick-page:has(#edit-every:checked) .pick-row.every input { opacity: 1; cursor: pointer; accent-color: var(--pick); }
.pick-page:not(:has(#show-every:checked)) .pick-row.every,
.pick-page:not(:has(#show-every:checked)) .pick-cluster:not(:has(.pick-row:not(.every))) { display: none; }
.pick-page:has(#show-every:checked) .every-hint { display: none; }
.pick-row.every .pick-label { cursor: default; }
.pick-row.every input { opacity: .45; cursor: default; accent-color: var(--warn-ink); }
.pick-page .pick-row.every .name { font-weight: 400; }
.badge.every { margin-left: 6px; }

/* Cluster add lines: the options unfold while the line has focus or text. */
.cluster-add, .pack-page .cluster-add { display: block; padding: 6px 4px 4px; min-height: 0; }
.cluster-add-line { display: flex; gap: 6px; align-items: center; }
.cluster-add-line input[type=text] {
  flex: 1 1 auto; min-width: 0; padding: 5px 8px; font: inherit; font-size: 0.85rem; border: 1px dashed var(--line);
  border-radius: 8px; background: transparent; color: var(--text);
}
.cluster-add-line input[type=text]:focus { border-style: solid; border-color: var(--accent); outline: none; }
.pick-page .cluster-add-line input[type=text]:focus { border-color: var(--pick); }
.cluster-add-line input:disabled, .cluster-add-line button:disabled { opacity: .45; cursor: default; }
.cluster-add-line .button.small { padding: 4px 10px; font-size: 0.8rem; }
.cluster-add-options { display: none; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; color: var(--muted); }
.cluster-add:focus-within .cluster-add-options,
.cluster-add:has(input[name=name]:not(:placeholder-shown)) .cluster-add-options { display: flex; }
.cluster-add-options .switch { gap: 5px; cursor: pointer; }
.cluster-add-options .switch input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.pick-page .cluster-add-options .switch input { accent-color: var(--pick); }
.cluster-add-options:has(input[name=library]:not(:checked)) .every-opt { opacity: .4; }
.cluster-add .error { margin: 4px 0 0; color: var(--danger); }

.switch { display: inline-flex; align-items: center; gap: 6px; }
.switch input { margin: 0; }

.form label { display: block; margin: 0 0 12px; font-weight: 600; }
.form input[type=text], .form input[type=password], .form input[type=date], .form textarea, .form select {
  display: block; width: 100%; margin-top: 4px; padding: 10px; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text);
}
.form input[type=checkbox] { width: 18px; height: 18px; margin-right: 8px; vertical-align: middle; }
.form fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; padding: 8px 12px; }
.form fieldset ul { list-style: none; padding: 0; margin: 0; }
.form fieldset label { font-weight: 400; margin: 6px 0; }
.form .errorlist { color: var(--danger); list-style: none; padding: 0; margin: 4px 0 0; font-size: 0.85rem; font-weight: 400; }
.form .details-grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form .details-grid.two { grid-template-columns: 1fr; } }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.messages { list-style: none; padding: 0; margin: 0 0 12px; }
.messages li { padding: 10px 14px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); }
.messages li.success { background: color-mix(in srgb, var(--accent) 18%, var(--card)); color: var(--text); }
.notes { white-space: pre-wrap; }
.form .big-switch { font-weight: 600; margin: 4px 0 14px; }
.form .switch { display: flex; }
.essential-switch input { accent-color: var(--warn-ink); }

/* Item chips (cluster peeks, the cluster edit page) */
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; line-height: 1.5;
  border: 1px solid var(--line); color: var(--muted); background: var(--bg); text-decoration: none;
}
.tag.archived { text-decoration: line-through; opacity: .6; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-weight: 400; margin: 0; cursor: pointer; }
.chip:has(input:checked) { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.chip input { margin: 0; width: 16px; height: 16px; }
.chip.archived span { text-decoration: line-through; opacity: .6; }
.char-group { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; padding: 6px 0; }
.char-group + .char-group { border-top: 1px solid var(--line); }
.char-group.current { background: color-mix(in srgb, var(--accent) 6%, transparent); border-radius: 8px; margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
.char-group.current + .char-group { border-top-color: transparent; }
.char-group-name { flex: 0 0 120px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.char-group .chips { flex: 1 1 200px; }

/* Library: tabs + table */
.js .js-hide { display: none; }
.js-only { display: none; }
.js .js-only { display: inline; }
[hidden] { display: none !important; } /* class display rules (pills, flex bars) must never resurrect hidden elements */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 4px 0 14px; }
.tab { padding: 10px 16px; margin-bottom: -1px; border: 1px solid transparent; border-radius: 10px 10px 0 0; color: var(--muted); text-decoration: none; font-weight: 600; }
.tab.active { color: var(--text); background: var(--card); border-color: var(--line); border-bottom-color: var(--card); }
.tabs .tab.tab-task.active { box-shadow: inset 0 3px 0 var(--task); }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.editor-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 560px; font-size: 0.95rem; }
.editor-table thead th { position: sticky; top: 0; z-index: 1; background: var(--card); text-align: left; padding: 10px 8px; font-size: 0.8rem; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
.editor-table td { padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.editor-table .cat-row th { text-align: left; padding: 14px 8px 6px; background: var(--bg); font-size: 1rem; border-bottom: 1px solid var(--line); }
.editor-table .ed-select { width: 36px; text-align: center; padding-right: 0; }
.editor-table .ed-name { min-width: 220px; }
.editor-table .ed-check { text-align: center; width: 90px; }
.editor-table th.ed-essential, .editor-table td.ed-essential { border-right: 1px solid var(--line); }
.editor-table td.ed-essential input[type=checkbox] { accent-color: var(--warn-ink); }
.editor-table input[type=text], .editor-table select { width: 100%; padding: 6px 8px; font: inherit; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text); }
.editor-table td > select { width: auto; max-width: 100%; min-width: 160px; }
.editor-table input[type=text]:hover, .editor-table select:hover { border-color: var(--line); }
.editor-table input[type=text]:focus, .editor-table select:focus { border-color: var(--accent); background: var(--card); outline: none; }
.editor-table input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.editor-table .ed-actions { white-space: nowrap; text-align: right; width: 72px; }
.editor-table .ed-actions a, .editor-table .ed-actions button { margin-left: 10px; }
.editor-table .ed-order { white-space: nowrap; text-align: center; width: 72px; }
.editor-table .ed-order button { font-size: 0.9rem; padding: 2px 6px; text-decoration: none; }
.editor-table .ed-order button[disabled] { opacity: .25; cursor: default; }
.editor-row.saved td { animation: saved-flash .8s ease-out; }
@keyframes saved-flash { from { background: color-mix(in srgb, var(--accent) 18%, transparent); } to { background: transparent; } }
.editor-row.archived input[name=name] { color: var(--muted); text-decoration: line-through; }
/* To-do clusters share the amber look in both Library tables. */
.editor-table tbody.tasks .cat-row th { border-left: 5px solid var(--task); padding-left: 3px; color: var(--task-ink); }
.editor-table tbody.tasks td { background: color-mix(in srgb, var(--task) 7%, var(--card)); }
.editor-table tbody.tasks .editor-row td:first-child { border-left: 5px solid var(--task); padding-left: 3px; }
.editor-table tbody.tasks .add-row-tr td { border-left: 5px solid var(--task); padding-left: 3px; }
.editor-table tbody.tasks .add-row-tr input[type=text] { background: transparent; }
.editor-table tr.editor-row.task td { background: color-mix(in srgb, var(--task) 7%, var(--card)); }
.editor-table tr.editor-row.task td:first-child { border-left: 5px solid var(--task); padding-left: 3px; }
.add-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 4px 0; }
.add-row input[type=text] { flex: 1 1 160px; padding: 8px; font: inherit; border: 1px dashed var(--line); border-radius: 8px; background: var(--card); color: var(--text); }
/* Keep selects on the add line; the table-wide `select { width: 100% }` would wrap them. */
.add-row select, .add-row .group-pick { width: auto; flex: 0 1 220px; }
.add-row .group-pick.new { flex-basis: 380px; }
.group-pick { display: inline-flex; gap: 6px; align-items: center; max-width: 100%; }
.group-pick select { flex: 0 1 auto; }
.group-pick input[name=group_new] { flex: 1 1 auto; }
.js .group-pick:not(.new) input[name=group_new] { display: none; }
.editor-table .group-pick select { width: auto; max-width: 100%; min-width: 160px; }
.editor-table .add-row-tr td { padding: 6px 8px 10px; }
.editor-table .add-row-tr input[type=text] { border: 1px dashed var(--line); background: var(--card); }

/* Add item panel on the Library's Items tab */
.add-panel { margin: 0 0 14px; padding: 0; }
.add-panel summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
.add-panel summary::-webkit-details-marker { display: none; }
.add-panel summary .plus { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.add-panel[open] summary { border-bottom: 1px solid var(--line); }
.add-panel-form { padding: 12px 16px 16px; }
.add-panel-grid { display: grid; grid-template-columns: 2fr 1fr 2fr; gap: 12px; }
@media (max-width: 720px) { .add-panel-grid { grid-template-columns: 1fr; } }
.add-panel-form label { display: block; font-weight: 600; margin: 0; }
.add-panel-form input[type=text], .add-panel-form select { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; font-weight: 400; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
.add-panel-form .essential-switch { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; font-weight: 600; }
.add-panel-form .actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }

/* Bulk bar: above the table without JS; with JS it floats while something is ticked. */
.bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 0 0 10px; padding: 8px 12px; background: var(--card); border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.js .bulkbar { position: fixed; z-index: 20; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(calc(100vw - 32px), 1100px); margin: 0; box-shadow: 0 12px 32px rgba(0,0,0,.28); }
.js .bulkbar:not([hidden]) { animation: bulk-in .15s ease-out; }
@keyframes bulk-in { from { transform: translate(-50%, 12px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.js body.bulk-open main { padding-bottom: 140px; } /* the floating bar must never cover the last rows */
.bulkbar .bulk-count { font-weight: 600; min-width: 90px; }
.bulkbar .bulk-group { display: inline-flex; align-items: center; gap: 6px; }
.bulkbar select { padding: 6px 8px; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); max-width: 220px; }
.bulkbar .button.danger { background: var(--danger); color: #fff; border-color: transparent; }
.bulkbar [data-bulk-clear] { margin-left: auto; }

/* Row menu (⋯): a <details> anchored right. */
.rowmenu { position: relative; display: inline-block; vertical-align: middle; }
.rowmenu summary { list-style: none; cursor: pointer; width: 32px; height: 32px; line-height: 30px; text-align: center; border: 1px solid transparent; border-radius: 6px; color: var(--muted); font-size: 1.1rem; letter-spacing: 1px; }
.rowmenu summary::-webkit-details-marker { display: none; }
.rowmenu summary:hover, .rowmenu[open] summary { border-color: var(--line); background: var(--card); color: var(--text); }
.rowmenu-menu { position: absolute; z-index: 5; top: 100%; right: 0; margin-top: 4px; min-width: 220px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; display: grid; gap: 2px; text-align: left; }
.rowmenu-menu a, .rowmenu-menu label, .rowmenu-menu button { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap; text-decoration: none; font: inherit; color: var(--text); background: none; border: 0; text-align: left; margin: 0; }
.rowmenu-menu a:hover, .rowmenu-menu label:hover, .rowmenu-menu button:hover { background: var(--bg); }
.rowmenu-menu .rowmenu-field { flex-direction: column; align-items: stretch; gap: 4px; cursor: default; color: var(--muted); font-size: 0.8rem; border-bottom: 1px solid var(--line); margin-bottom: 4px; border-radius: 6px 6px 0 0; }
.rowmenu-menu .rowmenu-field select { width: 100%; padding: 6px 8px; font: inherit; font-size: 0.95rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.rowmenu-menu .danger-link { color: var(--danger); border-top: 1px solid var(--line); margin-top: 4px; border-radius: 0 0 6px 6px; }
.rowmenu-menu form { display: contents; }
.trip-menu summary { width: 40px; height: 40px; line-height: 38px; font-size: 1.3rem; border-color: var(--line); }

/* Library: click the item count under a cluster to peek at its items */
.peek summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 0 8px 2px; }
.peek summary::-webkit-details-marker { display: none; }
.peek summary .caret { color: var(--muted); font-size: 0.8rem; transition: transform .15s; }
.peek[open] summary .caret { transform: rotate(180deg); }
.peek .chips { padding: 4px 8px 8px; max-width: 480px; }
.peek-edit { display: inline-block; padding: 0 8px 8px; }

/* Archived trips */
.archived-trips { margin-top: 20px; }
.archived-trips summary { cursor: pointer; padding: 8px 4px; }
.trip-card.archived { opacity: .7; }
