/* ============================================================
   Rendszeretet - design system and views
   Mobile first; the grid widens on larger screens.
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  color-scheme: light;

  --paper:      #f6f4ef;
  --paper-2:    #efece5;
  --surface:    #ffffff;
  --surface-2:  #faf8f4;
  --ink:        #1d1b17;
  --ink-2:      #4d4740;
  --muted:      #857e73;
  --faint:      #a9a29a;
  --line:       #e5e0d6;
  --line-2:     #d8d2c6;

  --accent:      #b0552e;
  --accent-ink:  #ffffff;
  --accent-soft: #f6e7de;
  --accent-line: #e6c9b8;

  --danger:      #b03a2e;
  --danger-soft: #f8e5e2;
  --ok:          #4a7c4e;
  --ok-soft:     #e4efe2;

  --shadow-1: 0 1px 2px rgba(29, 27, 23, .06), 0 1px 3px rgba(29, 27, 23, .04);
  --shadow-2: 0 2px 6px rgba(29, 27, 23, .07), 0 8px 22px rgba(29, 27, 23, .07);
  --shadow-3: 0 10px 40px rgba(29, 27, 23, .18);

  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;
  --r-xl: 26px;

  --ease: cubic-bezier(.32, .72, 0, 1);
  --fast: 140ms var(--ease);
  --slow: 300ms var(--ease);

  --header-h: 60px;
  --maxw: 1480px;

  /* card tints - light */
  --c-default: #ffffff;
  --c-sand:    #f6eedd;
  --c-rose:    #fbe7e6;
  --c-amber:   #fbeed0;
  --c-olive:   #eef0d9;
  --c-sage:    #e4efe4;
  --c-teal:    #dcefec;
  --c-sky:     #e0ebf7;
  --c-indigo:  #e6e6f6;
  --c-plum:    #f1e4f1;
  --c-clay:    #f4e6de;
  --c-slate:   #e8eaed;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --paper:      #16150f;
  --paper-2:    #1d1b16;
  --surface:    #211f19;
  --surface-2:  #262319;
  --ink:        #f0ece3;
  --ink-2:      #cec8bc;
  --muted:      #9d968a;
  --faint:      #7b7469;
  --line:       #35322a;
  --line-2:     #423e34;

  --accent:      #d97a4e;
  --accent-ink:  #1a1611;
  --accent-soft: #38251b;
  --accent-line: #5a3a28;

  --danger:      #e0796a;
  --danger-soft: #3a221e;
  --ok:          #8fc08f;
  --ok-soft:     #23301f;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, .45), 0 10px 26px rgba(0, 0, 0, .35);
  --shadow-3: 0 12px 44px rgba(0, 0, 0, .6);

  --c-default: #211f19;
  --c-sand:    #302a1d;
  --c-rose:    #35211f;
  --c-amber:   #352c19;
  --c-olive:   #2a2d1c;
  --c-sage:    #202c22;
  --c-teal:    #1b2c2b;
  --c-sky:     #1d2833;
  --c-indigo:  #232336;
  --c-plum:    #2e2130;
  --c-clay:    #322520;
  --c-slate:   #23262a;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
img { display: block; max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent-soft); color: var(--ink); }

.sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- app shell ---------- */
#app { min-height: 100vh; min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--fast), background var(--fast);
}

/* Contents share the page width, so the brand and search line up with the
   grid below instead of hugging the window edge on a wide screen. */
.topbar-inner {
  max-width: var(--maxw);
  height: 100%;
  margin: 0 auto;
  padding: 0 12px;
  display: flex; align-items: center; gap: 10px;
}
@media (min-width: 700px) { .topbar-inner { padding: 0 20px; } }
.topbar.is-scrolled { border-bottom-color: var(--line); }

.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 640; letter-spacing: -.01em; font-size: 16px;
  padding: 6px 4px; border: 0; background: none; color: var(--ink);
  flex-shrink: 0;
}
.brand svg { width: 24px; height: 24px; flex-shrink: 0; }
.brand span { display: none; }
@media (min-width: 640px) { .brand span { display: inline; } }

