:root {
  --bg: #f6f7f8;
  --card: #ffffff;
  --text: #15191e;
  --muted: #68727d;
  --line: #e3e7eb;
  --cell: #eef1f4;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e0f2ef;
  --heat: #0f9d8a;
  --danger: #c2410c;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111417;
    --card: #1a1e23;
    --text: #eef1f4;
    --muted: #97a1ab;
    --line: #2b3138;
    --cell: #252b32;
    --accent: #2dd4bf;
    --accent-ink: #06231f;
    --accent-soft: #143530;
    --heat: #2dd4bf;
    --danger: #fb923c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  word-break: keep-all;
}
h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1080px; margin: 0 auto; padding: 14px 16px;
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; letter-spacing: -0.02em; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); box-shadow: inset 0 0 0 5px color-mix(in srgb, var(--accent) 60%, #fff); }
.top-new { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; padding: 6px 10px; border-radius: 8px; }
.top-new:hover { background: var(--cell); color: var(--text); }

main { max-width: 1080px; margin: 0 auto; padding: 4px 16px 64px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.loading { text-align: center; color: var(--muted); padding: 80px 0; }
.error { color: var(--danger); font-size: 14px; font-weight: 600; }

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

/* 버튼·입력 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card);
  font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none; color: var(--text);
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.wide { width: 100%; min-height: 52px; font-size: 17px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.icon-btn { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; font-size: 24px; line-height: 1; cursor: pointer; }
.icon-btn:hover { background: var(--cell); }

.input {
  width: 100%; min-height: 44px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card);
}
.input.big { min-height: 52px; font-size: 18px; font-weight: 600; }
.input:focus-visible, .btn:focus-visible, .icon-btn:focus-visible, .cal-day:focus-visible, .day-btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.segment { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--cell); }
.segment button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.segment button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }

/* 만들기 화면 */
.hero { text-align: center; padding: 28px 0 24px; }
.hero h1 { font-size: clamp(28px, 6vw, 42px); line-height: 1.2; letter-spacing: -0.03em; }
.hero p { color: var(--muted); max-width: 440px; margin: 12px auto 0; }

.create { max-width: 520px; margin: 0 auto; display: grid; gap: 22px; }
.create { grid-template-columns: minmax(0, 1fr); }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.label { font-weight: 800; font-size: 15px; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

.calendar { border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-title { font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; user-select: none; -webkit-user-select: none; }
.cal-wd { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.sun { color: #dc4a3d; }
.sat { color: #3b82c4; }
.cal-day {
  aspect-ratio: 1; min-width: 0; padding: 0; border: 0; border-radius: 10px; background: transparent;
  font-weight: 600; cursor: pointer; touch-action: none;
}
.cal-day { position: relative; }
.cal-day.alt:not(.on) { background: color-mix(in srgb, var(--cell) 55%, transparent); }
.cal-day small { position: absolute; top: 2px; left: 0; right: 0; font-size: 9px; font-weight: 800; line-height: 1; color: var(--accent); pointer-events: none; }
.cal-day.on small { color: inherit; }
.cal-day:hover:not(:disabled):not(.on) { background: var(--cell); }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--muted); }
.cal-day.on { background: var(--accent); color: var(--accent-ink); }
.cal-day:disabled { color: var(--muted); opacity: 0.4; cursor: default; }

.day-picker { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day-btn { min-height: 48px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-weight: 700; cursor: pointer; }
.day-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.time-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.time-fields .field span { font-size: 13px; color: var(--muted); font-weight: 600; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 720px; margin: 32px auto 0; }
.step { text-align: center; padding: 8px; }
.step-n { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 14px; margin-bottom: 6px; }
.step strong { display: block; }
.step p { font-size: 13px; color: var(--muted); }

.empty { max-width: 420px; margin: 60px auto; text-align: center; display: grid; gap: 12px; justify-items: center; }
.empty h1 { font-size: 22px; }

/* 일정 화면 */
.event { display: grid; gap: 14px; }
.event-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 0 4px; }
.event-head h1 { font-size: clamp(24px, 5vw, 32px); letter-spacing: -0.02em; line-height: 1.25; overflow-wrap: anywhere; }
.share { display: flex; gap: 8px; }

.confirmed-box {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--accent); color: var(--accent-ink); border-radius: var(--radius); padding: 14px 18px; font-size: 17px;
}
.confirmed-box .btn { border-color: color-mix(in srgb, var(--accent-ink) 40%, transparent); color: var(--accent-ink); }
.confirmed-tag { display: inline-block; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: color-mix(in srgb, var(--accent-ink) 22%, transparent); margin-right: 8px; vertical-align: 2px; }

.best { background: var(--accent-soft); border-radius: var(--radius); padding: 16px 18px; }
.best h2 { font-size: 14px; color: var(--accent); margin-bottom: 8px; }
.best-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.best-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.best-list .btn { flex: none; }
.best-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--card); color: var(--muted); white-space: nowrap; }
.badge.full { background: var(--accent); color: var(--accent-ink); }

.tabs { display: none; }
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.panel { display: grid; gap: 12px; min-width: 0; }
.panel h2 { font-size: 17px; }

.login { display: grid; gap: 10px; }
.login-lead { font-weight: 600; }
.login-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }

.editor { display: grid; gap: 10px; }
.editor-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.save-status { font-size: 13px; color: var(--accent); font-weight: 700; min-height: 1em; }
.editor-foot { display: flex; gap: 6px; flex-wrap: wrap; }
.editor-foot .push { margin-left: auto; }

.people, .chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--cell); }
.chip.me { background: var(--accent-soft); color: var(--accent); }
.chip.yes { background: var(--accent-soft); color: var(--accent); }
.chip.no { color: var(--muted); text-decoration: line-through; }
.detail { min-height: 64px; border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; align-content: center; }
.detail-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail .badge { background: var(--cell); }

