/* Nocturne komponenty (převzato/adaptováno z design systému) + komponenty specifické pro tento
   prototyp, které Nocturne obecně nemá (bottom sheet, tab bar, FAB, chip picker, confirm bar,
   toast) - postavené nad tokeny z tokens.css. Viz docs/005_Design_System_Reference.md. */

/* — rules — */
.hr {
  height: 1px; border: 0; margin: var(--space-4) 0;
  background: linear-gradient(to right,
    transparent, var(--color-divider) 48px,
    var(--color-divider) calc(100% - 48px), transparent);
}

/* — buttons — */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: var(--radius-md);
}
.btn svg { display: block; width: 16px; height: 16px; flex: none; }
.btn-icon svg { width: 18px; height: 18px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { color: var(--color-accent); border-color: var(--color-accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.btn-primary:active { background: color-mix(in srgb, var(--color-accent) 22%, transparent); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); border-color: transparent; }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-ghost:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.btn-icon { width: 36px; height: 38px; padding: 0; flex: none; }
.btn-block { width: 100%; margin-top: var(--space-2); min-height: 46px; }
/* Výjimka pro hlavní mobilní akci (add sheet primary CTA) - plná akcentem, ne obtažená -
   viz design handoff, sekce "Přidání položky". */
.btn-fill-accent { background: var(--color-accent); color: var(--color-bg); border-color: var(--color-accent); font-weight: 500; }
/* color-mix z --color-accent (ne pevný --color-accent-500) - funguje správně v obou motivech
   bez dalšího tokenu jen pro hover jednoho tlačítka. */
.btn-fill-accent:hover, .btn-fill-accent:active { background: color-mix(in srgb, var(--color-accent) 85%, black); }

/* — forms — */
.field { margin-bottom: var(--space-4); }
.field > label {
  display: block; font-size: 12px; margin-bottom: 5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.input {
  width: 100%; min-height: 44px; padding: 6px 10px; font: inherit;
  font-size: 15px; color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
textarea.input { min-height: 66px; resize: vertical; }

/* — našeptávač (add/edit sheet, název položky) — */
.suggestions-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5;
  background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); max-height: 180px; overflow-y: auto;
}
.suggestion-item {
  display: block; width: 100%; text-align: left; padding: 9px 12px; font-size: 13px;
  background: transparent; border: none; cursor: pointer; color: var(--color-text);
}
.suggestion-item:hover, .suggestion-item:focus-visible { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.suggestion-item + .suggestion-item { border-top: 1px solid var(--color-divider); }
/* Přepis výchozího žlutého podbarvení <mark> - shoda se zvýrazní jako akcentový text, ne
   plocha (stejný princip jako zbytek Nocturne - akcent jako tint, ne velká barevná plocha). */
.suggestion-item mark { background: transparent; color: var(--color-accent); font-weight: 600; }

/* — cards — */
.card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-3); border-radius: var(--radius-md); background: var(--color-surface);
}
.card-title { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 15px; }
.elev-sm { box-shadow: var(--shadow-sm); }

/* — tags — */
.tag {
  display: inline-flex; align-items: center; font-size: 11px;
  letter-spacing: 0.02em; padding: 3px 10px;
  border-radius: calc(var(--radius-md) * 0.75);
}
.tag-accent { background: var(--color-accent-800); color: var(--color-accent-100); }
.tag-neutral { background: var(--color-neutral-800); color: var(--color-neutral-100); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }

/* — dialog / bottom sheet — */
.sheet-overlay {
  position: fixed; inset: 0; background: var(--color-overlay);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 40; opacity: 0; transition: opacity 160ms ease;
}
.sheet-overlay.is-open { opacity: 1; }
.sheet-overlay[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 560px; max-height: 88%; overflow-y: auto;
  background: var(--color-surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -1px 0 rgba(var(--color-ink),.14);
  padding: 12px 18px 22px;
  transform: translateY(18px); opacity: 0;
  transition: transform 240ms cubic-bezier(.22,1,.36,1), opacity 240ms cubic-bezier(.22,1,.36,1);
}
.sheet-overlay.is-open .sheet { transform: translateY(0); opacity: 1; }
.sheet-handle {
  width: 38px; height: 4px; border-radius: 2px; background: rgba(var(--color-ink),.22);
  margin: 0 auto 14px;
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.sheet-header h2 { font-size: 19px; margin: 0; }

.dialog-backdrop {
  position: fixed; inset: 0; display: grid; place-items: center;
  padding: var(--space-4); background: color-mix(in srgb, var(--color-neutral-900) 50%, transparent);
  z-index: 40;
}
.dialog-backdrop[hidden] { display: none; }
.dialog {
  width: min(440px, 100%); display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4); border-radius: var(--radius-lg);
  background: var(--color-surface); box-shadow: var(--shadow-lg);
}
.dialog-title { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 20px; }
.dialog-body { font-size: 14px; opacity: 0.85; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }

/* — app shell — */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.screen { padding: 10px 18px calc(120px + var(--confirm-bar-space, 0px)); flex: 1; }
.screen[hidden] { display: none; }

/* — header — */
.list-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.list-header h1 { font-size: 26px; margin: 2px 0; }
.list-summary { font-size: 12px; color: color-mix(in srgb, var(--color-text) 62%, transparent); margin: 0; }

.avatar-stack { display: flex; align-items: center; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500; color: var(--color-accent-200);
  box-shadow: 0 0 0 2px var(--color-bg); flex: none;
}
.avatar-stack .avatar + .avatar { margin-left: -8px; }
.avatar.tone-accent-800 { background: var(--color-accent-800); }
.avatar.tone-neutral-800 { background: var(--color-neutral-800); color: var(--color-neutral-100); }
.avatar.tone-accent-600 { background: var(--color-accent-600); }
.avatar.tone-neutral-600 { background: var(--color-neutral-600); color: var(--color-neutral-100); }

/* — actions row / filters — */
.actions-row { display: flex; gap: 8px; margin-top: 14px; }
.actions-row .btn-secondary { flex: 1; }
/* Tlačítko historie má i .btn-secondary (kvůli vzhledu) - bez týhle přesnější výjimky by ho
   ".actions-row .btn-secondary" natáhlo přes zbylý prostor místo šířky jen na ikonu. */
.actions-row .btn-icon { flex: none; width: 36px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px;
  background: var(--color-accent-900); color: var(--color-accent-300);
  border-radius: 6px; padding: 4px 8px; border: none; cursor: pointer;
}
.filter-chip .x { opacity: .6; }

/* — item list — */
.item-list { list-style: none; margin: 14px 0 0; padding: 0; }
.item-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 2px;
  border-bottom: 1px solid rgba(var(--color-ink),.07); cursor: pointer;
}
.item-row:active { background: rgba(var(--color-ink),.04); }
/* Pravá ruka (Nastavení) - přesune jen checkbox k pravému okraji (order, ne row-reverse), ať
   zůstane i štítek obchodu u pravé strany vedle něj místo přeskočení na levý okraj. Checkbox
   zůstává v DOMu první - stejné pořadí tabování/čtečky obrazovky, mění se jen vizuální pozice. */
.item-list.hand-right .checkbox-hit { order: 1; }

.checkbox-hit {
  position: relative;
  width: 44px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; padding: 0; cursor: pointer; margin: -9px;
}
/* Odškrtnutí zatím jen lokálně, čeká na odeslání (offline nebo request zrovna neprošel) -
   viz app.js, pendingToggles. */
.pending-dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-accent); box-shadow: 0 0 0 2px var(--color-bg);
}
.checkbox {
  width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid rgba(var(--color-ink),.28);
  display: flex; align-items: center; justify-content: center;
}
.checkbox.is-done { background: var(--color-accent-700); border: 1px solid var(--color-accent); }
.checkbox svg { width: 14px; height: 14px; color: var(--color-check); opacity: 0; }
.checkbox.is-done svg { opacity: 1; }

