﻿:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d6dbe3;
  --accent: #0f766e;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, #e8f5f4 0%, transparent 35%),
    radial-gradient(circle at 90% 15%, #fff0df 0%, transparent 30%),
    var(--bg);
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 32px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.panel.small {
  font-size: 14px;
}

h1,
h2 {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
}

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

.section-head h2 {
  margin: 0;
}

.muted {
  color: var(--muted);
  margin: 8px 0 0;
}

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

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.options-top-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
}

fieldset {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

legend {
  padding: 0 6px;
  font-weight: 600;
}

label {
  display: block;
  margin: 8px 0 4px;
  font-size: 14px;
}

.inline-row {
  display: grid;
  grid-template-columns: max-content 64px max-content minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 6px 0 8px;
}

.mode-row {
  margin-bottom: 12px;
  flex-wrap: nowrap;
}

.row-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.inline-row label {
  margin: 0;
  white-space: nowrap;
}

.control-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.control-row input {
  margin: 0;
}

.compact-two-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.compact-three-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.split-two-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
  margin-top: 8px;
}

.split-item label {
  margin-top: 2px;
}

.compact-item label {
  margin-top: 2px;
}

.control-row.compact {
  grid-template-columns: 74px minmax(0, 1fr);
  margin-bottom: 0;
}

.control-row.compact.mini {
  grid-template-columns: 68px minmax(80px, 130px);
  justify-self: start;
  width: 100%;
}

.control-row.compact.mini input[type="number"] {
  justify-self: start;
}

.control-row.compact.mini input[type="range"] {
  min-width: 0;
  width: 100%;
}

.mode-row .inline {
  margin: 0;
  white-space: nowrap;
}

label.inline {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 8px;
}

input,
textarea,
select,
button {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #c7cfda;
  border-radius: 8px;
  font: inherit;
}

input[type="checkbox"] {
  width: auto;
}

input[type="color"] {
  height: 40px;
  padding: 4px;
}

textarea {
  resize: vertical;
}

button {
  background: var(--accent);
  color: #fff;
  border-color: #0d5f58;
  cursor: pointer;
  font-weight: 600;
}

button:hover:not(:disabled) {
  filter: brightness(0.95);
}

button:disabled {
  background: #9ca3af;
  border-color: #9ca3af;
  cursor: not-allowed;
}

.drop-zone {
  display: block;
  border: 2px dashed #94a3b8;
  border-radius: 12px;
  text-align: center;
  padding: 20px;
  background: #f9fafb;
  cursor: pointer;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: #e6fffb;
}

.drop-zone input {
  display: none;
}

.font-meta p {
  margin: 6px 0;
}

.preview-wrap {
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: auto;
  padding: 10px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

#preview-canvas {
  display: block;
  margin: 0 auto;
  image-rendering: -webkit-optimize-contrast;
}

.actions {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.actions button {
  width: auto;
}

.preview-actions {
  margin-top: 0;
  margin-left: auto;
}

.status {
  min-height: 22px;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.hidden {
  display: none;
}

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

.ad-slot {
  border: 1px dashed #94a3b8;
  background: #f8fafc;
  border-radius: 8px;
  min-height: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--muted);
}

ul {
  margin: 0;
  padding-left: 18px;
}

@media (max-width: 860px) {
  .grid.two,
  .options-top-grid,
  .ad-slots {
    grid-template-columns: 1fr;
  }

  .inline-row {
    grid-template-columns: auto 1fr;
  }

  .inline-row .control-row.compact.mini {
    grid-column: 1 / -1;
  }

  .compact-two-row {
    grid-template-columns: 1fr;
  }

  .compact-three-row {
    grid-template-columns: 1fr;
  }

  .split-two-row {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .preview-actions {
    margin-left: 0;
  }

  .actions button {
    width: 100%;
  }
}
