:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --bg: #f4f2eb;
  --panel: #fffdf8;
  --line: #d8d9cf;
  --ink: #23382e;
  --muted: #666d64;
  --accent: #ac4928;
  --green-wash: #edf1e8;
  --mono: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; color: var(--ink); min-height: 100svh; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { touch-action: manipulation; }
.shell { width: min(100%, 1100px); margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 40px max(36px, env(safe-area-inset-bottom)); }
.header { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 10px 0 26px; border-bottom: 1px solid var(--ink); }
.identity { display: flex; align-items: center; gap: 13px; }
.logo { width: 32px; height: 32px; flex: none; }
.app-name { font-size: 30px; font-weight: 750; letter-spacing: -.045em; line-height: 1; }
.app-name span { font-family: Georgia, 'Times New Roman', serif; font-weight: 400; font-style: italic; letter-spacing: -.05em; }
.header-note { font-family: var(--mono); font-size: 11px; line-height: 1.7; text-align: right; }
.header-note span { display: block; color: var(--muted); font-size: 10px; }
.intro { padding: 38px 0 30px; }
h1 { font-size: clamp(30px, 4vw, 44px); font-weight: 650; letter-spacing: -.055em; line-height: 1.12; margin: 0 0 12px; }
.intro p { font-size: 15px; line-height: 1.6; margin: 0; color: var(--muted); }
.workbench { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.column { display: grid; gap: 18px; min-width: 0; }
.card { padding: 24px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.card h2 { font-size: 18px; font-weight: 650; letter-spacing: -.025em; line-height: 1.3; margin: 0; }
.step { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.file-picker { display: flex; align-items: center; gap: 14px; position: relative; cursor: pointer; min-height: 92px; padding: 18px 16px; border: 1px solid var(--line); border-radius: 3px; transition: border-color .15s, background .15s; }
.file-picker:hover { border-color: var(--ink); background: var(--green-wash); }
.file-picker:has(input:disabled) { cursor: default; }
.file-picker input { position: absolute; inset: 0; opacity: 0; cursor: inherit; width: 100%; height: 100%; font-size: 16px; }
.file-icon { width: 26px; height: 26px; flex: none; }
.file-copy { display: grid; gap: 6px; min-width: 0; flex: 1; }
.file-main { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-sub { font-size: 12px; line-height: 1.55; color: var(--muted); overflow-wrap: anywhere; }
.file-arrow { align-self: flex-start; font-size: 19px; line-height: 1; color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 20px; border-top: 1px solid var(--line); padding-top: 17px; gap: 12px; }
.stats > div, .runtime-stats > div { display: grid; gap: 5px; }
.stats strong, .runtime-stats strong { font-family: var(--mono); font-weight: 500; font-size: 21px; font-variant-numeric: tabular-nums; }
.stats span, .runtime-stats span { font-size: 11px; color: var(--muted); line-height: 1.5; }
.inline-alert { margin-top: 18px; border-left: 2px solid var(--accent); padding: 1px 0 1px 12px; color: #84371f; font-size: 13px; line-height: 1.6; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin: 20px 0 9px; }
.card-head + .field-label { margin-top: 0; }
.label-note { margin-left: 5px; font-family: var(--mono); font-size: 10px; font-weight: 400; color: var(--muted); }
select, input[type=text], input[type=number] { appearance: none; display: block; width: 100%; min-width: 0; min-height: 48px; background: var(--panel); border: 1px solid #b8beb1; color: var(--ink); font-size: 16px; border-radius: 3px; padding: 12px; }
select { padding-right: 36px; text-overflow: ellipsis; background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2323382e" stroke-width="1.5"%3E%3Cpath d="m7 10 5 5 5-5"/%3E%3C/svg%3E'); background-repeat: no-repeat; background-position: right 11px center; background-size: 18px; }
select:disabled { background-color: #f1f1ea; border-color: var(--line); color: var(--muted); opacity: 1; }
input::placeholder { color: #72796e; }
.target-details { display: grid; gap: 10px; padding: 15px 0; margin-top: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.target-details > div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; font-size: 12px; line-height: 1.4; }
.target-details span { color: var(--muted); flex: none; }
.target-details strong { font-size: 12px; font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); }
.help { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 9px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.source-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 18px; padding: 4px; background: #eeeee6; border-radius: 3px; }
.source-switch label { display: flex; justify-content: center; align-items: center; gap: 8px; min-height: 42px; border: 1px solid transparent; border-radius: 2px; font-size: 13px; font-weight: 600; cursor: pointer; }
.source-switch label:has(input:checked) { border-color: var(--line); background: var(--panel); }
.source-switch input { margin: 0; accent-color: var(--ink); }
.source-switch label:has(input:disabled) { cursor: default; }
.length-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.length-fields .field-label { margin-top: 0; }
.position-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; padding: 3px; margin: -3px; max-height: 256px; overflow-y: auto; }
.position-slot { display: grid; align-content: center; justify-items: center; gap: 5px; min-width: 0; min-height: 59px; padding: 7px 2px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 3px; cursor: pointer; }
.position-slot[aria-pressed=true] { border-color: var(--accent); background: #f7ece3; box-shadow: inset 0 -2px var(--accent); }
.position-slot[data-fixed=true] .slot-value { font-weight: 700; }
.slot-number { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.slot-value { font-family: var(--mono); font-size: 14px; line-height: 1.2; max-width: 100%; overflow: hidden; }
.position-editor { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 17px 0; margin-top: 20px; }
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.editor-head h3 { font-size: 14px; font-weight: 650; margin: 0; white-space: nowrap; }
.editor-head select { width: 154px; min-height: 42px; font-size: 14px; padding-top: 9px; padding-bottom: 9px; }
.character-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 17px; }
.character-groups label { display: flex; align-items: center; gap: 7px; font-size: 12px; line-height: 1.6; min-height: 32px; cursor: pointer; flex-wrap: wrap; }
.character-groups input { width: 16px; height: 16px; flex: none; margin: 0; accent-color: var(--ink); }
.character-groups span { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.apply-position { text-align: left; margin-top: 10px; }
.mask-summary { display: grid; gap: 7px; margin-top: 19px; }
.mask-summary > span { font-size: 11px; color: var(--muted); }
.mask-summary > span:nth-of-type(2) { margin-top: 7px; }
.mask-summary strong { font-family: var(--mono); font-size: 19px; font-weight: 500; overflow-wrap: anywhere; }
.mask-summary code { font-family: var(--mono); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.generator-fields:disabled .position-slot, .generator-fields:disabled label { cursor: default; }
.generator-fields:disabled input, .generator-fields:disabled .position-slot { opacity: .7; }
.consent { display: flex; gap: 10px; align-items: flex-start; margin: 24px 0 20px; font-size: 13px; line-height: 1.6; cursor: pointer; }
.consent input { width: 17px; height: 17px; accent-color: var(--ink); flex: none; margin: 2px 0 0; }
.button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 48px; padding: 11px 16px; border-radius: 3px; border: 1px solid var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s; }
.button:disabled { cursor: not-allowed; }
.button-primary { justify-content: space-between; background: var(--ink); color: var(--panel); }
.button-primary:disabled { background: #e7e9e0; color: #646e60; border-color: #d8dcd0; }
.button-primary:not(:disabled):hover { background: #354c3f; }
.button-primary span { font-size: 21px; font-weight: 400; line-height: 1; }
.button-secondary { color: var(--ink); background: transparent; border-color: #b8beb1; }
.button-danger { color: #84371f; background: transparent; border-color: #c9b6a6; }
.button-secondary:not(:disabled):hover { background: var(--green-wash); }
.button-danger:not(:disabled):hover { background: #f7ece2; }
.button-secondary:disabled, .button-danger:disabled { color: #72796e; border-color: var(--line); }
.button-row { display: flex; gap: 10px; }
.run-status { margin-left: auto; font-size: 11px; color: var(--muted); text-align: right; }
.percent-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.percent-row strong { font-family: var(--mono); font-size: 28px; font-weight: 500; letter-spacing: -.06em; }
.percent-row span { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; overflow-wrap: anywhere; min-width: 0; }
.progress-track { height: 5px; background: #e4e7dc; overflow: hidden; }
.progress-track > div { width: 0; height: 100%; background: var(--ink); transition: width .15s; }
.runtime-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 21px 0; }
.runtime-stats strong { overflow-wrap: anywhere; }
#engineStatus { margin: -7px 0 16px; }
.result-card { border-top: 2px solid var(--accent); }
.result-card[data-state=success] { border-top-color: var(--ink); background: var(--green-wash); }
.result-heading { display: flex; align-items: center; gap: 10px; }
.result-symbol { color: var(--accent); font-size: 20px; line-height: 1; }
.result-card[data-state=success] .result-symbol { color: var(--ink); }
.result-card p { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 10px 0 0; }
.password-box { margin-top: 18px; border-top: 1px solid #c8d1c0; padding-top: 18px; }
.password-box code { display: block; font-family: var(--mono); font-size: 18px; line-height: 1.5; overflow-wrap: anywhere; }
.password-box code.masked { letter-spacing: .12em; }
.password-actions { display: flex; gap: 18px; margin-top: 9px; }
.text-button { border: 0; border-bottom: 1px solid #a0ada0; background: none; padding: 8px 0; color: var(--ink); font-size: 13px; font-weight: 500; cursor: pointer; min-height: 36px; }
footer { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 16px; }
.format-guide summary { width: fit-content; cursor: pointer; color: var(--muted); font-size: 12px; padding: 6px 0; }
.format-content { max-width: 680px; padding: 6px 0 0; }
.format-content p { margin: 10px 0; font-size: 13px; line-height: 1.7; color: var(--muted); }
.format-content strong { color: var(--ink); font-weight: 600; }
[hidden] { display: none !important; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, .file-picker:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (max-width: 720px) {
  .shell { padding-left: 22px; padding-right: 22px; }
  .header { padding-top: 4px; padding-bottom: 23px; }
  .intro { padding: 30px 0 24px; }
  .workbench { grid-template-columns: 1fr; gap: 16px; }
  .column { gap: 16px; }
  .card { padding: 22px; }
}

@media (max-width: 380px) {
  .shell { padding-left: 16px; padding-right: 16px; }
  .identity { gap: 9px; }
  .app-name { font-size: 26px; }
  .logo { width: 28px; height: 28px; }
  .header-note { font-size: 10px; }
  .header-note span { font-size: 9px; }
  .card { padding: 18px; }
  .file-picker { padding: 15px 12px; gap: 10px; }
  .file-icon { width: 22px; height: 22px; }
}

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