/* Kloth Factory: one calm column over a sky gradient. No external fonts or assets. */
:root {
  --sky-top: #c9dcf0;
  --sky-mid: #dfe6f0;
  --sky-low: #f1ddd0;
  --sky-warm: #f2d2bf;
  --text: #17191d;
  --quiet: #4f5560;
  --solid: rgba(255, 255, 255, 0.9);      /* backing behind text: AA without blur */
  --glass: rgba(255, 255, 255, 0.62);
  --glass-line: rgba(255, 255, 255, 0.75);
  --user: #26303c;
  --user-text: #f5f7fa;
  --dark: #1b2027;
  --dark-text: #ffffff;
  --accent: #2f6b5a;
  --ok: #3fbf7f;
  --warn: #e0a43a;
  --fail: #b3261e;
  --shadow: 0 8px 30px rgba(30, 45, 70, 0.12);
  --r-card: 26px;
  --r-msg: 22px;
  --col: 700px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font: 16px/1.45 var(--sans);
  color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root {
    --sky-top: #0c0e26;
    --sky-mid: #14163a;
    --sky-low: #1b1b4a;
    --sky-warm: #1b1b4a;
    --text: #eef0f3;
    --quiet: #b3b9c3;
    --solid: rgba(18, 20, 50, 0.9);
    --glass: rgba(26, 28, 70, 0.66);
    --glass-line: rgba(255, 255, 255, 0.10);
    --user: #3d3f8f;
    --user-text: #f5f7fa;
    --dark: #0b0d11;
    --accent: #7fc4a9;
    --fail: #f28b82;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--sky-mid); overflow-x: hidden; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.serif { font-family: var(--serif); font-weight: 600; }
.quiet { color: var(--quiet); }
.error { color: var(--fail); }
.solid { background: var(--solid); }

/* Sky: the owner's illustrations (web/img, see docs/ART.md) over a gradient in matching
   colours, which is what shows while the picture loads or if it cannot. The busy corner of
   each picture (the fabric folds) is anchored to its edge so the column sits on calm space. */
.sky {
  position: fixed; inset: 0; z-index: -1;
  background-color: var(--sky-mid);
  background-image: url("img/bg-light.jpg"), linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-low) 78%, var(--sky-warm) 100%);
  background-image: image-set(url("img/bg-light.webp") type("image/webp") 1x, url("img/bg-light@2x.webp") type("image/webp") 2x, url("img/bg-light.jpg") type("image/jpeg") 1x),
                    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-low) 78%, var(--sky-warm) 100%);
  background-size: cover, cover;
  background-position: right bottom, center;
  background-repeat: no-repeat;
}
@media (prefers-color-scheme: dark) {
  .sky {
    background-image: url("img/bg-dark.jpg"), linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 60%, var(--sky-low) 100%);
    background-image: image-set(url("img/bg-dark.webp") type("image/webp") 1x, url("img/bg-dark@2x.webp") type("image/webp") 2x, url("img/bg-dark.jpg") type("image/jpeg") 1x),
                      linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 60%, var(--sky-low) 100%);
    background-position: left bottom, center;
  }
}
/* Wide screens: the 2560 px picture even at 1x density. */
@media (min-width: 1600px) {
  .sky { background-image: image-set(url("img/bg-light@2x.webp") type("image/webp"), url("img/bg-light.jpg") type("image/jpeg")),
                    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-low) 78%, var(--sky-warm) 100%); }
}
@media (min-width: 1600px) and (prefers-color-scheme: dark) {
  .sky { background-image: image-set(url("img/bg-dark@2x.webp") type("image/webp"), url("img/bg-dark.jpg") type("image/jpeg")),
                    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 60%, var(--sky-low) 100%); }
}
/* Narrow screens: keep the empty part of the picture behind the column (the folds sit low at
   the right in light and low at the left in dark). */
@media (max-width: 760px) {
  .sky { background-position: left top, center; }
}
@media (max-width: 760px) and (prefers-color-scheme: dark) {
  .sky { background-position: right top, center; }
}

/* Glass: a translucent surface with a solid enough base when blur is missing. */
.glass, .glass-btn {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  box-shadow: var(--shadow);
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .glass, .glass-btn { -webkit-backdrop-filter: blur(18px) saturate(1.2); backdrop-filter: blur(18px) saturate(1.2); }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .glass-btn { background: var(--solid); }
}
/* Round icon buttons: the icon is centred by flex on the button itself, with no padding or line box
   to push it off (the chevron's path is drawn centred on its 24 x 24 viewBox). */
.round { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  flex: none; padding: 0; line-height: 0; }
.round > svg { display: block; flex: none; }
.btn-dark { background: var(--dark); color: var(--dark-text); border-radius: 999px; padding: 10px 18px; font-weight: 600; }
.btn-soft { background: var(--solid); border: 1px solid var(--glass-line); border-radius: 999px; padding: 8px 16px; font-weight: 600; }
.btn-dark.round, .btn-soft.round { padding: 0; }

