:root {
  color-scheme:light;
  --bg:#f5f7fa;
  --surface:#ffffff;
  --inset:#f8fafc;
  --hover:#eef2f6;
  --line:#d5dde6;
  --text:#182431;
  --muted:#526174;
  --accent:#157347;
  --accent-ink:#ffffff;
  --error:#b42332;
  --drop-border:#8c9bad;
  --control-border:#8392a5;
  --control-hover:#526174;
  --placeholder:#64748b;
  --accent-hover:#115c39;
  --secondary-hover:#e2e8f0;
  --selected-bg:#e9f5ee;
  --selected-border:#91baa2;
  --code-text:#22563d;
  --code-bg:#f8fafc;
  --radius:14px;
  font-family:Inter,"Segoe UI","Microsoft YaHei",sans-serif;
  font-size:16px;
  line-height:1.6;
  color:var(--text);
  background:var(--bg);
}

:root[data-theme="dark"] {
  color-scheme:dark;
  --bg:#0d1117;
  --surface:#141b24;
  --inset:#0f151e;
  --hover:#1d2836;
  --line:#2d3a4b;
  --text:#edf2f7;
  --muted:#a3b0c2;
  --accent:#74e3af;
  --accent-ink:#082c1c;
  --error:#ff9d9d;
  --drop-border:#50637a;
  --control-border:#46556a;
  --control-hover:#7b8aa0;
  --placeholder:#9ba9bd;
  --accent-hover:#9bedc7;
  --secondary-hover:#29394c;
  --selected-bg:#173128;
  --selected-border:#32644d;
  --code-text:#bae9d1;
  --code-bg:#0b1119;
}

* {
  box-sizing:border-box;
}

body {
  margin:0;
}

button,input,textarea,select {
  font:inherit;
}

button,a,input,textarea,select,summary {
  -webkit-tap-highlight-color:transparent;
}

button,summary,select {
  cursor:pointer;
}

a {
  color:inherit;
  text-decoration:none;
}

button,input,textarea,select {
  max-width:100%;
}

button {
  touch-action:manipulation;
}

a:hover {
  color:var(--accent);
}

[hidden] {
  display:none!important;
}

h1,h2,p {
  margin:0;
}

h2 {
  font-size:20px;
  line-height:1.4;
}

button,a,summary,.control,.drop-zone {
  transition:background-color .18s,border-color .18s,color .18s;
}

button:focus-visible,a:focus-visible,summary:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible {
  outline:2px solid var(--accent);
  outline-offset:4px;
}

.sr-only,.skip-link:not(:focus) {
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
}

.skip-link:focus {
  position:fixed;
  top:8px;
  left:8px;
  background:var(--surface);
  padding:12px;
  z-index:10;
}

.topbar {
  min-height:80px;
  padding:16px 4%;
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
}

.brand {
  display:flex;
  align-items:center;
  gap:12px;
  font-size:17px;
  font-weight:650;
}

.brand-mark {
  display:grid;
  place-items:center;
  width:38px;
  height:38px;
  background:var(--accent);
  color:var(--accent-ink);
  border-radius:10px;
  font-family:Consolas,monospace;
  font-size:22px;
}

.brand-caption {
  font-size:13px;
  font-weight:400;
  color:var(--muted);
  border-left:1px solid var(--line);
  padding-left:14px;
  margin-left:4px;
}

.source-link {
  display:flex;
  align-items:center;
  min-height:44px;
  gap:12px;
  font-size:14px;
  color:var(--muted);
}

.shell {
  max-width:1520px;
  margin:auto;
  padding:48px 4% 64px;
  min-height:calc(100dvh - 160px);
}

.intro {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:24px;
  margin-bottom:32px;
}

.eyebrow {
  font:600 11px/1.8 Consolas,monospace;
  letter-spacing:2px;
  color:var(--muted);
  margin-bottom:10px;
}

h1 {
  font-size:clamp(28px,3vw,38px);
  line-height:1.35;
  letter-spacing:1px;
  font-weight:600;
}

.intro-copy {
  margin-top:12px;
  color:var(--muted);
  font-size:14px;
}

