:root {
  --bg: #ece7dc;
  --panel: #fbf8f1;
  --text: #2a2f3d;
  --muted: #6b6f7a;
  --border: #d6cfbf;
  --accent: #1f2b4a;
  --accent-text: #fbf8f1;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1d22;
    --panel: #25282f;
    --text: #e6e2d8;
    --muted: #a3a6ae;
    --border: #3a3e47;
    --accent: #c9b98f;
    --accent-text: #1b1d22;
  }
}

:root[data-theme="dark"] {
  --bg: #1b1d22;
  --panel: #25282f;
  --text: #e6e2d8;
  --muted: #a3a6ae;
  --border: #3a3e47;
  --accent: #c9b98f;
  --accent-text: #1b1d22;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Zen Kaku Gothic New", system-ui, sans-serif;
  line-height: 1.6;
}

.site-header {
  padding: 24px 16px 8px;
  max-width: 1280px;
  margin: 0 auto;
}

.site-header h1 { margin: 0; font-size: 1.5rem; }
.site-header p { margin: 4px 0 0; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 24px;
  padding: 16px;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.row .field { flex: 1 1 140px; }

/* 横並びの中で入力欄の幅を超えて広がらないように、中身の幅より縮めてよいことにする */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; min-width: 0; }
.field > span { color: var(--muted); }

.check { display: flex; gap: 8px; align-items: center; font-size: 0.9rem; padding-bottom: 8px; }

textarea, input, select, button {
  font: inherit;
  color: inherit;
}

textarea, input[type="date"], select {
  width: 100%;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* iPhone の Safari は日付欄に独自の最小幅を持たせ、文字を中央に寄せるため、ほかの欄とそろえる */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  min-height: 2.6em;
  text-align: left;
}

input[type="date"]::-webkit-date-and-time-value { text-align: left; }

textarea { resize: vertical; line-height: 1.7; }

.notice {
  margin: 0;
  padding: 8px 12px;
  border-left: 3px solid #b5523b;
  background: var(--bg);
  font-size: 0.9rem;
}

.actions { display: flex; gap: 12px; flex-wrap: wrap; }

button {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.preview-area {
  position: sticky;
  top: 16px;
  display: flex;
  justify-content: center;
}

#preview {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  box-shadow: 0 2px 12px rgb(0 0 0 / 0.15);
}

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .preview-area { position: static; }
  #preview { max-height: none; }
}
