:root {
  --canvas: #f6f0e7;
  --surface: #fffdf9;
  --surface-soft: #eee4d6;
  --ink: #2f2925;
  --muted: #7d736c;
  --line: #ded4c7;
  --coral: #c9684d;
  --coral-soft: #f2d6ca;
  --olive: #72816a;
  --olive-soft: #dce3d6;
  --gold: #b69255;
  --gold-soft: #f3e7ca;
  --blue: #677c8c;
  --blue-soft: #e1e9ee;
  --shadow: 0 16px 50px rgba(78, 55, 35, 0.08);
}

* { box-sizing: border-box; }
html { background: var(--canvas); }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 3% 0%, rgba(201, 104, 77, 0.10), transparent 25rem),
    radial-gradient(circle at 100% 12%, rgba(114, 129, 106, 0.10), transparent 28rem),
    var(--canvas);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.login-view {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  min-height: 100dvh;
  padding: 24px;
  place-items: center;
  background:
    radial-gradient(circle at 10% 10%, rgba(201, 104, 77, .16), transparent 30rem),
    radial-gradient(circle at 90% 90%, rgba(114, 129, 106, .15), transparent 32rem),
    var(--canvas);
}

.login-card {
  width: min(470px, 100%);
  padding: clamp(30px, 7vw, 54px);
  border: 1px solid rgba(112, 91, 73, .15);
  border-radius: 32px;
  background: rgba(255, 253, 249, .94);
  box-shadow: 0 28px 90px rgba(78, 55, 35, .13);
  text-align: center;
}

.login-card h1 { font-size: clamp(38px, 9vw, 56px); }
.login-card > p:not(.eyebrow) { color: var(--muted); font-size: 14px; line-height: 1.75; }
.login-form { display: grid; gap: 8px; margin-top: 28px; text-align: left; }
.login-form label { color: var(--muted); font-size: 11px; font-weight: 750; }
.password-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.password-row button {
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  color: white;
  background: var(--coral);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 34px 28px 64px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.top-actions { display: flex; align-items: center; gap: 9px; }
.sync-state {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--olive);
  background: rgba(220, 227, 214, .75);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}
.sync-state i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.sync-state.waiting { color: var(--gold); background: var(--gold-soft); }
.text-button { padding: 7px 5px; border: 0; color: var(--muted); background: transparent; font-size: 11px; cursor: pointer; }

.eyebrow, .section-kicker {
  margin: 0 0 7px;
  color: var(--coral);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 5px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 5vw, 54px);
  font-weight: 500;
  letter-spacing: -.04em;
}

h1 span { color: var(--coral); }
.subtitle { margin-bottom: 0; color: var(--muted); font-size: 14px; }

.icon-button, .close-button {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(47, 41, 37, .12);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(62, 44, 31, .08);
  cursor: pointer;
}

.icon-button { font-size: 28px; }
.close-button { border: 0; box-shadow: none; font-size: 27px; }

.countdown-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 112px;
  margin-bottom: 22px;
  padding: 23px 28px;
  overflow: hidden;
  border-radius: 24px;
  color: #fffaf4;
  background: linear-gradient(115deg, rgba(255,255,255,.10), transparent 45%), #4a3c33;
  box-shadow: var(--shadow);
}