.item-text { flex: 1; min-width: 0; }
.item-name { font-size: 15px; font-weight: 500; letter-spacing: -0.005em; }
.item-name.is-done { color: rgba(var(--color-ink),.38); text-decoration: line-through; }
.item-meta {
  font-size: 11.5px; color: rgba(var(--color-ink),.5); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.store-chip {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; padding: 3px 8px;
  border-radius: 6px; background: var(--color-chipbg); color: var(--color-accent-300); flex: none;
}
.item-name.is-done + .item-meta + .store-chip,
.item-row.is-done .store-chip { opacity: .4; }

.empty-state { text-align: center; margin-top: 60px; }
.empty-state p:first-child { font-size: 15px; margin-bottom: 4px; }
.empty-state p:last-child { font-size: 13px; color: color-mix(in srgb, var(--color-text) 62%, transparent); }

/* — chip picker (kategorie/obchod, filtry, add sheet) — */
.chip-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 11px; border-radius: 6px; font-size: 12.5px; cursor: pointer;
  border: 1px solid var(--color-divider); background: transparent; color: color-mix(in srgb, var(--color-text) 72%, transparent);
}
.chip.chip-category.is-active { background: var(--color-neutral-800); border-color: var(--color-neutral-500); color: var(--color-neutral-100); }
.chip.chip-store.is-active { background: var(--color-accent-900); border-color: var(--color-accent); color: var(--color-accent-300); }
.chip.chip-suggest { background: var(--color-accent-900); border: 1px solid var(--color-accent-800); color: var(--color-accent-300); }