.local-note {
  display:flex;
  align-items:center;
  gap:10px;
  font-size:12px;
  color:var(--muted);
  white-space:nowrap;
}

.status-dot {
  display:inline-block;
  width:7px;
  height:7px;
  border-radius:50%;
  background:var(--accent);
}

.panel {
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius);
  min-width:0;
}

.import-panel>summary {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  list-style:none;
  min-height:68px;
  padding:18px 24px;
  font-size:15px;
  font-weight:600;
}

.import-panel>summary::-webkit-details-marker {
  display:none;
}

.import-panel>summary::after {
  content:'＋';
  color:var(--muted);
  font-size:20px;
}

.import-panel[open]>summary::after {
  content:'−';
}

.step {
  font:12px Consolas,monospace;
  color:var(--accent);
  margin-right:14px;
}

.summary-hint {
  font-size:12px;
  font-weight:400;
  color:var(--muted);
  margin-left:auto;
}

.import-grid {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:32px;
  padding:0 24px 24px;
}

.drop-zone {
  position:relative;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:10px;
  min-height:164px;
  padding:20px;
  border:1px dashed var(--drop-border);
  border-radius:10px;
  background:var(--inset);
  cursor:pointer;
  text-align:center;
  font-size:14px;
}

.drop-zone svg {
  color:var(--accent);
  margin-bottom:2px;
}

.drop-zone strong {
  color:var(--accent);
  font-weight:500;
}

.drop-zone:hover,.drop-zone.dragging {
  border-color:var(--accent);
  background:var(--hover);
}

.drop-zone:focus-within {
  outline:2px solid var(--accent);
  outline-offset:4px;
}

.drop-zone input {
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  opacity:0;
  cursor:pointer;
}

.remote-section {
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:flex-start;
  gap:8px;
}

.remote-section form {
  width:100%;
}

.remote-controls {
  display:flex;
  gap:10px;
}

.remote-controls input {
  min-width:0;
  flex:1;
}

.remote-controls button {
  flex-shrink:0;
}

.control {
  display:block;
  width:100%;
  border:1px solid var(--control-border);
  background:var(--inset);
  color:var(--text);
  border-radius:8px;
  padding:10px 12px;
  min-height:44px;
  font-size:14px;
}

.control:hover {
  border-color:var(--control-hover);
}

.control::placeholder {
  color:var(--placeholder);
}

.control[aria-invalid=true] {
  border-color:var(--error);
}

textarea.control {
  min-height:108px;
  resize:vertical;
}

.control[multiple] {
  min-height:132px;
}

option {
  padding:5px;
}

.button {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  min-height:44px;
  border:1px solid transparent;
  border-radius:8px;
  padding:9px 16px;
  font-size:13px;
  font-weight:600;
  line-height:1.5;
}

.button.primary {
  background:var(--accent);
  color:var(--accent-ink);
}

.button.primary:hover {
  background:var(--accent-hover);
}

.button.secondary {
  background:var(--hover);
  border-color:var(--control-border);
  color:var(--text);
}

.button.secondary:hover {
  background:var(--secondary-hover);
  border-color:var(--control-hover);
}

.button.subtle {
  padding:8px 0;
  background:transparent;
  color:var(--accent);
  font-weight:400;
}

.button.subtle:hover {
  text-decoration:underline;
}

.button.danger {
  color:var(--error);
}

.button:disabled {
  opacity:.4;
  cursor:not-allowed;
}

.notice {
  font-size:13px;
  color:var(--muted);
  margin:16px 2px 24px;
  min-height:24px;
  overflow-wrap:anywhere;
}

.notice.error {
  color:var(--error);
  border-left:2px solid var(--error);
  padding-left:12px;
}

.empty-state {
  text-align:center;
  padding:48px 16px 32px;
}

.empty-symbol {
  display:inline-grid;
  place-items:center;
  width:70px;
  height:70px;
  border:1px solid var(--line);
  border-radius:18px;
  color:var(--muted);
  font:28px Consolas,monospace;
  margin-bottom:24px;
}