.topbar-spacer { flex: 1; }

/* ---------- desktop header navigation ---------- */

/*
 * Below the breakpoint everything lives in the overflow menu, as on a phone.
 * From 1180px there is room to put navigation directly in the bar, which is
 * both faster to reach and shows which view you are in.
 */
.topbar-nav { display: none; }

.nav-item {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 12px;
  border: 0; border-radius: 999px;
  background: none; color: var(--ink-2);
  font-size: 14px; font-weight: 540;
  white-space: nowrap;
  transition: background var(--fast), color var(--fast);
}
.nav-item svg { width: 17px; height: 17px; opacity: .85; }
.nav-item:hover { background: var(--paper-2); color: var(--ink); }
.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-item.is-active svg { opacity: 1; }

.nav-sep {
  width: 1px; height: 22px;
  background: var(--line-2);
  margin: 0 4px;
  flex-shrink: 0;
}

@media (min-width: 1180px) {
  .topbar-nav {
    display: flex; align-items: center; gap: 2px;
    flex-shrink: 0;
  }
  /* The overflow button is redundant once the nav is on show.  Two classes,
     because `.icon-btn { display: inline-flex }` is declared later in this
     file and would otherwise win on source order. */
  .icon-btn.nav-overflow { display: none; }
}

/* Narrow enough that the labels would wrap: icons only, still all visible. */
@media (min-width: 1180px) and (max-width: 1439px) {
  .nav-item { padding: 0 9px; gap: 0; }
  .nav-item span { display: none; }
  .nav-new span { display: none; }
  .nav-new { padding: 0 11px; }
}

.search {
  position: relative;
  flex: 1 1 auto;
  max-width: 460px;
  min-width: 0;
}
/* Direct child only: the magnifier. The clear button also contains an svg,
   and it must not inherit this absolute positioning. */
.search > svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--muted); pointer-events: none;
}
.search input {
  width: 100%;
  height: 40px;
  padding: 0 34px 0 36px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--paper-2);
  transition: background var(--fast), border-color var(--fast), box-shadow var(--fast);
}
.search input:focus {
  background: var(--surface);
  border-color: var(--line-2);
  box-shadow: var(--shadow-1);
  outline: none;
}
.search .clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border: 0; border-radius: 50%;
  background: none; color: var(--muted);
  display: none; align-items: center; justify-content: center;
}
.search.has-value .clear { display: flex; }
.search .clear:hover { background: var(--paper-2); color: var(--ink); }
.search .clear svg { width: 15px; height: 15px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 520; font-size: 14px;
  white-space: nowrap;
  transition: background var(--fast), border-color var(--fast), transform var(--fast), box-shadow var(--fast), color var(--fast);
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn svg { width: 17px; height: 17px; }

.btn-primary {
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
  box-shadow: var(--shadow-1);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); border-color: transparent; }

.btn-ghost { background: none; border-color: transparent; }
.btn-ghost:hover { background: var(--paper-2); border-color: transparent; }

.btn-danger { color: var(--danger); border-color: var(--line-2); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; border-radius: 999px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex-shrink: 0;
  border: 0; border-radius: 50%;
  background: none; color: var(--ink-2);
  transition: background var(--fast), color var(--fast), transform var(--fast);
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.is-active { color: var(--accent); }

/* ---------- layout ---------- */
.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 12px 120px;
}
@media (min-width: 700px) { .page { padding: 20px 20px 120px; } }

.page-head {
  display: flex; align-items: center; gap: 12px;
  margin: 4px 0 18px;
  min-height: 40px;
}
.page-head h1 {
  margin: 0; font-size: 21px; font-weight: 640; letter-spacing: -.015em;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.page-head .sub { color: var(--muted); font-size: 13px; font-weight: 450; }

.section-title {
  display: flex; align-items: center; gap: 9px;
  margin: 26px 0 12px;
  font-size: 12px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted);
}
.section-title::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.section-title .count {
  font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--faint);
}