/* — tab bar / FAB — */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-around;
  background: var(--color-bg); box-shadow: 0 -1px 0 rgba(var(--color-ink),.08);
  padding: 9px max(12px, env(safe-area-inset-left)) calc(9px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto; left: 0; right: 0;
}
.tab-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer; color: rgba(var(--color-ink),.45);
  font-size: 10px; padding: 4px 14px; flex: 1;
}
.tab-item svg { width: 21px; height: 21px; }
.tab-item.is-active { color: var(--color-accent-400); }
/* FAB sedí uprostřed lišty absolutně - nezávisle na pořadí tří tabů v DOM
   (design handoff: "Uprostřed FAB pro přidání"). */
.fab {
  position: absolute; left: 50%; top: -18px; transform: translateX(-50%);
  width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--color-accent); background: var(--color-accent-900);
  box-shadow: 0 6px 18px rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.fab svg { width: 24px; height: 24px; color: var(--color-accent-400); }

/* — confirm bar — */
.confirm-bar {
  position: fixed; left: 14px; right: 14px; bottom: 82px; z-index: 20;
  border-radius: 14px; background: var(--color-accent-900);
  box-shadow: 0 0 0 1px var(--color-accent-700), 0 10px 26px rgba(0,0,0,.55);
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  transform: translateY(0); transition: transform 220ms ease, opacity 220ms ease;
  max-width: 560px; margin: 0 auto;
}
.confirm-bar[hidden] { display: none; }
.confirm-bar-text { min-width: 0; }
.confirm-bar-count { font-size: 13.5px; font-weight: 500; color: var(--color-accent-200); margin: 0; }
.confirm-bar-names {
  font-size: 11px; color: rgba(var(--color-ink),.5); margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* — toast — */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 12px); z-index: 50;
  background: var(--color-neutral-800); border-radius: 12px; padding: 10px 16px;
  display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.4;
  opacity: 0; transition: transform 200ms ease, opacity 200ms ease; pointer-events: none;
  width: max-content; max-width: calc(100% - 32px);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast svg { width: 16px; height: 16px; color: var(--color-accent-400); flex: none; margin-top: 1px; }
.toast-text { min-width: 0; white-space: normal; word-break: break-word; }

/* — detail screen — */
.detail-top { display: flex; align-items: center; justify-content: space-between; }
.detail-image {
  height: 196px; border-radius: 14px; background: var(--color-imgbg); box-shadow: inset 0 0 0 1px rgba(var(--color-ink),.1);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  margin-top: 10px; color: rgba(var(--color-ink),.5); font-size: 12.5px; overflow: hidden;
}
.detail-image img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.detail-image svg { width: 30px; height: 30px; }
.detail-title { font-size: 26px; margin-top: 14px; }

/* — fotka na celou obrazovku (klik na náhled v detailu) — */
/* Vždy tmavé pozadí bez ohledu na motiv appky - stejný princip jako u prohlížečů fotek,
   fotka na tmavém podkladu vynikne v obou motivech. */
.image-lightbox {
  position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.image-lightbox[hidden] { display: none; }
.image-lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--radius-md); }
.image-lightbox-close {
  position: absolute; top: 16px; right: 16px; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.12); border: none; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.image-lightbox-close:hover { background: rgba(255,255,255,.2); }

.image-picker {
  border: 1px dashed var(--color-divider); border-radius: var(--radius-md); min-height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; color: var(--color-text); opacity: .7; font-size: 12px;
}
.image-picker svg { width: 24px; height: 24px; }
.image-preview-actions { display: flex; gap: 8px; margin-top: 8px; }
.image-preview-actions .btn { flex: 1; }
.detail-tags { display: flex; gap: 6px; margin-bottom: 14px; }
.detail-note-kicker { margin-bottom: 4px; }
.detail-note { font-size: 14px; line-height: 1.6; }
.detail-link {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
  color: var(--color-accent-300); font-size: 13px; text-decoration: none;
}
.detail-link svg { flex: none; }
.detail-link span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-link:hover { color: var(--color-accent-200); text-decoration: underline; }
.detail-meta-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; }
.detail-meta-row .label { color: color-mix(in srgb, var(--color-text) 62%, transparent); }
.detail-meta-row .value.status { color: var(--color-accent-400); }
.detail-actions { display: flex; align-items: stretch; gap: 8px; margin-top: 14px; }
.detail-actions .btn { min-height: 44px; box-sizing: border-box; }
.detail-actions .btn-primary { flex: 1; }
.detail-actions .btn-icon { width: 44px; }

