/* My Shit — dark UI, phone-first, widens into a sidebar layout on desktop. */

:root {
  --bg: #0b0d14;
  --bg-2: #0f121b;
  --surface: #141826;
  --surface-2: #1a1f30;
  --surface-3: #232a3e;
  --border: #222839;
  --border-strong: #31394f;
  --text: #e6e9f2;
  --muted: #9aa2b8;
  --faint: #687089;
  --accent: #6d75f7;
  --accent-hover: #8189ff;
  --accent-ink: #ffffff;
  --accent-text: #a4aaff;
  --accent-soft: rgba(109, 117, 247, .16);
  --danger: #f06a6a;
  --danger-soft: rgba(240, 106, 106, .13);
  --ok: #4cc38a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 16px 40px rgba(0, 0, 0, .45);
  --top: 60px;
  --side: 288px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }
.hidden { display: none !important; }

svg.i { width: 20px; height: 20px; flex: none; }
.i-sm svg.i, svg.i.sm { width: 16px; height: 16px; }
svg.i.fill { fill: currentColor; }

/* ---------- Boot / spinner ---------- */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--surface-3); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 64px 0; display: grid; place-items: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  font-weight: 560; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg.i { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: rgba(240, 106, 106, .35); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: #1b0a0a; border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.lg { min-height: 50px; padding: 0 22px; font-size: 16px; }
.btn.block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 50%; border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm svg.i { width: 17px; height: 17px; }

/* ---------- App frame ---------- */
body.app {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  grid-template-rows: var(--top) 1fr;
  grid-template-areas: "top top" "side main";
  min-height: 100dvh;
}
body.app #app { display: contents; }
.topbar {
  grid-area: top; position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: rgba(11, 13, 20, .86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; overflow: hidden; flex: none; }
.brand-mark img { width: 100%; height: 100%; }
.topbar .spacer { flex: 1; }
.search-wrap {
  position: relative; flex: 1; max-width: 620px; margin: 0 auto;
  display: flex; align-items: center;
}
.search-wrap svg.i { position: absolute; left: 14px; color: var(--faint); pointer-events: none; }
.search-input {
  width: 100%; height: 42px; padding: 0 16px 0 44px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); outline: none;
  transition: border-color .15s, background .15s;
}
.search-input:focus { border-color: var(--accent); background: var(--surface-2); }
.search-input::placeholder { color: var(--faint); }

.sidebar {
  grid-area: side; position: sticky; top: var(--top); height: calc(100dvh - var(--top));
  overflow-y: auto; padding: 14px 10px 14px; background: var(--bg-2); border-right: 1px solid var(--border);
}
.main { grid-area: main; min-width: 0; padding: 28px 36px 64px; }
.page { max-width: 1180px; margin: 0 auto; }
.scrim { display: none; }
.bottombar { display: none; }

.side-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 560;
}
.side-link:hover { background: var(--surface); color: var(--text); }
.side-link.active { background: var(--accent-soft); color: var(--accent-text); }
.side-label {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 4px 6px 12px; font-size: 12px; font-weight: 650; letter-spacing: .06em;
  text-transform: uppercase; color: var(--faint);
}
.side-foot { margin: 22px 12px 0; font-size: 13px; color: var(--faint); }
/* Settings sits at the very bottom of the menu. */
.sidebar { display: flex; flex-direction: column; }
.side-bottom { margin-top: auto; flex: none; }
.side-foot { margin-top: 8px; margin-bottom: 0; }

