/* Claude Password — famiglia "carta calda" (come PT Log/Viaggi), espresso + ottone */
:root {
  --bg: #f3efe7;
  --card: #fffdf8;
  --text: #26221b;
  --muted: #6e6555;
  --primary: #5a4632;
  --accent: #a8802f;
  --danger: #b3261e;
  --ok: #3f7d3a;
  --border: #e0d8c9;
  --header-bg: #2b1c12;
  --header-text: #faf3ea;
  --chip-bg: #ece5d8;
  --shadow: 0 1px 4px rgba(40, 30, 20, .12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17150f;
    --card: #211e17;
    --text: #ece7da;
    --muted: #9f9784;
    --primary: #c2a578;
    --accent: #c99e4f;
    --border: #332f25;
    --header-bg: #171009;
    --chip-bg: #2a261c;
    --shadow: 0 1px 4px rgba(0, 0, 0, .4);
  }
}
/* Toggle manuale (🌙/☀️ in header, come le altre app): forza il tema
   indipendentemente dalla preferenza di sistema. */
html[data-theme="dark"] {
  --bg: #17150f; --card: #211e17; --text: #ece7da; --muted: #9f9784;
  --primary: #c2a578; --accent: #c99e4f; --border: #332f25;
  --header-bg: #171009; --chip-bg: #2a261c; --shadow: 0 1px 4px rgba(0, 0, 0, .4);
}
html[data-theme="light"] {
  --bg: #f3efe7; --card: #fffdf8; --text: #26221b; --muted: #6e6555;
  --primary: #5a4632; --accent: #a8802f; --border: #e0d8c9;
  --header-bg: #2b1c12; --chip-bg: #ece5d8; --shadow: 0 1px 4px rgba(40, 30, 20, .12);
}
.lock-hint { color: #cbb9a4; font-size: 13.5px; font-style: italic; margin: -10px 0 14px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- Lock screen ---- */
.lock-screen {
  position: fixed; inset: 0; z-index: 100;
  background: var(--header-bg);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.lock-box { width: 100%; max-width: 360px; text-align: center; color: var(--header-text); }
.lock-logo { font-size: 56px; margin-bottom: 8px; }
.lock-box h1 { margin: 0 0 6px; font-size: 26px; }
.lock-box p { color: #cbb9a4; margin: 0 0 18px; }
.lock-box input {
  width: 100%; padding: 14px; margin-bottom: 12px;
  border-radius: 10px; border: 1px solid #55402e;
  background: #3a2a1c; color: #fff; font-size: 17px;
}
.lock-box input:focus { outline: 2px solid var(--accent); }
.lock-error { color: #f0a294; min-height: 20px; font-weight: 600; }
.lock-status { color: #b3a48e; font-size: 14px; }

.btn-primary {
  width: 100%; padding: 14px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff;
  font-size: 17px; font-weight: 700; cursor: pointer;
}
.btn-primary:active { filter: brightness(.9); }

/* ---- Header ---- */
header {
  position: sticky; top: 0; z-index: 20;
  background: var(--header-bg); color: var(--header-text);
  display: flex; align-items: center; justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
}
.hdr-title {
  background: none; border: 0; color: var(--header-text);
  font-size: 19px; font-weight: 700; cursor: pointer; padding: 6px;
}
.hdr-actions { display: flex; align-items: center; gap: 4px; }
.hdr-btn {
  background: none; border: 0; font-size: 22px; cursor: pointer;
  color: var(--header-text); padding: 8px; min-width: 44px; min-height: 44px;
  border-radius: 8px;
}
.hdr-btn:focus-visible, .btn-primary:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: #888; display: inline-block; margin-right: 4px; }
.sync-dot.synced { background: #4cc38a; }
.sync-dot.syncing { background: #e2b23e; }
.sync-dot.error { background: #e5534b; }
.sync-dot.offline { background: #8899aa; }

/* ---- Main ---- */
main { max-width: 640px; margin: 0 auto; padding: 14px 14px 90px; }

.search-wrap { position: relative; margin-bottom: 12px; }
.search-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  font-size: 16px; opacity: .55; pointer-events: none;
}
#searchInput {
  width: 100%; padding: 12px 40px 12px 40px; font-size: 17px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text);
}
#searchInput::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border: 0; background: none; cursor: pointer;
  font-size: 20px; color: var(--muted); border-radius: 50%;
}
.search-clear:hover { background: var(--chip-bg); }
.recent-searches {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 15;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 0 0 12px 12px; box-shadow: var(--shadow);
  max-height: 300px; overflow: auto;
}
.recent-searches button {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; border-top: 1px solid var(--border);
  padding: 11px 14px; font-size: 15px; color: var(--text); cursor: pointer;
}
.recent-searches button:hover { background: var(--chip-bg); }

.filters { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px; margin-bottom: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--chip-bg); color: var(--text);
  border-radius: 20px; padding: 7px 14px; font-size: 14px; white-space: nowrap; cursor: pointer;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- Item list ---- */
.item-list { list-style: none; margin: 0; padding: 0; }
.item-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
  cursor: pointer; box-shadow: var(--shadow);
}
.item-icon { font-size: 22px; width: 34px; text-align: center; flex-shrink: 0; }
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-btn {
  background: none; border: 0; font-size: 21px; cursor: pointer;
  color: var(--muted); padding: 8px; min-width: 44px; min-height: 44px;
}
.fav-btn.on { color: var(--accent); }
.empty { text-align: center; color: var(--muted); margin-top: 40px; }

/* ---- Pulsante Nuovo elemento: centrale e ben visibile (niente FAB) ---- */
.big-add {
  display: block; width: 100%; margin: 4px 0 14px;
  border: 0; border-radius: 14px; padding: 15px;
  background: linear-gradient(140deg, var(--accent), #c2913f); color: #fff;
  font-size: 17px; font-weight: 800; cursor: pointer;
  box-shadow: 0 6px 18px rgba(168, 128, 47, .3); transition: .15s;
}
.big-add:active { transform: scale(.985); }
.item-count { text-align: center; color: var(--muted); font-size: 13.5px; margin: -6px 0 12px; }

/* ---- Footer ---- */
footer {
  position: fixed; left: 0; right: 0; bottom: 0;
  text-align: center; font-size: 11.5px; color: var(--muted);
  background: var(--bg); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

/* ---- Modali ---- */
.modal-back {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 16, 22, .55);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 600px) { .modal-back { align-items: center; } }
.modal {
  background: var(--card); color: var(--text);
  width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 600px) { .modal { border-radius: 16px; } }
.modal h2 { margin: 0 0 14px; font-size: 20px; display: flex; justify-content: space-between; align-items: center; }
.modal h2 .close-x { background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--muted); padding: 4px 10px; }
.modal label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
.modal input[type=text], .modal input[type=password], .modal input[type=url],
.modal select, .modal textarea {
  width: 100%; padding: 11px 12px; font-size: 16px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}
.modal textarea { min-height: 90px; resize: vertical; }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row input { flex: 1; }
.mini-btn {
  border: 1px solid var(--border); background: var(--chip-bg); color: var(--text);
  border-radius: 8px; padding: 9px 11px; font-size: 15px; cursor: pointer; min-height: 42px;
}
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn-primary { flex: 1; }
.btn-danger {
  border: 1px solid var(--danger); color: var(--danger); background: none;
  border-radius: 10px; padding: 12px 16px; font-size: 15px; cursor: pointer;
}
.btn-plain {
  border: 1px solid var(--border); background: none; color: var(--text);
  border-radius: 10px; padding: 12px 16px; font-size: 15px; cursor: pointer;
}

/* Vista dettaglio */
.detail-field { margin-bottom: 4px; }
.detail-field .df-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.detail-field .df-row { display: flex; align-items: center; gap: 6px; }
.detail-field .df-value {
  flex: 1; font-size: 16.5px; word-break: break-all;
  padding: 6px 0; font-variant-ligatures: none;
}
.df-value.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Generatore */
.gen-box { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-top: 8px; }
.gen-box .gen-out { font-family: ui-monospace, Menlo, monospace; font-size: 16px; word-break: break-all; margin-bottom: 8px; }
.gen-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.gen-row input[type=range] { flex: 1; }

/* Griglia di pulsanti azione, tutti visibili (selettore tipo elemento, dettagli, ecc.) */
.grid-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-actions button { background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 6px; font-size: 12.5px; font-weight: 600; color: var(--text); cursor: pointer; text-align: center; }
.grid-actions button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Menu: griglia di pulsanti tutti visibili (niente liste a scorrimento) */
.menu-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-list li { display: contents; }
.menu-list button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  width: 100%; text-align: center; background: var(--bg);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 8px; font-size: 13.5px; font-weight: 600; color: var(--text); cursor: pointer; min-height: 72px;
}
.menu-list button:hover { background: var(--chip-bg); }
.backup-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border); font-size: 14.5px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 90;
  background: var(--header-bg); color: var(--header-text);
  padding: 10px 18px; border-radius: 22px; font-size: 15px;
  box-shadow: 0 3px 10px rgba(0,0,0,.35); max-width: 90vw;
}
