@font-face {
  font-family: "Archivo";
  src: url("archivo-ui.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
}
:root {
  color-scheme: light;
  --ink: #16212b;
  --muted: #5a6b79;
  --rule: #e3e8ef;
  --matte: #f5f7fb;
  --accent: #3f67e6;
  --accent-deep: #2443a8;
  --cyan: #59b8d7;
  --brand-grad: linear-gradient(100deg, var(--accent) 0%, #5268d8 52%, var(--cyan) 100%);
  --gutter: clamp(18px, 5vw, 72px);
  --note-size: .875rem;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: "Archivo", -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink);
  background: #fff;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body, h1, h2, p, pre { margin: 0; }
body { min-height: 100svh; }
button, input { font: inherit; color: inherit; }
button { border: 0; background: transparent; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: rgba(63, 103, 230, .16); }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.site-head {
  color: #f4f7fc;
  background: linear-gradient(105deg, #121b32 0%, #192442 55%, #203e52 100%);
  border-bottom: 1px solid #324b61;
}
.site-head :focus-visible { outline-color: #7be2f6; }
.head-inner, .workspace {
  width: min(calc(100% - 2 * var(--gutter)), 1200px);
  margin-inline: auto;
}
.head-inner, .brand, .service-state, .head-actions, .button, .text-button {
  display: flex; align-items: center;
}
.head-inner { min-height: 64px; gap: 20px; }
.brand { min-width: 0; gap: 10px; }
.brand-mark { display: block; width: 40px; height: auto; flex: none; }
.brand h1 { font-size: 1.125rem; font-weight: 500; line-height: 1.2; letter-spacing: -.025em; text-wrap: balance; }
.service-state { margin-left: auto; gap: 7px; color: #c3d2df; font-size: var(--note-size); white-space: nowrap; }
.service-state i, .status-dot {
  display: inline-block; width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--muted);
}
.service-state i { background: #91a6ba; }
.service-state.online i { background: var(--cyan); }
.status-line.ok .status-dot { background: var(--accent); }
.head-actions { gap: 12px; }
.button, .text-button { gap: 7px; min-height: 36px; white-space: nowrap; font-size: 1rem; line-height: 1.4; }
.button:hover:enabled, .text-button:hover:enabled { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.button:disabled, .text-button:disabled { color: #687887; }
.button.primary { padding: 7px 16px; border-radius: 3px; background: var(--accent); color: white; font-weight: 500; }
.button.primary:hover:enabled { background: var(--accent-deep); color: white; text-decoration: none; }
.button.primary:disabled { background: rgb(199 221 242 / .12); color: #bacada; }
.site-head .button.subtle:hover:enabled { color: #c0e7f4; }

.workspace { padding-block: clamp(12px, 2vh, 22px) 28px; }
.decoding { border-bottom: 1px solid var(--rule); }
.decoding summary {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; width: fit-content; padding: 9px 0 11px;
  cursor: pointer; list-style: none;
}
.decoding summary::-webkit-details-marker { display: none; }
.decoding-title { display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; font-weight: 500; }
.decoding-title::before {
  content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1px 1px 0;
  transform: rotate(-45deg); transition: transform 260ms ease-in-out;
}
.decoding[open]:not(.is-closing) .decoding-title::before { transform: translateY(-2px) rotate(45deg); }
#decodingSummary, .decoding small { font-size: var(--note-size); line-height: 1.5; color: var(--muted); }
#decodingSummary, .decoding-grid, .view-caption, .file-info span, .status-line { font-variant-numeric: tabular-nums; }
#decodingForm {
  display: grid; grid-template-rows: 1fr; overflow-y: clip;
  transition: grid-template-rows 260ms ease-in-out, opacity 260ms ease-in-out;
}
.decoding.is-closing #decodingForm { grid-template-rows: 0fr; opacity: 0; }
.decoding-fields { min-height: 0; }
.decoding-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; padding-top: 6px; }
.decoding-grid label, .temperature-field { display: flex; flex-direction: column; gap: 5px; font-size: var(--note-size); font-weight: 500; }
.decoding-grid input:not([type="range"]) {
  min-width: 0; width: 100%; padding: 5px 8px; border: 1px solid #c4d1df;
  border-radius: 2px; background: white; font-size: 1rem; font-weight: 400;
}
#temperature { appearance: textfield; }
#temperature::-webkit-inner-spin-button, #temperature::-webkit-outer-spin-button { appearance: none; margin: 0; }
#temperatureRange { width: 100%; min-width: 0; margin: 3px 0; accent-color: var(--accent); cursor: pointer; }
.decoding small { font-weight: 400; }
.decoding-reset { width: fit-content; margin: 12px 0 16px auto; }
@media (prefers-reduced-motion: reduce) {
  #decodingForm, .decoding-title::before { transition: none; }
}

.panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(20px, 2.8vw, 40px); margin-top: clamp(20px, 3vh, 32px); }
.panel { min-width: 0; }
.panel-head, .tab-row, .panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-head h2 { font-size: clamp(1.25rem, 1.8vw, 1.5rem); font-weight: 500; line-height: 1.2; letter-spacing: -.02em; }
.output-head { flex-wrap: wrap; row-gap: 0; }
.output-actions { display: flex; gap: 16px; margin-left: auto; }
#gifDialog {
  width: min(1120px, calc(100% - 32px)); max-height: 90svh; overflow: hidden;
  margin: auto; padding: 0; border: 1px solid var(--rule); border-radius: 8px;
  background: #fff; color: var(--ink); box-shadow: 0 20px 70px rgb(15 32 53 / .18);
}
#gifDialog[open] { display: flex; flex-direction: column; }
#gifDialog::backdrop { background: rgb(16 28 47 / .45); }
.gif-heading { display: flex; flex: none; justify-content: space-between; align-items: center; padding: 10px clamp(14px, 2.5vw, 30px); border-bottom: 1px solid var(--rule); }
.gif-heading h2 { font-size: 20px; font-weight: 500; letter-spacing: -.02em; }
#gifMount { flex: 0 1 auto; height: min(65svh, 540px); min-height: 0; }
#gifMount iframe { display: block; width: 100%; height: 100%; border: 0; }
.tab-row { min-height: 42px; margin: 4px 0 9px; border-bottom: 1px solid var(--rule); }
.tabs { align-self: stretch; display: flex; gap: 20px; }
.tabs button { margin-bottom: -1px; padding: 6px 0; border-bottom: 2px solid transparent; font-size: 1rem; line-height: 1.4; color: var(--muted); }
.tabs button:hover { color: var(--accent); }
.tabs button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--accent); border-image: var(--brand-grad) 1; }
.view-caption { white-space: nowrap; color: var(--muted); font-size: var(--note-size); }
.canvas {
  position: relative; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center;
  height: clamp(264px, min(50svh, 41vw), 540px); container-type: size; overflow: hidden;
  background: linear-gradient(135deg, #f4f7fc 0%, #f1f6fe 55%, #edf9fc 100%);
}
.paper {
  display: block; width: min(100cqw, calc(100cqh * var(--image-ratio, 1)));
  height: min(100cqh, calc(100cqw / var(--image-ratio, 1))); object-fit: contain; background: #fff;
}
.drop-overlay {
  display: none; place-items: center; position: absolute; inset: 6px; pointer-events: none;
  border: 1px dashed var(--accent); background: rgb(241 246 254 / .95); color: var(--accent-deep);
}
.source-canvas.dragging .drop-overlay { display: grid; }
.panel-foot { padding-block: 10px; }
.file-info { display: grid; gap: 2px; min-width: 0; }
.file-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--note-size); font-weight: 500; }
.file-info span, .status-line { font-size: var(--note-size); color: var(--muted); }
.text-button { color: var(--muted); }
.canvas-empty { display: grid; justify-items: center; gap: 8px; max-width: 100%; padding: 16px; color: var(--muted); text-align: center; }
.empty-icon .icon { width: 24px; height: 24px; }
#liveSnippet, #sourceCode { font: 400 .8125rem/1.6 var(--mono); color: #455565; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }
#liveSnippet { max-width: min(36em, 100%); max-height: 4.8em; overflow: hidden; }
.result-canvas.code-view { background: var(--matte); }
#sourceCode {
  position: absolute; inset: 0; padding: 16px; overflow: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: #c7d3df transparent; tab-size: 2;
}
#sourceCode:focus-visible { outline-offset: -2px; }
.status-line { display: flex; align-items: center; gap: 9px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--rule); }
.status-line.busy .status-dot { background: var(--accent); }
.status-line.error { color: #893c31; }
.status-line.error .status-dot { background: currentColor; }

@media (max-width: 900px) {
  .decoding-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 740px) {
  .head-inner { min-height: 58px; flex-wrap: wrap; gap: 6px 12px; padding-block: 8px; }
  .brand { gap: 8px; }
  .brand-mark { width: 36px; }
  .panels { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .canvas { height: clamp(220px, min(90vw, 55svh), 420px); }
  .panel-foot { padding-bottom: 0; }
  .status-line { margin-top: 18px; }
}
@media (max-width: 560px) {
  #gifDialog { width: calc(100% - 12px); max-height: 94svh; }
  .head-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
  .brand { grid-column: 1; grid-row: 1 / span 2; }
  .brand h1 { font-size: 1rem; }
  .service-state, .head-actions { grid-column: 2; justify-self: end; }
  .service-state { margin-left: 0; }
  .head-actions { gap: 4px 7px; flex-wrap: wrap; justify-content: end; max-width: 40vw; }
  .head-actions .button { min-height: 36px; }
  .button.primary { padding: 4px 11px; }
  .decoding-grid { gap: 12px; }
  .status-line { align-items: baseline; }
}
@media (max-width: 380px) {
  .brand-mark { width: 28px; }
}