/* Sign in: the character with the spool large, the card beside it (above it on narrow screens). */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 400px); gap: 28px;
  align-items: center; padding: 32px max(16px, 4vw); }
.hero { width: 100%; box-shadow: var(--shadow); border-radius: 32px; }
.hero img { width: 100%; max-height: 72vh; aspect-ratio: 1280 / 723; object-fit: cover; }
.login-card { width: 100%; display: grid; gap: 14px; padding: 28px; border-radius: var(--r-card); background: var(--solid); }
.login-card h1 { margin: 0; font-size: 30px; }
.login-card p { margin: 0; }
.login-card label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.login-card input { border: 1px solid rgba(127, 127, 127, .45); border-radius: 14px; padding: 11px 14px; background: transparent; }
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; align-content: start; gap: 18px; padding-top: 24px; }
  .login-card { max-width: 440px; justify-self: center; }
}

/* Top bar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.switch { position: absolute; left: 50%; transform: translateX(-50%); display: flex; padding: 4px; border-radius: 999px; }
.switch button { padding: 9px 20px; border-radius: 999px; font-weight: 600; color: var(--quiet); }
.switch button.on { background: var(--dark); color: var(--dark-text); }
.right { display: flex; align-items: center; gap: 10px; }
.search { display: flex; align-items: center; gap: 6px; border-radius: 999px; padding: 0 14px; height: 44px; color: var(--quiet); }
.search input { border: 0; background: none; outline: none; width: 120px; color: var(--text); }
.search input::placeholder { color: var(--quiet); }
.search:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.avatar { background: var(--dark); color: var(--dark-text); font-weight: 700; font-size: 17px; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 52px; min-width: 190px; border-radius: 18px; padding: 8px; box-shadow: var(--shadow); }
.menu-user { margin: 6px 10px 8px; font-weight: 600; overflow-wrap: anywhere; }
.menu button { width: 100%; text-align: left; padding: 10px; border-radius: 12px; }
.menu button:hover { background: rgba(127, 127, 127, .15); }

/* Date and time in the left margin (wide screens only) */
.clock {
  position: fixed; left: 4vw; top: 50%; transform: translateY(-50%);
  display: grid; font-size: 64px; line-height: 1.05; font-weight: 500; letter-spacing: -0.02em;
  color: var(--text); opacity: .85;
}
@media (max-width: 1180px) { .clock { display: none; } }

/* Column and thread */
.column { width: min(var(--col), 100% - 32px); margin: 0 auto; padding: 88px 0 170px; }
.thread { display: flex; flex-direction: column; gap: 18px; }
.msg {
  max-width: 85%; padding: 14px 18px; border-radius: var(--r-msg);
  white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: var(--shadow);
}
.msg.assistant { align-self: flex-start; background: var(--solid); }
.msg.user { align-self: flex-end; background: var(--user); color: var(--user-text); }
.msg .atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.att { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; background: rgba(255, 255, 255, .14); border-radius: 999px; padding: 3px 10px 3px 3px; max-width: 220px; }
.att img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.att .kind { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .2); font-size: 10px; text-transform: uppercase; }
.att span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Execution box: the character scene of the job's stage fills a tall frame so the whole character
   is in view. Every scene is 1280 x 723 with the character centred, face at about 35-45 % of the
   height and feet and props at 85-92 %. The picture stops 40 px above the frame's bottom and fades
   into the scenes' own floor blue, so the status pill and the expand button sit on that floor
   under a soft scrim instead of over the character or the thing it holds. */
.exec { border-radius: var(--r-card); overflow: hidden; position: relative; }
.exec-head { position: relative; min-height: 76px; display: flex; align-items: flex-end; padding: 20px; cursor: pointer; }
.exec.scene .exec-head { width: 100%; aspect-ratio: 11 / 6; max-height: 380px; }  /* a set width keeps max-height from narrowing it */
.exec-bg { position: absolute; inset: 10px; border-radius: 18px; overflow: hidden; background: rgba(255, 255, 255, .35); }
.exec.scene .exec-bg { background: #1262b7; }   /* the floor colour along the bottom of every scene */
.exec-bg img { position: absolute; left: 0; top: 0; width: 100%; height: calc(100% - 40px); display: block; object-fit: cover;
  object-position: 50% 66%; opacity: 0; transition: opacity .45s ease;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent); }
.exec-bg img.on { opacity: 1; }
.exec-bg .scrim { position: absolute; left: 0; right: 0; bottom: 0; height: 34%; pointer-events: none;
  background: linear-gradient(to bottom, rgba(8, 20, 66, 0), rgba(8, 20, 66, .5)); }
