:root {
  color-scheme: light;
  --bg: #f2efe7;
  --panel: rgba(255, 251, 244, 0.88);
  --panel-strong: #fffaf0;
  --line: rgba(112, 87, 56, 0.18);
  --text: #2d261f;
  --muted: #77685b;
  --accent: #ee6c4d;
  --accent-strong: #d94f2d;
  --shadow: 0 18px 45px rgba(77, 53, 25, 0.12);
  --checker-a: rgba(161, 149, 134, 0.12);
  --checker-b: rgba(255, 255, 255, 0.75);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(244, 154, 107, 0.22), transparent 28%),
    radial-gradient(circle at bottom right, rgba(255, 214, 10, 0.18), transparent 24%),
    linear-gradient(160deg, #f7f2e8 0%, #ede3d2 100%);
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  grid-template-areas:
    "tuning stage"
    "tuning results";
  gap: 20px;
  padding: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand h1,
.stage-head h2,
.status-card h2 {
  margin: 0;
  font-family: "Avenir Next", "Hiragino Kaku Gothic ProN", sans-serif;
  letter-spacing: 0.01em;
}

.brand h1 {
  font-size: 1.55rem;
  letter-spacing: 0.12em;
  line-height: 1.05;
  color: #1f1712;
}

.brand {
  display: grid;
  gap: 10px;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hint,
.status-card p,
.placeholder,
small {
  color: var(--muted);
}

.top-panel {
  grid-area: top;
  padding: 28px;
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
}

.top-panel.is-empty {
  display: none;
}

.file-drop {
  display: grid;
  gap: 4px;
  padding: 20px;
  border: 2px dashed rgba(217, 79, 45, 0.28);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 246, 235, 0.9));
  cursor: pointer;
}

.file-drop.dragging {
  border-color: var(--accent-strong);
  transform: translateY(-1px);
}

.file-drop input {
  display: none;
}

.control-group {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.tuning-panel {
  display: grid;
  gap: 18px;
  min-width: 0;
}

#topContent,
#tuningContent {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.control-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

select,
button {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  background: #fffdf8;
  color: var(--text);
}

button {
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

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

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(180deg, #ff845f 0%, #e7603b 100%);
  color: white;
  border-color: transparent;
}

.secondary-actions button {
  background: rgba(255, 255, 255, 0.82);
}

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

.status-card {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(112, 87, 56, 0.1);
  min-width: 0;
}

.status-card ol {
  margin: 10px 0 14px;
  padding-left: 20px;
}

.tuning-card,
.stage,
.result-card,
.results-panel {
  padding: 20px;
}

.tuning-card {
  grid-area: tuning;
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 28px 30px;
  min-width: 0;
}

.stage {
  grid-area: stage;
  min-width: 0;
}

.results-panel {
  grid-area: results;
  min-width: 0;
}

.stage-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 16px;
}

.stage-head.compact {
  margin-bottom: 12px;
}

.canvas-wrap {
  position: relative;
  min-height: 280px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(112, 87, 56, 0.12);
  background-color: rgba(255, 255, 255, 0.55);
}

.canvas-wrap.solid-preview {
  background-image: none;
}

.checkerboard {
  background-image:
    linear-gradient(45deg, var(--checker-a) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-a) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-a) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-a) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-color: var(--checker-b);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
}

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

.preview-toolbar {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.preview-actions {
  margin-top: 12px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "top"
      "stage"
      "tuning"
      "results";
  }
}

@media (max-width: 760px) {
  .result-grid,
  .actions,
  .stage-head {
    grid-template-columns: 1fr;
  }

  .stage-head {
    align-items: start;
  }

  .app-shell {
    padding: 14px;
  }

  .top-panel,
  .tuning-card,
  .stage,
  .results-panel {
    padding: 16px;
  }

  .brand h1 {
    font-size: 1.3rem;
  }

  .canvas-wrap {
    min-height: 220px;
  }
}