.countdown-label { margin-bottom: 7px; color: #d9cbbd; font-size: 12px; }
.countdown-card strong { font: 500 32px/1 Georgia, serif; }
.countdown-date { display: grid; gap: 4px; text-align: right; }
.countdown-date span { color: #d9cbbd; font-size: 12px; }
.countdown-date b { font-size: 18px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(400px, .86fr) minmax(470px, 1.14fr);
  gap: 22px;
  align-items: start;
}

.calendar-card, .schedule-card {
  border: 1px solid rgba(112, 91, 73, .14);
  border-radius: 28px;
  background: rgba(255, 253, 249, .92);
  box-shadow: var(--shadow);
}

.calendar-card { padding: 25px; }
.schedule-card { overflow: hidden; }

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2 { margin-bottom: 0; font-size: 23px; letter-spacing: -.03em; }
.section-heading p:last-child { margin-bottom: 0; }
.range-chip {
  padding: 8px 11px;
  border-radius: 999px;
  color: var(--olive);
  background: var(--olive-soft);
  font-size: 11px;
  font-weight: 700;
}

.weekdays, .month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays { margin-top: 24px; color: var(--muted); text-align: center; font-size: 11px; }
.month-grid { margin-top: 7px; gap: 5px; }

.day-cell {
  position: relative;
  display: grid;
  min-height: 53px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 15px;
  color: #b8afa7;
  background: transparent;
  cursor: default;
}

.day-cell.in-range { color: var(--ink); background: #f7f1e9; cursor: pointer; }
.day-cell.in-range:hover { background: #efe3d5; }
.day-cell.selected { color: white; background: var(--coral); box-shadow: 0 7px 18px rgba(201, 104, 77, .25); }
.day-number { line-height: 1; }
.event-dots { position: absolute; bottom: 6px; display: flex; gap: 3px; }
.event-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.calendar-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-dot.wedding { background: var(--coral); }
.legend-dot.travel { background: var(--olive); }
.legend-dot.meal { background: var(--gold); }
.legend-dot.todo { background: var(--blue); }

.schedule-heading { padding: 25px 25px 19px; border-bottom: 1px solid var(--line); }
.schedule-heading h2 { margin-bottom: 5px; }
.schedule-heading h2 + p { color: var(--muted); font-size: 12px; }

.add-button, .primary-button {
  border: 0;
  border-radius: 13px;
  color: white;
  background: var(--coral);
  font-weight: 750;
  cursor: pointer;
}

.add-button { padding: 10px 13px; font-size: 12px; white-space: nowrap; }
.primary-button { width: 100%; padding: 14px 18px; }

.all-day {
  display: grid;
  grid-template-columns: 53px 1fr;
  gap: 12px;
  padding: 12px 16px 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 240, 231, .55);
}

.all-day > span { padding-top: 8px; color: var(--muted); font-size: 10px; text-align: right; }
#all-day-events { display: grid; gap: 6px; }
.all-day-event {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid rgba(201, 104, 77, .2);
  border-left: 4px solid var(--coral);
  border-radius: 10px;
  background: #fff2eb;
  cursor: pointer;
}
.all-day-event.travel { border-color: rgba(114,129,106,.22); border-left-color: var(--olive); background: #eef3e9; }
.all-day-event.meal { border-color: rgba(182,146,85,.22); border-left-color: var(--gold); background: #fbf3e1; }
.all-day-event.todo { border-color: rgba(103,124,140,.22); border-left-color: var(--blue); background: #edf3f6; }
.all-day-event.completed span { text-decoration: line-through; opacity: .55; }
.all-day-event small { color: var(--muted); }

.timeline-wrap {
  position: relative;
  height: min(580px, 64vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #d1c3b5 transparent;
}

.timeline {
  position: relative;
  height: 1440px;
  margin-left: 70px;
  border-left: 1px solid var(--line);
}

.hour-line { position: absolute; left: 0; right: 0; height: 1px; background: #eee6dc; }
.half-hour-line { position: absolute; left: 0; right: 0; height: 1px; background: #f5efe8; }
.hour-label {
  position: absolute;
  left: -58px;
  top: -7px;
  width: 44px;
  color: #a3978d;
  font-size: 10px;
  text-align: right;
}

.empty-timeline {
  position: absolute;
  top: 510px;
  left: 50%;
  width: min(250px, calc(100% - 40px));
  transform: translateX(-50%);
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}
.empty-timeline b { display: block; margin-bottom: 5px; color: var(--ink); font-size: 14px; }

.event-card {
  position: absolute;
  min-height: 34px;
  padding: 8px 11px;
  overflow: hidden;
  border: 1px solid rgba(201, 104, 77, .2);
  border-left: 4px solid var(--coral);
  border-radius: 11px;
  background: #fff2eb;
  box-shadow: 0 5px 16px rgba(72, 52, 40, .07);
  cursor: pointer;
  text-align: left;
}

.event-card.travel { border-color: rgba(114,129,106,.22); border-left-color: var(--olive); background: #eef3e9; }
.event-card.meal { border-color: rgba(182,146,85,.22); border-left-color: var(--gold); background: #fbf3e1; }
.event-card.todo { border-color: rgba(103,124,140,.22); border-left-color: var(--blue); background: #edf3f6; }
.event-card.completed { opacity: .55; }
.event-card.completed .event-title { text-decoration: line-through; }
.event-time { margin: 0 0 3px; color: var(--coral); font-size: 10px; font-weight: 800; }
.event-card.travel .event-time { color: var(--olive); }
.event-card.meal .event-time { color: var(--gold); }
.event-card.todo .event-time { color: var(--blue); }
.event-title { margin: 0; overflow: hidden; font-size: 13px; font-weight: 780; text-overflow: ellipsis; white-space: nowrap; }
.event-note { margin: 4px 0 0; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.editor {
  width: min(520px, calc(100% - 24px));
  padding: 0;
  border: 0;
  border-radius: 26px;
  background: var(--surface);
  box-shadow: 0 30px 100px rgba(50, 36, 27, .25);
}

.editor::backdrop { background: rgba(47, 41, 37, .38); backdrop-filter: blur(5px); }
.editor-form { display: grid; gap: 15px; padding: 24px; }
.editor-handle { display: none; }
.editor-header { display: flex; align-items: flex-start; justify-content: space-between; }
.editor-header h2 { margin-bottom: 0; }
.editor label { display: grid; gap: 7px; font-size: 12px; font-weight: 750; }
.editor label small { color: var(--muted); font-weight: 500; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  color: var(--ink);
  background: #fff;
}

input, select { min-height: 46px; padding: 0 13px; }
textarea { padding: 12px 13px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--coral); box-shadow: 0 0 0 3px var(--coral-soft); }
.time-fields { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; }
.time-arrow { padding-bottom: 14px; color: var(--muted); }
.minute-note { margin: -8px 0 0; color: var(--muted); font-size: 11px; }
.time-fields.disabled { opacity: .42; }

.check-label { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 9px !important; cursor: pointer; }
.check-label input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--coral); }
.editor-actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.delete-button {
  padding: 0 16px;
  border: 1px solid #e6c6bc;
  border-radius: 13px;
  color: #a54632;
  background: #fff5f1;
  font-weight: 750;
  cursor: pointer;
}
.form-error { min-height: 16px; margin: -5px 0 0; color: #a54632; font-size: 11px; }

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 999px;
  color: white;
  background: #3e342d;
  box-shadow: 0 12px 34px rgba(47, 41, 37, .2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity .2s ease, transform .2s ease;
  font-size: 12px;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .app-shell { padding: 26px 18px 48px; }
  .workspace { grid-template-columns: 1fr; }
  .timeline-wrap { height: 540px; }
}

@media (max-width: 580px) {
  .app-shell { padding: max(20px, env(safe-area-inset-top)) 12px calc(40px + env(safe-area-inset-bottom)); }
  .topbar { align-items: center; padding: 0 6px; margin-bottom: 20px; }
  .top-actions { align-items: flex-end; flex-wrap: wrap; justify-content: flex-end; }
  .sync-state { order: 2; }
  .text-button { display: none; }
  h1 { font-size: 36px; }
  .subtitle { font-size: 12px; }
  .countdown-card { min-height: 96px; padding: 20px; border-radius: 20px; }
  .calendar-card, .schedule-card { border-radius: 22px; }
  .calendar-card { padding: 20px 14px; }
  .day-cell { min-height: 47px; border-radius: 13px; }
  .calendar-legend { gap: 12px; }
  .schedule-heading { padding: 21px 18px 17px; }
  .timeline { margin-left: 57px; }
  .hour-label { left: -49px; }
  .editor { align-self: end; width: 100%; max-width: none; margin: auto 0 0; border-radius: 24px 24px 0 0; }
  .editor-form { max-height: 92dvh; overflow-y: auto; padding: 10px 20px calc(20px + env(safe-area-inset-bottom)); }
  .editor-handle { display: block; width: 44px; height: 5px; margin: 0 auto 5px; border-radius: 99px; background: var(--line); }
  .login-view { padding: 12px; }
  .login-card { border-radius: 26px; }
}

@media (prefers-reduced-motion: no-preference) {
  .icon-button, .add-button, .day-cell, .event-card { transition: transform .18s ease, background .18s ease, box-shadow .18s ease; }
  .icon-button:hover, .add-button:hover { transform: translateY(-2px); }
  .event-card:hover { z-index: 5; transform: translateY(-1px); }
  .editor[open] { animation: rise .22s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
}
