:root {
  color-scheme: dark;
  --bg: #0b0f17;
  --panel: #111824;
  --panel-raised: #151e2c;
  --field: #090d14;
  --line: #273244;
  --line-strong: #3b4b62;
  --text: #f1f5f9;
  --muted: #7e8da3;
  --muted-strong: #a9b6c8;
  --cyan: #70e2de;
  --cyan-soft: rgba(112, 226, 222, 0.12);
  --violet: #aa98ff;
  --violet-soft: rgba(170, 152, 255, 0.12);
  --orange: #ff9c6e;
  --green: #6ee7a8;
  --red: #ff6d76;
  --shadow: rgba(0, 0, 0, 0.24);
}

body.light {
  color-scheme: light;
  --bg: #edf1f4;
  --panel: #f9fbfc;
  --panel-raised: #ffffff;
  --field: #f3f6f8;
  --line: #ccd5df;
  --line-strong: #98a8ba;
  --text: #17202b;
  --muted: #69798b;
  --muted-strong: #4d5c6c;
  --cyan: #087d7b;
  --cyan-soft: rgba(8, 125, 123, 0.1);
  --violet: #6751d6;
  --violet-soft: rgba(103, 81, 214, 0.1);
  --orange: #c65327;
  --green: #138352;
  --red: #c73d48;
  --shadow: rgba(35, 51, 69, 0.09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 8% -10%, rgba(112, 226, 222, 0.08), transparent 29rem),
    radial-gradient(circle at 92% 38%, rgba(170, 152, 255, 0.045), transparent 25rem),
    var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  transition: background-color 0.2s, color 0.2s;
}

button, textarea, input { font: inherit; }
button { color: inherit; cursor: pointer; }
.app { width: min(1220px, calc(100% - 48px)); margin: 0 auto; }

.topbar {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.17em;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  font: 600 11px "IBM Plex Mono", monospace;
}

.brand-mark i { color: var(--cyan); font-style: normal; }
.brand-mark b { color: var(--orange); font-size: 11px; }
.top-actions { display: flex; align-items: center; gap: 20px; }

.local-status {
  color: var(--muted);
  font: 500 10px "IBM Plex Mono", monospace;
  letter-spacing: 0.12em;
}

.local-status i {
  width: 6px;
  height: 6px;
  display: inline-block;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 9px var(--green);
}

.square-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: transparent;
}

.square-button:hover { border-color: var(--line-strong); background: var(--panel); }
.square-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; }

.intro {
  min-height: 174px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 48px;
  padding: 40px 0 31px;
}

.eyebrow, .card-label {
  margin: 0;
  color: var(--muted);
  font: 500 9px "IBM Plex Mono", monospace;
  letter-spacing: 0.15em;
}

.intro h1 {
  max-width: 760px;
  margin: 8px 0 0;
  font-size: clamp(33px, 4.4vw, 58px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.045em;
}

.intro > p {
  width: min(360px, 36%);
  margin: 0 0 3px;
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.65;
}

.codec-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 50px var(--shadow);
}

.codec {
  min-width: 0;
  min-height: 83px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: center;
  gap: 5px 9px;
  padding: 13px 14px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  text-align: left;
  transition: background 0.15s;
}

.codec:last-child { border-right: 0; }
.codec:hover { background: var(--panel-raised); }
.codec.is-active { background: var(--cyan-soft); box-shadow: inset 0 -2px 0 var(--cyan); }
.codec span { color: var(--muted); font: 500 8px "IBM Plex Mono", monospace; }
.codec strong { min-width: 0; overflow: hidden; color: var(--muted-strong); font: 600 9px "IBM Plex Mono", monospace; letter-spacing: 0.08em; text-overflow: ellipsis; }
.codec small { grid-column: 2; color: var(--muted); font: 400 7px "IBM Plex Mono", monospace; letter-spacing: 0.09em; }
.codec.is-active span, .codec.is-active strong { color: var(--cyan); }

