:root {
  --bg: #faf7f3;
  --surface: #ffffff;
  --surface-2: #f3ede6;
  --border: #e9e0d6;
  --text: #201a15;
  --text-dim: #6b6058;
  --accent: #f97316;
  --accent-dim: #ffedd5;
  --on: #f97316;
  --off: #c9bfb4;
  --danger: #dc2626;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(40, 20, 0, 0.06), 0 2px 10px rgba(40, 20, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171210;
    --surface: #221a15;
    --surface-2: #2b2119;
    --border: #3a2d23;
    --text: #f3ece4;
    --text-dim: #a89a8c;
    --accent: #fb923c;
    --accent-dim: #4a2a12;
    --on: #fb923c;
    --off: #564b40;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  --bg: #171210;
  --surface: #221a15;
  --surface-2: #2b2119;
  --border: #3a2d23;
  --text: #f3ece4;
  --text-dim: #a89a8c;
  --accent: #fb923c;
  --accent-dim: #4a2a12;
  --on: #fb923c;
  --off: #564b40;
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo",
    "Malgun Gothic", sans-serif;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100vh;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px 48px;
}

header {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 19px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.icon-btn {
  border: none;
  background: var(--surface-2);
  color: var(--text-dim);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.card h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}

.row + .row { border-top: 1px solid var(--border); }

.room-name {
  font-size: 16px;
  font-weight: 600;
}

.room-sub {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

.switch {
  position: relative;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: var(--off);
  border: none;
  flex-shrink: 0;
  transition: background 0.15s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.switch.on { background: var(--on); }
.switch.on::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.5; }

.speed-group {
  display: flex;
  gap: 6px;
}

.pill-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
}

.pill-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.temp-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.temp-value {
  min-width: 56px;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
}

.step-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 17px;
  line-height: 1;
}

.step-btn:disabled { opacity: 0.4; }

.meta-row {
  display: flex;
  gap: 14px;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

.actions-row {
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #2a1200;
}

.btn.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.form-group { margin-bottom: 12px; }

.form-group label {
  display: block;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 600;
}

select, input[type="datetime-local"], input[type="number"], input[type="time"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
}

.day-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.day-group .pill-btn {
  padding: 8px 0;
  width: 38px;
  text-align: center;
}

.form-note {
  font-size: 12px;
  color: var(--text-dim);
  margin: -4px 0 12px;
}

.mode-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 12px;
}

.mode-tabs button {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-dim);
}

.mode-tabs button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }

.resv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
}

.resv-item + .resv-item { border-top: 1px solid var(--border); }

.resv-label { font-size: 14.5px; font-weight: 600; }
.resv-time { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

.empty-note {
  font-size: 13.5px;
  color: var(--text-dim);
  text-align: center;
  padding: 8px 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}

.modal h3 { margin: 0 0 8px; font-size: 16px; }
.modal p { font-size: 13.5px; color: var(--text-dim); margin: 0 0 14px; }

#toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
