:root {
  --bg: #0e0f12;
  --surface: #16181e;
  --surface-hover: #1c1f28;
  --border: #2a2e38;
  --text: #e8eaef;
  --text-muted: #8b92a3;
  --accent: #7c9cff;
  --accent-soft: rgba(124, 156, 255, 0.15);
  --radius: 12px;
  --font: "Noto Sans SC", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(124, 156, 255, 0.12), transparent 50%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.subtitle strong {
  color: var(--accent);
  font-weight: 500;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone__inner {
  text-align: center;
  padding: 1.5rem;
}

.dropzone__icon {
  display: block;
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
  opacity: 0.9;
}

.dropzone .hint {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 380px);
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

.preview-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
}

.preview-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.preview-toggle {
  display: flex;
  gap: 0.25rem;
  padding: 0.2rem;
  background: var(--bg);
  border-radius: 8px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.is-active {
  background: var(--surface-hover);
  color: var(--text);
}

.canvas-frame {
  position: relative;
  padding: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 280px;
  background:
    linear-gradient(45deg, #1a1d24 25%, transparent 25%),
    linear-gradient(-45deg, #1a1d24 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a1d24 75%),
    linear-gradient(-45deg, transparent 75%, #1a1d24 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #12141a;
}

.pick-hint {
  position: absolute;
  left: 50%;
  bottom: 0.75rem;
  transform: translateX(-50%);
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  background: rgba(124, 156, 255, 0.95);
  color: #0a0b0e;
  font-size: 0.78rem;
  font-weight: 600;
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.canvas-frame canvas {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: min(78vh, 900px);
}

.tool-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.75rem 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.tool-tab {
  flex: 1;
  min-width: 3.2rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.74rem;
  padding: 0.4rem 0.35rem;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.tool-tab:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.tool-tab.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.controls-scroll {
  overflow-y: auto;
  padding: 1rem 1.2rem 0.25rem;
  flex: 1;
  min-height: 0;
}

.tool-panel .controls__title {
  margin-top: 0;
}

.controls__title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.controls__desc {
  margin: 0 0 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.field {
  margin-bottom: 1.25rem;
}

.field label,
.label-block {
  display: block;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.unit {
  font-family: var(--mono);
  font-size: 0.8rem;
  opacity: 0.85;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
}

.value {
  font-family: var(--mono);
  font-size: 0.85rem;
  min-width: 3.5rem;
  text-align: right;
  color: var(--accent);
}

.field-hint {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.color-row {
  display: flex;
  gap: 1rem;
}

.color-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.color-chip input[type="color"] {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 4px;
  background: var(--bg);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0;
  padding: 0.85rem 1.2rem 1.15rem;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.radio-row {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.radio {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
}

.radio input {
  accent-color: var(--accent);
}

.row--stack {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.mini-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.mini-field input[type="range"] {
  flex: 1;
}

.mini-field .value {
  min-width: 3rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

.check input {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
}

.text-input,
.select-input {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.select-input {
  cursor: pointer;
}

.color-chip--full {
  max-width: 100%;
}

.btn--small {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 0.75rem;
}

.row.gap {
  gap: 0.5rem;
}

.text-input--grow,
.select-input--grow {
  flex: 1;
  min-width: 0;
}

.btn--block {
  width: 100%;
  margin-top: 0.5rem;
}

.preset-row {
  margin-top: 0.45rem;
}

.file-inline {
  width: 100%;
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}

.footer a {
  color: var(--accent);
}

.btn {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.btn--primary {
  background: var(--accent);
  color: #0a0b0e;
  font-weight: 600;
  border-color: var(--accent);
}

.btn--primary:hover {
  filter: brightness(1.08);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn--ghost:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.footer {
  margin-top: 2.5rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}