.empty-state h2 {
  font-size:22px;
  font-weight:500;
}

.empty-state>p {
  font-size:14px;
  color:var(--muted);
  margin:10px 0 30px;
}

.workflow {
  list-style:none;
  padding:0;
  margin:0;
  display:flex;
  justify-content:center;
  gap:40px;
  font-size:13px;
  color:var(--muted);
}

.workflow span {
  font:12px Consolas,monospace;
  margin-right:8px;
  color:var(--accent);
}

.format-list {
  display:flex;
  justify-content:center;
  gap:8px;
  margin-top:32px;
}

.format-list span,.type-tag {
  font:11px/1.8 Consolas,monospace;
  color:var(--muted);
  background:var(--inset);
  padding:2px 8px;
  border:1px solid var(--line);
  border-radius:5px;
  white-space:nowrap;
}

.workspace {
  display:grid;
  grid-template-columns:190px minmax(0,1.35fr) minmax(300px,1fr);
  gap:24px;
  align-items:start;
}

.config-sidebar {
  padding:10px 0;
  min-width:0;
}

.config-sidebar h2 {
  font-size:14px;
  display:flex;
  gap:10px;
  align-items:center;
  margin-bottom:20px;
  flex-wrap:wrap;
}

.config-sidebar .eyebrow {
  font-size:10px;
}

.config-item {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  text-align:left;
  width:100%;
  border:1px solid transparent;
  padding:12px;
  border-radius:8px;
  background:transparent;
  color:var(--muted);
  font-size:14px;
  min-height:48px;
  margin-bottom:8px;
  overflow-wrap:anywhere;
}

.config-item:hover {
  background:var(--hover);
  color:var(--text);
}

.config-item.active {
  background:var(--selected-bg);
  border-color:var(--selected-border);
  color:var(--accent);
}

.source-info {
  border-top:1px solid var(--line);
  margin-top:28px;
  padding:20px 8px;
}

.source-info p {
  font:12px/1.7 Consolas,monospace;
  margin:8px 0 14px;
  overflow-wrap:anywhere;
}

.panel-heading {
  padding:24px 24px 0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
}

.panel-heading h2 {
  overflow-wrap:anywhere;
}

.panel-heading .eyebrow {
  font-size:10px;
  margin-bottom:6px;
}

.format-badge {
  color:var(--accent);
  border:1px solid var(--selected-border);
  border-radius:6px;
  padding:4px 10px;
  font:12px/1.6 Consolas,monospace;
}

.editor-description {
  padding:12px 24px 20px;
  color:var(--muted);
  font-size:13px;
  overflow-wrap:anywhere;
  border-bottom:1px solid var(--line);
}

.config-form {
  padding:24px;
}

.field {
  min-width:0;
  margin-bottom:24px;
}

.field:last-child {
  margin-bottom:0;
}

.field-label {
  display:block;
  margin-bottom:8px;
  font-size:14px;
  font-weight:500;
  overflow-wrap:anywhere;
}

.field-key {
  font:11px/1.5 Consolas,monospace;
  color:var(--muted);
  margin-left:10px;
  font-weight:400;
}

.required {
  color:var(--error);
}

.help {
  font-size:12px;
  line-height:1.7;
  color:var(--muted);
  margin-top:7px;
  overflow-wrap:anywhere;
}

.field-error {
  font-size:12px;
  color:var(--error);
  margin-top:7px;
}

.switch {
  appearance:none;
  display:block;
  width:48px;
  height:44px;
  border-radius:20px;
  background:linear-gradient(var(--control-border),var(--control-border)) center/48px 28px no-repeat;
  border:0;
  position:relative;
  cursor:pointer;
  margin:8px 0 12px;
  box-shadow:0 0 0 8px transparent;
}

.switch::before {
  content:'';
  display:block;
  width:20px;
  height:20px;
  background:var(--text);
  border-radius:50%;
  margin:12px 4px;
  transition:transform .18s;
}

.switch:checked {
  background:linear-gradient(var(--accent),var(--accent)) center/48px 28px no-repeat;
}

