/* ============================================================================
   Masterpiece Media Image Portal — design system
   Hand-written, no build step. Tokens → primitives → components → responsive.
   ========================================================================= */

/* ----------------------------------------------------------------- tokens */
:root {
  /* brand */
  --ink-900: #062630;
  --ink-800: #0b3b4a;
  --ink-700: #10505f;
  --ink-600: #17697b;
  --accent:  #f2b134;
  --accent-600: #d99a1f;
  --accent-ink: #45330a;

  /* neutrals */
  --bg:      #f4f6f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --line:    #e4eaec;
  --line-2:  #d3dcdf;
  --text:    #17262c;
  --muted:   #62787f;
  --faint:   #8ea2a8;

  /* status */
  --ok: #157a52; --ok-bg: #e7f6ef; --ok-line: #b5e3ce;
  --warn: #9a6100; --warn-bg: #fff5e2; --warn-line: #f2ce8d;
  --bad: #b3261e; --bad-bg: #fdeeec; --bad-line: #f3c6c1;
  --info: #14556a; --info-bg: #e8f2f6; --info-line: #bfd9e2;

  /* shape */
  --r-sm: 7px; --r: 11px; --r-lg: 16px; --r-full: 999px;
  --sh-1: 0 1px 2px rgba(6,38,48,.05);
  --sh-2: 0 1px 3px rgba(6,38,48,.06), 0 8px 24px -12px rgba(6,38,48,.22);
  --sh-3: 0 20px 48px -20px rgba(6,38,48,.4);
  --sidebar-w: 248px;
  --ring: 0 0 0 3px rgba(23,105,123,.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: "cv05", "ss01";
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--ink-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; color: var(--ink-800); letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: 25px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0 0 10px; }
small, .small { font-size: 13px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 10px; }
.right { margin-left: auto; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* ----------------------------------------------------------- app shell */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--ink-800) 0%, var(--ink-900) 100%);
  color: #fff; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; text-decoration: none; }
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand img { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.sidebar-brand > span { min-width: 0; }
.sidebar-brand .bn { display: block; font-weight: 800; font-size: 14.5px; line-height: 1.2; letter-spacing: -.01em; }
.sidebar-brand .bs { display: block; font-size: 10.5px; color: rgba(255,255,255,.55); letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }

.nav { flex: 1; overflow-y: auto; padding: 6px 10px 14px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: rgba(255,255,255,.42); margin: 16px 8px 6px; font-weight: 700; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px;
  color: rgba(255,255,255,.76); font-weight: 600; font-size: 14px; text-decoration: none; margin-bottom: 2px;
  transition: background .12s, color .12s;
}
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav a.on { background: rgba(255,255,255,.14); color: #fff; }
.nav a .ico { width: 18px; text-align: center; font-size: 15px; opacity: .92; flex: none; }
.nav a .cnt { margin-left: auto; font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: var(--r-full); background: rgba(255,255,255,.16); }
.nav a.on .cnt { background: rgba(255,255,255,.24); }
.nav a .cnt.hot { background: var(--accent); color: var(--accent-ink); }

.sidebar-foot { border-top: 1px solid rgba(255,255,255,.12); padding: 12px 12px 14px; }
.me { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 6px; border-radius: 9px; }
.me:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.me .who { min-width: 0; }
.me .nm { display: block; font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .rl { display: block; font-size: 11px; color: rgba(255,255,255,.55); margin-top: 1px; }
.sidebar-foot form { margin-top: 6px; }
.signout { width: 100%; background: rgba(255,255,255,.08); color: rgba(255,255,255,.85); border: 0; padding: 8px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.signout:hover { background: rgba(255,255,255,.16); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.page { padding: 26px 30px 70px; max-width: 1320px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .ttl { min-width: 0; }
.page-head h1 { margin-bottom: 3px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; }
.page-head .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs .sep { color: var(--faint); }

/* --------------------------------------------------------------- avatars */
.av { display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-full); font-weight: 800; flex: none; letter-spacing: .02em; }
.av-sm { width: 26px; height: 26px; font-size: 10.5px; }
.av-md { width: 34px; height: 34px; font-size: 12.5px; }
.av-lg { width: 46px; height: 46px; font-size: 15px; }
.av-accent { background: var(--accent); color: var(--accent-ink); }
.av-ink { background: rgba(255,255,255,.16); color: #fff; }
.av-soft { background: #dceaee; color: var(--ink-700); }

/* ----------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-1); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head .hint { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 12px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r) var(--r); }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ----------------------------------------------------------------- stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
@media (min-width: 1200px) { .stats.wide8 { grid-template-columns: repeat(8, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--sh-1); display: block; color: inherit; text-decoration: none; transition: border-color .12s, transform .12s; }
a.stat:hover { border-color: var(--line-2); transform: translateY(-1px); text-decoration: none; }
.stat .n { font-size: 26px; font-weight: 800; color: var(--ink-800); line-height: 1.1; letter-spacing: -.02em; }
.stat .l { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 5px; font-weight: 700; }
.stat.hot .n { color: var(--warn); }
.stat.good .n { color: var(--ok); }

/* ----------------------------------------------------------------- forms */
label { display: block; font-weight: 650; font-size: 13px; color: var(--ink-800); margin-bottom: 5px; }
label .opt { font-weight: 400; color: var(--muted); }
.field { margin-bottom: 14px; }
.input, textarea, select {
  width: 100%; font: inherit; font-size: 14.5px; padding: 9px 12px;
  border: 1px solid var(--line-2); border-radius: 9px; background: #fff; color: var(--text);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.input::placeholder, textarea::placeholder { color: var(--faint); }
.input:focus, textarea:focus, select:focus { border-color: var(--ink-600); box-shadow: var(--ring); }
.input:disabled, textarea:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
textarea { min-height: 80px; resize: vertical; line-height: 1.45; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2362787f' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 180px; margin-bottom: 0; align-self: flex-start; }
.row.center { align-items: center; }
.inline { display: inline-block; }

.check { display: flex; align-items: flex-start; gap: 9px; font-weight: 500; font-size: 14px; color: var(--text); cursor: pointer; margin: 0; }
.check input { width: 17px; height: 17px; accent-color: var(--ink-700); margin: 1px 0 0; flex: none; cursor: pointer; }
.check .hint { display: block; margin-top: 3px; }
.check > span { min-width: 0; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 650; font-size: 14px; line-height: 1.2;
  padding: 9px 15px; border-radius: 9px; border: 1px solid transparent;
  background: var(--surface); color: var(--ink-800); border-color: var(--line-2);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s, opacity .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink-800); border-color: var(--ink-800); color: #fff; }
.btn-primary:hover { background: var(--ink-700); border-color: var(--ink-700); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: var(--accent-600); border-color: var(--accent-600); }
.btn-danger { color: var(--bad); border-color: var(--bad-line); background: #fff; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink-800); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }
.btn-icon { padding: 7px; width: 32px; height: 32px; }

/* ----------------------------------------------------------------- pills */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: var(--r-full); background: #e6edef; color: var(--ink-700); letter-spacing: .02em; white-space: nowrap; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-accent { background: var(--accent); color: var(--accent-ink); }
.pill-ink { background: var(--ink-800); color: #fff; }
.pill-line { background: #fff; border: 1px solid var(--line-2); color: var(--muted); }

/* ---------------------------------------------------------------- tables */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sm-only { display: none; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl thead th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl td.acts { text-align: right; white-space: nowrap; }
.tbl td.acts form, .tbl td.acts .inline { display: inline-block; }
.tbl a.strong { font-weight: 700; color: var(--ink-800); }
.cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-main .t { min-width: 0; }
.cell-main .t b { display: block; font-weight: 700; color: var(--ink-800); }
.cell-main .t span { display: block; font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------- member list */
.people { display: flex; flex-direction: column; }
.person { display: flex; align-items: center; gap: 11px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.person:last-child { border-bottom: 0; }
.person .who { min-width: 140px; flex: 1 1 200px; }
.person .who b { display: block; color: var(--ink-800); font-weight: 700; font-size: 14px; }
.person .who span { display: block; font-size: 12.5px; color: var(--muted); word-break: break-word; }
.person .acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.person .acts form { display: inline-flex; }

/* --------------------------------------------------------------- folders */
.folder-bar { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: var(--r-full);
  border: 1px solid var(--line-2); background: #fff; color: var(--ink-800);
  font-weight: 650; font-size: 13.5px; text-decoration: none; transition: background .12s, border-color .12s;
}
.chip:hover { background: var(--surface-2); text-decoration: none; }
.chip.on { background: var(--ink-800); border-color: var(--ink-800); color: #fff; }
.chip .c { font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: var(--r-full); background: rgba(6,38,48,.08); }
.chip.on .c { background: rgba(255,255,255,.22); }
.chip.chip-trash { color: var(--bad); border-color: var(--bad-line); }
.chip.chip-trash.on { background: var(--bad); border-color: var(--bad); color: #fff; }

/* ----------------------------------------------------------- photo grid */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 16px; }
.photo { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--sh-1); display: flex; flex-direction: column; position: relative; transition: border-color .12s, box-shadow .12s; }
.photo:hover { border-color: var(--line-2); box-shadow: var(--sh-2); }
.photo.sel { border-color: var(--ink-600); box-shadow: var(--ring); }
.photo .shot { position: relative; display: block; aspect-ratio: 4/3; background: #eef2f4; overflow: hidden; }
.photo .shot img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.photo:hover .shot img { transform: scale(1.03); }
.photo .shot .noprev { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 12.5px; text-align: center; padding: 12px; }
.photo .shot .noprev .big { font-size: 26px; }
.photo .tags { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 5px; flex-wrap: wrap; pointer-events: none; }
.photo .pick { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 6px; border: 1.5px solid rgba(255,255,255,.9); background: rgba(6,38,48,.35); backdrop-filter: blur(3px); display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .12s; z-index: 2; }
.photo:hover .pick, .photo .pick:has(input:checked), .picking .photo .pick { opacity: 1; }
.photo .pick input { appearance: none; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.photo .pick input:checked { background: var(--accent); border-radius: 4px; }
.photo .pick input:checked::after { content: '✓'; color: var(--accent-ink); font-size: 14px; font-weight: 900; display: grid; place-items: center; height: 100%; }
.photo .body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.photo textarea { min-height: 58px; font-size: 13.5px; padding: 7px 9px; }
.photo .cap { font-size: 13.5px; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.photo .cap.none { color: var(--faint); font-style: italic; }
.photo .meta { font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.photo .meta .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo .foot { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 2px; flex-wrap: wrap; }
.photo .foot .right { margin-left: auto; display: flex; gap: 6px; }
.photo.gone .shot img { filter: grayscale(1) opacity(.62); }

/* touch devices have no hover: the select tick and card actions must be visible */
@media (hover: none) {
  .photo .pick { opacity: 1; width: 30px; height: 30px; background: rgba(6,38,48,.5); }
  .photo .pick input:checked::after { font-size: 17px; }
}
.photo .movebar { display: flex; align-items: center; gap: 8px; }
.photo .movebar label { font-size: 11.5px; color: var(--muted); font-weight: 700; flex: none; }
.photo .movebar select { flex: 1; min-width: 0; }
.folder-empty { margin-top: 10px; font-size: 13.5px; color: var(--muted); }
.folder-crumbs { margin-bottom: 10px; font-size: 13px; }
.chip .sub { font-size: 10.5px; font-weight: 700; margin-left: 6px; padding: 1px 6px; border-radius: var(--r-full); background: rgba(6,38,48,.06); color: var(--muted); }
.chip.on .sub { background: rgba(255,255,255,.18); color: #fff; }
.chip-up { font-weight: 700; }
.chip .ic { margin-right: 6px; opacity: .85; }

/* ------------------------------------------------------------- camera */
.up-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.btn-cam { font-weight: 700; border-color: var(--ink-600); color: var(--ink-800); }
.btn-cam:hover { background: var(--surface-2); }
.cam { position: fixed; inset: 0; z-index: 90; background: rgba(6,24,30,.92); display: grid; place-items: center; padding: 16px; }
.cam-box { width: min(720px, 100%); display: flex; flex-direction: column; gap: 12px; }
.cam video { width: 100%; max-height: 70vh; background: #000; border-radius: var(--r); object-fit: contain; }
.cam-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cam-bar .btn-ghost { background: rgba(255,255,255,.12); color: #fff; border-color: transparent; }
.cam-bar .btn-ghost:hover { background: rgba(255,255,255,.2); }
.cam-bar .btn-shot { flex: 1; max-width: 260px; font-size: 15px; padding: 12px 18px; }
.cam-msg { color: #fff; text-align: center; font-size: 13.5px; min-height: 18px; }
@media (max-width: 560px) {
  .cam-bar .btn-shot { max-width: none; }
  .up-actions .btn-cam { width: 100%; justify-content: center; }
}
.save-state { font-size: 11.5px; color: var(--muted); min-height: 14px; }
.save-state.ok { color: var(--ok); }
.save-state.err { color: var(--bad); }
.mini-select { padding: 5px 26px 5px 8px; font-size: 12.5px; border-radius: 7px; background-position: right 8px center; max-width: 100%; }

/* ------------------------------------------------------------ selection */
.selbar { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 130%); z-index: 60; display: flex; align-items: center; gap: 10px; background: var(--ink-900); color: #fff; padding: 10px 12px 10px 16px; border-radius: var(--r-full); box-shadow: var(--sh-3); transition: transform .2s cubic-bezier(.2,.8,.3,1); }
.selbar.up { transform: translate(-50%, 0); }
.selbar .n { font-weight: 700; font-size: 13.5px; white-space: nowrap; }
.selbar .btn { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.selbar .btn:hover { background: rgba(255,255,255,.22); }
.selbar .btn-danger { color: #ffc9c4; }
.selbar select { background-color: rgba(255,255,255,.12); border-color: transparent; color: #fff; padding: 7px 26px 7px 10px; font-size: 13px; width: auto; }
.selbar select option { color: var(--text); }

/* ------------------------------------------------------------- uploader */
.drop { border: 2px dashed var(--line-2); border-radius: var(--r-lg); background: var(--surface-2); padding: 30px 20px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover { border-color: var(--ink-600); background: #f2f7f9; }
.drop.over { border-color: var(--accent); background: #fff8e8; }
.drop .big { font-size: 30px; margin-bottom: 6px; }
.drop strong { color: var(--ink-800); }
.drop input[type=file] { display: none; }
.queue { margin-top: 14px; display: grid; gap: 10px; }
.q { display: grid; grid-template-columns: 78px 1fr auto; gap: 12px; align-items: start; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 10px; }
.q img { width: 78px; height: 78px; object-fit: cover; border-radius: 8px; background: #eef2f4; }
.q .nm { font-size: 12.5px; font-weight: 650; margin-bottom: 5px; word-break: break-all; color: var(--ink-800); }
.q textarea { min-height: 52px; font-size: 13.5px; }
.q .st { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.q.done { border-color: var(--ok-line); background: var(--ok-bg); }
.q.fail { border-color: var(--bad-line); background: var(--bad-bg); }
.bar { height: 5px; background: #e7edef; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* --------------------------------------------------------------- toasts */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--ink-600); border-radius: var(--r); padding: 11px 13px; box-shadow: var(--sh-2); font-size: 14px; animation: slideIn .22s cubic-bezier(.2,.8,.3,1); }
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--bad); }
.toast.info { border-left-color: var(--info); }
.toast .x { background: none; border: 0; color: var(--faint); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; margin-left: auto; }
.toast.out { animation: slideOut .2s forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes slideOut { to { opacity: 0; transform: translateX(16px); } }

/* --------------------------------------------------------------- notices */
.notice { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; font-size: 14px; background: var(--surface-2); }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-line); color: #6b4400; }
.notice.info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.notice.ok { background: var(--ok-bg); border-color: var(--ok-line); color: #0e5a3c; }
.notice.bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.errors { background: var(--bad-bg); border: 1px solid var(--bad-line); color: #8b241c; border-radius: var(--r); padding: 11px 14px 11px 16px; margin-bottom: 16px; font-size: 14px; }
.errors ul { margin: 0; padding-left: 18px; }
.errors li + li { margin-top: 3px; }

/* ----------------------------------------------------------------- empty */
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty .empty-icon { font-size: 38px; margin-bottom: 10px; opacity: .85; }
.empty h2, .empty h3 { color: var(--ink-800); margin-bottom: 6px; }
.empty p { max-width: 440px; margin: 0 auto 14px; }
.empty-page { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* ------------------------------------------------------------- disclosure */
details.disc { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
details.disc > summary { cursor: pointer; list-style: none; padding: 13px 16px; font-weight: 650; color: var(--ink-800); display: flex; align-items: center; gap: 8px; font-size: 14px; }
details.disc > summary::-webkit-details-marker { display: none; }
details.disc > summary::before { content: '›'; font-size: 17px; transition: transform .15s; color: var(--muted); }
details.disc[open] > summary::before { transform: rotate(90deg); }
details.disc .disc-body { padding: 0 16px 16px; }
.input[readonly] { background: var(--surface-2); color: var(--muted); cursor: default; }
.input[readonly]:focus { box-shadow: none; border-color: var(--line); }
details.pw-change { margin: 20px 0 16px; }
details.pop { position: relative; display: inline-block; }
details.pop > summary { list-style: none; }
details.pop > summary::-webkit-details-marker { display: none; }
details.pop .pop-body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-2); padding: 12px; min-width: 268px; text-align: left; }

/* -------------------------------------------------------------- lightbox */
.lb { position: fixed; inset: 0; background: rgba(6,24,30,.93); display: none; align-items: center; justify-content: center; z-index: 95; padding: 28px; }
.lb.open { display: flex; }
.lb img { max-width: 100%; max-height: 86vh; border-radius: var(--r); box-shadow: var(--sh-3); }
.lb .cap { position: absolute; left: 0; right: 0; bottom: 20px; text-align: center; color: #fff; font-size: 14px; padding: 0 28px; }
.lb .x { position: absolute; top: 16px; right: 20px; background: rgba(255,255,255,.14); border: 0; color: #fff; width: 36px; height: 36px; border-radius: 50%; font-size: 20px; cursor: pointer; }

/* ---------------------------------------------------------------- auth */
body.bare { background: radial-gradient(1200px 700px at 12% -8%, var(--ink-700) 0%, var(--ink-800) 42%, var(--ink-900) 100%); display: flex; flex-direction: column; min-height: 100vh; }
.bare-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.bare-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: var(--r-lg); padding: 30px 30px 26px; box-shadow: 0 30px 70px -24px rgba(0,0,0,.6); }
.bare-card.wide { max-width: 620px; }
.bare-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }
.bare-brand img { width: 34px; height: 34px; border-radius: 9px; }
.bare-brand > span { min-width: 0; }
.bare-brand .bn { display: block; font-weight: 800; color: var(--ink-800); font-size: 15.5px; line-height: 1.2; }
.bare-brand .bs { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.bare-card h1 { font-size: 21px; margin-bottom: 4px; }
.bare-card .lead { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.bare-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; font-size: 13.5px; flex-wrap: wrap; }
.bare-foot { text-align: center; color: rgba(255,255,255,.5); font-size: 12.5px; padding: 0 20px 24px; line-height: 1.7; }
.bare-foot a { color: rgba(255,255,255,.72); }
.devlink { background: #fff8e8; border: 1px dashed var(--accent); padding: 10px 12px; border-radius: 9px; font-size: 12.5px; word-break: break-all; margin-top: 14px; }

/* ------------------------------------------------------------ login list */
.logins { border: 1px solid var(--ok-line); background: var(--ok-bg); border-radius: var(--r); padding: 14px 16px; }
.logins table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 8px; }
.logins td, .logins th { padding: 6px 8px; text-align: left; border-bottom: 1px solid rgba(21,122,82,.18); }
.logins th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #0e5a3c; }
.logins .mono { background: rgba(255,255,255,.7); padding: 2px 6px; border-radius: 5px; }

/* ------------------------------------------------------------ responsive */
.menu-btn { display: none; }
.scrim { display: none; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 272px; height: 100dvh;
    transform: translateX(-100%); transition: transform .22s cubic-bezier(.2,.8,.3,1);
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--sh-3); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(6,24,30,.45); z-index: 39; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    background: var(--ink-800); color: #fff; padding: 9px 12px;
  }
  .topbar .tb-brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 14px; text-decoration: none; min-width: 0; }
  .topbar .tb-brand img { width: 26px; height: 26px; border-radius: 7px; }
  .topbar .tb-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .menu-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 17px; cursor: pointer; flex: none; }
  .topbar .right-act { margin-left: auto; display: flex; gap: 8px; align-items: center; }
  .page { padding: 18px 14px 80px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-head .acts .btn { flex: 1; }
  h1 { font-size: 21px; }
  .row > .field { flex: 1 1 100%; }
  .row .btn { width: 100%; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .photos { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .photo .body { padding: 9px 10px 10px; }
  .photo textarea { min-height: 78px; }
  .photo .movebar { flex-direction: column; align-items: stretch; gap: 3px; }
  .photo .movebar select { width: 100%; }
  .photo .foot .right { margin-left: 0; width: 100%; }
  .photo .foot .right > .btn, .photo .foot .right > form { flex: 1 1 0; min-width: 0; }
  .photo .foot .right .btn { width: 100%; padding-left: 8px; padding-right: 8px; }
  .card-head { padding: 13px 14px; }
  .sm-hide { display: none !important; }
  .sm-only { display: block; }
  .tbl th, .tbl td { padding: 10px 11px; }
  .card-body { padding: 14px; }
  .q { grid-template-columns: 58px 1fr; }
  .q img { width: 58px; height: 58px; }
  .q > div:last-child { grid-column: 1 / -1; }
  .selbar { left: 12px; right: 12px; bottom: 12px; transform: translateY(150%); border-radius: var(--r); justify-content: space-between; }
  .selbar.up { transform: none; }
  /* two rows on a phone so nothing runs off the edge: "2 selected · Cancel" / "Move to… · Delete" */
  .selbar { flex-wrap: wrap; row-gap: 8px; padding: 10px 12px; }
  .selbar .n { flex: 1 1 auto; }
  .selbar [data-bulk="clear"] { order: 1; }
  .selbar select { order: 2; flex: 1 1 60%; min-width: 0; }
  .selbar [data-bulk="delete"], .selbar [data-bulk="restore"], .selbar [data-bulk="purge"] { order: 3; }
  .toasts { left: 12px; right: 12px; top: 12px; max-width: none; }
  details.pop .pop-body { position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; min-width: 0; }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .photos { grid-template-columns: 1fr 1fr; }
}
@media print { .sidebar, .topbar, .selbar, .toasts { display: none !important; } .app { grid-template-columns: 1fr; } }
