:root {
  --bg: #eceff5;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --ink: #0f172a;
  --sub: #6b7690;
  --line: #e6e9f0;
  --accent: #6d5efc;
  --accent-2: #9b8cff;
  --note: #f5a524;
  --note-bg: #fff8ec;
  --ok: #16a34a;
  --danger: #e11d48;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
  --shadow-md: 0 10px 30px rgba(15,23,42,.10);
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}
.hidden { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 80% at 50% 0%, #1e293b, #0f172a); }
.login-card { background: var(--surface); border-radius: 22px; padding: 32px 26px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-md); text-align: center; }
.brand-mark { width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 15px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2)); position: relative; box-shadow: var(--shadow-sm); }
.brand-mark::after { content:""; position:absolute; inset:0; margin:auto; width:24px; height:14px;
  border-left:4px solid #fff; border-bottom:4px solid #fff; transform: rotate(-45deg) translate(2px,-3px); border-radius:2px; }
.login-card h1 { font-size: 25px; margin-bottom: 6px; }
.login-card p { color: var(--sub); font-size: 16px; margin-bottom: 20px; }
.login-card input { width: 100%; font-size: 18px; padding: 14px 15px; border: 1.5px solid var(--line);
  border-radius: 13px; margin-bottom: 12px; }
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button { width: 100%; font-size: 18px; font-weight: 650; padding: 14px; border: none; border-radius: 13px;
  background: var(--accent); color: #fff; cursor: pointer; }
.login-err { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 18px; }

/* ---------- App ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; max-width: 680px; margin: 0 auto; }

.topbar { position: sticky; top: 0; z-index: 5; background: var(--surface);
  padding: max(env(safe-area-inset-top), 14px) 8px 0; border-bottom: 1px solid var(--line); }
.topbar-row { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 10px; }
.topbar-row h1 { font-size: 22px; font-weight: 750; letter-spacing: -.3px; }
.icon-btn { width: 38px; height: 38px; border: none; background: transparent; color: var(--sub); border-radius: 10px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn circle { fill: currentColor; stroke: none; }

/* tabs liste */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 8px 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; font-size: 15px; font-weight: 600; padding: 8px 15px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--sub); cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.tab.vault { border-color: #f3d391; color: var(--note); }
.tab.vault.active { background: linear-gradient(135deg, var(--note), #f3bd4f); border-color: transparent; color: #fff; }
.tab-add { flex: none; width: 38px; height: 37px; border-radius: 999px; border: 1.5px dashed var(--line);
  background: transparent; color: var(--sub); font-size: 20px; cursor: pointer; display: grid; place-items: center; }

/* contenuto */
.content { flex: 1; padding: 14px 14px 130px; }
.items { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.item { display: flex; gap: 13px; background: var(--surface); border-radius: var(--radius); padding: 15px 14px;
  box-shadow: var(--shadow-sm); align-items: flex-start; }
.item .check { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #c3cad9;
  display: grid; place-items: center; cursor: pointer; margin-top: 1px; transition: .15s; }
.item .check svg { width: 15px; height: 15px; stroke: #fff; opacity: 0; }
.item.done .check { background: var(--ok); border-color: var(--ok); }
.item.done .check svg { opacity: 1; }
.item .body { flex: 1; min-width: 0; }
.item .txt { font-size: 17px; line-height: 1.4; word-break: break-word; white-space: pre-wrap; cursor: pointer;
  border-radius: 8px; margin: -2px -4px; padding: 2px 4px; transition: background .12s; }
.item .txt:active { background: var(--surface-2); }
.item.done .txt { color: var(--sub); text-decoration: line-through; }
.item .row-actions { flex: none; display: flex; gap: 2px; }
.item .copy, .item .del { flex: none; width: 34px; height: 34px; border: none; background: transparent; color: #c3cad9;
  border-radius: 9px; cursor: pointer; display: grid; place-items: center; }
.item .copy svg, .item .del svg { width: 18px; height: 18px; }
.item .copy:hover, .item .copy:active { color: var(--accent); background: var(--surface-2); }
.item .del:hover, .item .del:active { color: var(--danger); background: var(--surface-2); }

/* nota */
.item.note { background: var(--note-bg); border-left: 4px solid var(--note); }
.item.note .tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--note); margin-bottom: 4px; }

.empty { text-align: center; color: var(--sub); font-size: 16px; padding: 60px 20px; }

/* composer */
.composer { position: fixed; bottom: 0; left: 0; right: 0; max-width: 680px; margin: 0 auto;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: linear-gradient(to top, var(--bg) 78%, transparent); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin-bottom: 8px; }
.seg button { border: none; background: transparent; color: var(--sub); font-size: 13.5px; font-weight: 650;
  padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { flex: 1; font: inherit; font-size: 17px; padding: 13px 15px; border: 1.5px solid var(--line);
  border-radius: 15px; background: var(--surface); resize: none; max-height: 140px; line-height: 1.4; box-shadow: var(--shadow-sm); }
.composer textarea:focus { outline: none; border-color: var(--accent); }
.add-btn { flex: none; width: 50px; height: 50px; border: none; border-radius: 15px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2)); color: #fff; cursor: pointer; box-shadow: var(--shadow-sm); }
.add-btn svg { width: 24px; height: 24px; stroke: #fff; }

/* toast */
.status { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff;
  font-size: 14px; padding: 9px 16px; border-radius: 999px; opacity: 0; transition: .2s; pointer-events: none; z-index: 50; }
.status.show { opacity: 1; }
.status.err { background: var(--danger); }

/* sheet */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.4); }
.sheet-card { position: relative; background: var(--surface); width: 100%; max-width: 680px;
  border-radius: 20px 20px 0 0; padding: 14px 12px calc(env(safe-area-inset-bottom) + 12px); box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 6px; animation: rise .18s ease; }
@keyframes rise { from { transform: translateY(20px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-card h3 { font-size: 15px; color: var(--sub); font-weight: 600; padding: 6px 10px; }
.sheet-item { text-align: left; border: none; background: transparent; font-size: 17px; padding: 15px 12px;
  border-radius: 12px; color: var(--ink); cursor: pointer; }
.sheet-item:hover { background: var(--surface-2); }
.sheet-item.danger { color: var(--danger); }