.tree-children { padding-left: 14px; margin-left: 13px; border-left: 1px solid var(--border); }
.tree-row { display: flex; align-items: center; gap: 2px; border-radius: 8px; }
.tree-row:hover { background: var(--surface); }
.tree-row.active { background: var(--accent-soft); }
.tree-row.active .tree-link { color: var(--accent-text); }
.tree-toggle {
  width: 26px; height: 30px; display: grid; place-items: center; flex: none;
  border: 0; background: none; color: var(--faint); cursor: pointer; border-radius: 6px;
}
.tree-toggle svg.i { width: 15px; height: 15px; transition: transform .15s; }
.tree-toggle.open svg.i { transform: rotate(90deg); }
.tree-toggle:hover { color: var(--text); }
.tree-spacer { width: 26px; flex: none; }
.tree-link {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 2px; color: var(--muted); font-size: 14px;
}
.tree-link:hover { color: var(--text); }
.tree-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tree-empty { padding: 8px 12px; color: var(--faint); font-size: 14px; }

@media (min-width: 900px) {
  .only-mobile { display: none !important; }
}

@media (max-width: 899px) {
  :root { --top: 56px; }
  body.app { display: block; }
  .topbar { padding: 0 8px 0 4px; gap: 6px; }
  .topbar .search-wrap { display: none; }
  .brand { font-size: 16px; }
  .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
  .main { padding: 16px 16px calc(96px + var(--safe-b)); }
  .only-desktop { display: none !important; }
  .sidebar {
    position: fixed; z-index: 60; top: 0; left: 0; bottom: 0; height: 100dvh;
    width: min(86vw, 330px); padding-top: 18px;
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow);
  }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .55); }
  .bottombar {
    display: flex; position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    padding: 6px 8px calc(6px + var(--safe-b));
    background: rgba(15, 18, 27, .94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
  }
  .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 0; font-size: 11px; font-weight: 560; color: var(--faint);
    background: none; border: 0; cursor: pointer;
  }
  .tab.active { color: var(--accent-text); }
  .tab-add {
    flex: 0 0 auto; width: 54px; height: 54px; margin: -18px 10px 0; border-radius: 50%;
    display: grid; place-items: center; border: 4px solid var(--bg);
    background: var(--accent); color: var(--accent-ink); cursor: pointer; box-shadow: 0 6px 18px rgba(109, 117, 247, .45);
  }
  .tab-add svg.i { width: 26px; height: 26px; }
  h1 { font-size: 23px; }
}

