:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #f2f3f5;
  --muted: #9aa3b2;
  --accent: #ff7a1a;
  --accent-ink: #1a0d00;
  --ok: #37c46f;
  --bad: #ff5c5c;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* author display rules must never override the hidden attribute */
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 22px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
em { font-style: normal; color: var(--muted); font-weight: 400; }
strong { color: var(--text); }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: #111318; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .01em; }
.brand-mark { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); display: inline-block; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.who { color: var(--muted); max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-switch { font: inherit; font-size: 14px; color: var(--text); background: var(--panel); border: 1.5px solid var(--accent); border-radius: 10px; padding: 6px 28px 6px 10px; max-width: 48vw; -webkit-appearance: none; 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' fill='none' stroke='%23ff7a1a' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }

/* layout */
#app { max-width: 560px; margin: 0 auto; padding: 22px 16px 60px; }
.screen[hidden] { display: none; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* fields */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 14px; color: var(--muted); }
input[type=text], input[type=email], textarea {
  width: 100%; font: inherit; font-size: 20px; color: var(--text);
  background: var(--panel); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px; outline: none; -webkit-appearance: none;
}
textarea { font-size: 17px; resize: vertical; }
input:focus, textarea:focus { border-color: var(--accent); }
#code { letter-spacing: .25em; font-size: 26px; text-align: center; }
#job-ref { font-size: 24px; font-weight: 600; }

/* buttons */
.btn {
  font: inherit; font-size: 18px; font-weight: 600; border: 0; cursor: pointer;
  border-radius: var(--radius); padding: 15px 18px; width: 100%;
  background: var(--panel-2); color: var(--text); touch-action: manipulation;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.secondary { background: transparent; border: 1.5px solid var(--line); color: var(--text); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.big { font-size: 21px; padding: 22px 18px; margin-top: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.google { background: #fff; color: #1f1f1f; display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 6px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 20px 0 10px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn .plus { font-size: 26px; line-height: 0; vertical-align: -2px; margin-right: 6px; }
.link {
  font: inherit; font-size: 15px; color: var(--accent); background: none; border: 0;
  padding: 6px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}

/* recent chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: 15px; color: var(--text); background: var(--panel);
  border: 1.5px solid var(--line); border-radius: 999px; padding: 9px 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; touch-action: manipulation;
}
.chip b { font-weight: 700; }
.chip small { color: var(--muted); }

/* upload */
.jobhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.jobhead h1 { word-break: break-word; }
.queue { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 8px; }
.qitem {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px;
}
.qthumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--panel-2); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.qthumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.qmeta { min-width: 0; }
.qname { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qsub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.qbar { height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin-top: 7px; }
.qbar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
.qitem.done .qbar > i { background: var(--ok); width: 100% !important; }
.qitem.failed .qbar > i { background: var(--bad); }
.qstatus { font-size: 13px; color: var(--muted); white-space: nowrap; }
.qitem.done .qstatus { color: var(--ok); font-weight: 600; }
.qitem.failed .qstatus { color: var(--bad); }
.qitem .link { font-size: 13px; padding: 0; }

.summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 10px; font-size: 15px; color: var(--muted); }
.summary .btn { width: auto; font-size: 15px; padding: 10px 14px; }

#btn-finish { margin-top: 10px; }

/* existing grid */
.count { color: var(--text); margin-left: 4px; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--panel-2); border: 0; padding: 0; cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .vid { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.tile .x { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.65); color: #fff; border-radius: 999px; width: 22px; height: 22px; font-size: 14px; line-height: 22px; text-align: center; }

/* modal / toast / errors */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border-radius: 18px 18px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); width: 100%; max-width: 560px; }
.modal-card h2 { margin-top: 0; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 20px; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #2a2f3a; color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 15px; z-index: 30; max-width: 90vw; }
.toast[hidden] { display: none; }

.error { color: var(--bad); font-size: 15px; margin-top: 12px; }
.notice { background: #2a2214; border: 1px solid #5a4420; color: #f3d9a4; border-radius: var(--radius); padding: 12px 14px; font-size: 14px; line-height: 1.4; margin: 0 0 14px; }
.notice b { color: #ffe3b0; }
.error[hidden] { display: none; }

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(6, 1fr); }
}
