:root {
  --ink: #16181d;
  --soft: #5d6370;
  --line: #e3e5ea;
  --wash: #f6f7f9;
  --paper: #fff;
  --accent: #3b4cca;
  --accent-ink: #fff;
  --bad: #b42318;
  --good: #067647;
  --radius: 8px;
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--wash);
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
p { margin: 0; }
[hidden] { display: none !important; }

.bar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px;
  background: var(--paper); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.mark { font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.mark:hover { text-decoration: none; }
#nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
#nav a { color: var(--soft); padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
#nav a:hover { background: var(--wash); text-decoration: none; }
#nav a.on { color: var(--ink); background: var(--wash); font-weight: 600; }
#who { display: flex; gap: 12px; align-items: center; color: var(--soft); font-size: 14px; white-space: nowrap; }

main { max-width: 1200px; margin: 0 auto; padding: 24px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row select { width: auto; }
.muted { color: var(--soft); }
.small { font-size: 13px; }
.pill { font-size: 12px; background: var(--wash); border: 1px solid var(--line); border-radius: 99px; padding: 1px 7px; color: var(--soft); }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stack > * + * { margin-top: 12px; }

button, .button {
  font: inherit; font-size: 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 6px; padding: 7px 12px; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .button:hover { background: var(--wash); text-decoration: none; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover, .button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button:disabled { opacity: 0.55; cursor: default; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  font: inherit; width: 100%; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink);
}
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.hint { font-size: 12px; color: var(--soft); margin-top: 4px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card .art { aspect-ratio: 1; background: var(--wash); display: grid; place-items: center; overflow: hidden; cursor: pointer; border: 0; padding: 0; border-radius: 0; width: 100%; }
.card .art img { width: 100%; height: 100%; object-fit: contain; }
.card .body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.card .actions button { padding: 4px 8px; font-size: 13px; }
a.card:hover { text-decoration: none; border-color: #c9ccd4; }

.status { font-size: 12px; font-weight: 600; text-transform: capitalize; }
.status.failed { color: var(--bad); }
.status.succeeded { color: var(--good); }
.wait { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .wait { animation: none; } }

.studio { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; }
.studio aside { position: sticky; top: 80px; }
.refs { display: flex; gap: 6px; flex-wrap: wrap; }
.ref { position: relative; width: 56px; height: 56px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--wash); padding: 0; }
.ref img { width: 100%; height: 100%; object-fit: cover; }
.ref.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.price { display: flex; justify-content: space-between; font-size: 13px; color: var(--soft); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--soft); padding: 8px 10px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--soft); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plus { color: var(--good); }
code, .key { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--wash); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; word-break: break-all; }
.key { display: block; padding: 10px; font-size: 14px; }

.empty { text-align: center; padding: 48px 16px; color: var(--soft); }
.more { display: flex; justify-content: center; margin-top: 20px; }

.welcome { max-width: 420px; margin: 12vh auto 0; text-align: center; }
.welcome h1 { font-size: 30px; margin-bottom: 8px; }
.welcome .row { justify-content: center; margin-top: 24px; }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; max-width: min(960px, calc(100vw - 32px)); width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
dialog::backdrop { background: rgba(16,18,24,0.5); }
dialog .inner { padding: 20px; }
dialog.narrow { max-width: 480px; }
.view { display: grid; grid-template-columns: 1fr 280px; gap: 20px; }
.view img { width: 100%; max-height: 72vh; object-fit: contain; background: var(--wash); border-radius: 6px; }
.view dl { margin: 0; font-size: 13px; }
.view dt { color: var(--soft); margin-top: 10px; }
.view dd { margin: 2px 0 0; word-break: break-word; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.2s; max-width: calc(100vw - 32px); z-index: 20; }
#toast.on { opacity: 1; }
#toast.bad { background: var(--bad); }

@media (max-width: 800px) {
  .bar { gap: 12px; padding: 0 12px; height: auto; min-height: 52px; flex-wrap: wrap; }
  .mark { padding: 14px 0; }
  #who { margin-left: auto; }
  #email { display: none; }
  #nav { order: 3; flex-basis: 100%; padding-bottom: 8px; }
  main { padding: 16px 12px; }
  .studio { grid-template-columns: 1fr; }
  .studio aside { position: static; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .view { grid-template-columns: 1fr; }
}