.switch:checked::before {
  background:var(--accent-ink);
  transform:translateX(20px);
}

.field-group {
  border:1px solid var(--line);
  border-radius:10px;
  padding:0 16px;
  background:var(--inset);
}

.field-group>summary {
  padding:14px 0;
  font-size:14px;
  min-height:48px;
  overflow-wrap:anywhere;
}

.field-group>summary .type-tag {
  float:right;
  margin-left:6px;
}

.group-content {
  padding:14px 0 18px;
}

.field-group>.help {
  margin-top:0;
}

.bound-fields:not(:empty) {
  margin-top:20px;
  padding-left:14px;
  border-left:2px solid var(--selected-border);
}

.bound-fields>div:empty {
  display:none;
}

.editor-actions {
  border-top:1px solid var(--line);
  padding:20px 24px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.editor-actions .help {
  margin:0;
}

.preview-panel {
  position:sticky;
  top:24px;
}

.preview-meta {
  display:flex;
  flex-wrap:wrap;
  justify-content:space-between;
  gap:8px;
  margin:22px 24px 0;
  padding-bottom:12px;
  font:11px/1.7 Consolas,monospace;
  color:var(--muted);
  overflow-wrap:anywhere;
}

#preview {
  display:block;
  width:100%;
  min-height:380px;
  resize:vertical;
  border:0;
  border-top:1px solid var(--line);
  border-bottom:1px solid var(--line);
  border-radius:0;
  padding:20px 24px;
  color:var(--code-text);
  background:var(--code-bg);
  font:13px/1.9 Consolas,"Courier New",monospace;
  tab-size:2;
}

#preview::placeholder {
  color:var(--placeholder);
  font-family:"Segoe UI","Microsoft YaHei",sans-serif;
  font-size:13px;
}

.export-actions {
  display:flex;
  gap:10px;
  padding:20px 24px 0;
}

.export-actions .button {
  flex:1;
}

.preview-help {
  padding:0 24px 20px;
  margin-top:14px;
}

.footer {
  border-top:1px solid var(--line);
  display:flex;
  justify-content:space-between;
  gap:16px;
  padding:24px 4%;
  font-size:12px;
  color:var(--muted);
}

.footer-divider {
  margin:0 12px;
  color:var(--muted);
}

.footer a {
  margin-left:14px;
}

@media(min-width:1500px) {
  .workspace {
    grid-template-columns:210px minmax(0,1.35fr) minmax(350px,1fr);
  }
}

@media(max-width:1100px) {
  .workspace {
    grid-template-columns:160px minmax(0,1fr);
  }
  .preview-panel {
    grid-column:2;
    position:static;
  }
  .config-sidebar {
    grid-row:1 / span 2;
  }
  .local-note {
    display:none;
  }
}

@media(max-width:700px) {
  .topbar {
    padding:12px 5%;
    min-height:68px;
  }
  .brand {
    font-size:14px;
    gap:8px;
  }
  .brand-caption {
    display:none;
  }
  .source-link {
    font-size:12px;
  }
  .shell {
    padding:32px 5% 40px;
  }
  .intro {
    margin-bottom:24px;
  }
  .intro-copy {
    font-size:13px;
    max-width:30em;
  }
  .import-grid {
    grid-template-columns:1fr;
    gap:20px;
    padding:0 16px 20px;
  }
  .import-panel>summary {
    padding:16px;
  }
  .summary-hint {
    display:none;
  }
  .remote-controls {
    flex-wrap:wrap;
  }
  .remote-controls input {
    flex-basis:100%;
  }
  .remote-controls button {
    width:100%;
  }
  .remote-section {
    width:100%;
  }
  .workspace {
    grid-template-columns:minmax(0,1fr);
    gap:20px;
  }
  .config-sidebar {
    grid-row:auto;
    padding:0;
  }
  .config-sidebar .eyebrow,.source-info {
    display:none;
  }
  .config-sidebar h2 {
    margin-bottom:10px;
  }
  #config-list {
    display:flex;
    flex-wrap:wrap;
    gap:8px;
  }
  .config-item {
    width:auto;
    max-width:100%;
    margin:0;
  }
  .preview-panel {
    grid-column:auto;
  }
  .panel-heading {
    padding:20px 20px 0;
  }
  .editor-description {
    padding:12px 20px 18px;
  }
  .config-form {
    padding:20px;
  }
  .editor-actions {
    padding:16px 20px;
    flex-wrap:wrap;
  }
  .editor-actions .button {
    width:100%;
  }
  .control {
    font-size:16px;
  }
  .field-group {
    padding:0 10px;
  }
  .workflow {
    gap:16px;
    flex-wrap:wrap;
    font-size:12px;
  }
  .empty-state {
    padding-top:28px;
  }
  .footer {
    flex-direction:column;
    gap:6px;
    font-size:11px;
  }
  .preview-meta {
    margin-left:20px;
    margin-right:20px;
  }
  #preview {
    padding:16px 20px;
    min-height:300px;
  }
  .export-actions {
    padding:16px 20px 0;
  }
  .preview-help {
    padding:0 20px 20px;
  }
}

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

