:root {
  color-scheme: dark;
  --bg: #111318;
  --surface: #171a21;
  --surface-raised: #1b1f28;
  --surface-deep: #13161c;
  --border: #2a2f3a;
  --border-soft: #232832;
  --text: #edf0f6;
  --muted: #9299a8;
  --subtle: #687080;
  --accent: #a995ff;
  --accent-strong: #8c72f5;
  --green: #72d6a2;
  --red: #ff858f;
  --yellow: #e9c77d;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--text); }
button, textarea { font: inherit; }
button { color: inherit; }
.app-shell { min-height: 100vh; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 clamp(18px, 4vw, 56px); border-bottom: 1px solid var(--border-soft); background: rgba(18, 20, 26, .94); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: 0; }
.brand-mark { width: 34px; height: 34px; border: 1px solid #454058; background: #211e2d; border-radius: 9px; display: flex; align-items: center; justify-content: center; gap: 3px; }
.brand-mark span { display: block; width: 3px; border-radius: 4px; background: #b4a5ff; }
.brand-mark span:nth-child(1) { height: 10px; opacity: .65; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 13px; opacity: .8; }
.brand-copy { display: flex; flex-direction: column; gap: 2px; }
.brand-copy strong { font-size: 14px; font-weight: 650; letter-spacing: -.01em; }
.brand-copy small { font-size: 9px; letter-spacing: .12em; color: var(--subtle); font-weight: 650; }
.topbar-right { display: flex; align-items: center; gap: 22px; }
.privacy-note, .engine-status { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.privacy-dot, .engine-indicator { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(114,214,162,.09); }
.engine-status { padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-deep); color: #b8c0ce; }
.engine-status[data-state="loading"] .engine-indicator { background: var(--yellow); box-shadow: 0 0 0 3px rgba(233,199,125,.1); animation: pulse 1.3s ease-in-out infinite; }
.engine-status[data-state="error"] .engine-indicator { background: var(--red); box-shadow: 0 0 0 3px rgba(255,133,143,.1); }
@keyframes pulse { 50% { opacity: .35; } }
.main-content { width: min(1600px, 100%); margin: 0 auto; padding: 42px clamp(18px, 4vw, 56px) 24px; }
.intro-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 10px; color: var(--accent); font: 700 10px/1.2 var(--mono); letter-spacing: .14em; }
h1 { margin: 0; font-size: clamp(25px, 3vw, 34px); line-height: 1.18; letter-spacing: -.045em; font-weight: 650; }
.intro-copy { margin: 10px 0 0; max-width: 720px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.intro-copy code { padding: 2px 5px; color: #c9c0ff; border-radius: 4px; background: #272438; font: 11px var(--mono); }
.engine-credit { display: flex; flex-direction: column; gap: 4px; min-width: 166px; padding: 12px 15px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.credit-label { color: var(--subtle); font-size: 9px; font-weight: 700; letter-spacing: .12em; }
.engine-credit strong { font-size: 13px; font-weight: 650; }
.engine-credit strong span { color: var(--muted); font: 11px var(--mono); }
.credit-sub { color: var(--muted); font-size: 10px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr); gap: 18px; align-items: stretch; }
.editor-panel { min-width: 0; height: clamp(450px, 58vh, 690px); border: 1px solid var(--border); border-radius: 10px; background: var(--surface); overflow: hidden; display: flex; flex-direction: column; transition: border-color .18s ease, background .18s ease; }
.editor-panel.is-dragging { border-color: var(--accent); background: #1b1a26; }
.panel-heading { min-height: 62px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--border-soft); }
.panel-title-group { min-width: 0; display: flex; align-items: center; gap: 11px; }
.panel-index { color: #716b88; font: 11px var(--mono); }
.panel-title-group h2 { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: -.01em; }
.panel-title-group p { margin: 3px 0 0; color: var(--subtle); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.panel-actions { display: flex; align-items: center; gap: 6px; }
.button { min-height: 38px; padding: 0 13px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 7px; background: #1a1e26; color: #d6dbe5; font-size: 12px; font-weight: 600; cursor: pointer; transition: background .16s ease, border-color .16s ease, transform .16s ease, opacity .16s ease; }
.button:hover:not(:disabled) { background: #242936; border-color: #444b5c; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.button:disabled { cursor: not-allowed; opacity: .38; }
.button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.button-small { min-height: 31px; padding: 0 9px; font-size: 10px; gap: 6px; }
.button-small svg { width: 13px; height: 13px; }
.button-quiet { background: transparent; }
.editor-meta { min-height: 30px; padding: 0 14px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--subtle); font: 10px var(--mono); }
.language-label { display: inline-flex; align-items: center; gap: 7px; color: #a7adba; font-size: 9px; letter-spacing: .06em; }
.language-label i { width: 6px; height: 6px; border-radius: 50%; background: #7c6ed1; }
.code-editor { display: flex; flex: 1; min-height: 0; background: #14171d; overflow: hidden; }
.line-gutter { flex: 0 0 48px; padding: 16px 9px 24px 0; overflow: hidden; user-select: none; text-align: right; color: #535b6b; border-right: 1px solid #222731; background: #15181f; white-space: pre; font: 12px/22px var(--mono); font-variant-numeric: tabular-nums; }
.code-viewport { position: relative; min-width: 0; flex: 1; min-height: 0; overflow: hidden; }
.syntax-layer, .code-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 16px 17px 24px; border: 0; outline: 0; overflow: auto; white-space: pre; tab-size: 4; font: 12px/22px var(--mono); font-variant-ligatures: none; letter-spacing: 0; }
.syntax-layer { color: #d7dce7; pointer-events: none; scrollbar-width: none; }
.syntax-layer::-webkit-scrollbar { display: none; }
.code-input { resize: none; color: transparent; -webkit-text-fill-color: transparent; caret-color: #f0edff; background: transparent; z-index: 2; }
.code-input::placeholder { color: #596172; -webkit-text-fill-color: #596172; opacity: 1; }
.code-input::selection { background: rgba(147, 127, 255, .28); color: transparent; -webkit-text-fill-color: transparent; }
.output-code-editor .code-input { cursor: text; }
.syntax-layer .tok-keyword { color: #c5a4ff; }
.syntax-layer .tok-string { color: #a8d6a2; }
.syntax-layer .tok-comment { color: #747d8d; font-style: italic; }
.syntax-layer .tok-number { color: #e8bd83; }
.syntax-layer .tok-builtin { color: #8ec9df; }
.syntax-layer .tok-function { color: #82b9ed; }
.syntax-layer .tok-operator { color: #d0b8ff; }
.syntax-layer .tok-type { color: #e1a8cb; }
.output-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: var(--subtle); pointer-events: none; z-index: 1; }
.output-empty[hidden] { display: none; }
.empty-icon { display: grid; place-items: center; width: 38px; height: 38px; margin-bottom: 3px; border: 1px solid #303544; border-radius: 9px; background: #191d25; }
.empty-icon svg { width: 18px; height: 18px; fill: none; stroke: #777f91; stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; }
.output-empty strong { color: #aab1bf; font-size: 12px; font-weight: 600; }
.output-empty > span:last-child { font-size: 10px; }
.panel-footer { min-height: 33px; padding: 0 13px; border-top: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--subtle); font-size: 10px; }
.panel-footer > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-language { color: #687183; font: 9px var(--mono); letter-spacing: .07em; flex-shrink: 0; }
.workspace-divider { display: flex; align-items: center; justify-content: center; }
.workspace-divider span { height: 42px; width: 1px; background: linear-gradient(transparent, #393248, transparent); }
.action-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; }
.action-left { display: flex; align-items: center; gap: 15px; min-width: 0; }
.shortcut-hint { color: var(--subtle); font-size: 10px; display: flex; align-items: center; gap: 4px; }
kbd { min-width: 19px; padding: 3px 5px; color: #aab1c0; border: 1px solid #353b49; border-radius: 4px; background: #191d25; font: 9px var(--mono); text-align: center; }
.button-primary { min-width: 170px; min-height: 42px; padding: 0 15px; border-color: #7967d6; background: #7863df; color: white; font-size: 12px; box-shadow: inset 0 1px 0 rgba(255,255,255,.12); }
.button-primary:hover:not(:disabled) { background: #8874f1; border-color: #9887f5; }
.button-primary:disabled { opacity: .55; }
.button-primary svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }
.button-arrow { margin-left: auto; font-size: 16px; opacity: .8; }
.button-spinner { display: none; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.35); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }
.button-primary.is-loading .button-spinner { display: block; }
.button-primary.is-loading .beautify-icon { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-region { min-height: 46px; margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--border-soft); }
.status-message { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--muted); font-size: 11px; }
.status-mark { flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: #747c8b; }
.status-message[data-tone="success"] .status-mark { background: var(--green); }
.status-message[data-tone="error"] .status-mark { background: var(--red); }
.status-message[data-tone="working"] .status-mark { background: var(--yellow); animation: pulse 1.2s infinite; }
#status-text { overflow-wrap: anywhere; }
.result-stats { color: var(--subtle); font: 10px var(--mono); white-space: nowrap; }
.page-footer { display: flex; justify-content: space-between; gap: 12px; padding-top: 17px; margin-top: 11px; border-top: 1px solid var(--border-soft); color: #626a79; font-size: 10px; }

@media (min-width: 1700px) {
  .main-content { padding-top: 54px; }
  .editor-panel { height: min(66vh, 820px); }
  .syntax-layer, .code-input { font-size: 13px; line-height: 23px; }
  .line-gutter { font-size: 13px; line-height: 23px; }
}
@media (max-width: 980px) {
  .main-content { padding-top: 32px; }
  .intro-row { align-items: flex-start; }
  .workspace { gap: 12px; }
  .editor-panel { height: 56vh; min-height: 410px; }
  .panel-heading { padding: 11px; }
  .panel-title-group p { max-width: 150px; }
  .button-small { padding: 0 7px; }
}
@media (max-width: 720px) {
  .topbar { height: 62px; padding: 0 16px; }
  .topbar-right { gap: 8px; }
  .privacy-note { display: none; }
  .engine-status { font-size: 10px; padding: 6px 8px; }
  .main-content { padding: 28px 14px 18px; }
  .intro-row { display: block; margin-bottom: 19px; }
  h1 { font-size: 26px; }
  .intro-copy { max-width: 570px; font-size: 12px; }
  .engine-credit { display: none; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .workspace-divider { display: none; }
  .editor-panel { height: 440px; min-height: 340px; }
  .panel-heading { min-height: 58px; }
  .panel-title-group p { max-width: 155px; }
  .action-row { margin-top: 13px; align-items: stretch; flex-wrap: wrap; }
  .action-left { order: 2; width: 100%; justify-content: space-between; }
  .button-primary { order: 1; width: 100%; min-height: 44px; }
  .status-region { align-items: flex-start; padding: 12px 0; }
  .result-stats { font-size: 9px; }
}
@media (max-width: 420px) {
  .brand-copy small { font-size: 8px; }
  .brand-mark { width: 31px; height: 31px; }
  .engine-status { max-width: 132px; overflow: hidden; }
  .panel-heading { gap: 6px; padding: 9px; }
  .panel-title-group { gap: 7px; }
  .panel-title-group p { max-width: 112px; font-size: 9px; }
  .panel-actions { gap: 4px; }
  .button-small { padding: 0 6px; }
  .button-small span { font-size: 9px; }
  .line-gutter { flex-basis: 38px; padding-right: 7px; font-size: 11px; }
  .syntax-layer, .code-input { padding-left: 11px; font-size: 11px; }
  .panel-footer { font-size: 9px; }
  .shortcut-hint { font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