/* — history — */
.history-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.history-card { box-shadow: 0 0 0 1px var(--color-neutral-800); }
.history-card-top { display: flex; align-items: center; justify-content: space-between; }
.history-card-date { font-size: 15px; font-weight: 500; }
.history-card-count { font-size: 11.5px; color: color-mix(in srgb, var(--color-text) 62%, transparent); }
.history-card-names { font-size: 12.5px; color: color-mix(in srgb, var(--color-text) 62%, transparent); line-height: 1.5; margin: 4px 0; }
.history-card-tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* — settings — */
.settings-section { margin-top: 20px; }
.settings-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(var(--color-ink),.07); }
.member-row .avatar { width: 30px; height: 30px; }
.member-row .name { flex: 1; font-size: 14px; }
.settings-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.settings-add-row { display: flex; gap: 8px; }
.settings-add-row .input { flex: 1; }

/* — auth screens — */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card h1 { font-size: 24px; margin: 4px 0 16px; }
.auth-form { margin-top: 14px; }
.auth-submit { min-height: 46px; }
.auth-switch { margin-top: 14px; text-align: center; font-size: 13px; }
.auth-divider {
  display: flex; align-items: center; gap: 10px; margin: 16px 0;
  font-size: 12px; color: color-mix(in srgb, var(--color-text) 55%, transparent);
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--color-divider); }
.auth-google-note { font-size: 11.5px; text-align: center; margin-top: 6px; }
.google-g {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; border: 1px solid currentColor;
  font-size: 11px; font-weight: 500; flex: none;
}

/* — flash — */
.flash {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 60;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px; font-size: 13px;
}
.flash--success { background: var(--color-accent-900); color: var(--color-accent-200); box-shadow: 0 0 0 1px var(--color-accent-700); }
.flash--error { background: var(--color-neutral-900); color: var(--color-neutral-100); box-shadow: 0 0 0 1px var(--color-neutral-700); }

/* — offline banner — */
.offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 80;
  background: var(--color-neutral-900); color: var(--color-neutral-100);
  text-align: center; padding: 8px 16px; font-size: 12.5px; font-weight: 500;
  box-shadow: 0 1px 0 rgba(var(--color-ink),.14);
}
.offline-banner[hidden] { display: none; }

/* — responsivita — */
@media (min-width: 640px) {
  .screen { max-width: 560px; margin: 0 auto; }
  .confirm-bar { max-width: 560px - 28px; }
}

/* ══════════════════════ Světlý motiv - přepisy komponent ══════════════════════
   Pár tříd designového systému má v podkladu (design_handoff_nakupni_seznam-svetly/README.md,
   sekce "Elevace a komponenty DS") bespoke světlé hodnoty místo prostého swapu tokenů (jiný
   odstín než obecná ramp položka, nebo přidaná stínová vrstva) - ty patří sem, ne do tokens.css.
   Stejný pár pravidel v @media guardu i v [data-theme] atributu, ze stejného důvodu jako
   proměnné v tokens.css (systémová preference vs. vynucená volba v Nastavení). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .input,
  :root:not([data-theme="dark"]) textarea.input { background: #fdfdff; border-color: rgba(var(--color-ink), .2); }
  :root:not([data-theme="dark"]) .btn-secondary { border-color: rgba(var(--color-ink), .22); }
  :root:not([data-theme="dark"]) .tag-neutral { background: #e2e5f0; color: #262838; }
  :root:not([data-theme="dark"]) .tag-accent,
  :root:not([data-theme="dark"]) .tag-accent-2 { background: #e7e5fe; color: #423a6a; }
  /* Nocturne stín je laděný na tmu (hairline + ambientní tma) - na světlém pozadí nefunguje,
     sheet proto navíc dostává jemný stín nahoru (design handoff, "Elevace a komponenty DS"). */
  :root:not([data-theme="dark"]) .sheet { box-shadow: 0 -1px 0 rgba(var(--color-ink),.14), 0 -8px 24px rgba(38,40,56,.10); }
}
:root[data-theme="light"] .input,
:root[data-theme="light"] textarea.input { background: #fdfdff; border-color: rgba(var(--color-ink), .2); }
:root[data-theme="light"] .btn-secondary { border-color: rgba(var(--color-ink), .22); }
:root[data-theme="light"] .tag-neutral { background: #e2e5f0; color: #262838; }
:root[data-theme="light"] .tag-accent,
:root[data-theme="light"] .tag-accent-2 { background: #e7e5fe; color: #423a6a; }
:root[data-theme="light"] .sheet { box-shadow: 0 -1px 0 rgba(var(--color-ink),.14), 0 -8px 24px rgba(38,40,56,.10); }
