:root {
  --bg: #1c1d20;
  --panel: #232428;
  --panel-2: #2b2d31;
  --line: #34363b;
  --text: #ececee;
  --muted: #9a9ca3;
  --accent: #f2c14e;
  --live: #3ecf6e;
  --done: #4f8cff;
  --danger: #ff6b6b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: #4a4d54; }
a.button { display: inline-block; text-align: center; text-decoration: none; color: inherit; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
a.button:hover { border-color: #4a4d54; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 4px 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
button.primary { background: var(--accent); color: #1c1d20; border-color: var(--accent); font-weight: 600; }
button.icon { padding: 6px 9px; }
button:disabled { opacity: .45; cursor: default; }
[hidden] { display: none !important; }

/* Layout */
.app { display: grid; grid-template-columns: 260px 1fr; grid-template-rows: 52px 1fr; height: 100vh; }
header { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
header .title { font-weight: 600; margin-right: 6px; }
header .sub { color: var(--muted); }
header .spacer { flex: 1; }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #666; }
.dot.on { background: var(--live); }
.people { color: var(--muted); }

aside { background: var(--panel); border-right: 1px solid var(--line); overflow: auto; padding: 10px 8px; }
aside .actions { display: flex; gap: 6px; padding: 0 4px 10px; }
aside .actions button { flex: 1; }
.tree { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; user-select: none; }
.row:hover { background: var(--panel-2); }
.row.selected { background: rgba(110, 160, 255, .22); }
.row.selected .icon { color: #8fb6ff; }
.row .icon { flex: none; width: 17px; height: 17px; color: var(--muted); }
.row .chev { flex: none; width: 12px; height: 12px; color: var(--muted); transition: transform .15s; transform: rotate(90deg); }
.row.group.collapsed .chev { transform: rotate(0deg); }
.row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .count { color: var(--muted); font-size: 12px; }
.row.group { font-weight: 600; color: #cfd0d4; }
.row.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.children { list-style: none; margin: 0; padding-left: 20px; }
.row input { width: 100%; background: var(--bg); border: 1px solid var(--accent); border-radius: 5px; padding: 2px 6px; }
.ungrouped-drop { margin-top: 8px; padding: 10px; border: 1px dashed transparent; border-radius: 8px; color: var(--muted); font-size: 12px; text-align: center; }
.ungrouped-drop.active { border-color: var(--line); }
.ungrouped-drop.drop-target { border-color: var(--accent); color: var(--text); }

main { position: relative; overflow: auto; }
.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: var(--muted); gap: 10px; pointer-events: none; }
.empty h2 { color: var(--text); margin: 0; font-size: 22px; }
.empty button { pointer-events: auto; justify-self: center; }
.grid { display: grid; gap: 14px; padding: 18px; grid-template-columns: repeat(auto-fill, minmax(var(--thumb, 180px), 1fr)); }
.cell { position: relative; aspect-ratio: 1; background: #2a2b30; border-radius: 9px; overflow: hidden; cursor: pointer; border: 3px solid transparent; }
.cell img { width: 100%; height: 100%; object-fit: contain; padding: 6px; transition: opacity .2s; pointer-events: none; }
.cell.selected { border-color: #8fb6ff; }
.cell.starred { box-shadow: inset 0 0 0 2px var(--accent); }
.cell .star { position: absolute; right: 6px; bottom: 6px; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: rgba(0, 0, 0, .55); color: #ddd; opacity: 0; transition: opacity .15s; }
.cell .star .icon { width: 16px; height: 16px; }
.cell:hover .star { opacity: 1; }
.cell.starred .star { opacity: 1; color: var(--accent); }
.cell.starred .star svg path { fill: var(--accent); }
.cell.from-mac:not(.starred) .star { display: none; }
.cell.from-mac .star { cursor: default; }
.cell.live { border-color: var(--live); }
.cell.done img { opacity: .4; }
.cell .badge { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; }
.cell .badge.live { background: var(--live); }
.cell .done-mark { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--done); color: #fff; display: grid; place-items: center; font-size: 13px; }
.cell.drop-before::before { content: ""; position: absolute; left: -9px; top: 6px; bottom: 6px; width: 3px; background: var(--accent); border-radius: 2px; }
.cell .uploading { position: absolute; inset: 0; display: grid; place-items: end center; padding-bottom: 10px; pointer-events: none; }
.cell .uploading span { font-size: 11px; color: #ddd; background: rgba(0, 0, 0, .55); padding: 2px 8px; border-radius: 10px; }
.cell.pending img { opacity: .55; }
.r90 { transform: rotate(90deg); } .r180 { transform: rotate(180deg); } .r270 { transform: rotate(270deg); }
main.dropping { outline: 3px dashed var(--accent); outline-offset: -10px; }

/* Overlays */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(380px, calc(100vw - 32px)); display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.card h1 { margin: 0 0 4px; font-size: 20px; }
.card input { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
.card .error { color: var(--danger); min-height: 1em; font-size: 13px; }
.card.wide { width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 120px; }
.help.check { display: flex; align-items: center; gap: 6px; padding: 0; }
.row .tag { color: var(--muted); font-size: 12px; }
.row button { padding: 4px 8px; font-size: 12px; }
.menu { position: fixed; z-index: 60; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 5px; min-width: 200px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 6px; }
.menu button:hover { background: #3a3c42; }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 70; max-width: 90vw; }
.help { color: var(--muted); font-size: 12px; padding: 8px 12px; }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 52px auto 1fr; }
  aside { max-height: 35vh; border-right: 0; border-bottom: 1px solid var(--line); }
  header .hide-small { display: none; }
}
.row .lock-wrap { display: inline-flex; }
.row .icon.lock { width: 13px; height: 13px; }
#accessList label.row input[type=checkbox] { flex: none; width: 16px; height: 16px; margin: 0; padding: 0; accent-color: var(--accent); }
.help.check input[type=checkbox] { padding: 0; margin: 0; }
.card .brand { color: var(--muted); font-size: 13px; letter-spacing: .04em; }
.card button.link { background: none; border: 0; color: var(--accent); padding: 2px; }
header button.attention { border-color: var(--accent); color: var(--accent); }

.card .sent { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--accent); border-radius: 10px; background: rgba(242, 193, 78, .07); }
.card .sent-title { font-weight: 600; color: var(--accent); }

/* Instructions panel (per project) */
.instructions { margin: 14px 18px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.ins-head { width: 100%; display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 10px 14px; font-weight: 600; text-align: left; }
.ins-head .chev { width: 12px; height: 12px; color: var(--muted); transform: rotate(90deg); transition: transform .15s; flex: none; }
.instructions.collapsed .ins-head .chev { transform: rotate(0deg); }
.ins-summary { color: var(--muted); font-weight: 400; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.instructions:not(.collapsed) .ins-summary { display: none; }
.ins-body { display: grid; gap: 10px; padding: 0 14px 14px; }
.instructions.collapsed .ins-body { display: none; }
.ins-note { color: var(--muted); font-size: 12px; }
.ins-field { display: grid; grid-template-columns: 70px 1fr; gap: 10px; align-items: start; }
.ins-field > span { color: var(--muted); font-size: 13px; padding-top: 6px; }
.ins-field textarea, .ins-field input:not([type=checkbox]) { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; resize: vertical; width: 100%; }
.ins-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-2); font-size: 13px; }
.chip input[type=checkbox] { margin: 0; accent-color: var(--accent); }
.chip .chip-label { background: none; border: 0; padding: 0; min-width: 4ch; color: inherit; font-size: 13px; }
.chip .chip-label:focus { outline: none; border-bottom: 1px solid var(--accent); }
.chip-remove { background: none; border: 0; padding: 0 2px; color: var(--muted); font-size: 14px; line-height: 1; }
.chip.add { color: var(--muted); cursor: pointer; }
.ins-field :disabled { opacity: .8; cursor: default; }