/* ---------- card grid (masonry-ish) ---------- */
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 560px)  { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 860px)  { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1120px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1400px) { .grid { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 1700px) { .grid { grid-template-columns: repeat(6, 1fr); } }

.card {
  position: relative;
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--card-bg, var(--surface));
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--slow), transform var(--slow), border-color var(--fast);
  animation: card-in 320ms var(--ease) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(6px) scale(.99); }
  to   { opacity: 1; transform: none; }
}
.card:hover { box-shadow: var(--shadow-2); border-color: var(--line-2); }
.card:active { transform: scale(.994); }
.card.is-dragging { opacity: .4; }
.card.is-drop-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.card-covers {
  display: grid; gap: 2px;
  background: var(--paper-2);
  aspect-ratio: 16 / 10;
}
.card-covers[data-n="1"] { grid-template-columns: 1fr; }
.card-covers[data-n="2"] { grid-template-columns: 1fr 1fr; }
.card-covers[data-n="3"] { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.card-covers[data-n="3"] > :first-child { grid-row: span 2; }
.card-covers[data-n="4"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.card-covers img {
  width: 100%; height: 100%; object-fit: cover;
  background: var(--paper-2);
  opacity: 0; transition: opacity var(--slow);
}
.card-covers img.is-loaded { opacity: 1; }

.card-body { padding: 13px 14px 14px; flex: 1; min-width: 0; }

.card-title {
  margin: 0 0 3px;
  font-size: 15.5px; font-weight: 600; letter-spacing: -.01em;
  line-height: 1.32;
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-title:empty::before {
  content: attr(data-empty); color: var(--faint); font-weight: 450;
}
.card-notes {
  margin: 5px 0 0;
  font-size: 13.5px; color: var(--ink-2); line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: var(--ink-2);
  font-size: 12px; font-weight: 520;
}
.chip svg { width: 13px; height: 13px; opacity: .75; }

.card-pin {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(8px);
  color: var(--muted);
  transition: color var(--fast), background var(--fast);
}
/* Always visible, on every device: hiding these behind hover meant they were
   undiscoverable on desktop and impossible on touch. */
.card-pin:hover { background: var(--surface); color: var(--ink); }
.card-pin.is-on { color: var(--accent); }
.card-pin svg { width: 15px; height: 15px; }

/* ---------- empty / loading states ---------- */
.empty {
  text-align: center;
  padding: 64px 20px 72px;
  color: var(--muted);
  animation: fade-in 300ms var(--ease) both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
/* Direct child only: this sizes the big illustration, and must not reach the
   small icons inside buttons placed in the same empty state. */
.empty > svg { width: 52px; height: 52px; color: var(--line-2); margin-bottom: 14px; }
.empty h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; color: var(--ink); }
.empty p { margin: 0 auto; max-width: 34ch; font-size: 14px; line-height: 1.55; }
.empty .btn { margin-top: 18px; }

.skeleton-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px)  { .skeleton-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 860px)  { .skeleton-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1120px) { .skeleton-grid { grid-template-columns: repeat(4, 1fr); } }
.skeleton {
  border-radius: var(--r-lg);
  background: linear-gradient(100deg, var(--paper-2) 30%, var(--surface-2) 50%, var(--paper-2) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
  height: 178px;
}
@keyframes shimmer { from { background-position: 130% 0; } to { background-position: -30% 0; } }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid color-mix(in srgb, currentColor 22%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- FAB ---------- */
.fab-wrap {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 14px));
  z-index: 45;
  display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 10px;
}
.fab {
  display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px;
  border: 0; border-radius: 20px;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: var(--shadow-2);
  transition: transform var(--fast), box-shadow var(--fast);
}
.fab:hover { transform: translateY(-1px); box-shadow: var(--shadow-3); }
.fab:active { transform: scale(.94); }
.fab svg { width: 25px; height: 25px; transition: transform var(--slow); }
.fab.is-open svg { transform: rotate(135deg); }

.fab-menu {
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  pointer-events: none;
}
.fab-menu .fab-item {
  display: flex; align-items: center; gap: 9px;
  height: 42px; padding: 0 16px 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 540;
  box-shadow: var(--shadow-2);
  opacity: 0; transform: translateY(8px) scale(.96);
  transition: opacity var(--fast), transform var(--fast);
}
.fab-menu.is-open { pointer-events: auto; }
.fab-menu.is-open .fab-item { opacity: 1; transform: none; }
.fab-menu.is-open .fab-item:nth-child(2) { transition-delay: 40ms; }
.fab-menu.is-open .fab-item:nth-child(3) { transition-delay: 80ms; }
.fab-item svg { width: 18px; height: 18px; color: var(--accent); }

/* ---------- sheets and dialogs ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 18, 14, .42);
  backdrop-filter: blur(2px);
  animation: fade-in 180ms var(--ease) both;
}

.sheet {
  position: fixed; z-index: 61;
  left: 0; right: 0; bottom: 0;
  max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  animation: sheet-up 280ms var(--ease) both;
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

@media (min-width: 620px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    width: min(560px, calc(100vw - 40px));
    transform: translate(-50%, -50%);
    border-radius: var(--r-xl);
    animation: dialog-in 220ms var(--ease) both;
  }
  @keyframes dialog-in {
    from { opacity: 0; transform: translate(-50%, -46%) scale(.97); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  }
  .sheet.is-wide { width: min(860px, calc(100vw - 40px)); }
}

.sheet-grab {
  width: 38px; height: 4px; border-radius: 99px;
  background: var(--line-2);
  margin: 9px auto 0;
  flex-shrink: 0;
}
@media (min-width: 620px) { .sheet-grab { display: none; } }

.sheet-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 10px 18px;
  flex-shrink: 0;
}
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 640; flex: 1; letter-spacing: -.01em; }

.sheet-body { padding: 4px 18px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.sheet-foot {
  display: flex; gap: 9px; justify-content: flex-end;
  padding: 12px 18px 18px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.sheet-foot .grow { flex: 1; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field > label {
  display: block; margin-bottom: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  letter-spacing: .01em;
}
.field .hint { margin-top: 6px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.field .err { margin-top: 6px; font-size: 12.5px; color: var(--danger); font-weight: 520; }

.input, .textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface-2);
  transition: border-color var(--fast), background var(--fast), box-shadow var(--fast);
}
.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input.has-error, .textarea.has-error { border-color: var(--danger); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }

/* The folder/document name field: a normal input, just a size larger, so it
   is unmistakably something you type into. */
.title-field {
  font-size: 16.5px;
  font-weight: 580;
  letter-spacing: -.01em;
}

/* colour swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 30px; height: 30px;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: var(--sw);
  position: relative;
  transition: transform var(--fast);
}
.swatch:hover { transform: scale(1.12); }
.swatch.is-on { border-color: var(--ink); border-width: 2px; }
.swatch.is-on::after {
  content: ""; position: absolute; inset: -4px;
  border: 1px solid var(--ink); border-radius: 50%; opacity: .35;
}

/* segmented control */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--paper-2); border-radius: 999px;
}
.seg button {
  border: 0; background: none; color: var(--muted);
  height: 30px; padding: 0 14px; border-radius: 999px;
  font-size: 13px; font-weight: 560;
  transition: background var(--fast), color var(--fast);
}
.seg button.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- login ---------- */
.auth {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
}
.auth-card {
  width: 100%; max-width: 392px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  padding: 30px 26px 26px;
  animation: auth-in 400ms var(--ease) both;
}
@keyframes auth-in { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
.auth-mark {
  width: 46px; height: 46px; margin-bottom: 18px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--accent-soft); color: var(--accent);
}
.auth-mark svg { width: 26px; height: 26px; }
.auth-card h1 { margin: 0 0 7px; font-size: 22px; font-weight: 660; letter-spacing: -.02em; }
.auth-card .lead { margin: 0 0 22px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.auth-card .lead strong { color: var(--ink); font-weight: 600; }

.code-input {
  width: 100%;
  text-align: center;
  font-size: 30px; font-weight: 640;
  letter-spacing: .34em; text-indent: .34em;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  padding: 14px 10px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface-2);
  transition: border-color var(--fast), box-shadow var(--fast);
}
.code-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
.code-input.has-error {
  border-color: var(--danger);
  animation: shake 320ms var(--ease);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-3px); }
}

