@font-face {
  font-family: "Geist";
  src: url("/geist-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Geist";
  src: url("/geist-cyrillic.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #111111;
  --muted: #6b6b6b;
  --faint: #f4f4f2;
  --line: #e6e6e3;
  --control: #cfcfcb;
  --raised: #ffffff;
  --primary: #111111;
  --primary-hover: #2e2e2e;
  --ring: rgba(17, 17, 17, .5);
  --scrollbar-thumb: rgba(17, 17, 17, .18);
  --radius: 12px;
  --ease: cubic-bezier(.16, 1, .3, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #111111;
    --ink: #f4f4f2;
    --muted: #9b9b97;
    --faint: #1c1c1c;
    --line: #2a2a2a;
    --control: #3d3d3b;
    --raised: #343434;
    --primary: #f4f4f2;
    --primary-hover: #ffffff;
    --ring: rgba(244, 244, 242, .5);
    --scrollbar-thumb: rgba(244, 244, 242, .2);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
p, h1, ol, ul { margin: 0; padding: 0; }
a { color: inherit; text-underline-offset: 3px; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
.sprite { position: absolute; width: 0; height: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

header, main { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 24px; }
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  margin-top: max(24px, env(safe-area-inset-top));
}
.brand { display: block; padding: 6px 0; }
.logo { display: block; height: 22px; width: auto; }
.logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .logo-light { display: none; }
  .logo-dark { display: block; }
}
#again { padding: 0 4px; font-size: 14px; border: 0; color: var(--muted); animation: fade .4s .2s backwards; }
#again:hover { background: none; color: var(--ink); }
#again .short { display: none; }
body:not([data-state="result"]) #again, body.empty #again { display: none; }
dialog { margin: auto; padding: 0; width: min(400px, calc(100vw - 40px)); border: 1px solid var(--control); border-radius: 16px; background: var(--paper); color: var(--ink); box-shadow: 0 24px 60px rgba(0, 0, 0, .35); opacity: 0; transform: translateY(8px) scale(.97); transition: opacity .2s, transform .25s var(--ease); }
dialog::backdrop { background: rgba(0, 0, 0, 0); transition: background-color .2s; }
dialog[open]:not(.closing) { opacity: 1; transform: none; }
dialog[open]:not(.closing)::backdrop { background: rgba(0, 0, 0, .5); }
@starting-style {
  dialog[open]:not(.closing) { opacity: 0; transform: translateY(8px) scale(.97); }
  dialog[open]:not(.closing)::backdrop { background: rgba(0, 0, 0, 0); }
}
dialog .box { padding: 24px; }
dialog h2 { font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
dialog p { margin-top: 8px; font-size: 15px; color: var(--muted); }
dialog .choices { margin-top: 24px; display: flex; gap: 8px; }
dialog .choices button { flex: 1; }

main { padding-top: clamp(32px, 7vh, 72px); padding-bottom: 72px; }
section { display: grid; grid-template-columns: minmax(0, 1fr); }

.intro h1 { font-size: clamp(30px, 5.4vw, 40px); line-height: 1.1; font-weight: 600; letter-spacing: -.03em; }
.intro h1:focus { outline: none; }
.intro p { margin-top: 10px; font-size: 17px; color: var(--muted); overflow-wrap: anywhere; }
.intro .meta { margin-top: 8px; font-size: 15px; }
.split { display: flex; }
.split span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split span:last-child { flex: none; white-space: pre; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  background: none;
  border: 1px solid var(--control);
  border-radius: var(--radius);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, color .15s, opacity .15s, transform .15s var(--ease);
}
button svg, .button svg { width: 18px; height: 18px; }
button:hover:not(:disabled), .button:hover { background: var(--faint); }
button:active:not(:disabled), .button:active { transform: scale(.985); }
button:disabled { color: var(--muted); opacity: .75; cursor: default; }
button.primary, .button.primary { background: var(--primary); color: var(--paper); border-color: transparent; font-weight: 600; }
button.primary:hover:not(:disabled), .button.primary:hover { background: var(--primary-hover); }
button.primary:disabled { background: var(--faint); color: var(--muted); opacity: 1; box-shadow: inset 0 0 0 1px var(--control); }
button.big { height: 52px; font-size: 16px; }
button.text { padding: 0 4px; border: 0; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
button.text:hover:not(:disabled) { background: none; }

input[type=password], select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background-color: var(--paper);
  border: 1px solid var(--control);
  border-radius: var(--radius);
  transition: background-color .15s;
}
select:hover { background-color: var(--faint); }
input::placeholder { color: var(--muted); }
select {
  appearance: none;
  padding-right: 36px;
  text-overflow: ellipsis;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}

.switch { position: relative; display: flex; flex: none; gap: 2px; height: 44px; padding: 4px; background: var(--faint); border-radius: var(--radius); }
.switch::before { content: ""; position: absolute; left: 0; top: 0; width: var(--highlight-w, 0); height: var(--highlight-h, 0); transform: translate(var(--highlight-x, 0), var(--highlight-y, 0)); border-radius: 9px; background: var(--raised); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); opacity: 0; }
.switch.ready::before { opacity: 1; transition: transform .35s var(--ease), width .35s var(--ease); }
.switch button { position: relative; height: 36px; padding: 0 14px; border: 0; border-radius: 9px; font-size: 14px; color: var(--muted); }
.switch button:hover:not(:disabled) { background: none; color: var(--ink); }
.switch button[aria-selected=true], .switch button[aria-pressed=true] { color: var(--ink); }
.switch button:active:not(:disabled) { transform: none; }
.switch.small { height: 32px; padding: 3px; border-radius: 9px; background: var(--line); }
.switch.small::before { border-radius: 7px; }
.switch.small button { height: 26px; padding: 0 10px; border-radius: 7px; font-size: 13px; }

.hint { font-size: 14px; color: var(--muted); }
.message { display: flex; gap: 8px; font-size: 14px; font-weight: 500; line-height: 1.45; }
.message::before {
  content: "!";
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.line { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.line div { height: 100%; background: var(--ink); opacity: .85; transform: scaleX(0); transform-origin: left; transition: transform .4s var(--ease); }

.drop {
  position: relative;
  margin-top: 32px;
  display: grid;
  place-items: center;
  min-height: 176px;
  padding: 24px;
  border: 1.5px dashed var(--control);
  border-radius: 16px;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.drop:hover { background: color-mix(in srgb, var(--faint) 45%, var(--paper)); }
body.over .drop { border-color: var(--muted); background: var(--faint); }
.drop:has(input:focus-visible) { outline: 2px solid var(--ring); outline-offset: 2px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-empty { display: grid; justify-items: center; gap: 4px; text-align: center; color: var(--muted); font-size: 15px; }
.drop-empty svg { width: 26px; height: 26px; color: var(--ink); margin-bottom: 10px; }
.drop-empty strong { font-size: 17px; font-weight: 600; color: var(--ink); }
.drop.chosen { min-height: 0; padding: 16px 18px; border: 1px solid var(--control); place-items: stretch; }
.drop-file { display: flex; align-items: center; gap: 14px; }
.drop-file svg { width: 24px; height: 24px; }
.drop-file .name { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.drop-file strong { font-weight: 600; }
.drop-file #file-size, .swap { font-size: 14px; color: var(--muted); }
.swap { text-decoration: underline; text-underline-offset: 3px; }

.fields { margin-top: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--muted); }

.keys { margin-top: 12px; border: 1px solid var(--control); border-radius: var(--radius); }
.keys summary { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; font-size: 15px; cursor: pointer; list-style: none; border-radius: var(--radius); }
.keys summary .count { margin-left: auto; font-size: 14px; color: var(--muted); }
.keys summary svg { width: 18px; height: 18px; color: var(--muted); transition: transform .2s var(--ease); }
.keys[open] summary svg { transform: rotate(180deg); }
.keys-body { display: grid; gap: 12px; padding: 4px 14px 14px; }
.keys ul { list-style: none; }
.keys li { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; column-gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.keys code { grid-column: 2; font: 14px ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.keys .left { grid-column: 2; font-size: 13px; color: var(--muted); }
.keys .ring, .keys li button { grid-row: 1 / span 2; }
.keys li button { grid-column: 3; }
.ring { width: 20px; height: 20px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke: var(--line); stroke-width: 3; transition: stroke-dasharray .6s var(--ease); }
.ring circle + circle { stroke: var(--ink); stroke-linecap: round; }
.key-add { display: flex; gap: 8px; }
.key-add input { flex: 1; min-width: 0; }
.keys small { font-size: 13px; line-height: 1.5; color: var(--muted); }

#setup-error { margin-top: 20px; }
#start { margin-top: 24px; }
#setup-error:not([hidden]) + #start { margin-top: 14px; }
#start-hint { margin-top: 10px; }
#start-hint:empty { display: none; }

.job { margin-top: 32px; padding: 20px 20px 22px; border: 1px solid var(--control); border-radius: 16px; }
.job-percent { font-size: 40px; line-height: 1; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.job-message { margin: 10px 0 16px; min-height: 24px; color: var(--muted); }
.under { margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }

#result .intro h1 { font-size: clamp(22px, 4vw, 28px); line-height: 1.2; letter-spacing: -.02em; }
.tools { margin-top: 24px; display: flex; align-items: center; gap: 8px; }
.tools select { width: auto; min-width: 0; flex: 1 1 120px; max-width: 260px; }
#download { flex: none; margin-left: auto; min-width: 150px; }

.strip { flex: none; border-bottom: 1px solid var(--line); font-size: 14px; }
.strip > * { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 6px 12px 6px 16px; }
.strip label { color: var(--muted); white-space: nowrap; }
.strip .pick { flex-wrap: wrap; }
.strip .pick select, .strip .pick input { width: auto; min-width: 0; flex: 0 1 220px; }
.strip .pick .text { order: 4; margin-left: auto; }
.strip .pick .message { order: 5; flex: 1 1 100%; padding-bottom: 6px; }
.strip .busy { gap: 14px; color: var(--muted); }
.strip .busy .line { flex: 1 1 60px; min-width: 40px; }
.strip .busy span { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.strip .note { justify-content: space-between; padding-top: 10px; padding-bottom: 10px; }
.strip .note .message { align-items: center; flex: 1; min-width: 0; }
.strip .note .actions { display: flex; gap: 14px; flex: none; }
.strip .note .actions button { height: 32px; }
.strip .note.warn .message { font-weight: 400; color: var(--muted); }
.strip .note.warn .message::before { background: none; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--muted); }

.viewer { margin-top: 16px; border: 1px solid var(--control); border-radius: 16px; overflow: hidden; }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none; height: 48px; padding: 0 8px; background: var(--faint); border-bottom: 1px solid var(--line); }
#copy { height: 32px; min-width: 104px; margin-left: auto; padding: 0 10px; gap: 6px; font-size: 13px; border-radius: 9px; background: var(--paper); }
#copy:hover { background: var(--paper); opacity: .8; }
#copy svg { width: 15px; height: 15px; }
.viewer-body { overflow-x: clip; outline-offset: -3px; scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }

.rows { list-style: none; padding: 8px 0; }
.rows li { padding: 9px 18px; }
.rows .when { display: block; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.rows .when b { font-weight: 500; margin-right: 10px; }
.rows .text { display: block; margin-top: 2px; line-height: 1.5; overflow-wrap: anywhere; }
.viewer-body pre { margin: 0; padding: 16px 18px; font: 13px/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.viewer-body .prose { padding: 16px 18px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }

.empty-actions { margin-top: 28px; display: grid; gap: 10px; }

@media (min-width: 521px) and (min-height: 560px) {
  body[data-state="result"]:not(.empty) { height: 100dvh; display: flex; flex-direction: column; }
  body[data-state="result"]:not(.empty) main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-bottom: 32px; }
  body[data-state="result"]:not(.empty) #result { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  body[data-state="result"]:not(.empty) .viewer { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
  body[data-state="result"]:not(.empty) .viewer-body { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
}

@media (max-width: 520px) {
  header, main { padding-left: 20px; padding-right: 20px; }
  .logo { height: 20px; }
  .drop { min-height: 160px; }
  .fields { grid-template-columns: 1fr; }
  .under { flex-direction: column-reverse; align-items: stretch; }
  .tools { flex-wrap: wrap; position: sticky; top: 0; z-index: 2; margin: 16px -20px 0; padding: 8px 20px; background: var(--paper); border-bottom: 1px solid var(--line); }
  .tools select { flex: 1 1 100%; max-width: none; }
  .tools .switch { flex: 1; }
  .tools .switch button { flex: 1; padding: 0 6px; }
  #download { min-width: 0; }
  .viewer { overflow: visible; }
  .viewer-head { position: sticky; top: var(--tools-height, 113px); z-index: 1; height: 56px; border-radius: 15px 15px 0 0; }
  .strip .pick { padding: 4px 14px 14px; }
  .strip .pick label { flex: 1; }
  .strip .pick .text { order: 0; margin-left: 0; }
  .strip .pick select, .strip .pick input, .strip .pick button:not(.text) { flex: 1 1 100%; max-width: none; }
  .strip .note { flex-wrap: wrap; padding-left: 14px; }
  .strip .note .message { flex: 1 1 100%; }
  .strip .note .actions { padding-left: 28px; }
  .switch.small { height: 44px; }
  .switch.small button { height: 38px; padding: 0 12px; }
  #copy { height: 44px; }
  .rows li { padding: 9px 14px; }
  .viewer-body pre, .viewer-body .prose { padding: 14px; }
}
@media (max-width: 400px) {
  #again .long { display: none; }
  #again .short { display: inline; }
}
@media (max-width: 350px) {
  #download span { display: none; }
  #download { padding: 0 14px; }
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }
main > section.enter > * { animation: rise .45s var(--ease) backwards; }
main > section.enter > :nth-child(2) { animation-delay: .05s; }
main > section.enter > :nth-child(3) { animation-delay: .1s; }
main > section.enter > :nth-child(4) { animation-delay: .15s; }
main > section.enter > :nth-child(n+5) { animation-delay: .2s; }
@keyframes from-right { from { opacity: 0; transform: translateX(18px); } }
@keyframes from-left { from { opacity: 0; transform: translateX(-18px); } }
@keyframes tick { from { transform: scale(.4); } 60% { transform: scale(1.15); } }
.viewer-body > .from-right { animation: from-right .32s var(--ease); }
.viewer-body > .from-left { animation: from-left .32s var(--ease); }
.viewer-body > .fade { animation: fade .15s; }
#copy.done svg { animation: tick .35s var(--ease); }
#download svg { transition: transform .2s var(--ease); }
#download:hover svg { transform: translateY(2px); }
.keys[open] .keys-body { animation: drop .25s var(--ease); }
.drop svg { transition: transform .25s var(--ease); }
.drop:hover #drop-empty svg, body.over #drop-empty svg { transform: translateY(-3px); }

@media (prefers-reduced-motion: reduce) {
  *, ::backdrop { transition: none !important; animation: none !important; }
}
