:root {
  --bg: #0b0b0b;
  --panel: #171717;
  --panel-2: #1f1f1f;
  --text: #f2f2f2;
  --muted: #a0a0a0;
  --accent: #f7971d;
  --line: #2e2e2e;
  --input: #101010;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    BlinkMacSystemFont,
    'Segoe UI',
    'Hiragino Sans',
    'Hiragino Kaku Gothic ProN',
    'Yu Gothic UI',
    'Yu Gothic',
    Meiryo,
    system-ui,
    -apple-system,
    sans-serif;
  background:
    radial-gradient(circle at top right, rgba(247, 151, 29, 0.08), transparent 28%),
    linear-gradient(180deg, #111, #090909 30%, #060606);
  color: var(--text);
  min-height: 100vh;
}

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px;
}

.header {
  margin-bottom: 20px;
}

.title {
  margin: 0 0 8px;
  font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.7rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.grid {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-preview {
  content-visibility: auto;
  contain-intrinsic-size: 760px;
}

.panel-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.panel-head h2 {
  margin: 0 0 6px;
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.controls {
  padding: 18px 20px 20px;
}

.field + .field,
.row + .row,
details + details,
.actions,
.hint-box,
.meta {
  margin-top: 14px;
}

.field label,
details summary {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
  color: #fff;
  font-weight: 600;
}

.field input[type='text'],
.field input[type='number'],
.field select {
  width: 100%;
  border: 1px solid #333;
  background: var(--input);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.98rem;
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.field input[type='text']:focus,
.field input[type='number']:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(247, 151, 29, 0.14);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.inline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}

.inline input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.inline span {
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.4;
}

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

.color-input {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
  align-items: center;
}

.color-input input[type='color'] {
  width: 52px;
  height: 44px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.color-input input[type='text'] {
  min-width: 0;
}

details {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 12px;
}

details summary {
  margin: 0;
  cursor: pointer;
  list-style: none;
}

details summary::-webkit-details-marker {
  display: none;
}

.small {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

button {
  border: none;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    opacity 0.12s ease,
    box-shadow 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.primary {
  background: var(--accent);
  color: #000;
  box-shadow: 0 10px 26px rgba(247, 151, 29, 0.22);
}

.secondary {
  background: #252525;
  color: #fff;
  border: 1px solid #363636;
}

.preview-wrap {
  padding: 18px;
}

.checker {
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 16px;
  background:
    linear-gradient(45deg, #161616 25%, transparent 25%),
    linear-gradient(-45deg, #161616 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #161616 75%),
    linear-gradient(-45deg, transparent 75%, #161616 75%);
  background-size: 24px 24px;
  background-position:
    0 0,
    0 12px,
    12px -12px,
    -12px 0;
}

.canvas-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 260px;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.preview-placeholder {
  position: absolute;
  inset: auto 16px 16px;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
  background: rgba(8, 8, 8, 0.72);
  backdrop-filter: blur(10px);
  transition:
    opacity 0.16s ease,
    transform 0.16s ease;
}

.canvas-frame.is-ready .preview-placeholder {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

#previewCanvas {
  display: block;
  width: min(100%, 1000px);
  height: auto;
  border-radius: 12px;
  background: transparent;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.38);
  opacity: 0;
  transition: opacity 0.16s ease;
}

.canvas-frame.is-ready #previewCanvas {
  opacity: 1;
}

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

.stat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}

.stat .label {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 5px;
}

.stat strong {
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.hint-box {
  border: 1px dashed #3a3a3a;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.92rem;
  background: rgba(255, 255, 255, 0.015);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 8px;
  color: #fff;
}

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

@media (max-width: 720px) {
  .page {
    padding: 18px;
  }

  .row,
  .colors,
  .actions,
  .meta {
    grid-template-columns: 1fr;
  }
}