.control-bar {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  margin-top: 16px;
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.direction-toggle { display: grid; grid-template-columns: 92px 92px; height: 40px; border: 1px solid var(--line); background: var(--field); }
.direction-toggle button { border: 0; background: transparent; color: var(--muted); font: 600 8px "IBM Plex Mono", monospace; letter-spacing: 0.11em; }
.direction-toggle button.is-active { background: var(--cyan); color: #061414; }

.route { min-width: 0; display: flex; align-items: center; gap: 12px; color: var(--muted); font: 500 8px "IBM Plex Mono", monospace; letter-spacing: 0.08em; }
.route b { color: var(--cyan); font-size: 16px; font-weight: 400; }

.bar-actions { display: flex; align-items: center; gap: 10px; }
.bar-actions > button { padding: 7px 0; border: 0; background: transparent; color: var(--muted); font: 500 8px "IBM Plex Mono", monospace; letter-spacing: 0.08em; }
.bar-actions > button:hover { color: var(--text); }
.bar-actions > i { color: var(--line-strong); font-style: normal; }

.option-toggle { display: flex; align-items: center; gap: 7px; margin-right: 6px; color: var(--muted); font: 500 8px "IBM Plex Mono", monospace; letter-spacing: 0.07em; cursor: pointer; }
.option-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.option-toggle span { width: 25px; height: 14px; position: relative; border: 1px solid var(--line-strong); background: var(--field); }
.option-toggle span::after { content: ""; width: 8px; height: 8px; position: absolute; top: 2px; left: 2px; background: var(--muted); transition: 0.15s; }
.option-toggle input:checked + span::after { left: 13px; background: var(--cyan); }
.option-toggle[hidden] { display: none; }

.workspace {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.editor-panel { min-width: 0; border: 1px solid var(--line); background: var(--panel); }
.panel-head { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 17px; border-bottom: 1px solid var(--line); }
.panel-head > div { display: flex; align-items: center; gap: 14px; }
.panel-index { color: var(--cyan); font: 600 11px "IBM Plex Mono", monospace; }
.output-panel .panel-index { color: var(--violet); }
.panel-head p { margin: 0 0 5px; color: var(--muted); font: 500 8px "IBM Plex Mono", monospace; letter-spacing: 0.11em; }
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 500; }
.panel-stat { color: var(--muted); font: 500 8px "IBM Plex Mono", monospace; letter-spacing: 0.07em; }

.copy-button { padding: 9px 11px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: 500 8px "IBM Plex Mono", monospace; letter-spacing: 0.08em; }
.copy-button:hover { border-color: var(--line-strong); color: var(--text); }

.editor-panel textarea {
  width: 100%;
  min-height: 300px;
  display: block;
  resize: vertical;
  padding: 22px;
  border: 0;
  border-bottom: 1px solid var(--line);
  outline: 0;
  background: var(--field);
  color: var(--text);
  font: 13px/1.75 "IBM Plex Mono", monospace;
  tab-size: 2;
  overflow-wrap: anywhere;
}

.editor-panel textarea:focus { box-shadow: inset 3px 0 0 var(--cyan); }
.output-panel textarea { color: var(--muted-strong); }
.output-panel textarea:focus { box-shadow: inset 3px 0 0 var(--violet); }
.editor-panel textarea::placeholder { color: var(--muted); }

.panel-foot { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 9px 9px 18px; }
.panel-foot > span { color: var(--muted); font: 400 8px "IBM Plex Mono", monospace; letter-spacing: 0.06em; }
.convert-button { width: 176px; height: 43px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; border: 0; background: var(--cyan); color: #061414; font-size: 9px; font-weight: 700; letter-spacing: 0.1em; }
.convert-button b { font-size: 17px; font-weight: 400; }
.convert-button:hover { filter: brightness(1.08); }
.output-foot { padding-right: 18px; }
.success-state { display: flex; align-items: center; gap: 7px; color: var(--green) !important; }
.success-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.success-state.is-error { color: var(--red) !important; }
.success-state.is-error i { background: var(--red); box-shadow: none; }

.swap-button {
  width: 38px;
  height: 38px;
  position: absolute;
  z-index: 2;
  top: 160px;
  left: 50%;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line-strong);
  background: var(--panel-raised);
  color: var(--muted-strong);
  box-shadow: 0 7px 18px var(--shadow);
}
.swap-button:hover { border-color: var(--cyan); color: var(--cyan); }
.swap-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; }

.notice { min-height: 60px; display: flex; align-items: center; gap: 13px; margin: 16px 0; padding: 12px 16px; border: 1px solid var(--line); background: var(--panel); }
.notice-icon { width: 25px; height: 25px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 50%; color: var(--green); font: 600 11px "IBM Plex Mono", monospace; }
.notice strong { display: block; font-size: 11px; font-weight: 600; }
.notice p { margin: 3px 0 0; color: var(--muted); font: 400 9px "IBM Plex Mono", monospace; }
.notice.is-success { border-color: color-mix(in srgb, var(--green) 42%, var(--line)); }
.notice.is-error { border-color: color-mix(in srgb, var(--red) 50%, var(--line)); }
.notice.is-error .notice-icon { color: var(--red); }

.details-grid { display: grid; grid-template-columns: 1.15fr 0.8fr 1.15fr; gap: 16px; }
.detail-card { min-height: 190px; padding: 18px; border: 1px solid var(--line); background: var(--panel); }
.card-label { padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.codec-name { display: flex; align-items: center; gap: 13px; padding: 18px 0 13px; }
.codec-name > span { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--cyan); background: var(--cyan-soft); color: var(--cyan); font: 600 9px "IBM Plex Mono", monospace; }
.codec-name h2, .privacy-detail h2 { margin: 0; font-size: 17px; font-weight: 600; }
.codec-name p { margin: 4px 0 0; color: var(--muted); font: 400 8px "IBM Plex Mono", monospace; letter-spacing: 0.04em; }
.codec-detail > p, .privacy-detail > p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.byte-detail dl { margin: 8px 0 0; }
.byte-detail dl > div { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.byte-detail dl > div:last-child { border-bottom: 0; }
.byte-detail dt { color: var(--muted); font: 500 8px "IBM Plex Mono", monospace; letter-spacing: 0.07em; }
.byte-detail dd { margin: 0; color: var(--muted-strong); font: 600 10px "IBM Plex Mono", monospace; }
.pipeline { display: grid; grid-template-columns: auto 1fr auto 1fr auto; align-items: center; gap: 8px; padding: 25px 0 19px; }
.pipeline span { color: var(--muted-strong); font: 500 7px "IBM Plex Mono", monospace; letter-spacing: 0.07em; }
.pipeline i { height: 1px; position: relative; background: var(--line-strong); }
.pipeline i::after { content: ""; width: 4px; height: 4px; position: absolute; top: -2px; right: 0; border-radius: 50%; background: var(--cyan); }
.privacy-detail h2 { margin-bottom: 7px; }

footer { min-height: 100px; display: flex; align-items: center; justify-content: space-between; gap: 24px; color: var(--muted); font: 400 8px "IBM Plex Mono", monospace; letter-spacing: 0.08em; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 10; padding: 10px 14px; transform: translate(-50%, 12px); opacity: 0; pointer-events: none; background: var(--text); color: var(--bg); font: 500 9px "IBM Plex Mono", monospace; transition: 0.2s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 980px) {
  .codec-strip { grid-template-columns: repeat(4, 1fr); }
  .codec:nth-child(4) { border-right: 0; }
  .codec:nth-child(-n + 4) { border-bottom: 1px solid var(--line); }
  .control-bar { grid-template-columns: auto 1fr; }
  .bar-actions { grid-column: 1 / -1; justify-content: flex-end; padding: 0 4px 3px; }
}

@media (max-width: 760px) {
  .intro { align-items: flex-start; flex-direction: column; gap: 18px; }
  .intro > p { width: min(100%, 560px); }
  .workspace { grid-template-columns: 1fr; }
  .swap-button {
    position: static;
    justify-self: center;
    margin: -6px 0;
    transform: rotate(90deg);
  }
  .details-grid { grid-template-columns: 1fr 1fr; }
  .privacy-detail { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .app { width: min(100% - 24px, 1220px); }
  .topbar { height: 66px; }
  .local-status { display: none; }
  .intro { min-height: 0; padding: 30px 0 24px; }
  .intro h1 { font-size: 36px; }
  .codec-strip { grid-template-columns: 1fr 1fr; }
  .codec, .codec:nth-child(4) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .codec:nth-child(2n) { border-right: 0; }
  .codec:last-child { grid-column: 1 / -1; border-right: 0; border-bottom: 0; }
  .control-bar { display: flex; align-items: stretch; flex-direction: column; gap: 10px; }
  .direction-toggle { width: 100%; grid-template-columns: 1fr 1fr; }
  .route { justify-content: center; min-height: 28px; }
  .bar-actions { justify-content: space-between; flex-wrap: wrap; }
  .option-toggle { width: 100%; margin-bottom: 5px; }
  .editor-panel textarea { min-height: 230px; padding: 17px; font-size: 11px; }
  .panel-head { min-height: 65px; }
  .panel-foot { align-items: stretch; flex-direction: column; padding: 10px; }
  .panel-foot > span { padding: 5px 8px 0; }
  .convert-button { width: 100%; }
  .output-foot { min-height: 54px; align-items: center; flex-direction: row; padding: 10px 17px; }
  .output-foot > span { padding: 0; }
  .details-grid { grid-template-columns: 1fr; }
  .privacy-detail { grid-column: auto; }
  footer span:nth-child(2) { display: none; }
}

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