/* ---------- Page pieces ---------- */
.crumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  margin-bottom: 14px; font-size: 13px; color: var(--faint);
}
.crumbs a { color: var(--muted); padding: 2px 4px; border-radius: 6px; }
.crumbs a:hover { color: var(--text); background: var(--surface); }
.crumbs svg.i { width: 14px; height: 14px; }
.crumbs .here { color: var(--text); padding: 2px 4px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.section { margin-top: 30px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { display: flex; align-items: baseline; gap: 8px; }
.section-head .count { font-size: 13px; font-weight: 500; color: var(--faint); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card.pad { padding: 18px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; }
.stat-label { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.stat-value { margin-top: 4px; font-size: 22px; font-weight: 680; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-value { font-size: 19px; }
}

/* Space cards */
.space-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
@media (max-width: 640px) { .space-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.space-card { overflow: hidden; transition: border-color .15s, transform .15s; display: flex; flex-direction: column; }
.space-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.space-card .thumb { aspect-ratio: 4 / 3; border-radius: 0; }
.space-card-body { padding: 10px 12px 12px; min-width: 0; }
.space-card-name { font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-card-meta { font-size: 12.5px; color: var(--faint); margin-top: 2px; }
.add-space-card {
  align-items: center; justify-content: center; gap: 10px; min-height: 160px;
  border: 2px dashed var(--border-strong); border-radius: var(--radius); color: var(--muted); font-weight: 600;
  transition: border-color .15s, color .15s, background .15s;
}
.add-space-card:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); transform: none; }
.add-space-card svg.i { width: 30px; height: 30px; }

.thumb {
  position: relative; width: 100%; background: var(--surface-2); overflow: hidden;
  display: grid; place-items: center; color: var(--faint); border-radius: var(--radius-sm);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Whole photo, never cropped; a blurred copy fills the leftover edges. */
.fit, .thumb.fit { position: relative; display: block; overflow: hidden; background: #08090c; isolation: isolate; }
.fit .fit-bg, .fit .fit-fg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.fit .fit-bg { object-fit: cover; filter: blur(18px) brightness(.6) saturate(1.2); transform: scale(1.2); z-index: 0; }
.fit .fit-fg { object-fit: contain; z-index: 1; }
.fit > :not(img) { z-index: 2; }
.thumb svg.i { width: 34%; height: 34%; max-width: 44px; max-height: 44px; opacity: .7; }

/* Item rows */
.item-list { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: flex; align-items: center; gap: 14px; padding: 10px 14px 10px 10px;
  transition: border-color .15s, background .15s;
}
.item-row:hover { border-color: var(--border-strong); background: var(--surface-2); }
.item-row .thumb { width: 58px; height: 58px; flex: none; }
.item-row .thumb svg.i { width: 24px; height: 24px; }
.item-main { flex: 1; min-width: 0; }
.item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.item-sub .sep { color: var(--faint); margin: 0 6px; }
.item-path { font-size: 12.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.item-side { text-align: right; flex: none; }
.item-value { font-weight: 620; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted); font-size: 12px; font-weight: 600;
}
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.ok { background: rgba(76, 195, 138, .14); color: var(--ok); }
.snippet { font-size: 13px; color: var(--muted); margin-top: 3px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
mark { background: var(--accent-soft); color: var(--accent-text); border-radius: 3px; padding: 0 1px; }

/* Hero (space header) */
.hero { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 22px; align-items: start; }
.hero .thumb { aspect-ratio: 4 / 3; border-radius: var(--radius); cursor: pointer; border: 1px solid var(--border); }
.hero .thumb.empty { cursor: default; }
.hero-body h1 { word-break: break-word; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; color: var(--muted); font-size: 14px; }
.hero-desc { margin-top: 10px; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.hero .actions { margin-top: 16px; }
@media (max-width: 640px) {
  .hero { grid-template-columns: 1fr; gap: 14px; }
  .hero .thumb { aspect-ratio: 16 / 9; }
}

/* Item detail */
.detail { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 960px) { .detail { grid-template-columns: minmax(0, 1fr); gap: 20px; } }
.gallery-main { aspect-ratio: 4 / 3; border-radius: var(--radius); border: 1px solid var(--border); cursor: zoom-in; }
.gallery-main.empty { cursor: default; }
.gallery-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px; text-align: center; }
.gallery-strip { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px; }
.gallery-strip .thumb { width: 72px; height: 72px; flex: none; cursor: pointer; border: 2px solid transparent; }
.gallery-strip .thumb.active { border-color: var(--accent); }
.gallery-strip .primary-dot { position: absolute; top: 4px; right: 4px; color: var(--accent-text); }
.gallery-strip .primary-dot svg.i { width: 14px; height: 14px; }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.detail-actions, .pk-actions { margin-top: 14px; }
svg.i.flip { transform: rotate(180deg); }

.reorder-hint { margin-bottom: 14px; }
.reorder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
@media (max-width: 640px) { .reorder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.reorder-tile {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2); border: 2px solid var(--border); cursor: grab;
  touch-action: none; user-select: none; -webkit-user-select: none; transition: opacity .12s;
}
.reorder-tile.is-main { border-color: var(--accent); }
.reorder-tile.dragging { opacity: .45; cursor: grabbing; }
.reorder-pos {
  position: absolute; top: 6px; left: 6px; display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 650;
  background: rgba(0, 0, 0, .7); color: #fff;
}
.reorder-tile.is-main .reorder-pos { background: var(--accent); color: var(--accent-ink); }
.reorder-btns {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between;
  padding: 18px 4px 4px; background: linear-gradient(transparent, rgba(0, 0, 0, .75));
}
.reorder-btns .icon-btn { color: #fff; background: rgba(0, 0, 0, .35); }
.reorder-btns .icon-btn:hover { background: rgba(0, 0, 0, .6); }
.reorder-btns .icon-btn:disabled { opacity: .3; }
.link-note { margin-top: 12px; font-size: 13px; }
.page > .search-wrap { margin-bottom: 18px; max-width: none; }

.detail-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.detail-title h1 { word-break: break-word; }
.detail-value { margin-top: 6px; font-size: 20px; font-weight: 650; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 18px; margin: 0; }
.fields dt { color: var(--faint); font-size: 13.5px; padding-top: 1px; }
.fields dd { margin: 0; word-break: break-word; white-space: pre-wrap; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 2px 10px; border-radius: 999px; background: var(--surface-3); font-size: 13px; color: var(--muted); }
.tag:hover { color: var(--text); }
.text-block { white-space: pre-wrap; word-break: break-word; color: var(--muted); }
.meta-line { font-size: 13px; color: var(--faint); display: flex; flex-wrap: wrap; gap: 4px 16px; }

.file-list { display: flex; flex-direction: column; gap: 6px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 10px; }
.file-row .thumb { width: 44px; height: 44px; flex: none; }
.file-row .thumb svg.i { width: 20px; height: 20px; }
.file-main { flex: 1; min-width: 0; }
.file-name { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.file-name:hover { color: var(--accent-text); }
.file-meta { font-size: 12.5px; color: var(--faint); }

/* Empty states */
.empty {
  padding: 34px 20px; text-align: center; border: 1px dashed var(--border-strong);
  border-radius: var(--radius); color: var(--muted);
}
.empty h3 { color: var(--text); font-size: 16px; margin-bottom: 6px; }
.empty .actions { justify-content: center; margin-top: 16px; }

/* ---------- Forms ---------- */
.form { max-width: 760px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12.5px; color: var(--faint); }
.input, textarea.input, select.input {
  width: 100%; min-height: 44px; padding: 10px 13px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--border-strong); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--faint); }
input[type="date"].input { color-scheme: dark; }
.input-prefix { position: relative; }
.input-prefix > span {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.input-prefix > .input { padding-left: 28px; }
.picker {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 13px;
  border-radius: var(--radius-sm); background: var(--bg-2); border: 1px solid var(--border-strong);
  text-align: left; cursor: pointer;
}
.picker:hover { border-color: var(--faint); }
.picker span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker svg.i { color: var(--faint); }
.form-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 18px;
  border-top: 1px solid var(--border);
}
@media (max-width: 640px) {
  .form-actions { position: sticky; bottom: calc(76px + var(--safe-b)); background: var(--bg); margin: 20px -16px 0; padding: 12px 16px; }
  .form-actions .btn { flex: 1; }
}
.queue { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.queue-item { position: relative; width: 86px; height: 86px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.queue-item img { width: 100%; height: 100%; object-fit: cover; }
.queue-item button {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .7); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.queue-item button svg.i { width: 14px; height: 14px; }

/* ---------- Modal / menu / toast ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .6);
  display: grid; place-items: center; padding: 16px; animation: fade .12s ease;
}
.modal {
  width: min(520px, 100%); max-height: min(86dvh, 760px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow);
  animation: pop .14s ease;
}
.modal.wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 12px 8px 20px; }
.modal-body { padding: 8px 20px 16px; overflow-y: auto; }
.modal-body p + p { margin-top: 10px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px 18px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .modal-overlay { place-items: end center; padding: 0; }
  .modal { width: 100%; border-radius: 18px 18px 0 0; max-height: 90dvh; padding-bottom: var(--safe-b); }
  .modal-actions .btn { flex: 1; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

.choice-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.choice {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
}
.choice:hover { border-color: var(--border-strong); background: var(--surface-3); }
.choice strong { display: block; }
.choice span { font-size: 13px; color: var(--muted); }
.choice.danger strong { color: var(--danger); }

.space-pick-list { display: flex; flex-direction: column; margin-top: 10px; }
.space-pick {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px;
  background: none; text-align: left; cursor: pointer;
}
.space-pick:hover { background: var(--surface-2); }
.space-pick.selected { background: var(--accent-soft); color: var(--accent-text); }
.space-pick:disabled { opacity: .35; cursor: not-allowed; }
.space-pick .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-pick .path { font-size: 12px; color: var(--faint); }
.space-pick svg.i { color: var(--faint); width: 18px; height: 18px; }

.menu {
  position: fixed; z-index: 110; min-width: 210px; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow);
  animation: pop .1s ease;
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px;
  background: none; text-align: left; cursor: pointer; font-size: 14px;
}
.menu button:hover { background: var(--surface-3); }
.menu button.danger { color: var(--danger); }
.menu button svg.i { width: 18px; height: 18px; color: var(--muted); }
.menu button.danger svg.i { color: var(--danger); }

.toasts {
  position: fixed; z-index: 200; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(440px, calc(100% - 32px)); pointer-events: none;
}
@media (max-width: 899px) { .toasts { bottom: calc(90px + var(--safe-b)); } }
.toast {
  width: 100%; padding: 12px 16px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); font-size: 14px; pointer-events: auto; animation: pop .14s ease;
}
.toast.error { border-color: rgba(240, 106, 106, .5); color: #ffd2d2; }
.toast.ok { border-color: rgba(76, 195, 138, .45); }
.toast .bar { height: 4px; border-radius: 4px; background: var(--surface); margin-top: 8px; overflow: hidden; }
.toast .bar div { height: 100%; width: 0; background: var(--accent); transition: width .15s; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 150; background: rgba(5, 6, 8, .96);
  display: flex; flex-direction: column; animation: fade .12s ease;
}
.lb-top {
  display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 18px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px)); color: var(--muted); flex-wrap: wrap;
}
.lb-top .count { flex: 1; font-size: 14px; }
.lb-top .icon-btn, .lb-top .btn { color: var(--text); }
.lb-stage {
  flex: 1; min-height: 0; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; padding: 8px 64px 24px;
}
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; user-select: none; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, .08); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.lb-nav:hover { background: rgba(255, 255, 255, .16); }
.lb-nav.prev { left: 6px; }
.lb-nav.prev svg.i { transform: rotate(180deg); }
.lb-nav.next { right: 6px; }
.lb-caption { text-align: center; font-size: 12.5px; color: var(--faint); padding: 0 16px calc(14px + var(--safe-b)); word-break: break-all; }
@media (max-width: 640px) {
  .lb-stage { padding: 8px 8px 16px; }
  .lb-nav { display: none; }
  .lb-top .btn span { display: none; }
}

/* ---------- Login / pair ---------- */
body.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(900px 500px at 50% -10%, rgba(109, 117, 247, .16), transparent 70%), var(--bg); }
.login-card { width: min(420px, 100%); padding: 32px 26px; text-align: center; }
.login-card .logo { width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 20px; overflow: hidden; box-shadow: 0 10px 30px rgba(109, 117, 247, .35); }
.login-card h1 { font-size: 28px; }
.login-card > p { margin-top: 8px; color: var(--muted); }
.login-card .btn.lg { margin-top: 24px; }
.setup-box { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--border); text-align: left; }
.setup-box h2 { display: flex; align-items: center; gap: 8px; }
.setup-box p { margin: 8px 0 14px; color: var(--muted); font-size: 14px; }
.setup-box .btn { margin-top: 12px; }
.notice { margin-top: 20px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: 14px; text-align: left; }
.notice.warn { background: var(--danger-soft); color: #ffd2d2; }

/* ---------- Settings ---------- */
.settings { max-width: 860px; margin: 0 auto; }
.pk-row { display: flex; align-items: center; gap: 14px; padding: 14px; }
.pk-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--surface-3); display: grid; place-items: center; color: var(--accent-text); flex: none; }
.pk-main { flex: 1; min-width: 0; }
.pk-name { font-weight: 620; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pk-meta { font-size: 13px; color: var(--faint); margin-top: 2px; }
.activity { display: flex; flex-direction: column; }
.act-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 4px 16px; padding: 10px 2px; border-bottom: 1px solid var(--border); font-size: 14px; }
.act-row:last-child { border-bottom: 0; }
.act-when { color: var(--faint); font-size: 13px; }
.act-what strong { font-weight: 600; }
.act-what .muted { font-size: 13px; }
@media (max-width: 640px) { .act-row { grid-template-columns: 1fr; } }
.qr-wrap { display: grid; place-items: center; padding: 14px; background: #fff; border-radius: 14px; width: fit-content; margin: 6px auto 14px; }
.qr-wrap img { width: 220px; height: 220px; image-rendering: pixelated; }
.link-box { display: flex; gap: 8px; }
.link-box .input { font-size: 13px; }

/* ---------- Export / print ---------- */
.export-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.paper {
  max-width: 900px; margin: 0 auto; padding: 44px 48px; border-radius: 6px;
  background: #fff; color: #16181d; box-shadow: var(--shadow);
}
.paper h1 { font-size: 26px; color: #000; }
.paper .sub { color: #555b66; margin-top: 4px; }
.paper .summary { display: flex; flex-wrap: wrap; gap: 6px 26px; margin: 18px 0 8px; padding: 12px 0; border-top: 2px solid #16181d; border-bottom: 1px solid #d5d8de; font-size: 14px; }
.paper .summary b { font-variant-numeric: tabular-nums; }
.paper .note { font-size: 12.5px; color: #555b66; margin-top: 8px; }
.rec { padding: 26px 0; border-bottom: 1px solid #d5d8de; break-inside: avoid-page; }
.rec:last-child { border-bottom: 0; }
.rec h2 { font-size: 19px; color: #000; }
.rec .where { color: #555b66; font-size: 13.5px; margin-top: 3px; }
.rec table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13.5px; }
.rec th { text-align: left; font-weight: 600; color: #555b66; width: 170px; padding: 5px 12px 5px 0; vertical-align: top; }
.rec td { padding: 5px 0; vertical-align: top; white-space: pre-wrap; word-break: break-word; }
.rec h3 { font-size: 14px; margin: 16px 0 8px; color: #000; }
/* One photo per row on screen, one per page when printed. */
.rec-photos { display: flex; flex-direction: column; gap: 16px; }
.rec-photos figure { margin: 0; break-inside: avoid; }
.rec-photos img { width: 100%; max-height: 80vh; object-fit: contain; background: #f2f3f5; border: 1px solid #e2e4e8; border-radius: 4px; }
.rec-photos figcaption, .rec-files li { font-size: 11.5px; color: #555b66; margin-top: 4px; word-break: break-all; }
.rec-photos a, .rec-files a { color: #0b57d0; text-decoration: underline; }
.rec-files { margin: 0; padding-left: 18px; }
@media (max-width: 640px) {
  .paper { padding: 24px 18px; margin: 0 -8px; }
  .rec th { width: 120px; }
}

@media print {
  @page { margin: 14mm; }
  body, body.app { display: block; background: #fff !important; color: #000; }
  .topbar, .sidebar, .bottombar, .scrim, .no-print, .toasts { display: none !important; }
  .main { padding: 0 !important; }
  .paper { box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
  .rec { border-bottom: 0; padding: 0; }
  .rec + .rec { break-before: page; }
  .rec h3 { display: none; }
  /* Each photo gets its own page, as big as the printable area allows (Letter or A4). */
  .rec-photos { display: block; }
  .rec-photos figure {
    break-before: page; break-inside: avoid;
    height: 245mm; display: flex; align-items: center; justify-content: center;
  }
  .rec-photos img { width: 100%; height: 100%; max-height: none; object-fit: contain; border: 0; background: none; border-radius: 0; }
  .rec-photos a, .rec-files a { color: #000; text-decoration: none; }
}
