:root {
  --void: #070b09;
  --surface: #0c1310;
  --surface-raised: #111b16;
  --surface-soft: #15231c;
  --line: #263d31;
  --line-bright: #3c654f;
  --text: #d4e4da;
  --muted: #7f9989;
  --green: #85f2aa;
  --green-strong: #a2ffbd;
  --green-dim: #315e42;
  --amber: #efba63;
  --red: #ff7e72;
  --radius: 7px;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--void);
  font-family: var(--sans);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--void); }
body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  background:
    radial-gradient(circle at 50% -20%, rgba(65, 118, 82, .15), transparent 45%),
    linear-gradient(180deg, #090f0c 0%, var(--void) 100%);
}
button, input { font: inherit; }
button, label, summary { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible, label:has(input:focus-visible) {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.topbar {
  height: 54px;
  padding: 0 clamp(16px, 3vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid #1d2d25;
  background: rgba(7, 11, 9, .9);
  backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-copy { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand-copy strong { color: var(--green-strong); font: 800 17px var(--mono); letter-spacing: .1em; }
.brand-copy small { color: var(--muted); font-size: 13px; white-space: nowrap; }
.topbar-meta { display: flex; align-items: center; gap: 10px; font: 12px var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.browser-badge { padding: 6px 9px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); white-space: nowrap; }
.browser-badge.is-supported { color: var(--green); border-color: var(--green-dim); background: rgba(133, 242, 170, .04); }
.language-switch { display: inline-flex; align-items: center; gap: 4px; padding: 3px 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--green-dim); }
.language-switch button { min-width: 31px; padding: 3px 4px; border: 0; border-radius: 2px; background: transparent; color: var(--muted); cursor: pointer; font: 700 12px var(--mono); letter-spacing: .05em; }
.language-switch button:hover { color: var(--green); }
.language-switch button[aria-pressed="true"] { background: var(--surface-soft); color: var(--green-strong); box-shadow: inset 0 0 8px rgba(133, 242, 170, .06); }

main { width: min(1600px, 100%); margin: 0 auto; padding: 18px clamp(12px, 2.5vw, 28px) 16px; }
.console {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 20px 80px rgba(0, 0, 0, .38), inset 0 0 50px rgba(94, 166, 116, .025);
}
.console::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: .18;
  background: repeating-linear-gradient(180deg, transparent 0 3px, rgba(154, 255, 185, .035) 3px 4px);
  mix-blend-mode: screen;
}
.console-grid { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(330px, .85fr); }
.config-panel, .operation-panel { min-width: 0; padding: 20px 22px; }
.operation-panel { border-left: 1px solid var(--line); background: rgba(16, 27, 21, .72); }
.panel-heading, .status-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.eyebrow { margin: 0 0 5px; color: var(--green); font: 700 12px var(--mono); letter-spacing: .15em; text-transform: uppercase; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(24px, 2vw, 32px); line-height: 1.1; letter-spacing: -.035em; }
.protocol-tag { padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font: 12px var(--mono); white-space: nowrap; }

.module { margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.module-heading { display: grid; grid-template-columns: 32px 1fr; gap: 10px; align-items: start; margin-bottom: 12px; }
.module-index { width: 27px; height: 22px; display: grid; place-items: center; border: 1px solid var(--green-dim); border-radius: 3px; color: var(--green); font: 700 12px var(--mono); }
.module-heading h2, .status-heading h2 { margin: 0; font-size: 18px; line-height: 1.25; letter-spacing: -.01em; }
.module-heading p { margin: 3px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.module-heading code { color: var(--green); font: inherit; }

.device-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 57px; padding: 10px 11px 10px 13px; border: 1px solid var(--line); border-radius: 5px; background: rgba(20, 34, 27, .72); }
.device-details { min-width: 0; display: grid; gap: 3px; }
.device-details strong, .device-details span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-details strong { color: var(--text); font-size: 14px; }
.device-details span { color: var(--muted); font: 12px var(--mono); }

.button { min-height: 38px; border: 1px solid transparent; border-radius: 4px; padding: 0 14px; cursor: pointer; font-size: 13px; font-weight: 750; letter-spacing: .02em; transition: border-color .15s ease, background .15s ease, color .15s ease, box-shadow .15s ease; }
.button:disabled { cursor: not-allowed; opacity: .35; }
.button-secondary { border-color: var(--line-bright); background: #132019; color: var(--green); }
.button-secondary:hover:not(:disabled) { border-color: var(--green); background: #182b20; }
.button-primary { display: inline-flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 44px; background: var(--green); color: #07140c; border-color: var(--green); text-transform: uppercase; font-family: var(--mono); box-shadow: 0 0 22px rgba(133, 242, 170, .1); }
.button-primary:hover:not(:disabled) { background: var(--green-strong); box-shadow: 0 0 24px rgba(133, 242, 170, .2); }
.button-danger { border-color: #6a3934; background: transparent; color: var(--red); }
.button-danger:hover:not(:disabled) { border-color: var(--red); background: rgba(255, 126, 114, .06); }

.file-drop { min-height: 64px; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px dashed var(--line-bright); border-radius: 5px; background: rgba(16, 28, 22, .55); cursor: pointer; }
.file-drop:hover, .file-drop.is-dragging { border-color: var(--green); background: rgba(133, 242, 170, .055); }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-drop > span:last-child { display: grid; gap: 2px; }
.file-drop strong { color: var(--green); font-size: 14px; }
.file-drop small { color: var(--muted); font-size: 12px; }
.file-glyph { width: 29px; height: 29px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--green-dim); border-radius: 4px; color: var(--green); font: 22px var(--mono); }
.file-facts { display: grid; grid-template-columns: 1fr 1fr; margin: 10px 0 0; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.file-facts > div { min-width: 0; padding: 7px 10px; background: rgba(5, 10, 7, .27); }
.file-facts > div:nth-child(2) { border-left: 1px solid var(--line); }
.file-facts .hash-row { grid-column: 1 / -1; border-top: 1px solid var(--line); }
.file-facts dt { margin-bottom: 3px; color: var(--muted); font: 10px var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.file-facts dd { min-width: 0; margin: 0; overflow: hidden; color: var(--text); font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.file-facts .hash-row dd { overflow-wrap: anywhere; color: #9eb8a8; font: 11px/1.35 var(--mono); white-space: normal; }
.validation { margin: 8px 0 0; color: var(--muted); font: 11px/1.35 var(--mono); }
.validation::before { content: "[i] "; }
.validation.is-valid { color: var(--green); }
.validation.is-valid::before { content: "[ok] "; }
.validation.is-error { color: var(--red); }
.validation.is-error::before { content: "[err] "; }

.status-heading h2 { max-width: 260px; font-size: 20px; }
.status-heading > strong { color: var(--green); font: 700 28px var(--mono); text-shadow: 0 0 12px rgba(133, 242, 170, .23); }
progress { width: 100%; height: 7px; margin: 16px 0 17px; border: 0; border-radius: 0; overflow: hidden; background: #1d3025; }
progress::-webkit-progress-bar { background: #1d3025; }
progress::-webkit-progress-value { background: var(--green); box-shadow: 0 0 12px rgba(133, 242, 170, .45); transition: width .2s ease; }
progress::-moz-progress-bar { background: var(--green); box-shadow: 0 0 12px rgba(133, 242, 170, .45); }
.stages { margin: 0; padding: 0; list-style: none; }
.stages li { position: relative; display: grid; grid-template-columns: 18px 1fr; gap: 9px; min-height: 41px; color: #587060; }
.stages li:not(:last-child)::after { content: ""; position: absolute; left: 5px; top: 15px; bottom: 1px; width: 1px; background: var(--line); }
.stage-marker { width: 11px; height: 11px; margin-top: 2px; border: 1px solid var(--line-bright); border-radius: 2px; background: var(--surface); }
.stages li > span:last-child { display: grid; align-content: start; gap: 2px; }
.stages strong { font: 700 12px var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.stages small { color: inherit; font-size: 11px; }
.stages li.is-active, .stages li.is-complete { color: var(--text); }
.stages li.is-active .stage-marker { border-color: var(--green); background: var(--green); box-shadow: 0 0 10px rgba(133, 242, 170, .5); }
.stages li.is-complete .stage-marker { border-color: var(--green-dim); background: var(--green-dim); }
.stages li.is-complete::after { background: var(--green-dim); }

.action-zone { margin-top: 5px; padding-top: 14px; border-top: 1px solid var(--line); }
.consent-row { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; color: #a5b9ac; font-size: 12px; line-height: 1.45; }
.consent-row input { position: absolute; opacity: 0; }
.custom-check { width: 16px; height: 16px; flex: 0 0 auto; border: 1px solid var(--line-bright); border-radius: 2px; background: #0b120e; position: relative; }
.consent-row input:checked + .custom-check { border-color: var(--green); background: var(--green); }
.consent-row input:checked + .custom-check::after { content: ""; position: absolute; left: 4px; top: 2px; width: 5px; height: 8px; border-right: 2px solid #07140c; border-bottom: 2px solid #07140c; transform: rotate(45deg); }
.consent-row:has(input:disabled) { cursor: not-allowed; opacity: .43; }
.action-row { display: flex; gap: 8px; margin-top: 12px; }
.action-row .button-primary { flex: 1; }
.power-warning { display: flex; align-items: center; gap: 6px; margin: 9px 0 0; color: var(--amber); font: 11px var(--mono); }
.power-warning > span:first-child { width: 14px; height: 14px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid #795b2f; border-radius: 50%; }
.power-warning > span:last-child { min-width: 0; width: auto; }

.log-panel { position: relative; z-index: 2; border-top: 1px solid var(--line); background: #09100c; }
.log-panel summary { min-height: 43px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 0 18px; cursor: pointer; list-style: none; }
.log-panel summary::-webkit-details-marker { display: none; }
.log-label { display: inline-flex; align-items: center; gap: 7px; color: var(--green); font: 700 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green-dim); }
.log-preview { min-width: 0; overflow: hidden; color: var(--muted); font: 11px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.log-preview.log-success { color: var(--green); }
.log-preview.log-warning { color: var(--amber); }
.log-preview.log-error { color: var(--red); }
.log-toggle { color: var(--muted); font: 11px var(--mono); }
.log-toggle::before { content: "+ "; color: var(--green); }
.log-toggle .when-open { display: none; }
.log-panel[open] .log-toggle::before { content: "− "; }
.log-panel[open] .log-toggle .when-closed { display: none; }
.log-panel[open] .log-toggle .when-open { display: inline; }
.log-content { display: grid; grid-template-columns: 180px minmax(0, 1fr); border-top: 1px solid var(--line); }
.log-toolbar { padding: 13px 17px; border-right: 1px solid var(--line); color: var(--muted); font: 11px/1.45 var(--mono); }
.log-toolbar button { display: block; margin-top: 10px; padding: 0; border: 0; background: transparent; color: var(--green); cursor: pointer; font: 11px var(--mono); text-transform: uppercase; }
.operation-log { min-height: 105px; max-height: 155px; margin: 0; padding: 11px 15px; overflow-y: auto; list-style: none; background: #070c09; }
.log-line { display: grid; grid-template-columns: 67px minmax(0, 1fr); gap: 10px; margin-bottom: 5px; color: #9bb0a2; font: 11px/1.45 var(--mono); }
.log-line time { color: #52675a; }
.log-success span { color: var(--green); }
.log-warning span { color: var(--amber); }
.log-error span { color: var(--red); }

.console-footer { position: relative; z-index: 2; min-height: 34px; display: flex; align-items: center; gap: 16px; padding: 0 18px; border-top: 1px solid var(--line); color: #566b5e; font: 10px var(--mono); letter-spacing: .05em; text-transform: uppercase; }
.footer-local { margin-right: auto; }
.console-footer nav { display: flex; gap: 15px; }
.console-footer a { text-decoration: none; }
.console-footer a:hover { color: var(--green); }

@media (max-width: 850px) {
  .console-grid { grid-template-columns: 1fr; }
  .operation-panel { border-top: 1px solid var(--line); border-left: 0; }
  .stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
  .stages li { display: grid; grid-template-columns: 1fr; gap: 5px; min-height: 0; }
  .stages li::after { display: none; }
  .stage-marker { width: 100%; height: 3px; margin: 0; border: 0; border-radius: 0; background: var(--line); }
  .stages small { display: none; }
}

@media (max-width: 600px) {
  .topbar { height: 50px; padding-inline: 12px; }
  .brand-copy small { display: none; }
  .browser-badge { max-width: 175px; overflow: hidden; text-overflow: ellipsis; }
  .topbar-meta { gap: 6px; }
  .language-switch { gap: 1px; padding-inline: 3px; }
  .language-switch button { min-width: 27px; padding-inline: 2px; }
  main { padding: 10px 8px; }
  .config-panel, .operation-panel { padding: 17px 14px; }
  .panel-heading { align-items: center; }
  .device-row { grid-template-columns: 1fr; }
  .device-row .button { width: 100%; }
  .file-facts { grid-template-columns: 1fr; }
  .file-facts > div:nth-child(2) { border-top: 1px solid var(--line); border-left: 0; }
  .file-facts .hash-row { grid-column: auto; }
  .stages strong { font-size: 10px; }
  .action-row { flex-direction: column-reverse; }
  .action-row .button { width: 100%; }
  .log-panel summary { grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding-inline: 13px; }
  .log-toggle { display: none; }
  .log-content { grid-template-columns: 1fr; }
  .log-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 13px; border-right: 0; border-bottom: 1px solid var(--line); }
  .log-toolbar button { margin: 0; }
  .log-line { grid-template-columns: 58px minmax(0, 1fr); }
  .console-footer { flex-wrap: wrap; gap: 8px 13px; padding: 8px 13px; }
  .footer-local { flex-basis: 100%; order: 3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