/* 시간표 */
.grid-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px 4px; }
.grid {
  display: grid;
  grid-template-columns: 46px repeat(var(--cols), minmax(46px, 1fr));
  column-gap: 3px;
  user-select: none; -webkit-user-select: none;
}
.g-corner, .g-time { position: sticky; left: 0; z-index: 1; background: var(--card); }
.g-day { text-align: center; padding: 2px 0 8px; display: grid; line-height: 1.2; }
.g-day b { font-size: 14px; }
.g-day span { font-size: 12px; color: var(--muted); font-weight: 600; }
.g-day span.sun { color: #dc4a3d; }
.g-day span.sat { color: #3b82c4; }
.g-time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; padding-right: 6px; text-align: right; line-height: 1; transform: translateY(-5px); }
.cell { height: 26px; background: var(--cell); border-bottom: 1px solid var(--card); }
.cell.hour { border-top: 2px solid var(--card); }
.grid.mine .cell { cursor: pointer; touch-action: none; }
.grid.mine .cell.on, .tiles.mine .tile.on { background: var(--accent); color: var(--accent-ink); }
.grid.all .cell { cursor: default; }
.cell.confirmed { box-shadow: inset 3px 0 0 var(--text), inset -3px 0 0 var(--text); }

/* 날짜만 정하는 일정 */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; user-select: none; -webkit-user-select: none; }
.tile { min-height: 64px; border-radius: 12px; background: var(--cell); display: grid; place-content: center; text-align: center; line-height: 1.25; padding: 6px; }
.tile b { font-size: 16px; }
.tile span { font-size: 12px; font-weight: 600; color: var(--muted); }
.tile em { font-style: normal; font-size: 12px; font-weight: 800; }
.tiles.mine .tile { cursor: pointer; touch-action: none; }
.tiles.mine .tile.on span, .tile.hot span { color: inherit; opacity: 0.85; }
.tile.hot, .cell.hot { color: var(--accent-ink); }
.tile.confirmed { box-shadow: 0 0 0 3px var(--text); }

.legend { display: flex; align-items: center; justify-content: flex-end; gap: 8px; font-size: 12px; color: var(--muted); }
.legend-bar { width: 96px; height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--cell), var(--heat)); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; width: max-content; max-width: calc(100vw - 32px); text-align: center; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 휴대폰 */
@media (max-width: 820px) {
  .tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 12px; background: var(--cell); position: sticky; top: 8px; z-index: 5; }
  .tabs button { border: 0; background: transparent; min-height: 40px; border-radius: 10px; font-weight: 800; font-size: 14px; color: var(--muted); cursor: pointer; }
  .event[data-tab="mine"] .tabs button[data-for="mine"],
  .event[data-tab="all"] .tabs button[data-for="all"] { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
  .panels { grid-template-columns: 1fr; }
  .event[data-tab="mine"] .panel-all, .event[data-tab="all"] .panel-mine { display: none; }
  .panel h2 { display: none; }
  .card { padding: 16px; }
  .login-row { grid-template-columns: 1fr 1fr; }
  .login-row .btn { grid-column: 1 / -1; }
  .steps { grid-template-columns: 1fr; gap: 4px; }
  .share { width: 100%; }
  .share .btn { flex: 1; }
}
