/* Verano Studio — one stylesheet. Desktop first (sidebar + wide content), phone layout under 900px (bottom tabs).
   Black on white like the shop, hairlines instead of shadows, square-ish corners, tabular numbers. */
@font-face { font-family: "Montserrat"; src: url("/fonts/Montserrat-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
:root {
  --bg: #ffffff; --panel: #f6f6f6; --panel2: #ededed; --line: #e2e2e2; --line2: #cfcfcf;
  --ink: #1c1c1c; --text: #1c1c1c; --body2: #3d3d3d; --muted: #747474; --faint: #a3a3a3;
  --green: #1a7f4b; --green-bg: #e9f5ee; --amber: #a86400; --amber-bg: #fbf1df; --red: #ba0001; --red-bg: #fbeaea;
  --blue: #2b59c3; --blue-bg: #e9eefb; --purple: #6a4ec9; --purple-bg: #efeafb;
  --r: 6px; --r2: 8px; --tabh: 60px; --side: 220px; --focus: 0 0 0 2px #fff, 0 0 0 4px var(--ink);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
  --brand: "Montserrat", var(--font);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: none; box-shadow: var(--focus); }
img, video { max-width: 100%; }

/* ---- frame: sidebar on desktop, top bar + bottom tabs on phone ---- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font: 600 13px/1 var(--brand); letter-spacing: .14em; text-transform: uppercase; }
.mark { width: 18px; height: 18px; background: var(--ink); position: relative; flex: none; }
.mark::after { content: ""; position: absolute; inset: 5px; background: #fff; }
.pill { font-size: 12px; padding: 4px 8px; border: 1px solid var(--line); border-radius: var(--r); color: var(--muted); font-weight: 500; white-space: nowrap; }
.pill:empty { display: none; }
main { padding: 12px 16px 24px; max-width: 680px; margin: 0 auto; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--tabh) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--bg); border-top: 1px solid var(--line); z-index: 20; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); font-weight: 500; position: relative; }
.tabs a.on { color: var(--ink); font-weight: 600; }
.tabs .ico { font-size: 18px; line-height: 1; }
.tabs .side-only { display: none; }
.badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 17px; text-align: center; font-weight: 600; }
.reload { position: sticky; top: 0; z-index: 30; background: var(--ink); color: #fff; padding: 9px 16px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.reload button { background: #fff; color: var(--ink); border: 0; border-radius: var(--r); padding: 5px 12px; font-weight: 600; }
body { padding-bottom: calc(var(--tabh) + env(safe-area-inset-bottom)); }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .top { display: none; }
  .tabs { top: 0; bottom: 0; right: auto; width: var(--side); height: auto; flex-direction: column; align-items: stretch; padding: 22px 14px 18px; border-top: 0; border-right: 1px solid var(--line); background: var(--bg); }
  .tabs .side-only { display: flex; }
  .tabs .brand { padding: 0 10px 22px; }
  .tabs a { flex: none; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 8px 10px; border-radius: var(--r); font-size: 14px; font-weight: 500; color: var(--body2); }
  .tabs a:hover { background: var(--panel); }
  .tabs a.on { background: var(--ink); color: #fff; }
  .tabs .ico { width: 18px; text-align: center; font-size: 15px; color: inherit; opacity: .8; }
  .tabs .badge { position: static; margin-left: auto; }
  .tabs .foot { margin-top: auto; padding: 0 10px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
  .tabs .foot .pill { align-self: flex-start; }
  main { margin: 0 0 0 var(--side); max-width: none; padding: 28px 36px 48px; }
  .page { max-width: 1240px; }
  .reload { margin-left: var(--side); }
}

/* ---- primitives ---- */
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r2); padding: 14px 16px; margin-bottom: 10px; }
.card.tap { cursor: pointer; }
.card.tap:hover { border-color: var(--line2); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.title { font-weight: 600; font-size: 14px; line-height: 1.3; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
h2.sec { font-size: 12px; font-weight: 600; color: var(--muted); margin: 20px 0 8px; }
h2.sec:first-child { margin-top: 0; }
.chips { display: flex; gap: 6px; margin: 0 0 12px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: var(--r); background: var(--bg); border: 1px solid var(--line); font-weight: 500; font-size: 13px; color: var(--body2); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.stage { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--body2); white-space: nowrap; text-transform: capitalize; }
.stage::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.stage.queued::before { background: var(--blue); }
.stage.generating::before { background: var(--purple); }
.stage.ready::before { background: var(--amber); }
.stage.approved::before { background: var(--green); }
.stage.pushed::before { background: var(--green); box-shadow: 0 0 0 2px var(--green-bg); }
.stage.failed::before, .stage.rejected::before { background: var(--red); }
.stage.failed, .stage.rejected { color: var(--red); }
.thumb { width: 56px; height: 70px; border-radius: 4px; background: var(--panel) center/cover no-repeat; flex: none; position: relative; overflow: hidden; }
.thumb.wide { height: 56px; }
.thumb .play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 10px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.stat { background: var(--bg); padding: 6px 10px; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 14px; font-weight: 600; }
.stat.up .v { color: var(--green); }
.stat.down .v { color: var(--red); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 6px; padding: 2px 8px; border-radius: 4px; background: var(--panel); color: var(--body2); }
.tag.need { background: var(--amber-bg); color: var(--amber); }
.tag.guess { background: var(--blue-bg); color: var(--blue); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: var(--r); border: 1px solid var(--ink); background: var(--ink); color: #fff; font-weight: 600; font-size: 13px; line-height: 1.2; white-space: nowrap; }
.btn:hover { background: #000; }
.btn.sec { background: var(--bg); color: var(--ink); border-color: var(--line2); }
.btn.sec:hover { background: var(--panel); }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn.green { background: var(--green); border-color: var(--green); }
.btn.green:hover { background: #156a3e; }
.btn.red { background: var(--bg); color: var(--red); border-color: var(--line2); }
.btn.red:hover { background: var(--red-bg); border-color: var(--red); }
.btn.full { width: 100%; }
.btn:disabled { opacity: .4; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btnrow { display: flex; gap: 8px; margin-top: 12px; }
.btnrow .btn { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; font-size: 13px; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; font-size: 14px; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line2); border-radius: var(--r); background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: none; outline: none; }
textarea { min-height: 90px; resize: vertical; }
label.f { display: block; margin-top: 10px; font-size: 12px; font-weight: 500; color: var(--muted); }
label.f > * { margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.opt { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.opt:last-child { border-bottom: 0; }
.opt input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button { padding: 6px 10px; border-radius: var(--r); border: 1px solid var(--line); background: #fff; font-weight: 500; font-size: 13px; color: var(--body2); }
.seg button:hover { border-color: var(--line2); }
.seg button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv b { font-weight: 600; text-align: right; }
.ok { color: var(--green); font-weight: 600; } .bad { color: var(--red); font-weight: 600; }
.log { font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; color: var(--body2); max-height: 260px; overflow: auto; background: var(--panel); border-radius: var(--r); padding: 10px; }
.qrow { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.qrow:last-child { border-bottom: 0; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--purple); border-radius: 50%; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2s; } .rv { transition: none !important; } }
.login { max-width: 360px; margin: 48px auto; }
.login .names { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.pinbox { font-size: 22px; letter-spacing: .3em; text-align: center; }
.ver { font-size: 11px; color: var(--faint); text-align: center; margin-top: 24px; }
.prod { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.prod:last-child { border-bottom: 0; }
.prod img[src=""] { visibility: hidden; }
.prod img { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; background: var(--panel); }
.prod.on { background: var(--panel); margin: 0 -8px; padding: 8px; border-radius: var(--r); cursor: default; }
.reason { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; }
.reason .m { color: var(--muted); }
.lib-link { color: var(--blue); font-weight: 600; font-size: 13px; }
details.prompt summary { font-size: 12px; color: var(--muted); font-weight: 500; cursor: pointer; margin-top: 8px; }
details.prompt p { font-size: 13px; color: var(--body2); margin: 6px 0 0; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; flex-wrap: wrap; }
@media (max-width: 899px) { .toolbar .note { width: 100%; } }
.toolbar .chips { margin: 0; }
.note { font-size: 12px; color: var(--muted); }
.note.warn { color: var(--amber); }

/* ---- winners: rows ---- */
.ad { display: grid; grid-template-columns: 56px 1fr; grid-template-areas: "thumb main" "thumb stage" "stats stats"; gap: 4px 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r2); margin-bottom: 8px; cursor: pointer; background: var(--bg); }
.ad:hover { border-color: var(--line2); }
.ad .thumb { grid-area: thumb; }
.ad .main { grid-area: main; min-width: 0; }
.ad .name { font-weight: 600; font-size: 14px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ad .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 3px; }
.ad .stats { grid-area: stats; margin-top: 4px; }
.ad .stagecol { grid-area: stage; display: flex; gap: 10px; align-items: center; font-size: 12px; }
@media (min-width: 900px) {
  .ad { grid-template-columns: 48px minmax(0, 1fr) 150px 440px; grid-template-areas: "thumb main stage stats"; align-items: center; gap: 16px; padding: 10px 14px; margin-bottom: 0; border-radius: 0; border-bottom: 0; }
  .ad:first-of-type { border-radius: var(--r2) var(--r2) 0 0; }
  .ad:last-of-type { border-radius: 0 0 var(--r2) var(--r2); border-bottom: 1px solid var(--line); }
  .ad:only-of-type { border-radius: var(--r2); }
  .ad .thumb { width: 48px; height: 60px; }
  .ad .thumb.wide { height: 48px; }
  .ad .name { -webkit-line-clamp: 1; }
  .ad .stagecol { flex-direction: column; align-items: flex-start; gap: 2px; }
  .ad .stats { margin: 0; border: 0; background: transparent; gap: 0; border-radius: 0; }
  .ad .stat { padding: 0 10px; border-left: 1px solid var(--line); }
  .ad .stat .v { font-size: 14px; }
}

/* ---- sheet: bottom sheet on phone, right-hand panel on desktop; .wide = centred for full-size viewing ---- */
.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-bg { position: absolute; inset: 0; background: rgba(28,28,28,.4); }
.sheet-card { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow: auto; background: var(--bg); border-radius: 12px 12px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet-card::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--line2); margin: 2px auto 12px; }
.sheet-card .card { background: var(--bg); }
@media (min-width: 900px) {
  .sheet-card { left: auto; top: 0; bottom: 0; width: min(680px, 62vw); max-height: none; border-radius: 0; border-left: 1px solid var(--line); padding: 24px 28px 32px; }
  .sheet-card::before { display: none; }
  .sheet-card.wide { left: 50%; top: 50%; bottom: auto; right: auto; transform: translate(-50%, -50%); width: min(1100px, 92vw); max-height: 92vh; border: 1px solid var(--line); border-radius: var(--r2); }
}
.toast { position: fixed; left: 50%; bottom: calc(var(--tabh) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r2); font-size: 13px; z-index: 50; max-width: 90vw; }
@media (min-width: 900px) { .toast { bottom: 24px; left: calc(var(--side) + (100vw - var(--side)) / 2); } }

/* ---- review ---- */
.rv { position: relative; touch-action: pan-y; transition: transform .15s ease, opacity .15s; }
.rv .rvck { position: absolute; top: 10px; left: 10px; z-index: 3; width: 22px; height: 22px; accent-color: var(--ink); pointer-events: none; }
.rv.dragging { transition: none; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pair .side { position: relative; }
.pair .lab { position: absolute; z-index: 2; top: 6px; left: 6px; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 4px; background: rgba(28,28,28,.75); color: #fff; }
.pair video, .pair img { width: 100%; aspect-ratio: 4/5; object-fit: cover; border-radius: 4px; background: var(--panel); display: block; }
.pair.tall video, .pair.tall img { aspect-ratio: 9/16; }
.pair.square video, .pair.square img { aspect-ratio: 1/1; }
.pair .expand { position: absolute; right: 6px; bottom: 6px; z-index: 2; width: 30px; height: 30px; border-radius: 4px; border: 0; background: rgba(28,28,28,.75); color: #fff; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.pair .side img { cursor: zoom-in; }
.stamp { position: absolute; top: 30%; font-size: 26px; font-weight: 800; padding: 6px 14px; border: 3px solid; border-radius: 6px; transform: rotate(-12deg); opacity: 0; pointer-events: none; letter-spacing: .05em; z-index: 3; }
.stamp.yes { left: 20px; color: var(--green); border-color: var(--green); }
.stamp.no { right: 20px; color: var(--red); border-color: var(--red); transform: rotate(12deg); }
.viewer-media { width: 100%; max-height: 72vh; object-fit: contain; border-radius: var(--r); background: var(--panel); display: block; }
.hint-touch { display: none; } .hint-mouse { display: inline; }
@media (hover: none) { .hint-touch { display: inline; } .hint-mouse { display: none; } }
@media (min-width: 900px) {
  .review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; align-items: start; }
  .review-grid .card { margin-bottom: 0; }
  .sheet-card.wide .viewer-media { max-height: 78vh; }
}

/* ---- library ---- */
.lib { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: start; }
.lib .lthumb { width: 56px; height: 70px; border-radius: 4px; background: var(--panel) center/cover no-repeat; position: relative; overflow: hidden; }
.lib .lthumb.wide { height: 56px; }
.lib .lthumb .play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.lib.pick { grid-template-columns: 22px 56px 1fr; }
.lib input[type=checkbox] { width: 18px; height: 18px; margin: 4px 0 0; accent-color: var(--ink); }
.card.sel { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
@media (min-width: 900px) {
  .lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
  .lib-grid .card { margin-bottom: 0; padding: 10px; display: flex; flex-direction: column; }
  .lib { grid-template-columns: 1fr; gap: 8px; }
  .lib.pick { grid-template-columns: 1fr; }
  .lib input[type=checkbox] { position: absolute; margin: 8px; z-index: 2; }
  .lib-grid .card { position: relative; }
  .lib .lthumb, .lib .lthumb.wide { width: 100%; height: auto; aspect-ratio: 4/5; }
  .lib .lthumb.wide { aspect-ratio: 16/9; }
  .lib .lthumb.tall { aspect-ratio: 9/16; }
  .lib .lthumb.square { aspect-ratio: 1/1; }
  .lib-grid .btnrow { margin-top: auto; padding-top: 10px; flex-wrap: wrap; gap: 6px; }
  .lib-grid .btnrow .btn { flex: 1 1 calc(50% - 3px); min-width: 0; padding: 8px 6px; overflow: hidden; text-overflow: ellipsis; }
  .lib-grid .btnrow .btn.green, .lib-grid .btnrow .btn.green + .btn, .lib-grid .btnrow [data-push] { flex-basis: 100%; }
}

/* ---- create ---- */
.create { display: grid; gap: 0; }
.create-main { max-width: 760px; }
/* ---- batch: three columns on a desktop, one on a phone ---- */
.batch { display: grid; gap: 0 28px; align-items: start; }
@media (min-width: 1000px) { .batch { grid-template-columns: repeat(3, minmax(0, 1fr)); } .batch > div > h2.sec:first-child { margin-top: 0; } }
@media (min-width: 1500px) { .batch { gap: 0 40px; } }
.imgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
@media (min-width: 900px) { .imgrid { grid-template-columns: repeat(6, 1fr); } }
.imgrid .im { position: relative; aspect-ratio: 1; border-radius: 4px; overflow: hidden; background: var(--panel); border: 2px solid transparent; cursor: pointer; }
.imgrid .im img { width: 100%; height: 100%; object-fit: cover; display: block; }
.imgrid .im.off { opacity: .35; }
.imgrid .im.on { border-color: var(--ink); }
.imgrid .im .tick { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; }
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 3px; border: 1px solid var(--line); vertical-align: middle; margin-right: 6px; }
input[type=color] { width: 44px; height: 32px; padding: 2px; }
.crow { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.crow label { flex: 1; font-size: 13px; }

/* ---- settings: two columns on desktop ---- */
@media (min-width: 1100px) {
  .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; align-items: start; }
  .cols section { min-width: 0; }
  .cols section.wide { grid-column: 1 / -1; }
  .cols section.rules { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
  .cols section.rules h2, .cols section.rules .card:last-child { grid-column: 1 / -1; }
}

/* ---- learn: study write-up ---- */
ul.tight { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
ul.tight li { margin: 3px 0; }
.stads { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 900px) { .stads { grid-template-columns: repeat(3, 1fr); } .sheet-card.wide .stads { grid-template-columns: repeat(5, 1fr); } }
.stad { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden; }
.stad .thumb { width: 100%; height: 150px; border-radius: 0; }
.stad .small { padding: 8px 10px; line-height: 1.35; }
/* ---- calendar ---- */
.qrow.cal.past { opacity: .5; }
.qrow.cal.now > div:first-child b { color: var(--green); }
