/* Shared 3aileh palette. Every colour is defined on bare :root and only
   redefined inside the dark block, so nothing is left undefined in a theme. */
:root {
  --bg: #f3f6fa;
  --panel: #ffffff;
  --ink: #344861;
  --ink-soft: #6e7c8c;
  --accent: #325aaf;
  --accent-soft: #eaeef7;
  --accent-ink: #ffffff;
  --line: #bec6d4;
  --line-strong: #344861;
  --bad: #e55c6c;
  --bad-bg: #f7cfd6;
  --ok: #0aa06e;
  --shadow: 0 1px 2px rgba(52, 72, 97, .07), 0 8px 24px rgba(52, 72, 97, .07);
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141a;
    --panel: #191d25;
    --ink: #dfe5ee;
    --ink-soft: #939eae;
    --accent: #6f9dff;
    --accent-soft: #232c3c;
    --accent-ink: #0d1220;
    --line: #333b48;
    --line-strong: #93a0b4;
    --bad: #ff8894;
    --bad-bg: #4b1f26;
    --ok: #43d39e;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
/* Any rule that sets `display` beats the hidden attribute's own, and several
   below do. Without this, hiding a panel in script leaves it on the page —
   which for this app meant the unlocked vault showing through the lock. */
[hidden] { display: none !important; }
html {
  -webkit-text-size-adjust: 100%;
  /* Stop the phone treating an overscroll at the top of the board as
     pull-to-refresh, which reloaded the page mid-game. */
  overscroll-behavior: none;
}
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 16px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, select { font: inherit; color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
button, select, input { font: inherit; color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
svg { width: 100%; height: 100%; fill: currentColor; display: block; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem clamp(.9rem, 3vw, 2rem);
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: inherit; }
.brand-mark {
  width: 1.85rem; height: 1.85rem; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 1rem;
}
.brand-name { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; }
.top-right { display: flex; align-items: center; gap: .7rem; }

/* ---------- layout ---------- */
.layout {
  max-width: 1120px; margin: 0 auto;
  padding: clamp(.8rem, 2.2vw, 1.6rem);
  display: grid; gap: clamp(.9rem, 2.4vw, 2rem);
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
.col-main { display: grid; gap: .7rem; min-width: 0; }
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: .9rem; box-shadow: var(--shadow);
}
.title { margin: 0 0 .3rem; font-size: 1.4rem; letter-spacing: -.01em; }
.lede { margin: 0 0 .6rem; color: var(--ink-soft); }

/* ---------- sync pill ---------- */
.sync-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .75rem; font-weight: 600; color: var(--ink-soft);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: .3rem .7rem; white-space: nowrap;
}
.sync-dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--ink-soft); flex: none; }
.sync-pill[data-state="synced"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.sync-pill[data-state="synced"] .sync-dot { background: var(--ok); }
.sync-pill[data-state="syncing"] .sync-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .sync-pill .sync-dot { animation: none; } }
/* Kept visible on a phone: that is where you most want to know whether your
   progress actually reached the cloud. */
@media (max-width: 480px) { .sync-pill span:not(.sync-dot) { display: none; } }

/* ---------- status ---------- */
.status { margin: 0; min-height: 1.35rem; text-align: center; font-size: .85rem; color: var(--ink-soft); }
.status.good { color: var(--ok); font-weight: 600; }
.status.bad { color: var(--bad); font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  min-height: 46px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); font-size: .92rem; font-weight: 700; cursor: pointer;
  padding: .4rem 1rem;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 38px; padding: .3rem .75rem; font-size: .82rem; }
.btn.tiny { min-height: 32px; padding: .2rem .6rem; font-size: .76rem; font-weight: 600; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-bg); }
.btn[disabled] { opacity: .55; cursor: progress; }

/* ---------- fields ---------- */
.field { display: grid; gap: .3rem; margin-bottom: .7rem; min-width: 0; }
.field-label { font-size: .78rem; font-weight: 700; color: var(--ink-soft); letter-spacing: .01em; }
.opt { font-weight: 500; opacity: .75; }
input {
  min-height: 46px; width: 100%; min-width: 0;
  padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink);
}
input:focus { border-color: var(--accent); }
input[readonly] { color: var(--ink-soft); }
.grid-2 { display: grid; gap: 0 .7rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: .3rem; }
.row > input { flex: 1 1 12rem; }
.search-row > #search { flex: 1 1 14rem; }

/* ---------- the lock screen ---------- */
.lock-panel { max-width: 32rem; margin: 0 auto; padding: 1.2rem; }
.join-panel { max-width: 32rem; margin: 0 auto; width: 100%; }
summary { cursor: pointer; font-weight: 700; font-size: .9rem; padding: .1rem 0; }
.fineprint {
  margin: .9rem 0 0; padding-top: .8rem; border-top: 1px solid var(--line);
  font-size: .8rem; line-height: 1.45; color: var(--ink-soft);
}

/* ---------- the list ---------- */
.list { display: grid; gap: .7rem; }
.entry {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: .8rem .9rem; box-shadow: var(--shadow);
  display: grid; gap: .45rem;
}
.entry.locked { border-style: dashed; box-shadow: none; }
.entry-head { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.entry-site { margin: 0; font-size: 1.05rem; letter-spacing: -.01em; overflow-wrap: anywhere; }
.entry-url { font-size: .82rem; color: var(--accent); overflow-wrap: anywhere; }
.entry-url.plain { color: var(--ink-soft); }

.entry-row { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.entry-label {
  flex: none; width: 5.2rem; font-size: .74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft);
}
.entry-value {
  flex: 1 1 8rem; min-width: 0; overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem;
}
.entry-pass[data-revealed="false"] { letter-spacing: .12em; color: var(--ink-soft); }
.entry-tools { display: flex; gap: .35rem; flex: none; }
.entry-note { margin: .1rem 0 0; font-size: .85rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.entry-actions { display: flex; gap: .4rem; justify-content: flex-end; }

.share-panel { margin-top: .4rem; }
.entry-form { display: block; }

/* On a phone a password needs the full width, but letting it wrap pushes its
   own buttons onto a third line. A two-column grid keeps the label above the
   value and the buttons beside both. */
@media (max-width: 480px) {
  .entry-row {
    display: grid; gap: .1rem .6rem;
    grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  }
  .entry-label { width: auto; grid-column: 1; }
  .entry-value { grid-column: 1; }
  .entry-tools { grid-column: 2; grid-row: 1 / span 2; }
}
