:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e3e6ec;
  --text: #1c2230;
  --muted: #6b7384;
  --accent: #2f6feb;
  --accent-text: #ffffff;
  --shadow: 0 1px 2px rgba(20, 28, 50, 0.05), 0 4px 12px rgba(20, 28, 50, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c;
    --panel: #1a2030;
    --border: #2a3346;
    --text: #e9ecf3;
    --muted: #9aa3b6;
    --accent: #4d8bff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  padding: 28px 32px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -0.01em; }
.tagline { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.tagline code { font-size: 13px; }

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  padding: 24px;
  align-items: start;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card h2 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 28px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.dropzone.dragging { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.dropzone.small { padding: 14px 12px; }
.dz-title { font-weight: 500; }
.dz-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.optional { font-weight: 400; color: var(--muted); text-transform: none; font-size: 11px; letter-spacing: 0; }
.font-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 4px; }
.font-list:empty { display: none; }
.font-list li {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; font-size: 12px; padding: 6px 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
.font-list .name { font-family: ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-list .remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 2px 4px; }
.font-list .remove:hover { color: #d33a3a; }
.font-hint { font-size: 11px; color: var(--muted); margin: 10px 0 0; line-height: 1.4; }
.font-hint code { font-size: 11px; background: var(--bg); padding: 1px 4px; border-radius: 3px; }

.link-button {
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
}
.link-button:hover { text-decoration: underline; }

.primary, .secondary {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 120ms, opacity 120ms;
  font-family: inherit;
}
.primary {
  background: var(--accent);
  color: var(--accent-text);
}
.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
}
.primary:hover, .secondary:not(:disabled):hover { filter: brightness(1.08); }
.secondary:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.primary:disabled, .secondary:disabled { opacity: 0.4; cursor: not-allowed; }

.download-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }

.status {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
  min-height: 1.4em;
}
.status.error { color: #d33a3a; }
.status.success { color: #1d8a4d; }

.log { margin-top: 10px; font-size: 12px; }
.log pre {
  max-height: 200px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 6px;
  white-space: pre-wrap;
}

.placeholder p { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0; }

.form-card form { display: grid; gap: 18px; }
.section-group { display: grid; gap: 12px; }
.section-group h3 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.field { display: grid; gap: 4px; }
.field label.field-label {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.field .field-desc { font-size: 12px; color: var(--muted); }
.field input[type="text"],
.field input[type="number"],
.field select {
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.field input[type="range"] { width: 100%; }
.field .range-row { display: flex; gap: 10px; align-items: center; }
.field .range-row input[type="number"] { width: 80px; }
.field .checkbox-row { display: flex; align-items: center; gap: 8px; }

.viewer-card #viewer {
  width: 100%;
  height: 360px;
  border-radius: 8px;
  background: #0e1320;
  overflow: hidden;
}
.viewer-hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
