:root {
  color-scheme: dark;
  --bg: #0b1426;
  --bg-soft: #0f1b31;
  --panel: #101c31;
  --panel-2: #142238;
  --muted-panel: #17263d;
  --border: #253751;
  --border-soft: #1b2a42;
  --text: #eff6ff;
  --text-soft: #9eb0c9;
  --text-muted: #7287a5;
  --primary: #08a9e6;
  --primary-hover: #20b9ef;
  --primary-soft: rgba(8, 169, 230, .12);
  --success: #42d392;
  --danger: #fb7185;
  --shadow: 0 24px 65px rgba(0, 0, 0, .22);
  --radius: 13px;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-soft: #eaf0f7;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --muted-panel: #eef3f8;
  --border: #cfdae8;
  --border-soft: #e2e8f0;
  --text: #132137;
  --text-soft: #52647c;
  --text-muted: #718197;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-soft: rgba(2, 132, 199, .10);
  --shadow: 0 20px 55px rgba(15, 23, 42, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif; font-size: 14px; line-height: 1.6; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.topbar { height: 72px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 93%, transparent); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(16px); }
.nav-wrap { width: min(1218px, calc(100% - 36px)); height: 100%; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 40px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 750; letter-spacing: -.03em; white-space: nowrap; }
.brand em { padding: 2px 7px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 9px; font-style: normal; letter-spacing: .08em; }
.brand-mark { width: 40px; height: 25px; position: relative; display: inline-block; transform: rotate(-6deg); }
.brand-mark::before { content: ""; position: absolute; width: 35px; height: 12px; left: 0; top: 7px; border-radius: 60% 15% 40% 35%; background: linear-gradient(135deg, #ffad0b, #f26b00); box-shadow: inset -8px -2px 0 #e44b00; }
.brand-mark::after { content: ""; position: absolute; width: 17px; height: 4px; left: 8px; top: 3px; border-radius: 100%; background: #ff6b00; box-shadow: 12px 15px 0 -1px #6f829f; }
.brand-mark span { position: absolute; right: 0; top: 7px; width: 7px; height: 12px; border-left: 3px solid #607491; transform: rotate(7deg); }
nav { display: flex; gap: 35px; margin-left: auto; }
nav a { color: var(--text-soft); padding: 23px 0 20px; border-bottom: 2px solid transparent; transition: .2s; }
nav a:hover, nav a.active { color: var(--text); border-color: var(--primary); }
.nav-actions { display: flex; align-items: center; gap: 14px; }
.status-dot { display: inline-flex; align-items: center; gap: 7px; color: var(--text-soft); font-size: 12px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 999px; }
.status-dot i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(66, 211, 146, .1); }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; color: var(--text-soft); background: var(--panel-2); }
.icon-btn:hover { color: var(--primary); }
.icon-btn svg { width: 19px; }

.page-shell { width: min(1218px, calc(100% - 36px)); margin: 22px auto 70px; }
.tool-card { background: var(--bg-soft); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tool-heading { min-height: 96px; display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding: 18px 22px; border-bottom: 3px solid var(--border); }
.tool-icon { width: 54px; height: 54px; display: grid; place-items: center; border: 1px solid rgba(8, 169, 230, .3); border-radius: 50%; color: var(--primary); background: radial-gradient(circle at 35% 30%, rgba(35, 200, 255, .25), rgba(8, 169, 230, .07)); }
.tool-icon svg { width: 29px; stroke-width: 2.4; }
.tool-heading h1 { margin: 0; font-size: 23px; letter-spacing: -.02em; }
.tool-heading p { margin: 2px 0 0; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-heading .eyebrow { margin: 0 0 -2px; color: var(--primary); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; }
.heading-badges { display: flex; gap: 7px; }
.heading-badges span, .language-badge { color: var(--primary); background: var(--primary-soft); border: 1px solid rgba(8, 169, 230, .18); border-radius: 999px; padding: 3px 9px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 2.15fr) minmax(300px, .9fr); gap: 22px; padding: 22px; align-items: start; }
.work-column { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.settings-column { min-width: 0; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 94px; }
.panel { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); }
.input-panel, .result-panel { padding: 20px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.panel-head.compact { align-items: center; }
.panel-head p { margin: 3px 0 0; color: var(--text-muted); font-size: 12px; }
.step-label { display: flex; align-items: center; gap: 9px; font-weight: 720; font-size: 16px; }
.step-label span { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; color: var(--primary); background: var(--primary-soft); font-size: 12px; }
.privacy-pill { flex: none; display: flex; align-items: center; gap: 6px; color: var(--success); background: rgba(66, 211, 146, .08); border-radius: 999px; padding: 5px 9px; font-size: 11px; }
.privacy-pill svg { width: 14px; }
.editor-wrap { border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: #091326; transition: border-color .2s, box-shadow .2s; }
html[data-theme="light"] .editor-wrap { background: #f7fafc; }
.editor-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.editor-toolbar { height: 38px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-bottom: 1px solid var(--border-soft); color: var(--text-muted); font-size: 11px; }
.editor-toolbar span:first-child { display: flex; align-items: center; gap: 7px; }
.editor-toolbar i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
.editor-toolbar i.ready { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { width: 100%; resize: vertical; border: 0; outline: 0; color: var(--text); background: transparent; }
#nodeInput { display: block; min-height: 250px; padding: 15px; font: 12.5px/1.7 "Cascadia Code", "SFMono-Regular", Consolas, monospace; }
textarea::placeholder, input::placeholder { color: var(--text-muted); opacity: .78; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
label > span { display: block; margin-bottom: 6px; color: var(--text); font-size: 12px; font-weight: 620; }
input, select { width: 100%; min-height: 38px; border: 1px solid var(--border); border-radius: 7px; padding: 0 11px; color: var(--text); background: var(--panel); outline: none; transition: .2s; }
input:hover, select:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.action-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 16px; }
.secondary-actions, .result-actions > div:last-child { display: flex; gap: 9px; }
.button { min-height: 38px; border-radius: 8px; border: 1px solid var(--border); padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--text); background: transparent; font-weight: 620; transition: transform .16s, border-color .16s, background .16s; }
.button:hover { transform: translateY(-1px); border-color: var(--primary); }
.button.primary { border-color: var(--primary); color: #fff; background: var(--primary); box-shadow: 0 8px 20px rgba(8, 169, 230, .18); }
.button.primary:hover { background: var(--primary-hover); }
.button.danger { color: var(--danger); }
.button svg { width: 17px; }
.button[disabled] { opacity: .55; cursor: wait; transform: none; }

.result-panel.is-empty .result-output, .result-panel.is-empty .result-actions, .result-panel.is-empty .language-badge { display: none; }
.result-panel:not(.is-empty) .empty-state { display: none; }
.empty-state { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); border: 1px dashed var(--border); border-radius: 9px; text-align: center; }
.empty-state svg { width: 48px; margin-bottom: 10px; opacity: .46; }
.empty-state strong { color: var(--text-soft); font-size: 14px; }
.empty-state span { font-size: 12px; }
.result-output { min-height: 380px; padding: 15px; resize: vertical; color: #bdd9ed; background: #071121; border: 1px solid var(--border); border-radius: 9px; font: 12px/1.65 "Cascadia Code", "SFMono-Regular", Consolas, monospace; tab-size: 2; }
html[data-theme="light"] .result-output { color: #1e3a5f; background: #f7fafc; }
.result-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 13px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; color: var(--text-muted); font-size: 11px; }
.stats span { padding: 4px 8px; border-radius: 5px; background: var(--muted-panel); }

.settings-panel, .summary-panel { padding: 18px 19px; }
.aside-title { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 17px; }
.aside-title.small { align-items: center; margin-bottom: 12px; }
.aside-title h2 { margin: 0; font-size: 16px; }
.aside-title p { margin: 2px 0 0; color: var(--text-muted); font-size: 12px; }
.aside-icon { flex: none; width: 39px; height: 39px; display: grid; place-items: center; border-radius: 8px; color: var(--primary); background: var(--primary-soft); }
.aside-icon.neutral { color: var(--text-soft); background: var(--muted-panel); }
.aside-icon svg { width: 20px; }
.settings-form { display: flex; flex-direction: column; gap: 13px; }
.settings-form small { display: block; color: var(--text-muted); font-size: 10px; margin-top: 5px; }
.source-link { color: var(--primary); white-space: nowrap; }
.source-link:hover { text-decoration: underline; }
.settings-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hidden { display: none !important; }
.summary-panel dl { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.summary-panel dl div { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 9px 10px; border-radius: 7px; background: var(--muted-panel); }
.summary-panel dt { color: var(--text-muted); }
.summary-panel dd { margin: 0; text-align: right; font-weight: 650; }
.success-text { color: var(--success); }
.privacy-card { display: flex; gap: 12px; padding: 16px; border: 1px solid rgba(66, 211, 146, .18); border-radius: var(--radius); color: var(--text-soft); background: rgba(66, 211, 146, .055); }
.privacy-card > svg { flex: none; width: 21px; color: var(--success); }
.privacy-card strong { color: var(--text); font-size: 12px; }
.privacy-card p { margin: 3px 0 0; font-size: 11px; line-height: 1.55; }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mini-card { min-width: 0; padding: 15px; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--panel); }
.mini-card h2 { margin: 10px 0 3px; font-size: 13px; }
.mini-card p { margin: 0; color: var(--text-muted); font-size: 11px; }
.mini-icon { display: inline-grid; place-items: center; width: 27px; height: 27px; border-radius: 7px; color: var(--primary); background: var(--primary-soft); font-size: 9px; font-weight: 800; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 50; max-width: min(420px, calc(100% - 30px)); padding: 10px 15px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); background: var(--panel-2); box-shadow: var(--shadow); opacity: 0; transform: translate(-50%, 20px); pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(251, 113, 133, .45); color: #fecdd3; }
footer { border-top: 1px solid var(--border); color: var(--text-muted); font-size: 11px; }
footer > div { width: min(1218px, calc(100% - 36px)); min-height: 74px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .settings-column { position: static; grid-row: 1; }
  .settings-form { display: grid; grid-template-columns: repeat(2, 1fr); }
  .settings-split { display: contents; }
  .summary-panel, .privacy-card { display: none; }
}

@media (max-width: 680px) {
  .topbar { height: 62px; }
  .nav-wrap, .page-shell, footer > div { width: min(100% - 20px, 1218px); }
  .brand { font-size: 17px; }
  .brand-mark { width: 34px; transform: scale(.9) rotate(-6deg); transform-origin: left center; margin-right: -3px; }
  nav { display: none; }
  .status-dot { display: none; }
  .page-shell { margin-top: 10px; }
  .tool-heading { grid-template-columns: auto minmax(0, 1fr); padding: 15px; }
  .tool-icon { width: 45px; height: 45px; }
  .heading-badges { display: none; }
  .tool-heading h1 { font-size: 20px; }
  .workspace-grid { padding: 10px; gap: 10px; }
  .input-panel, .result-panel, .settings-panel { padding: 14px; }
  .settings-form, .inline-fields, .info-grid { grid-template-columns: 1fr; }
  .settings-column { gap: 10px; }
  .privacy-pill { display: none; }
  #nodeInput { min-height: 220px; }
  .action-row, .result-actions { align-items: stretch; flex-direction: column; }
  .secondary-actions, .result-actions > div:last-child { display: grid; grid-template-columns: 1fr 1fr; }
  .action-row > .primary { width: 100%; }
  footer > div { min-height: 68px; flex-direction: column; justify-content: center; gap: 2px; }
}