.auth-alt {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 16px;
  font-size: 13px; color: var(--muted);
}
.auth-alt button {
  border: 0; background: none; color: var(--accent);
  font-size: 13px; font-weight: 560; padding: 4px 2px;
}
.auth-alt button[disabled] { color: var(--faint); pointer-events: none; }

.auth-foot {
  margin-top: 22px; padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: var(--faint);
}

/* ---------- gallery / lightbox ---------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 6px;
}
@media (min-width: 700px) {
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
}

.tile {
  position: relative;
  aspect-ratio: 1;
  border: 0; padding: 0;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--paper-2);
  cursor: pointer;
}
.tile img {
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity var(--slow), transform var(--slow);
}
.tile img.is-loaded { opacity: 1; }
.tile:hover img { transform: scale(1.04); }
.tile.is-selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile .tile-check {
  position: absolute; top: 6px; left: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  display: none; align-items: center; justify-content: center;
  color: var(--accent);
}
.tile.is-selected .tile-check { display: flex; }
.tile .tile-check svg { width: 14px; height: 14px; }

.lightbox {
  position: fixed; inset: 0; z-index: 80;
  background: #0d0c0a;
  display: flex; flex-direction: column;
  animation: fade-in 180ms var(--ease) both;
}
.lightbox-stage {
  flex: 1; position: relative;
  display: grid; place-items: center;
  overflow: hidden;
  touch-action: pan-y;
}
.lightbox-stage img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  user-select: none; -webkit-user-drag: none;
  animation: zoom-in 220ms var(--ease) both;
}
@keyframes zoom-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }

.lightbox-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 8px;
  padding-top: max(10px, env(safe-area-inset-top));
  color: #f2efe9;
}
.lightbox-bar .title {
  flex: 1; min-width: 0; font-size: 14px; font-weight: 540;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lightbox-bar .icon-btn { color: #ded9d0; }
.lightbox-bar .icon-btn:hover { background: rgba(255, 255, 255, .13); color: #fff; }
.lightbox-foot {
  padding: 10px 16px max(14px, env(safe-area-inset-bottom));
  color: #a9a29a; font-size: 12.5px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.lightbox-caption { color: #ded9d0; font-size: 13.5px; margin-bottom: 4px; }

.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .11); color: #fff;
  display: grid; place-items: center;
  transition: background var(--fast), opacity var(--fast);
}
.lb-nav:hover { background: rgba(255, 255, 255, .2); }
.lb-nav[disabled] { opacity: .25; pointer-events: none; }
.lb-nav.prev { left: 10px; }
.lb-nav.next { right: 10px; }
.lb-nav svg { width: 22px; height: 22px; }
@media (max-width: 700px) { .lb-nav { display: none; } }

/* ---------- document rows ---------- */
.rows { display: flex; flex-direction: column; gap: 7px; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
}
.row:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); }
.row.is-dragging { opacity: .45; }
.row-icon {
  width: 38px; height: 38px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
}
.row-icon svg { width: 19px; height: 19px; }
.row-icon.is-failed { background: var(--danger-soft); color: var(--danger); }
.row-icon.is-busy { background: var(--paper-2); color: var(--muted); }
.row-main { flex: 1; min-width: 0; }
.row-title {
  font-size: 14.5px; font-weight: 570;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.row-meta .dot { opacity: .5; margin: 0 5px; }
.row-actions { display: flex; gap: 2px; flex-shrink: 0; }

/* ---------- scanner ---------- */
.scan-pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  margin-top: 4px;
}
.scan-page {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.scan-page img { width: 100%; height: 100%; object-fit: cover; }
.scan-page .num {
  position: absolute; bottom: 4px; left: 4px;
  min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 99px;
  background: rgba(20, 18, 14, .72); color: #fff;
  font-size: 11px; font-weight: 620;
  display: grid; place-items: center;
}
.scan-page .kill {
  position: absolute; top: 3px; right: 3px;
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: rgba(20, 18, 14, .72); color: #fff;
  display: grid; place-items: center;
}
.scan-page .kill svg { width: 12px; height: 12px; }
.scan-page.is-uploading::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(255, 255, 255, .55);
}

