:root {
  --ink: #1d1f23;
  --muted: #68707d;
  --line: #d8dde5;
  --soft: #f5f7fa;
  --accent: #246bfe;
  --accent-soft: #e8efff;
  --danger: #d92d20;
  --danger-soft: #fff1f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #fff;
  font-family:
    Inter, "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.app {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  min-height: 100vh;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 32px;
  border-right: 1px solid var(--line);
  background: #fff;
}

.brand h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: 0;
}

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

.field {
  display: grid;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.field span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.field b {
  display: inline-flex;
  color: var(--ink);
  font-weight: 650;
  white-space: nowrap;
}

.text-field textarea {
  width: 100%;
  min-height: 86px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-size: 18px;
  line-height: 1.45;
  outline: none;
  resize: vertical;
}

.text-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.grid {
  display: grid;
  gap: 18px;
}

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

.outline-field {
  opacity: 0.42;
}

.outline-field.active {
  opacity: 1;
}

.outline-field input:disabled {
  cursor: not-allowed;
}

.mode-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.mode-group legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 14px;
}

.mode-group label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}

.mode-group input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-group label:has(input:checked) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 650;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.stats > span {
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.stats > span b {
  color: var(--ink);
}

#densityText {
  grid-column: 1 / -1;
  text-align: center;
}

.stats .danger {
  border-color: #f1aaa4;
  color: var(--danger);
  background: var(--danger-soft);
}

.stats .danger b {
  color: var(--danger);
}

.stage-wrap {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px;
  min-width: 0;
  padding: 28px;
  background:
    linear-gradient(#eef1f5 1px, transparent 1px),
    linear-gradient(90deg, #eef1f5 1px, transparent 1px),
    #fff;
  background-size: 32px 32px;
}

#stage {
  width: 100%;
  height: 100%;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ad-slot {
  display: grid;
  place-items: center;
  min-height: 96px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: #9aa3af;
  background: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

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

  .controls {
    padding: 22px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage-wrap {
    min-height: 56vh;
    padding: 16px;
  }

  #stage {
    min-height: 420px;
  }
}
