/* ==========================================================================
   Address Book - styles
   Light and dark themes. Two panes on a computer (families on the left,
   the chosen family on the right); one pane at a time on a phone.
   ========================================================================== */

:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef0f6;
  --border: #e2e5ee;
  --border-strong: #cdd2df;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-soft: #eef0fe;
  --accent-text: #3730a3;
  --hl: #fff4c2;
  --danger: #c4320a;
  --danger-soft: #fdeee8;
  --ok: #047857;
  --focus: rgba(67, 56, 202, 0.35);
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05);
  --shadow: 0 1px 3px rgba(17, 24, 39, 0.08), 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-lg: 0 24px 48px -12px rgba(17, 24, 39, 0.28);
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e14;
    --surface: #141720;
    --surface-2: #181c26;
    --surface-3: #1f2430;
    --border: #262b38;
    --border-strong: #353c4d;
    --text: #e8eaf0;
    --text-2: #c4c8d4;
    --muted: #8b91a1;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #1e1f3d;
    --accent-text: #a5b4fc;
    --hl: #3b3413;
    --danger: #f97066;
    --danger-soft: #3a1a17;
    --ok: #34d399;
    --focus: rgba(129, 140, 248, 0.45);
    --shadow-sm: none;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.75);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0c0e14;
  --surface: #141720;
  --surface-2: #181c26;
  --surface-3: #1f2430;
  --border: #262b38;
  --border-strong: #353c4d;
  --text: #e8eaf0;
  --text-2: #c4c8d4;
  --muted: #8b91a1;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: #1e1f3d;
  --accent-text: #a5b4fc;
  --hl: #3b3413;
  --danger: #f97066;
  --danger-soft: #3a1a17;
  --ok: #34d399;
  --focus: rgba(129, 140, 248, 0.45);
  --shadow-sm: none;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.75);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- Brand ---------- */

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand img { border-radius: 8px; display: block; }
.brand-lg { font-size: 22px; }
.brand-light { color: #fff; font-size: 19px; }

/* ---------- Buttons & inputs ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
:root[data-theme="dark"] .btn-primary, :root[data-theme="dark"] .filters button.on { color: #0c0e14; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary, :root:not([data-theme="light"]) .filters button.on { color: #0c0e14; } }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 46px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; pointer-events: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-2); text-decoration: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm svg { width: 17px; height: 17px; }

.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 14px 0 6px; }
.field-label .opt { font-weight: 400; color: var(--muted); }
.input, .textarea, .select {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.input-lg { height: 46px; font-size: 15px; }
.textarea { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }

.notice { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; margin: 12px 0; }
.notice-error { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }

/* ---------- Login page ---------- */

.login-body { background: var(--surface); min-height: 100vh; }
.login-split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.login-hero {
  position: relative; overflow: hidden; color: #e0e7ff;
  background:
    radial-gradient(1200px 600px at -10% -20%, rgba(129, 140, 248, .55), transparent 60%),
    radial-gradient(900px 500px at 110% 120%, rgba(56, 189, 248, .35), transparent 60%),
    linear-gradient(150deg, #1e1b4b 0%, #312e81 55%, #3730a3 100%);
}
.login-hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .18;
  background-image: radial-gradient(rgba(255,255,255,.55) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}
.login-hero-inner { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; padding: 48px 56px; max-width: 640px; }
.hero-copy { margin-top: auto; }
.hero-copy h1 { color: #fff; font-size: clamp(30px, 3.4vw, 44px); line-height: 1.12; letter-spacing: -0.025em; margin: 0 0 16px; font-weight: 700; }
.hero-copy p { font-size: 17px; color: #c7d2fe; margin: 0; max-width: 460px; }
.hero-points { list-style: none; padding: 0; margin: 40px 0 auto; display: grid; gap: 18px; }
.hero-points li { display: flex; gap: 14px; align-items: flex-start; font-size: 14.5px; color: #c7d2fe; line-height: 1.45; }
.hero-points strong { color: #fff; font-weight: 600; }
.hero-ico { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); color: #fff; flex: none; }
.hero-foot { font-size: 13px; color: #a5b4fc; margin: 32px 0 0; }

.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.login-form { width: 100%; max-width: 380px; }
.login-mobile-brand { display: none; margin-bottom: 28px; }
.login-title { font-size: 28px; letter-spacing: -0.02em; margin: 0 0 6px; }
.login-sub { color: var(--muted); margin: 0 0 18px; }
.login-form .btn-block { margin-top: 24px; }
.login-foot { color: var(--muted); font-size: 13px; text-align: center; margin: 16px 0 0; }
.login-version { color: var(--muted); font-size: 12px; text-align: center; margin: 28px 0 0; opacity: .75; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; width: 38px; height: 38px; border: 0; background: transparent; color: var(--muted); border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.pw-toggle:hover, .pw-toggle.on { color: var(--accent); }

@media (max-width: 900px) {
  .login-split { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-mobile-brand { display: inline-flex; }
  .login-panel { align-items: flex-start; padding-top: 12vh; }
}

/* ---------- Top bar ---------- */

.topbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { height: var(--topbar-h); display: flex; align-items: center; gap: 20px; padding: 0 20px; }
.search { position: relative; flex: 1; max-width: 640px; margin: 0 auto; }
.search > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input {
  width: 100%; height: 42px; padding: 0 44px 0 40px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-3); color: var(--text); font-size: 15px;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.search input:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.search-kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 600 11px/1 "Inter", sans-serif; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 5px; padding: 4px 6px; background: var(--surface); }
.search input:focus + .search-kbd { display: none; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar-actions form { margin: 0; }

.banner { display: flex; gap: 12px; justify-content: center; align-items: center; padding: 9px 16px; font-size: 14px; background: #fef3c7; color: #92400e; border-bottom: 1px solid #fde68a; }
.banner a { color: inherit; font-weight: 700; }

/* ---------- Two-pane layout ---------- */

.layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: calc(100vh - var(--topbar-h)); }
body:has(.banner:not([hidden])) .layout { height: calc(100vh - var(--topbar-h) - 40px); }
.sidebar { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.count { font-weight: 600; background: var(--surface-3); color: var(--text-2); border-radius: 999px; padding: 2px 9px; letter-spacing: 0; }
.family-list { overflow-y: auto; padding: 0 10px 20px; flex: 1; }
.detail { overflow-y: auto; min-width: 0; outline: none; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; }
.filters button { flex: none; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 4px 11px; font-size: 13px; font-weight: 600; }
.filters button:hover { border-color: var(--border-strong); background: var(--surface-2); }
.filters button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.filters button .n { font-weight: 500; opacity: .7; margin-left: 2px; }
.fam-item { display: flex; gap: 12px; padding: 12px 10px; border-radius: 10px; text-decoration: none; color: inherit; border: 1px solid transparent; margin-bottom: 2px; }
.fam-item:hover { background: var(--surface-2); }
.fam-item.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.fam-item-body { min-width: 0; flex: 1; }
.fam-item-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fam-item-meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fam-item-people { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.chip.pet { display: inline-flex; align-items: center; gap: 3px; background: color-mix(in srgb, #f59e0b 14%, var(--surface)); color: var(--text-2); }
.chip.pet svg { width: 12px; height: 12px; stroke-width: 2; }
.chip.hit { background: var(--hl); color: var(--text); font-weight: 600; }
mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; }

/* Avatars: initials on a colour picked from the name */
.avatar { width: 42px; height: 42px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; color: #fff; flex: none; letter-spacing: .02em; }
.avatar.sq { border-radius: 12px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; border-radius: 18px; }
.avatar.sm { width: 36px; height: 36px; font-size: 13px; }
.av0 { background: linear-gradient(135deg, #6366f1, #4338ca); }
.av1 { background: linear-gradient(135deg, #0ea5e9, #0369a1); }
.av2 { background: linear-gradient(135deg, #10b981, #047857); }
.av3 { background: linear-gradient(135deg, #f59e0b, #b45309); }
.av4 { background: linear-gradient(135deg, #ec4899, #be185d); }
.av5 { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.av6 { background: linear-gradient(135deg, #14b8a6, #0f766e); }
.av7 { background: linear-gradient(135deg, #f43f5e, #be123c); }

.avatar.round { border-radius: 50%; }
.fam-item.hit-item .fam-item-name { background: var(--hl); border-radius: 4px; padding: 0 3px; margin-left: -3px; display: inline-block; }

/* Recycle bin count on the Settings icon */
.icon-btn.has-badge { position: relative; }
.badge-dot { position: absolute; top: 2px; right: 1px; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }

/* Families list (Settings) */
.card-head h2 .count { margin-left: 2px; }
#fams-filter { margin-bottom: 6px; }
.fam-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.fam-row:last-child { border-bottom: 0; padding-bottom: 0; }
.fam-row:first-child { padding-top: 0; }
.fam-row-body { flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.fam-row-body:hover .fam-row-name { color: var(--accent); }
.fam-row-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fam-row .meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fam-row-actions { display: flex; gap: 6px; flex: none; }
.settings .fam-row-actions .btn { margin-top: 0; }
#fams-card { scroll-margin-top: calc(var(--topbar-h) + 56px); }
@media (max-width: 620px) {
  .fam-row { flex-wrap: wrap; }
  .fam-row-actions { width: 100%; padding-left: 48px; }
}

/* Tick boxes (Copy family) */
.checks { display: grid; gap: 4px; margin-top: 10px; }
.check { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; }
.check:hover { background: var(--surface-2); }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; flex: none; }
.check.off { opacity: .5; cursor: default; }

/* Recycle bin list (Settings) */
.bin-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.bin-item:last-child { border-bottom: 0; padding-bottom: 0; }
.bin-thumb { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex: none; border: 1px solid var(--border); }
.bin-body { flex: 1; min-width: 0; }
.bin-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bin-what { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-3); border-radius: 999px; padding: 1px 7px; margin-left: 4px; vertical-align: 1px; }
.bin-item .meta { color: var(--muted); font-size: 12.5px; }
.bin-actions { display: flex; gap: 6px; flex: none; }
.settings .bin-actions .btn { margin-top: 0; }
.settings .card-head .btn { margin-top: 0; }
#bin-card { scroll-margin-top: calc(var(--topbar-h) + 56px); }
@media (max-width: 620px) {
  .bin-item { flex-wrap: wrap; }
  .bin-actions { width: 100%; padding-left: 48px; }
}

/* ---------- Detail pane ---------- */

.detail-inner { max-width: 980px; margin: 0 auto; padding: 28px 32px 64px; }
.back-link { display: none; align-items: center; gap: 6px; color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.fam-header { display: flex; gap: 18px; align-items: center; margin-bottom: 26px; }
.fam-header h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; line-height: 1.2; }
.fam-header .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.fam-header-actions { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card + .card, .grid-2 + .card, .card + .grid-2 { margin-top: 20px; }
.grid-2 > .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: .01em; display: flex; gap: 8px; align-items: center; }
.card-head h2 svg { color: var(--accent); width: 18px; height: 18px; }
.card-body { padding: 16px 18px; }
.empty-line { color: var(--muted); font-size: 14px; }

.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; padding: 16px 18px; }
.person { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); position: relative; transition: border-color .15s, box-shadow .15s; }
.person:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.person.hit { border-color: color-mix(in srgb, #eab308 60%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, #eab308 18%, transparent); }
.person-body { min-width: 0; flex: 1; }
.person-name { font-weight: 600; font-size: 15px; }
.person-nick { color: var(--muted); font-weight: 400; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); margin-top: 3px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.badges .badge { margin-top: 0; }
.badge.conn { background: color-mix(in srgb, #10b981 15%, var(--surface)); color: color-mix(in srgb, #047857 80%, var(--text)); }
.pets { display: flex; flex-wrap: wrap; gap: 10px; }
.pet-card { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.pet-ico { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: color-mix(in srgb, #f59e0b 18%, var(--surface)); color: #b45309; }
.pet-ico svg { width: 18px; height: 18px; }
.pet-name { font-weight: 600; font-size: 14.5px; line-height: 1.2; }
.pet-kind { font-size: 12.5px; color: var(--muted); }
.pet-row { display: grid; grid-template-columns: 1fr 150px 36px; gap: 8px; margin-top: 8px; align-items: center; }
.person-lines { margin-top: 8px; display: grid; gap: 3px; font-size: 13.5px; }
.person-lines a, .contact-line a { color: var(--text-2); text-decoration: none; }
.person-lines a:hover, .contact-line a:hover { color: var(--accent); text-decoration: underline; }
.person-lines .lbl, .contact-line .lbl { color: var(--muted); font-size: 12px; margin-right: 4px; }
.person-lines .note { color: var(--muted); white-space: pre-wrap; }
.person .edit-btn { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity .15s; }
.person:hover .edit-btn, .person:focus-within .edit-btn { opacity: 1; }
@media (hover: none) { .person .edit-btn { opacity: 1; } }

.address { font-size: 15px; line-height: 1.6; white-space: pre-line; }
.address-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.contact-line { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; }
.contact-line svg { color: var(--muted); width: 16px; height: 16px; }
.prose { white-space: pre-wrap; font-size: 14.5px; color: var(--text-2); line-height: 1.6; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; padding: 16px 18px; }
.shot { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-3); }
.shot button.open { display: block; width: 100%; padding: 0; border: 0; background: none; }
.shot img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transition: transform .25s; }
.shot:hover img { transform: scale(1.03); }
.shot-cap { padding: 7px 10px; font-size: 12.5px; color: var(--text-2); background: var(--surface); border-top: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shot-num { position: absolute; top: 8px; left: 8px; background: rgba(17,24,39,.72); color: #fff; font-size: 12px; font-weight: 700; border-radius: 999px; min-width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; padding: 0 7px; }
.drop { border: 1.5px dashed var(--border-strong); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 13px; min-height: 160px; cursor: pointer; background: transparent; text-align: center; padding: 10px; }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* Welcome / empty state */
.welcome { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.welcome-card { text-align: center; max-width: 440px; }
.welcome-art { width: 88px; height: 88px; margin: 0 auto 20px; border-radius: 24px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.welcome-art svg { width: 44px; height: 44px; stroke-width: 1.5; }
.welcome h2 { font-size: 22px; margin: 0 0 8px; letter-spacing: -0.01em; }
.welcome p { color: var(--muted); margin: 0 0 22px; }
.stats { display: flex; gap: 12px; justify-content: center; margin: 0 0 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 18px; min-width: 110px; }
.stat b { display: block; font-size: 22px; letter-spacing: -0.01em; }
.stat span { font-size: 12.5px; color: var(--muted); }
.list-empty { padding: 30px 14px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- Settings ---------- */

.settings h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0 0 22px; }
.settings .card-body > .btn, .settings .card-body form > .btn { margin-top: 18px; }
.device { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.device:last-child { border-bottom: 0; }
.device .meta { color: var(--muted); font-size: 12.5px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 14px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--accent-soft); color: var(--accent-text); }

/* ---------- Modal ---------- */

.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(10, 12, 20, .5); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; animation: fade .15s ease-out; }
.modal { width: 100%; max-width: 560px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: pop .18s ease-out; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 6px; }
.modal-head h3 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.modal-body { padding: 0 22px 8px; }
.modal-foot { display: flex; gap: 8px; align-items: center; padding: 18px 22px 20px; }
.modal-foot .spacer { flex: 1; }
.section-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--border); }
.phone-row { display: grid; grid-template-columns: 130px 1fr 36px; gap: 8px; margin-top: 8px; align-items: center; }
.add-link { margin-top: 8px; background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; gap: 4px; }
.add-link svg { width: 16px; height: 16px; }

.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(5, 6, 10, .92); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; animation: fade .15s; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 140px); border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lightbox-cap { color: #e5e7eb; margin-top: 14px; font-size: 15px; text-align: center; max-width: 700px; }
.lightbox-bar { position: absolute; top: 14px; right: 14px; display: flex; gap: 6px; }
.lightbox-bar .icon-btn { color: #e5e7eb; background: rgba(255,255,255,.08); }
.lightbox-bar .icon-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.lightbox-nav:hover { background: rgba(255,255,255,.2); }
.lightbox-nav.prev { left: 16px; } .lightbox-nav.next { right: 16px; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }

/* ---------- Toasts & loading ---------- */

.toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70; display: grid; gap: 8px; }
.toast { background: #111827; color: #f9fafb; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; }
.toast.err { background: #b42318; }
.toast.has-action { display: flex; align-items: center; gap: 14px; padding-right: 8px; }
.toast-btn { border: 0; background: rgba(255,255,255,.14); color: #fff; font-weight: 700; font-size: 13.5px; border-radius: 7px; padding: 5px 12px; }
.toast-btn:hover { background: rgba(255,255,255,.26); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px; font-size: 14px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Phones and small screens ---------- */

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  :root { --topbar-h: 112px; }
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .search-kbd { display: none; }
  .topbar-actions { margin-left: auto; }
  .btn-new span { display: none; }
  .btn-new { width: 38px; padding: 0; }
  .layout { grid-template-columns: 1fr; height: auto; }
  body:has(.banner:not([hidden])) .layout { height: auto; }
  .sidebar { border-right: 0; background: var(--bg); }
  .filters { padding: 0 10px 12px; }
  .family-list { overflow: visible; padding: 0 10px 40px; }
  .fam-item { background: var(--surface); border-color: var(--border); margin-bottom: 8px; }
  .detail { overflow: visible; }
  .layout.show-detail .sidebar { display: none; }
  .layout:not(.show-detail) .detail { display: none; }
  .back-link { display: inline-flex; }
  .detail-inner { padding: 16px 16px 48px; }
  .fam-header { flex-wrap: wrap; gap: 14px; }
  .fam-header h1 { font-size: 23px; }
  .fam-header-actions { margin-left: 0; width: 100%; justify-content: flex-start; }
  .people, .gallery { padding: 12px; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row3 { grid-template-columns: 1fr 1fr; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; overflow-y: auto; }
}
@media (max-width: 420px) {
  .row2 { grid-template-columns: 1fr; }
  .phone-row { grid-template-columns: 100px 1fr 36px; }
}