.header-actions {
  display:flex;
  align-items:center;
  gap:20px;
}

.theme-picker {
  position:relative;
}

.theme-symbols {
  position:absolute;
  width:0;
  height:0;
  overflow:hidden;
}

.theme-trigger {
  display:flex;
  align-items:center;
  gap:10px;
  min-height:44px;
  padding:10px 13px;
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--surface);
  color:var(--text);
  font-size:13px;
  font-weight:500;
}

.theme-trigger:hover,.theme-trigger[aria-expanded="true"] {
  background:var(--hover);
  border-color:var(--selected-border);
}

.theme-icon,.theme-check,.theme-chevron {
  width:18px;
  height:18px;
  flex-shrink:0;
  fill:none;
  stroke:currentColor;
  stroke-width:1.7;
  stroke-linecap:round;
  stroke-linejoin:round;
}

.theme-trigger>.theme-icon {
  color:var(--muted);
}

.theme-chevron {
  width:14px;
  height:14px;
  margin-left:2px;
  color:var(--muted);
  transition:transform .18s;
}

.theme-trigger[aria-expanded="true"] .theme-chevron {
  transform:rotate(180deg);
}

.theme-popover {
  position:absolute;
  top:calc(100% + 10px);
  right:0;
  z-index:20;
  width:252px;
  max-width:calc(100vw - 32px);
  padding:8px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--surface);
  box-shadow:0 12px 40px rgb(0 0 0 / 14%),0 2px 6px rgb(0 0 0 / 6%);
}

.theme-menu-heading {
  padding:5px 10px 10px;
  font-size:11px;
  font-weight:500;
  letter-spacing:1px;
  color:var(--muted);
}

.theme-option {
  display:flex;
  align-items:center;
  gap:12px;
  width:100%;
  min-height:62px;
  padding:10px 12px;
  border:1px solid transparent;
  border-radius:10px;
  background:transparent;
  color:var(--muted);
  text-align:left;
}

.theme-option+.theme-option {
  margin-top:4px;
}

.theme-option:hover {
  background:var(--hover);
}

.theme-option[aria-checked="true"] {
  background:var(--selected-bg);
  color:var(--accent);
}

.theme-option:focus-visible {
  outline-offset:-2px;
}

.theme-option-copy {
  display:flex;
  flex:1;
  flex-direction:column;
  gap:2px;
}

.theme-option-copy>span {
  font-size:13px;
  font-weight:500;
  color:var(--text);
}

.theme-option[aria-checked="true"] .theme-option-copy>span {
  color:var(--accent);
}

.theme-option-copy>small {
  color:var(--muted);
  font-size:11px;
  line-height:1.5;
}

.theme-check {
  width:16px;
  height:16px;
  visibility:hidden;
}

.theme-option[aria-checked="true"] .theme-check {
  visibility:visible;
}

@media(max-width:700px) {
  .topbar { flex-wrap:wrap; }
  .header-actions { gap:12px; margin-left:auto; }
  .theme-trigger { padding:10px; gap:8px; }
}