.scan-add {
  display: grid; place-items: center; gap: 6px;
  aspect-ratio: 3 / 4;
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px; font-weight: 560;
  transition: border-color var(--fast), color var(--fast), background var(--fast);
}
.scan-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.scan-add svg { width: 22px; height: 22px; }

.dropzone {
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  padding: 30px 18px;
  text-align: center;
  color: var(--muted);
  transition: border-color var(--fast), background var(--fast);
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
/* Direct child only, for the same reason as .empty > svg. */
.dropzone > svg { width: 32px; height: 32px; margin-bottom: 8px; color: var(--faint); }
.dropzone strong { color: var(--ink); font-weight: 600; }

/* ---------- progress ---------- */
.progress {
  height: 5px; border-radius: 99px;
  background: var(--paper-2);
  overflow: hidden;
}
.progress > i {
  display: block; height: 100%; width: 0;
  background: var(--accent);
  border-radius: 99px;
  transition: width 200ms linear;
}

.upload-tray {
  position: fixed; z-index: 50;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(14px, calc(env(safe-area-inset-bottom) + 10px));
  width: min(330px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-2);
  padding: 12px 14px;
  animation: sheet-up 240ms var(--ease) both;
}
.upload-tray .head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 580; margin-bottom: 8px;
}
.upload-tray .head .grow { flex: 1; }
.upload-tray .sub { font-size: 12px; color: var(--muted); margin-top: 7px; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; z-index: 90;
  left: 50%; transform: translateX(-50%);
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 14px));
  display: flex; flex-direction: column; gap: 8px;
  width: min(440px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  border-radius: var(--r);
  background: #26231d; color: #f4f1ea;
  box-shadow: var(--shadow-3);
  font-size: 13.5px; line-height: 1.4;
  pointer-events: auto;
  animation: toast-in 240ms var(--ease) both;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
.toast.is-out { animation: toast-out 180ms var(--ease) both; }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
.toast .msg { flex: 1; }
.toast.is-error { background: #5c241c; }
.toast.is-ok { background: #274b2a; }
.toast button {
  border: 0; background: none; color: #f6c9a8;
  font-weight: 620; font-size: 13px; padding: 2px 4px;
  flex-shrink: 0;
}
.toast svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .9; }

/* ---------- menus ---------- */
.menu {
  position: fixed; z-index: 70;
  min-width: 208px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-3);
  animation: menu-in 140ms var(--ease) both;
}
@keyframes menu-in { from { opacity: 0; transform: scale(.97) translateY(-3px); } to { opacity: 1; transform: none; } }
.menu button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 36px; padding: 0 10px;
  border: 0; border-radius: 9px;
  background: none; color: var(--ink);
  font-size: 14px; text-align: left;
}
.menu button:hover { background: var(--paper-2); }
.menu button.is-danger { color: var(--danger); }
.menu button.is-danger:hover { background: var(--danger-soft); }
.menu button svg { width: 17px; height: 17px; color: var(--muted); }
.menu button.is-danger svg { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.menu .menu-label {
  padding: 7px 10px 4px;
  font-size: 11px; font-weight: 650; letter-spacing: .07em;
  text-transform: uppercase; color: var(--faint);
}

/* ---------- offline banner ---------- */
.offline-bar {
  position: sticky; top: var(--header-h); z-index: 39;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 7px 12px;
  background: #3a3428; color: #f2e7d2;
  font-size: 12.5px; font-weight: 540;
}
.offline-bar svg { width: 15px; height: 15px; }

/* ---------- admin table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; white-space: nowrap; }
table.data th {
  background: var(--surface-2); color: var(--muted);
  font-size: 11.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
table.data td { border-bottom: 1px solid var(--line); }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--surface-2); }

.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 99px; font-size: 11.5px; font-weight: 620;
  background: var(--paper-2); color: var(--ink-2);
}
.badge.is-active { background: var(--ok-soft); color: var(--ok); }
.badge.is-invited { background: var(--accent-soft); color: var(--accent); }
.badge.is-disabled { background: var(--danger-soft); color: var(--danger); }

/* ---------- misc ---------- */
.meter { display: flex; flex-direction: column; gap: 6px; }
.meter .bar { height: 6px; border-radius: 99px; background: var(--paper-2); overflow: hidden; }
.meter .bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter .bar > i.is-full { background: var(--danger); }
.meter .legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pushed { margin-left: auto; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

/* the overflow menu sits to the left of the pin */
.card-more { right: 42px !important; }

/* first-paint spinner, sized without an inline style so the CSP stays tight */
.boot-spinner { width: 26px; height: 26px; color: var(--muted); }

/* ---------- text notes ---------- */

/* A note card has no cover image, so it needs a minimum height of its own to
   sit comfortably beside gallery cards in the same grid. */
.note-card { min-height: 132px; }
.note-card .card-body { display: flex; flex-direction: column; }

.note-body {
  -webkit-line-clamp: 8;
  font-size: 13.5px;
}

/* A note editor is mostly the text area, so let it breathe. */
.note-input {
  min-height: 200px;
  line-height: 1.55;
  font-size: 14.5px;
}
@media (min-width: 620px) { .note-input { min-height: 260px; } }

/* ---------- admin activity log ---------- */

.filters {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  margin: 4px 0 16px;
}
@media (min-width: 620px)  { .filters { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .filters { grid-template-columns: repeat(4, 1fr); } }

.filter-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.filter-field > label {
  font-size: 11.5px; font-weight: 650; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.filter-field select.input,
.filter-field input.input { height: 38px; padding: 0 11px; font-size: 13.5px; }
@media (min-width: 1000px) { .filter-field.is-wide { grid-column: span 4; } }

.filter-reset { display: flex; align-items: flex-end; }
@media (min-width: 1000px) { .filter-reset { grid-column: span 4; } }

.log-summary {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 13px; font-weight: 560;
}
.log-summary .muted { font-weight: 450; font-size: 12.5px; }

/* The detail column carries the variable-length text, so it gets the room
   and is allowed to wrap; everything else stays on one line. */
table.data.log-table td { white-space: normal; vertical-align: top; }
table.data.log-table td.nowrap { white-space: nowrap; }
.log-detail {
  max-width: 40ch;
  overflow-wrap: anywhere;
  color: var(--ink-2);
  font-size: 13px;
}
@media (min-width: 1200px) { .log-detail { max-width: 60ch; } }

/* Action tags, tinted by group so scanning the column is quick. */
.action-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px;
  white-space: nowrap;
  background: var(--paper-2);
  color: var(--ink-2);
}
.action-tag.is-auth     { background: var(--accent-soft); color: var(--accent); }
.action-tag.is-admin    { background: var(--danger-soft); color: var(--danger); }
.action-tag.is-card     { background: var(--c-sky);   color: var(--ink-2); }
.action-tag.is-gallery  { background: var(--c-teal);  color: var(--ink-2); }
.action-tag.is-photo    { background: var(--c-sage);  color: var(--ink-2); }
.action-tag.is-document { background: var(--c-amber); color: var(--ink-2); }
.action-tag.is-note     { background: var(--c-plum);  color: var(--ink-2); }
.action-tag.is-trash    { background: var(--c-clay);  color: var(--ink-2); }

.pager {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-top: 18px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
