:root {
  color-scheme: dark;
  --bg: #071018;
  --panel: rgba(11, 19, 29, 0.92);
  --panel-border: #27384a;
  --panel-soft: rgba(39, 56, 74, 0.55);
  --text: #eff7ff;
  --muted: #94a8bb;
  --accent: #58d1ff;
  --accent-soft: rgba(88, 209, 255, 0.14);
  --warn: #f7d072;
  --surface: #111b26;
  --surface-strong: #172434;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(24, 42, 61, 0.44), transparent 40%),
    linear-gradient(180deg, #08111a 0%, #060d14 100%);
  color: var(--text);
  font-family: "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  max-width: 2500px;
  margin: 0 auto;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 20px 22px;
  border-radius: 18px;
  background: rgba(8, 14, 22, 0.9);
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.hero h1 {
  margin: 0;
  font-size: 24px;
}

.subtitle {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file-button,
.ghost-button,
.tiny-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: 0.16s ease;
}

.file-button:hover,
.ghost-button:hover,
.tiny-button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.file-button {
  min-width: 190px;
  padding: 12px 16px;
}

.file-button input {
  display: none;
}

.ghost-button {
  min-width: 160px;
  padding: 12px 16px;
}

.tiny-button {
  padding: 7px 11px;
  font-size: 12px;
}

.controls-group {
  padding: 16px;
}

.ad-rect {
  min-height: 250px;
  display: grid;
  place-items: center;
}

.stage-center {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.controls-panel {
  padding: 18px;
}

.source-panel,
.preview-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-header {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--panel-soft);
}

.panel-header h2,
.section h2 {
  margin: 0;
  font-size: 16px;
}

.panel-header p,
.status-text {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.section {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--panel-soft);
}

.section:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-grid label,
.check {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.field-grid input,
.field-grid select {
  width: 100%;
  border: 1px solid var(--panel-border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
}

.checkbox-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.check {
  flex-direction: row;
  align-items: center;
}

.source-stage {
  flex: 1;
  overflow: auto;
  padding: 18px;
  max-height: 60vh;
}

#source-canvas {
  width: 100%;
  height: auto;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.04) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.04) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  border-radius: 12px;
}

.preview-main {
  padding: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#preview-canvas {
  width: 256px;
  height: 256px;
  border-radius: 14px;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.04) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.04) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  box-shadow: inset 0 0 0 1px var(--panel-border);
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px;
  padding: 0 18px 18px;
  overflow-y: auto;
}

.thumb-card {
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--surface);
  padding: 8px;
  cursor: pointer;
  transition: 0.16s ease;
}

.thumb-card:hover,
.thumb-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.thumb-card canvas {
  width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.04) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.04) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.thumb-card p {
  margin: 6px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1600px) {
  .stage-center {
    grid-template-columns: 1fr;
  }
}

/* ---- web-service layout: note, ads, content, guides, footer ---- */
.tool-note {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

.ad-slot {
  border: 1px dashed var(--panel-border);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.012);
}

.ad-top {
  min-height: 90px;
  display: grid;
  place-items: center;
}

.below {
  width: 100%;
  max-width: 900px;
  margin: 8px auto 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.content {
  color: #dbe7f1;
  line-height: 1.75;
  font-size: 15px;
}
.content h2 {
  font-size: 19px;
  margin: 24px 0 8px;
  padding-left: 11px;
  border-left: 4px solid var(--accent);
}
.content h3 { font-size: 15px; color: var(--accent); margin: 16px 0 4px; }
.content p { margin: 9px 0; }
.content ol, .content ul { margin: 9px 0 9px 2px; padding-left: 22px; }
.content li { margin: 6px 0; }
.content strong { color: #fff; }

.faq h3 {
  background: var(--surface); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 11px 13px; margin: 10px 0 0; color: var(--text); font-size: 14.5px;
}
.faq p {
  background: var(--surface-strong); border: 1px solid var(--panel-border); border-top: 0;
  border-radius: 0 0 10px 10px; margin: 0 0 8px; padding: 11px 13px; color: #cfe0ee; font-size: 14px;
}

.links-panel { border: 1px solid var(--panel-border); border-radius: 14px; background: var(--panel); padding: 14px; }
.links-head { font-size: 13px; font-weight: 800; color: var(--accent); margin-bottom: 10px; }
.links-panel a {
  display: block; color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--panel-border); border-radius: 10px;
  background: var(--surface);
}
.links-panel a:last-child { margin-bottom: 0; }
.links-panel a:hover { border-color: var(--accent); }
.links-panel a span { color: var(--muted); font-weight: 400; }

.site-footer {
  text-align: center; color: var(--muted); font-size: 12px; line-height: 1.8;
  padding: 16px 0 0; border-top: 1px solid var(--panel-border); margin-top: 4px;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* ---- 3-column rail layout ---- */
.page {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr) 400px;
  gap: 18px;
  align-items: stretch;
}
.center {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.rail-left, .rail-right { min-width: 0; }
.ad-sky { min-height: 600px; }
.sticky {
  position: sticky;
  top: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* Controls live in the rails, so we never hide them — below 1200px the
   columns stack (canvas first, then control panels) and un-stick. */
@media (max-width: 1400px) {
  .page { grid-template-columns: 1fr; }
  .center { order: -1; }
  .sticky { position: static; }
}