.exec.no-pic .scrim { display: none; }
.exec-head-row { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; justify-content: flex-end; flex-wrap: wrap; }
.state-pill {
  display: inline-flex; align-items: center; gap: 10px; max-width: 100%;
  background: var(--dark); color: var(--dark-text); border-radius: 999px; padding: 11px 18px; font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}
.state-pill .phrase { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: opacity .3s; }
.state-pill .phrase.fade { opacity: 0; }
.eta-line { font-size: 13px; padding: 5px 11px; border-radius: 999px; background: var(--solid); color: var(--text); }
.toggle { background: var(--dark); color: var(--dark-text); }
/* The whole round button turns, not the icon inside it: the disc and the chevron then share one
   layer while it animates, so the chevron cannot be left a pixel off the disc's centre. */
.exec[aria-expanded="true"] .toggle, .rcard.open .toggle { transform: rotate(180deg); }
.toggle { transition: transform .25s; }
.icon { width: 18px; height: 18px; flex: none; display: inline-grid; place-items: center; }
.icon.spin { border: 2.5px solid rgba(255, 255, 255, .3); border-top-color: #fff; border-radius: 50%; animation: spin 0.9s linear infinite; }
.icon.check svg { stroke: var(--ok); stroke-width: 3; width: 18px; height: 18px; }
.icon.warn svg { stroke: var(--warn); stroke-width: 2.4; width: 18px; height: 18px; }
.icon.wait svg { stroke: currentColor; fill: none; stroke-width: 2.2; width: 18px; height: 18px; }
@keyframes spin { to { transform: rotate(360deg); } }
.line { position: absolute; left: 24px; right: 24px; bottom: 4px; height: 3px; border-radius: 2px; background: rgba(127, 127, 127, .25); overflow: hidden; }
.line > div { height: 100%; width: 0; background: var(--accent); transition: width .5s; }

.exec-body { padding: 4px 18px 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.exec-body .panel, .rbody > * { min-width: 0; }
.exec-body .panel { background: var(--solid); border-radius: 18px; padding: 14px 16px; }
.now-phrase { margin: 0 0 8px; font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: rgba(127, 127, 127, .25); overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .5s; }
.times { margin: 8px 0 0; font-size: 13px; color: var(--quiet); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 7px 4px; }
.steps .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--quiet); flex: none; opacity: .6; }
.steps .st { margin-left: auto; font-size: 13px; color: var(--quiet); white-space: nowrap; }
.steps li.running .dot { border-color: var(--warn); background: var(--warn); opacity: 1; animation: pulse 1.2s infinite; }
.steps li.done .dot { border-color: var(--ok); background: var(--ok); opacity: 1; }
.steps li.failed .dot { border-color: var(--fail); background: var(--fail); opacity: 1; }
.steps li.needs_user .dot { border-color: var(--warn); opacity: 1; }
.steps li.skipped { color: var(--quiet); }
.steps li.skipped .dot { border-style: dashed; }
.steps .msgline { display: block; font-size: 13px; color: var(--quiet); }
/* The fixing sub-steps under "Fixing a problem in" (server work.steps) and the amber "stuck" note. */
.fix-steps { margin: 0 0 10px; font-size: 14px; }
.fix-steps li { padding: 5px 4px; align-items: flex-start; }
.fix-steps li > span:nth-child(2) { min-width: 0; overflow-wrap: anywhere; }
.fix-steps .dot { margin-top: 3px; }
.fix-steps .st { padding-left: 8px; }
.steps li.warned .dot { border-color: var(--warn); background: transparent; opacity: 1; }
.fix-steps li.needs_user .dot { background: var(--warn); }
.stuck-note { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 8px 12px; border-radius: 12px;
  font-weight: 600; font-size: 14px; background: rgba(224, 164, 58, .16); border-left: 3px solid var(--warn); }
