/* look-busy
   Outer shell: graph-paper notebook, pale green ruling.
   The console below is the dark tool and is separate from the paper. */

@font-face {
  font-family: "Patrick Hand";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/patrick-hand-400.woff2") format("woff2");
}

@font-face {
  font-family: "Patrick Hand";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/patrick-hand-500.woff2") format("woff2");
}

@font-face {
  font-family: "LXGW WenKai";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/lxgw-wenkai-400.woff2") format("woff2");
}

@font-face {
  font-family: "LXGW WenKai";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/lxgw-wenkai-500.woff2") format("woff2");
}

:root {
  --cell: 22px;
  --cell-px: 22;
  --cols: 39;

  --paper: #fdfcf9;
  --ink: #1a1a1a;
  --ink-2: rgba(26, 26, 26, 0.56);

  /* look-busy's ruling is pale green. Other tools in the series use their own colour. */
  --rule-green: rgba(45, 155, 95, 0.25);
  --rule: var(--rule-green);
  --hair: 1px;

  /* Latin is Patrick Hand. CJK is LXGW WenKai, which includes kana.
     No generic family before WenKai: a generic can resolve to another CJK face and steal the glyphs. */
  --type: "Patrick Hand";
  --type-cjk: "LXGW WenKai";

  --sans: "IBM Plex Sans", Inter, "Segoe UI", "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, monospace;
  --accent: #ffb15a;
  --accent-2: #ff7a59;

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .2 0 0 0 0 .18 0 0 0 0 .12 0 0 0 -1.3 .8'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
  color-scheme: light;
}

@media (min-resolution: 2dppx) {
  :root {
    --hair: 0.5px;
    --rule-green: rgba(45, 155, 95, 0.44);
  }
}

html[lang="ja"] {
  --sans: "Noto Sans CJK JP", "Hiragino Sans", "Yu Gothic", sans-serif;
}

html[lang="zh-Hans"] {
  --sans: "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--type), var(--type-cjk);
  font-weight: 400;
  font-size: calc(var(--cell) / 1.2);
  letter-spacing: normal;
  line-height: var(--cell);
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, var(--rule) var(--hair), transparent var(--hair)),
    linear-gradient(to bottom, var(--rule) var(--hair), transparent var(--hair)),
    var(--grain);
  background-size: var(--cell) var(--cell), var(--cell) var(--cell), 220px 220px;
  background-position: center top, center top, 0 0;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--ink); color: var(--paper); }

p { margin: 0; }

.page {
  width: calc(var(--cell) * var(--cols));
  max-width: 100%;
  margin: 0 auto;
  padding: calc(var(--cell) * 3) 0;
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--cell) * 2);
}

.title {
  display: flex;
  align-items: center;
  gap: calc(var(--cell) / 2);
}

.plug {
  display: block;
  width: calc(var(--cell) * 2);
  height: auto;
  color: var(--ink);
}

h1 {
  margin: 0;
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
}

.lang,
.segments button,
.primary,
.ghost {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font: inherit;
  line-height: var(--cell);
  cursor: pointer;
}

.lang-switch {
  display: flex;
  gap: calc(var(--cell) / 2);
}

.lang {
  color: var(--ink-2);
  white-space: nowrap;
}

.lang::before { content: "["; visibility: hidden; color: var(--ink); }
.lang::after { content: "]"; visibility: hidden; color: var(--ink); }
.lang.is-on { color: var(--ink); }
.lang.is-on::before,
.lang.is-on::after { visibility: visible; }
.lang:hover { color: var(--ink); }

.tagline {
  margin-top: calc(var(--cell) * 2);
  font-size: calc(var(--cell) / 0.6);
  line-height: calc(var(--cell) * 2);
}

html[lang="ja"] .tagline,
html[lang="zh-Hans"] .tagline {
  font-size: calc(var(--cell) * 2 - 8px);
  font-weight: 500;
  letter-spacing: normal;
}

.controls { margin-top: calc(var(--cell) * 2); }

.scene-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.segments {
  display: flex;
  flex-wrap: wrap;
  column-gap: calc(var(--cell) * 2);
}

.segments button {
  color: var(--ink-2);
  text-align: left;
  white-space: nowrap;
}

.segments button::before {
  content: "[\2002]";
  display: inline-block;
  min-width: 1.85em;
  margin-right: 0.35em;
  color: var(--ink);
  letter-spacing: normal;
  text-align: center;
  white-space: pre;
}

.segments button.is-on { color: var(--ink); }
.segments button.is-on::before { content: "[x]"; letter-spacing: normal; }
.segments button:hover { color: var(--ink); }

.go-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  column-gap: calc(var(--cell) * 2);
  margin-top: calc(var(--cell) * 2);
}

.primary {
  height: calc(var(--cell) * 2);
  padding: calc(var(--cell) / 2) var(--cell);
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  text-transform: uppercase;
}

