:root {
  --bg: #f4f5f7; --card: #fff; --line: #e2e5ea; --ink: #1c2230; --muted: #687083;
  --primary: #0b5f86; --primary-ink: #fff; --danger: #b42318; --warn: #a15c07; --ok: #067647;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 8px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
a { color: var(--primary); }
.muted, .hint { color: var(--muted); }
.hint { font-size: 13px; margin: 4px 0 10px; }

/* top bar */
.top { display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand span { font-weight: 400; color: var(--muted); }
.top-right { margin-left: auto; display: flex; gap: 8px; }
.name { font-size: 17px; font-weight: 600; border: 1px solid transparent; border-radius: 8px;
  padding: 6px 10px; min-width: 260px; flex: 0 1 420px; background: transparent; }
.name:hover, .name:focus { border-color: var(--line); background: #fff; outline: none; }
.saved { font-size: 13px; white-space: nowrap; }
.back { text-decoration: none; }

/* buttons + inputs */
button, .btn { font: inherit; border-radius: 8px; padding: 7px 14px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink); display: inline-block; }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.ghost { background: transparent; }
.ghost:hover { background: #eef1f4; }
.danger { color: var(--danger); }
.big { width: 100%; padding: 12px; font-size: 16px; margin-top: 6px; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
textarea { width: 100%; resize: vertical; line-height: 1.6; }
input[type=number] { width: 80px; }
input[type=color] { padding: 2px; width: 44px; height: 34px; vertical-align: middle; }
label.inline, span.inline { display: inline-flex; align-items: center; gap: 8px; }
label.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 16px; margin-top: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* layout */
.page { max-width: 1000px; margin: 24px auto; padding: 0 20px; }
.page.narrow { max-width: 380px; margin-top: 12vh; }
.page.wide { max-width: 1320px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.col-main.locked { opacity: .65; }
.sticky { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; }
@media (max-width: 980px) { .editor { grid-template-columns: 1fr; } .sticky { position: static; max-height: none; } }

/* login + list */
.login { display: grid; gap: 14px; }
.login input { width: 100%; margin-top: 6px; }
.err { color: var(--danger); }
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.empty p { margin: 0; }
.plist { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.pcard { display: flex; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; text-decoration: none; color: inherit; }
.pcard:hover { border-color: var(--primary); }
.pthumb { width: 96px; height: 72px; border-radius: 6px; background: #e9ecf0; overflow: hidden; flex: none; }
.pthumb img { width: 100%; height: 100%; object-fit: cover; }
.pbody { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pbody b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbody .muted { font-size: 13px; }
.pill { align-self: flex-start; font-size: 12px; border-radius: 99px; padding: 1px 8px; margin-top: 2px; }
.pill.ok { background: #e7f6ec; color: var(--ok); }
.pill.bad { background: #fdecea; color: var(--danger); }
.pill.busy { background: #e6f0f6; color: var(--primary); }

/* photos */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.drop.over { border-color: var(--primary); background: #f0f6fa; }
.drop-empty { text-align: center; color: var(--muted); margin: 34px 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ph { position: relative; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: #e9ecf0;
  cursor: grab; user-select: none; border: 2px solid transparent; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.ph.dragging { opacity: .35; }
.ph.unused img { opacity: .4; filter: grayscale(.6); }
.ph.focused { border-color: #f5c400; }
.ph .num { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: 12px;
  font-weight: 700; border-radius: 99px; min-width: 22px; height: 22px; display: grid; place-items: center; padding: 0 6px; }
.ph .tags { position: absolute; left: 6px; bottom: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; border-radius: 4px; padding: 1px 6px; background: rgba(0,0,0,.65); color: #fff; }
.tag.warn { background: rgba(161, 92, 7, .9); }
.tag.off { background: rgba(80, 80, 80, .9); }
.ph .x { position: absolute; right: 6px; top: 6px; padding: 0 8px; height: 24px; line-height: 22px;
  border-radius: 99px; background: rgba(0,0,0,.6); color: #fff; border: none; font-size: 15px; }
.ph .x.armed { background: var(--danger); font-size: 12px; }
.ph .crop-btn { position: absolute; right: 6px; bottom: 6px; padding: 1px 8px; font-size: 12px; border: none;
  background: rgba(255,255,255,.9); border-radius: 6px; opacity: 0; transition: opacity .15s; }
.ph:hover .crop-btn, .ph .crop-btn:focus { opacity: 1; }

/* captions */
.cap-row { display: grid; grid-template-columns: 210px minmax(0, 1fr) 170px auto 34px; gap: 8px; align-items: center; margin-bottom: 8px; }
.cap-row .x { padding: 4px 0; }
@media (max-width: 760px) { .cap-row { grid-template-columns: 1fr 1fr; } }

/* side panel */
.summary { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 6px 0 10px; font-size: 14px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; }
.msgs { margin: 8px 0; padding-left: 18px; font-size: 13px; }
.msgs:empty { display: none; }
.msgs.err { color: var(--danger); }
.msgs.warn { color: var(--warn); }
.job { margin-top: 10px; font-size: 14px; }
.job.busy { display: flex; align-items: center; gap: 10px; color: var(--primary); font-weight: 600; }
.job.bad { color: var(--danger); }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.vids { display: flex; gap: 10px; align-items: flex-start; }
.vids figure { margin: 0; }
.vids video { display: block; background: #000; border-radius: 6px; }
.v916 video { width: 150px; }
.v11 video { width: 180px; }
.vids figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
details { margin-top: 12px; font-size: 13px; }
.older { padding-left: 18px; }

/* crop dialog */
dialog { border: none; border-radius: 12px; padding: 0; max-width: min(960px, 94vw); }
dialog::backdrop { background: rgba(10, 16, 24, .55); }
.crop-box { padding: 18px 20px; }
.crop-box h3 { margin-top: 0; }
.crop-stage { position: relative; display: inline-block; cursor: crosshair; line-height: 0; overflow: hidden; }
.crop-stage img { max-width: 100%; max-height: 62vh; display: block; }
.crop-win { position: absolute; top: 0; bottom: 0; border: 3px solid #f5c400;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); pointer-events: none; }
.crop-win.dashed { border: 2px dashed #fff; box-shadow: none; }