.stuck-note svg { stroke: var(--warn); stroke-width: 2.4; width: 18px; height: 18px; flex: none; fill: none; }
@keyframes pulse { 50% { opacity: .35; } }
.big-preview img { width: 100%; border-radius: 14px; background: #fff; display: block; }
.big-preview .cap { margin: 8px 0 0; font-size: 13px; color: var(--quiet); }
.strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.strip button { flex: none; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; border: 2px solid transparent; background: #fff; padding: 0; }
.strip button.on { border-color: var(--accent); }
.strip img { width: 100%; height: 100%; object-fit: cover; }
.strip .tab { display: grid; place-items: center; font-size: 11px; color: #333; }
table.data { border-collapse: collapse; font-size: 13px; width: 100%; display: block; overflow-x: auto; }
table.data th, table.data td { border-bottom: 1px solid rgba(127, 127, 127, .25); padding: 5px 8px; text-align: left; white-space: nowrap; }
table.data td.pass { color: var(--accent); font-weight: 600; }
table.data td.fail { color: var(--fail); font-weight: 600; }
table.data.edits td.detail { white-space: normal; min-width: 14em; }

.question { margin: 0 14px 14px; background: var(--solid); border-radius: 18px; padding: 14px 16px; display: grid; gap: 10px; }
.question .q-text { margin: 0; font-weight: 600; }
.question .row { display: flex; gap: 8px; flex-wrap: wrap; }
.question .detail, .exec .detail { margin: 0; color: var(--quiet); font-size: 13px; }
/* The question as a short list with its answer field (renderQuestion). */
.question .q-lead { margin: 0; font-weight: 600; }
.question .q-items { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; }
.question ol.q-items .q-item { padding-left: 1.6em; }
.question .q-item { display: grid; gap: 6px; justify-items: start; position: relative; }
.question .q-item-text { margin: 0; line-height: 1.4; }
.question .q-num { position: absolute; left: 0; font-weight: 600; }
.question .q-choices { display: flex; gap: 6px; flex-wrap: wrap; }
.question .btn-soft.small, .question .btn-dark.small { padding: 6px 13px; font-size: 13px; }
.question .q-choice[aria-pressed="true"] { background: var(--dark); color: var(--dark-text); border-color: var(--dark); }
.question .q-more { padding: 2px 0; font-size: 12.5px; color: var(--quiet); text-decoration: underline;
  text-underline-offset: 2px; }
.question .q-more:hover { color: var(--text); }
.question .q-answer { display: flex; gap: 8px; align-items: center; }
.question .q-input { flex: 1; min-width: 0; height: 40px; border-radius: 999px; padding: 0 14px; background: transparent;
  border: 1px solid rgba(127, 127, 127, .45); outline: none; }
.question .q-input:focus-visible { border-color: var(--text); }
.question .q-input::placeholder { color: var(--quiet); }
.question .q-attach { width: 40px; height: 40px; flex: none; }
.question .q-send { flex: none; height: 40px; }
.question .q-send:disabled { opacity: .45; cursor: default; }
.question .q-files { display: flex; flex-wrap: wrap; gap: 6px; }
.question .q-files:empty, .question .q-msg:empty { display: none; }
.question .q-file { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; border: 1px solid rgba(127, 127, 127, .35); }
.question .q-file.refused { color: var(--fail); }
@media (max-width: 520px) {
  .question { padding: 12px 13px; }
  .question ol.q-items .q-item { padding-left: 1.3em; }
  .question .q-choices .btn-soft.small { padding: 6px 10px; font-size: 12.5px; }
}
.question .q-admin { margin: 0; font-size: 12px; color: var(--quiet); border: 1px dashed currentColor; border-radius: 8px;
  padding: 3px 8px; opacity: .85; word-break: break-word; }

/* Result card */
.rcard { width: min(420px, 100%); border-radius: var(--r-card); padding: 10px; align-self: flex-start; background: var(--solid); box-shadow: var(--shadow); overflow: hidden; }
.rcard.open { width: 100%; }
.rcard.open .pic { max-width: 420px; }
.rcard .pic { border-radius: 18px; overflow: hidden; background: rgba(127, 127, 127, .12); aspect-ratio: 16 / 10; }
.rcard .pic img { width: 100%; height: 100%; object-fit: contain; background: #fff; display: block; }
.rcard .rhead { display: flex; align-items: flex-start; gap: 10px; padding: 12px 8px 6px; cursor: pointer; }
.rcard h3 { margin: 0; font-family: var(--serif); font-size: 22px; line-height: 1.2; overflow-wrap: anywhere; }
.rcard .rline { margin: 4px 0 0; color: var(--quiet); font-size: 14px; }
.rcard .rhead .toggle { margin-left: auto; }
.rbody { padding: 6px 8px 8px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.rbody h4 { margin: 0 0 6px; font-size: 14px; }
.rbody ul { margin: 0; padding-left: 18px; }
.rbody li { margin: 3px 0; }
.rbody .detail { display: block; color: var(--quiet); font-size: 13px; }
.downloads { display: flex; flex-wrap: wrap; gap: 8px; }
.downloads a { text-decoration: none; color: var(--text); background: rgba(127, 127, 127, .14); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.actions { display: grid; gap: 8px; }
.actions textarea { border: 1px solid rgba(127, 127, 127, .35); border-radius: 14px; padding: 10px 12px; background: transparent; resize: vertical; }
.actions .row { display: flex; gap: 8px; flex-wrap: wrap; }
.published { font-weight: 700; color: var(--accent); margin: 0; }
.viewer-card { width: 100%; border-radius: 14px; display: block; margin-bottom: 6px; }
.fit { border-left: 3px solid var(--warn); padding-left: 10px; }
.rcard.grid-card { width: auto; align-self: stretch; }

/* Garments tab */
.garments { width: min(1040px, 100% - 32px); margin: 0 auto; padding: 88px 0 60px; }
.garments h2 { margin: 0 0 16px; font-size: 26px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; align-items: start; }
.note { border-radius: 18px; padding: 14px 18px; }

/* Composer */
.composer { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 15; width: min(var(--col), 100% - 24px); }
.cbar { display: flex; align-items: flex-end; gap: 6px; border-radius: 30px; padding: 7px; background: var(--solid); }
.cbar textarea { flex: 1; border: 0; background: none; outline: none; resize: none; padding: 11px 6px; max-height: 180px; line-height: 1.4; }
.cbar textarea::placeholder { color: var(--quiet); }
.plain { color: var(--text); }
.plain:hover { background: rgba(127, 127, 127, .15); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--solid); border-radius: 999px; padding: 4px 6px 4px 4px; font-size: 13px; max-width: 100%; box-shadow: var(--shadow); }
.chip img, .chip .kind { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; }
.chip .kind { display: grid; place-items: center; background: rgba(127, 127, 127, .2); font-size: 10px; text-transform: uppercase; }
.chip .kind.spin { border: 2.5px solid rgba(127, 127, 127, .3); border-top-color: var(--accent); animation: spin .9s linear infinite; background: none; }
.chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.chip.refused { color: var(--fail); }
.chip.refused .name { white-space: normal; max-width: 420px; }
.chip button { width: 24px; height: 24px; border-radius: 50%; color: var(--quiet); }
.jump { position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 16; }
.drop { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(40, 70, 110, .25); border: 3px dashed var(--accent); pointer-events: none; }
.drop p { padding: 16px 26px; border-radius: 999px; font-weight: 700; }

/* Narrower screens: the search folds into its icon so the centred switch keeps its room. */
@media (max-width: 820px) {
  .search { width: 44px; padding: 0; justify-content: center; }
  .search input { width: 0; padding: 0; }
  .search:focus-within { width: 170px; padding: 0 12px; position: absolute; right: 72px; z-index: 2; }
  .search:focus-within input { width: 120px; }
}

/* Small screens: icons only, full-width cards; the top bar is one flex row (mark, switch, buttons). */
@media (max-width: 640px) {
  .topbar { padding: 10px; gap: 6px; }
  .switch { position: static; transform: none; }
  .switch button { padding: 8px 14px; }
  .right { gap: 6px; }
  .topbar .home, .topbar .new-chat, .topbar .search, .topbar .avatar { width: 40px; height: 40px; }
  .topbar .search:focus-within { width: 170px; right: 56px; }
  .column { width: calc(100% - 20px); padding-top: 76px; }
  .msg { max-width: 92%; }
  .rcard { width: 100%; }
  .state-pill { padding: 10px 14px; }
  /* The box: a squarer frame keeps the character large; the expand button moves to the empty sky
     at the top right so the pill has the whole bottom row and never covers the face. */
  .exec.scene .exec-head { aspect-ratio: 4 / 3; max-height: none; }
  .exec-head-row { position: static; justify-content: flex-start; }
  .exec-head-row > * { position: relative; }
  .exec-head-row > .toggle { position: absolute; top: 20px; right: 20px; }
  .state-pill { font-size: 14px; }
  .state-pill .phrase { white-space: normal; line-height: 1.25; }
}
@media (max-width: 380px) {
  .switch button { padding: 8px 10px; font-size: 14px; }
  .round { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .icon.spin { border-top-color: rgba(255, 255, 255, .3); background: #fff; width: 10px; height: 10px; }
}
.job-slot, .rcard { scroll-margin-top: 76px; }
.table-holder, .big-preview > div:first-child { max-height: 380px; overflow: auto; }

/* The character: every scene is painted on deep cobalt, so it always sits in its own
   rounded frame (its blue is the frame) rather than blending into the page. */
.char-frame { border-radius: 18px; overflow: hidden; background: #1d4bb0; line-height: 0; }
.char-frame img { width: 100%; display: block; object-fit: cover; }
.welcome { border-radius: var(--r-card); padding: 10px; display: grid; gap: 12px; box-shadow: var(--shadow); }
.welcome .char-frame img { max-height: 260px; object-position: center 72%; }
.welcome-line { margin: 4px 8px 0; font-size: 17px; }
.prompts { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 8px 8px; }
.prompt { background: rgba(127, 127, 127, .14); border-radius: 999px; padding: 8px 14px; font-size: 14px; text-align: left; color: var(--text); }
.prompt:hover { background: rgba(127, 127, 127, .24); }
.empty-rail { max-width: 560px; border-radius: var(--r-card); padding: 10px; display: grid; gap: 10px; box-shadow: var(--shadow); }
.empty-rail .char-frame img { max-height: 300px; }
.empty-rail p { margin: 4px 8px 8px; }
.rcard .pic.char-frame img { object-fit: cover; background: #1d4bb0; }
.published { display: flex; align-items: center; gap: 8px; }
.published .mark { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
@media (max-width: 640px) {
  .welcome .char-frame img { max-height: 170px; }
  .hero img { max-height: 34vh; }
}

/* Brand: the 3D viewer's own lockup (K mark + the name in weight 650); the mark is inverted on dark. */
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: 0.2px; font-size: 17px;
  color: var(--text); text-decoration: none; }
.brand .mark { width: 26px; height: auto; display: block; flex: none; }
.home { height: 44px; padding: 0 16px 0 12px; border-radius: 999px; }
/* New chat: a labelled pill beside the search on wide screens, its icon alone on narrow ones. */
.new-chat { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 44px; padding: 0 16px 0 12px;
  border-radius: 999px; font-weight: 600; color: var(--text); line-height: 1; white-space: nowrap; }
.new-chat svg { display: block; flex: none; }
@media (max-width: 900px) {
  .new-chat { width: 44px; padding: 0; }
  .new-chat .label { display: none; }
}

/* Chats: the way back to the previous chat, and where you are while reading an earlier one. */
.chat-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chat-link { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
.chat-link.btn-dark { color: var(--dark-text); }
.chat-link svg { width: 18px; height: 18px; }
.chat-note { font-size: 14px; font-weight: 600; background: var(--solid); padding: 8px 14px; border-radius: 999px; }
.brand-large { font-size: 28px; gap: 12px; margin: 0 0 4px; }
.brand-large .mark { width: 40px; }
@media (prefers-color-scheme: dark) { .brand .mark { filter: invert(1); } }
@media (max-width: 900px) {
  .home { width: 44px; padding: 0; justify-content: center; }
  .home .brand-name { display: none; }
}

/* The 3D viewer, large inside the page; full screen on phones. */
.viewer-overlay { position: fixed; inset: 3vh 3vw; z-index: 50; display: flex; flex-direction: column; border-radius: 22px;
  overflow: hidden; box-shadow: 0 20px 80px rgba(0, 0, 0, .45); background: #9a9a9a; }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 18px; }
.viewer-title { font-weight: 650; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar a { color: var(--text); font-size: 14px; }
.viewer-frame { flex: 1; width: 100%; border: 0; background: #9a9a9a; }
@media (max-width: 640px) { .viewer-overlay { inset: 0; border-radius: 0; } }
.msg-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.viewer-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.viewer-actions a { color: var(--text); font-size: 14px; }

/* Finished one-size job: the quiet grading prompt inside the card. */
.grading-note { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 14px 12px;
  padding: 10px 12px; border-radius: 14px; background: var(--solid); border: 1px dashed var(--glass-line);
  color: var(--text); font-size: 14px; line-height: 1.4; }
.grading-note p { margin: 0; flex: 1 1 240px; }
.grading-note .small { padding: 6px 12px; font-size: 13px; }
.grid-card .grading-note { margin: 0 10px 10px; padding: 8px 10px; font-size: 13px; }

/* Sketch-and-photo check inside the result card. */
.review .review-state { margin: 0 0 10px; font-weight: 600; }
.review-blocked .review-state, .review-unchecked .review-state { color: var(--text); }
.review .mismatches { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.review .mismatch { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 12px; align-items: start;
  padding: 10px; border-radius: 14px; background: var(--solid); border: 1px solid var(--glass-line); }
.review .mismatch.accepted { opacity: .75; }
.review .mismatch figure { margin: 0; }
.review .mismatch img { width: 100%; height: auto; max-height: 220px; object-fit: contain; border-radius: 10px;
  background: #fff; cursor: zoom-in; display: block; }
.review .mm-text p { margin: 0 0 6px; }
.review .mm-name { font-weight: 650; }
.review .mismatch .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.review .badge.ok { background: var(--accent); color: #fff; }
.review .cannot-tell { margin-top: 10px; color: var(--quiet); font-size: 13px; }
.review .cannot-tell ul { margin: 6px 0 0; padding-left: 18px; }
@media (max-width: 560px) { .review .mismatch { grid-template-columns: 1fr; } }

/* ---- Steps that have not run yet: a quiet, static hollow dot (never a spinner or a dashed ring). The words come
   lower-case from the server and the page ("up next", "waiting", "not reached") and are sentence-cased here. */
.steps .st::first-letter { text-transform: uppercase; }
.steps li.waiting .dot { opacity: .45; animation: none; }
.steps li.waiting.next .dot { opacity: .85; border-color: var(--text); }
.steps li.waiting.next .st { color: var(--text); }
.steps li.notreached { color: var(--quiet); }
.steps li.notreached .dot { opacity: .3; }

/* ---- Alive picture: while the studio is really working on a job (.exec.alive) the character breathes, a warm glow
   drifts low in the scene, a slow light sweep passes and a few wool wisps rise at the sides, away from the face
   (35-45 % of the height) and the pill (on the floor band under the picture). Transform and opacity only, inside
   the picture's own clipped frame: no layout shift. The welcome picture idles the same way. Calm otherwise. */
.alive-layer { position: absolute; left: 0; top: 0; width: 100%; height: calc(100% - 40px); pointer-events: none;
  overflow: hidden; opacity: 0; transition: opacity .8s ease; }
.welcome .char-frame { position: relative; }
.welcome .alive-layer { height: 100%; }
.exec.alive .alive-layer, .welcome .alive-layer { opacity: 1; }
.exec.alive .exec-bg img { transform-origin: 50% 88%; animation: breathe 6.5s ease-in-out infinite; will-change: transform; }
.welcome .char-frame img { transform-origin: 50% 90%; animation: breathe 8s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-0.7%) scale(1.02); } }
.alive-layer .glow { position: absolute; left: 20%; top: 52%; width: 60%; height: 60%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 214, 150, .34), rgba(255, 214, 150, 0));
  animation: glow-drift 9s ease-in-out infinite; }
@keyframes glow-drift { 0%, 100% { transform: translate(-6%, 2%) scale(.92); opacity: .55; }
  50% { transform: translate(6%, -3%) scale(1.06); opacity: 1; } }
.alive-layer .sweep { position: absolute; top: -15%; height: 130%; left: -40%; width: 40%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .12), rgba(255, 255, 255, 0));
  opacity: 0; animation: sweep 8s ease-in-out infinite; }
@keyframes sweep { 0%, 25% { transform: translateX(0); opacity: 0; } 45% { opacity: 1; } 80%, 100% { transform: translateX(350%); opacity: 0; } }
.alive-layer .wisp { position: absolute; bottom: 4%; width: 12px; height: 12px; border-radius: 50%; opacity: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, .95) 0, rgba(255, 255, 255, .5) 35%, rgba(255, 255, 255, 0) 70%);
  animation: wisp 7s ease-in-out infinite; }
.alive-layer .w1 { left: 12%; }
.alive-layer .w2 { left: 21%; width: 8px; height: 8px; animation-duration: 8.5s; animation-delay: -3s; }
.alive-layer .w3 { right: 13%; animation-duration: 7.6s; animation-delay: -1.6s; }
.alive-layer .w4 { right: 22%; width: 9px; height: 9px; animation-duration: 9.2s; animation-delay: -5.2s; }
.alive-layer .w5 { left: 6%; width: 7px; height: 7px; animation-duration: 10s; animation-delay: -6.4s; }
@keyframes wisp { 0% { transform: translate(0, 0) scale(.5); opacity: 0; } 18% { opacity: .9; }
  55% { transform: translate(10px, -70px) scale(1); opacity: .7; } 100% { transform: translate(-6px, -140px) scale(.7); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .alive-layer { display: none; }
  .exec.alive .exec-bg img, .welcome .char-frame img { transform: none; will-change: auto; }
}

/* ---- Chats drawer (opened from the Kloth Factory lockup): every chat, newest first, with its garments. An
   overlay from the left on every width; Esc, the close button or a click outside closes it. */
.drawer-caret { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; opacity: .7; }
.drawer-scrim { position: fixed; inset: 0; z-index: 50; background: rgba(8, 20, 66, .32); }
.drawer { position: fixed; z-index: 51; top: 0; left: 0; bottom: 0; width: min(360px, 88vw); display: flex; flex-direction: column;
  gap: 12px; padding: 16px 14px; border-radius: 0 var(--r-card) var(--r-card) 0; box-shadow: 0 10px 40px rgba(0, 0, 0, .28);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); animation: drawer-in .22s ease-out; }
.drawer[hidden], .drawer-scrim[hidden] { display: none; }
@keyframes drawer-in { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 0 6px; }
.drawer-head h2 { margin: 0; font-size: 20px; }
.drawer-head svg, .drawer-new svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.drawer-new { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.chat-list { list-style: none; margin: 0; padding: 0 2px 8px; overflow-y: auto; display: grid; gap: 6px; align-content: start; flex: 1; }
.chat-open { width: 100%; text-align: left; display: grid; gap: 6px; padding: 10px 12px; border-radius: 14px;
  background: transparent; color: inherit; border: 1px solid transparent; }
.chat-open:hover, .chat-open:focus-visible { background: rgba(127, 127, 127, .12); }
.chat-item.on .chat-open { background: rgba(127, 127, 127, .16); border-color: var(--glass-line); }
.chat-top { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.chat-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-date { font-size: 12px; color: var(--quiet); white-space: nowrap; }
.chat-jobs { display: grid; gap: 3px; }
.chat-job { display: flex; align-items: center; gap: 7px; font-size: 13px; min-width: 0; }
.chat-job .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--quiet); opacity: .7; }
.chat-job.st-running .dot, .chat-job.st-queued .dot, .chat-job.st-screening .dot, .chat-job.st-needs_user .dot, .chat-job.st-fixing .dot { background: var(--warn); opacity: 1; }
.chat-job.st-review .dot, .chat-job.st-published .dot, .chat-job.st-done .dot { background: var(--ok); opacity: 1; }
.chat-job.st-failed .dot { background: var(--fail); opacity: 1; }
.chat-job-title { flex: 1 1 auto; min-width: 4em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-job-st { flex: 0 1 auto; max-width: 58%; color: var(--quiet); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.chat-more, .chat-empty { font-size: 13px; color: var(--quiet); }
li.chat-empty { padding: 10px 12px; }
@media (max-width: 900px) { .drawer-caret { display: none; } }

/* ---- Coloured card picture (the textured garment on the model, on the scenes' blue): the frame takes the same
   blue so the 3:4 picture never shows white bars; in the Garments grid the frame itself is 3:4. */
.rcard .pic.colour { background: #1262b7; }
.rcard .pic.colour img { object-fit: contain; background: #1262b7; }
.rcard.grid-card .pic.colour { aspect-ratio: 3 / 4; }
@media (min-width: 641px) { .rcard.grid-card .pic { aspect-ratio: 3 / 4; } }   /* grid rows of even height */

/* ---- Rename a chat in the drawer: the pencil shows on hover or keyboard focus (on a phone, a long press on the
   chat starts the edit); the input sits over the title row while editing. */
.chat-item { position: relative; }
.chat-item .chat-rename { position: absolute; top: 5px; right: 6px; width: 32px; height: 32px; opacity: 0;
  transition: opacity .15s; }
.chat-item .chat-rename svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chat-item:hover .chat-rename, .chat-item:focus-within .chat-rename { opacity: 1; }
.chat-item:hover .chat-date, .chat-item:focus-within .chat-date { visibility: hidden; }   /* the pencil takes its place */
@media (hover: none) { .chat-item .chat-rename { display: none; } .chat-item:focus-within .chat-date { visibility: visible; } }
.chat-item.editing .chat-rename, .chat-item.editing .chat-top, .chat-item.editing .chat-top .chat-date { visibility: hidden; }
.chat-rename-input { position: absolute; top: 4px; left: 4px; right: 4px; height: 34px; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--accent); background: var(--solid); color: var(--text); font: inherit; font-weight: 600; }
.chat-rename-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.chat-rename-error { display: block; padding: 0 12px 8px; font-size: 12px; color: var(--fail); }

/* ---- Under the picture: why a stopped job stopped and when it last changed, and the team update (studio jobs
   note) with a soft working dot. Outside the picture so the character stays visible; text is set as text. */
.exec-notes { display: grid; gap: 6px; padding: 0 10px 12px; }
.exec-notes[hidden], .exec-sub[hidden], .team-line[hidden] { display: none; }
.exec-sub, .team-line { margin: 0; }
.exec-notes .note-chip { display: flex; align-items: flex-start; gap: 9px; padding: 9px 14px; border-radius: 14px;
  background: var(--solid); color: var(--text); font-size: 14px; line-height: 1.4; }
.exec-sub .note-chip { color: var(--quiet); }
.soft-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--accent); margin-top: 6px;
  animation: pulse 2.4s ease-in-out infinite; }
.icon.team::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ok);
  animation: pulse 2.4s ease-in-out infinite; }
.rcard .card-team { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0 0; font-size: 13px; color: var(--text); }

/* ---- Sending: a "thinking" bubble (three soft dots; still under reduced motion) until the reply, a failed send's
   bubble dimmed with a "Try again" line, per-file upload progress on the chips, an answered question collapsed. */
.msg.thinking { padding: 14px 18px; }
.msg.thinking .dots { display: inline-flex; gap: 6px; align-items: center; height: 10px; }
.msg.thinking .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--quiet); opacity: .6;
  animation: think 1.2s ease-in-out infinite; }
.msg.thinking .dot:nth-child(2) { animation-delay: .2s; }
.msg.thinking .dot:nth-child(3) { animation-delay: .4s; }
@keyframes think { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.msg.user.failed { opacity: .6; }
.retry-line { align-self: flex-end; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--fail);
  background: var(--solid); padding: 6px 8px 6px 14px; border-radius: 999px; }
.retry-line .btn-soft { padding: 5px 12px; font-size: 13px; }
.chip.uploading { background-image: linear-gradient(to right, rgba(127, 196, 169, .28) var(--p, 0%), transparent var(--p, 0%)); }
.chip .pct { font-size: 12px; color: var(--quiet); font-variant-numeric: tabular-nums; padding-right: 6px; }
.question.answered { padding-top: 10px; padding-bottom: 10px; }
.q-answered { margin: 0; font-size: 14px; color: var(--quiet); }

/* Admins only: the real cause beside the customer's words (the server sends admin_line to admins alone). */
.exec-sub .note-chip.admin-line { font-size: 12px; color: var(--quiet); border: 1px dashed currentColor; opacity: .85;
  word-break: break-word; }