.primary::before { content: "[ "; font-weight: 400; white-space: pre; }
.primary::after { content: " ]"; font-weight: 400; white-space: pre; }
.primary:hover { background: #000; }

.hint {
  color: var(--ink-2);
  font-size: 0.82em;
  font-style: italic;
}

html[lang="ja"] .hint,
html[lang="zh-Hans"] .hint { font-style: normal; }

.stage { margin-top: calc(var(--cell) * 2); }

/* ---------- console ---------- */

.tool {
  --accent: #ffb15a;
  --accent-2: #ff7a59;
  display: flex;
  flex-direction: column;
  min-height: 36rem;
  border: 1px solid #1c2430;
  border-radius: 3px;
  background: #0c0f14;
  color: #e7edf4;
  box-shadow: none;
  overflow: hidden;
  color-scheme: dark;
  font-family: var(--sans);
}

.tool[data-scene="train"] { --accent: #3ddc97; --accent-2: #1aa37a; }
.tool[data-scene="export"] { --accent: #7cbcff; --accent-2: #3b82f6; }
.tool[data-scene="build"] { --accent: #b6f5a8; --accent-2: #5dbe52; }

.tool-bar {
  display: grid;
  grid-template-columns: minmax(5.5rem, auto) minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 3rem;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid #222a36;
  background: #12171e;
}

.tool-id {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

html[lang="ja"] .tool-id,
html[lang="zh-Hans"] .tool-id { letter-spacing: 0.06em; }

.live-dot,
.hud-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #ff5d5d;
  box-shadow: 0 0 0 0 rgba(255, 93, 93, 0.6);
  animation: pulse 1.6s ease-out infinite;
}

.tool-project {
  overflow: hidden;
  color: #93a0b0;
  font-family: var(--mono);
  font-size: 0.82rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-pct {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.tool-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 0.85rem 0.9rem 0.75rem;
}

.scene { min-width: 0; }

.preview {
  position: relative;
  height: 15.5rem;
  border-radius: 8px;
  overflow: hidden;
  background: #07080c;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.preview-art {
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(ellipse at 28% 38%, rgba(255, 176, 92, 0.95), transparent 42%),
    radial-gradient(ellipse at 74% 62%, rgba(88, 142, 255, 0.8), transparent 46%),
    radial-gradient(ellipse at 48% 78%, rgba(255, 92, 140, 0.38), transparent 36%),
    linear-gradient(160deg, #1a2030, #090b10 70%);
  background-size: 140% 140%;
  background-position: 30% 40%;
}

.preview-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(0, 0, 0, 0.45), transparent 36%),
    radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.38) 100%);
  pointer-events: none;
}

.preview-shade::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 18%;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.07), transparent);
  animation: scan 3.6s linear infinite;
}

.hud,
.hud-frame {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  display: flex;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.88);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.hud { top: 0.65rem; }
.hud-frame { bottom: 0.65rem; left: 0.75rem; right: auto; }

