:root {
  --bg: #f5f7fb;
  --bg-card: #ffffff;
  --text: #1c2433;
  --text-soft: #5b6678;
  --border: #e2e8f2;
  --border-strong: #cfd8e8;
  --accent: #3b6cf6;
  --accent-hover: #2f59d6;
  --accent-soft: #eaf0ff;
  --chip: #eef2fb;
  --danger: #d64545;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.05), 0 6px 24px rgba(20, 30, 60, 0.06);
  --radius: 14px;
  --radius-sm: 9px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --bg-card: #171d2b;
    --text: #e8edf6;
    --text-soft: #9aa6bd;
    --border: #283146;
    --border-strong: #344056;
    --accent: #5b86ff;
    --accent-hover: #6f95ff;
    --accent-soft: #1d2740;
    --chip: #212a3d;
    --danger: #f0746e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-header {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 8px;
}

.brand { display: flex; align-items: center; gap: 16px; }
.logo { color: var(--accent); flex: none; }
.brand-text h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }
.tagline { margin: 2px 0 0; color: var(--text-soft); font-size: 0.95rem; }

.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 24px 48px;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 24px;
  align-items: start;
}

.panel { display: flex; flex-direction: column; gap: 20px; }
.panel.preview { position: sticky; top: 24px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.step {
  display: inline-grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  flex: none;
}

.hint { margin: 0 0 14px; color: var(--text-soft); font-size: 0.88rem; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .input, .row > input { flex: 1 1 auto; min-width: 0; }

.input, .select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
}
.input:focus, .select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
textarea { resize: vertical; }

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; color: var(--text-soft); }
.btn-ghost:hover { color: var(--danger); border-color: transparent; }
.btn-small { padding: 6px 10px; font-size: 0.85rem; margin-top: 14px; }

/* Quick-add buttons */
.quick-add { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.quick-add button {
  font: inherit;
  font-size: 0.82rem;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-soft);
  border-radius: 999px;
  padding: 4px 11px;
  cursor: pointer;
}
.quick-add button:hover { color: var(--accent); border-color: var(--accent); }
.quick-add button[disabled] { opacity: 0.4; cursor: default; }

/* Time zone chips */
.chips { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--chip);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px 8px 12px;
}
.chip .chip-main { flex: 1 1 auto; min-width: 0; }
.chip .chip-zone { font-weight: 600; font-size: 0.92rem; }
.chip .chip-sub { color: var(--text-soft); font-size: 0.8rem; }
.chip .chip-label {
  font: inherit;
  font-size: 0.85rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  border-radius: 7px;
  padding: 5px 8px;
  width: 130px;
  flex: none;
}
.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  flex: none;
}
.icon-btn:hover { color: var(--danger); background: rgba(214, 69, 69, 0.08); }

/* Slot list */
.slot-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.slot {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px 9px 12px;
}
.slot-when { flex: 1 1 auto; min-width: 0; }
.slot-when .slot-date { font-weight: 600; font-size: 0.92rem; }
.slot-when .slot-time { color: var(--text-soft); font-size: 0.82rem; }

/* Customize section */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 0.85rem; font-weight: 600; color: var(--text-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.field.checkbox input { width: auto; }
.field.checkbox span { font-weight: 500; color: var(--text); }

/* Preview */
.preview-card { display: flex; flex-direction: column; }
.preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.preview-head h2 { margin: 0; }
.preview-text {
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 120px;
  max-height: 60vh;
  overflow: auto;
}
.empty-note { color: var(--text-soft); font-size: 0.85rem; margin: 12px 0 0; }

.app-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 40px;
  color: var(--text-soft);
  font-size: 0.82rem;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg-card);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 20;
  animation: toast-in 0.18s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .panel.preview { position: static; }
}
@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
  .chip .chip-label { width: 96px; }
}