.hud-rec {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.filmstrip {
  position: relative;
  margin-top: 0.65rem;
  padding: 0.15rem 0;
}

.film-row {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 0.28rem;
}

.thumb {
  aspect-ratio: 16 / 10;
  border-radius: 3px;
  opacity: 0.38;
}

.thumb.is-past { opacity: 1; }
.thumb.is-now { outline: 1px solid #fff; opacity: 1; }

.playhead {
  position: absolute;
  top: -0.15rem;
  bottom: -0.15rem;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  transform: translateX(-1px);
  pointer-events: none;
}

.meta,
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.k,
.batches th {
  margin: 0;
  color: #93a0b0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

html[lang="ja"] .k,
html[lang="zh-Hans"] .k,
html[lang="ja"] .batches th,
html[lang="zh-Hans"] .batches th {
  letter-spacing: 0.04em;
  text-transform: none;
}

.k { display: block; }

.v {
  display: block;
  margin-top: 0.12rem;
  color: #f2f6fb;
  font-family: var(--mono);
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.chart {
  display: block;
  width: 100%;
  height: 11.5rem;
  margin-top: 0.85rem;
  border-radius: 8px;
  background: #090c11;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.subline {
  margin: 0.7rem 0 0;
  color: #93a0b0;
  font-family: var(--mono);
  font-size: 0.82rem;
}

.meter {
  height: 6px;
  margin-top: 0.85rem;
  border-radius: 99px;
  background: #1c2430;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

.batches {
  width: 100%;
  margin-top: 0.75rem;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.batches th {
  padding: 0.35rem 0.2rem;
  text-align: left;
}

.batches td {
  padding: 0.38rem 0.2rem;
  border-top: 1px solid #222a36;
  color: #c5d0dc;
  font-family: var(--mono);
  font-size: 0.86rem;
}

.batches tr.is-hot td { color: var(--accent); }

.prompt {
  margin: 0;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.92rem;
}

.status-block { order: 2; margin-top: 0.9rem; }
.log { order: 3; }
.scene { order: 1; }

.bar {
  height: 8px;
  border-radius: 99px;
  background: #1c2430;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 45%, transparent);
}

.status-line {
  margin: 0.5rem 0 0;
  min-height: 1.35em;
  color: #e7edf4;
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.log {
  height: 9.4rem;
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.65rem;
  list-style: none;
  border-radius: 8px;
  background: #090c10;
  overflow: hidden;
}

.log li {
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr);
  gap: 0.55rem;
  color: #c5d0dc;
  font-size: 0.8rem;
  line-height: 1.55;
}

.log-time {
  color: #7f8b9c;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.log-msg { overflow-wrap: anywhere; }

.tool[data-scene="build"] .tool-main { background: #070908; }
.tool[data-scene="build"] .status-line,
.tool[data-scene="build"] .log,
.tool[data-scene="build"] .subline,
.tool[data-scene="build"] .prompt { color: #c9f5cf; }
.tool[data-scene="build"] .log {
  flex: 1;
  height: auto;
  min-height: 14rem;
  margin-top: 0.35rem;
  padding-right: 0;
  padding-left: 0;
  order: 2;
  background: transparent;
}
.tool[data-scene="build"] .log-time { color: #6f8f74; }
.tool[data-scene="build"] .log-msg { color: #d7ffe0; }
.tool[data-scene="build"] .status-block { order: 3; }
.tool[data-scene="build"] .bar { background: #16301a; }

/* ---------- share and signature ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--cell);
  margin-top: var(--cell);
}

.ghost {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

.ghost:hover { text-decoration-thickness: 2px; }

.copy-status {
  color: var(--ink-2);
  font-style: italic;
}

.copy-status:empty { display: none; }

html[lang="ja"] .copy-status,
html[lang="zh-Hans"] .copy-status { font-style: normal; }

.site-footer {
  margin-top: calc(var(--cell) * 3);
  text-align: right;
}

.site-footer a {
  color: var(--ink-2);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.tool :focus-visible { outline-color: var(--accent); }

.stage:fullscreen,
.stage:-webkit-full-screen {
  display: flex;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 1.1rem 1.25rem;
  background: #07090d;
}

.stage:fullscreen .tool,
.stage:-webkit-full-screen .tool {
  flex: 1;
  width: 100%;
  min-height: 0;
  height: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.stage:fullscreen .preview,
.stage:-webkit-full-screen .preview {
  flex: 1;
  height: auto;
  min-height: 12rem;
}

.stage:fullscreen .scene-video,
.stage:-webkit-full-screen .scene-video {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.stage:fullscreen .log,
.stage:-webkit-full-screen .log { height: 11rem; }

.stage:fullscreen .tool[data-scene="build"] .log,
.stage:-webkit-full-screen .tool[data-scene="build"] .log { height: auto; }

body.is-card .head,
body.is-card .controls,
body.is-card .actions,
body.is-card .site-footer { display: none; }

body.is-card .page {
  width: min(1080px, calc(100% - 44px));
  padding: var(--cell) 0 0;
}

body.is-card .tagline { margin-top: 0; }
body.is-card .stage { margin-top: var(--cell); padding-bottom: 0 !important; }

body.is-card .tool {
  min-height: 0;
  height: 528px;
}

body.is-card .preview { height: 138px; }
body.is-card .log {
  height: auto;
  min-height: 0;
  flex-shrink: 0;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 93, 93, 0.55); }
  100% { box-shadow: 0 0 0 8px rgba(255, 93, 93, 0); }
}

@keyframes scan {
  0% { top: -20%; }
  100% { top: 110%; }
}

@media (max-width: 720px) {
  body { background-position: 0 0, 0 0, 0 0; }

  .page {
    width: auto;
    margin: 0 var(--cell);
    padding-top: calc(var(--cell) * 2);
  }

  .tagline { font-size: calc(var(--cell) / 0.6 * 2 / 3); }

  html[lang="ja"] .tagline,
  html[lang="zh-Hans"] .tagline {
    font-size: calc(var(--cell) - 4px);
    font-weight: 500;
    letter-spacing: normal;
    line-height: calc(var(--cell) * 2);
  }

  .head {
    flex-direction: column;
    align-items: flex-start;
    height: auto;
    row-gap: var(--cell);
  }

  .controls { container-type: inline-size; }

  .segments {
    display: grid;
    grid-template-columns: calc(var(--cell) * 9) max-content;
    column-gap: 0;
  }

  /* Japanese labels are wider than nine squares plus a second column. */
  html[lang="ja"] .segments {
    grid-template-columns: max-content max-content;
    column-gap: calc(var(--cell) / 2);
  }

  @container (max-width: 336px) {
    .segments,
    html[lang="ja"] .segments {
      grid-template-columns: max-content;
      column-gap: 0;
    }
  }

  .go-row { row-gap: var(--cell); }
  .tool { min-height: 0; }
  .preview { height: 10.5rem; }
  .meta,
  .stats,
  .stats-3 { grid-template-columns: 1fr 1fr; gap: 0.65rem 0.8rem; }
  .log { height: 8.2rem; }
  .tool[data-scene="build"] .log { min-height: 11rem; }
  .tool-pct { font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .live-dot,
  .hud-dot,
  .preview-shade::after { animation: none; }
}

[hidden] { display: none !important; }
