/* 토스 스타일 참고: 흰 배경, 큰 굵은 숫자, 회색 표면, 파란 포인트 하나, 테두리 대신 여백 */
:root {
  --bg: #ffffff;
  --surface: #f2f4f6;
  --surface-strong: #e5e8eb;
  --text: #191f28;
  --text-2: #4e5968;
  --text-3: #8b95a1;
  --text-4: #b0b8c1;
  --blue: #3182f6;
  --blue-press: #1b64da;
  --blue-soft: #e8f3ff;
  --orange: #f66d00;
  --orange-soft: #fff3e6;
  --divider: #f2f4f6;
  --radius: 16px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17171c;
    --surface: #26262d;
    --surface-strong: #33333b;
    --text: #f2f2f4;
    --text-2: #c3c3c9;
    --text-3: #8e8e97;
    --text-4: #5c5c66;
    --blue: #4c96ff;
    --blue-press: #3182f6;
    --blue-soft: #1e2a40;
    --orange: #ff8a3d;
    --orange-soft: #3a2a1e;
    --divider: #202027;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: "tnum";
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
button, input { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

/* 상단 */
.top { padding: 16px 20px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; min-width: 0; white-space: nowrap; }
.brand img { width: 30px; height: 30px; object-fit: contain; }

.hero { padding: 16px 20px 16px; }
.hero h1 { font-size: 24px; line-height: 1.35; font-weight: 700; letter-spacing: -0.03em; }
.hero p { margin-top: 6px; font-size: 16px; color: var(--text-3); }

/* 풀장 선택 (세그먼트) */
.segmented {
  margin: 0 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border-radius: 14px;
}
.segmented button {
  height: 40px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-3);
  transition: background .2s, color .2s, box-shadow .2s;
  white-space: nowrap;
}
.segmented button[aria-selected="true"] {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
@media (prefers-color-scheme: dark) {
  .segmented button[aria-selected="true"] { background: var(--surface-strong); }
}

/* 날짜 선택 */
.dates { position: relative; margin-top: 16px; }
.date-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 20px 16px;
  scroll-padding-inline: 20px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.date-strip::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  width: 56px;
  height: 60px;
  border-radius: 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  scroll-snap-align: start;
  transition: background .15s, transform .1s;
}
.chip:active { transform: scale(.96); }
.chip small { font-size: 12px; font-weight: 500; color: var(--text-3); }
.chip strong { font-size: 18px; font-weight: 700; }
.chip.sun small, .chip.sun strong { color: #f04452; }
.chip.sat small, .chip.sat strong { color: var(--blue); }
.chip[aria-pressed="true"] { background: var(--blue); }
.chip[aria-pressed="true"] small, .chip[aria-pressed="true"] strong { color: #fff; }
.chip.pick { width: 68px; }
.chip.pick svg { color: var(--text-2); }
.chip.pick small { color: var(--text-2); }
.chip.pick[aria-pressed="true"] svg { color: #fff; }

.divider { height: 10px; background: var(--divider); }

/* 회차 보드 */
.board { padding: 16px 20px 12px; }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.head-right { display: flex; align-items: center; gap: 8px; }
.board-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.sub { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  color: var(--text-3);
  background: var(--surface);
}
.icon-btn:active { background: var(--surface-strong); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.col-head, .slot {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr 1fr;
  align-items: center;
  column-gap: 8px;
}
.col-head { margin-top: 12px; padding: 0 4px 8px; font-size: 13px; color: var(--text-3); }
.col-head span:not(:first-child), .slot > .v { text-align: right; }
.col-head.no-buoy, .slot.no-buoy { grid-template-columns: 1.25fr 1fr; }
.col-head.no-buoy span:nth-child(n+3) { display: none; }

.slots { list-style: none; }
.slot {
  min-height: 58px;
  padding: 8px 4px;
  border-radius: 12px;
}
.slot + .slot { border-top: 1px solid var(--divider); }
.slot .name strong { display: block; font-size: 17px; font-weight: 700; }
.slot .name small { display: block; margin-top: 2px; font-size: 13px; color: var(--text-3); }

.v { font-weight: 700; }
.v.seats { font-size: 20px; letter-spacing: -0.02em; }
.v.seats .unit { font-size: 14px; font-weight: 600; margin-left: 1px; }
.v.buoy { font-size: 17px; }
.v.buoy .unit { font-size: 13px; font-weight: 600; margin-left: 1px; }
.v.ok { color: var(--blue); }
.v.low { color: var(--orange); }
.v.closed { color: var(--text-4); font-size: 15px; font-weight: 600; }
.v.unknown { color: var(--text-4); font-size: 14px; font-weight: 500; }

.slot.off .name strong { color: var(--text-4); }
.slot.off .off-label { grid-column: 2 / -1; text-align: right; font-size: 14px; color: var(--text-4); }

/* 로딩 스켈레톤 */
.slot.skeleton .bar { height: 18px; border-radius: 6px; background: var(--surface); animation: pulse 1.2s ease-in-out infinite; }
.slot.skeleton .bar.short { width: 60%; justify-self: end; }
@keyframes pulse { 50% { opacity: .5; } }

.hint { margin-top: 12px; font-size: 13px; color: var(--text-3); line-height: 1.5; }
.hint:empty { display: none; }

/* 오류 */
.error { padding: 40px 0 28px; text-align: center; }
.error p { font-size: 16px; color: var(--text-2); }
.error button {
  margin-top: 16px; height: 40px; padding: 0 18px; border-radius: 10px;
  background: var(--blue-soft); color: var(--blue); font-weight: 600; font-size: 15px;
}

/* 유튜브 */
.yt {
  display: flex; align-items: center; gap: 14px;
  margin: 20px; padding: 18px;
  background: var(--surface);
  border-radius: var(--radius);
  transition: transform .1s;
}
.yt:active { transform: scale(.98); }
.yt-icon { flex: 0 0 44px; height: 44px; border-radius: 12px; background: #ff0000; display: grid; place-items: center; }
.yt-text { flex: 1; min-width: 0; }
.yt-text strong { display: block; font-size: 16px; font-weight: 700; }
.yt-text small { display: block; margin-top: 2px; font-size: 13px; color: var(--text-3); }
.chev { color: var(--text-4); }

.notice { padding: 4px 24px 24px; font-size: 12px; line-height: 1.6; color: var(--text-3); }

/* 하단 고정 버튼 */
.cta {
  display: flex; align-items: center; justify-content: center;
  height: 56px; margin-top: 16px;
  border-radius: 16px;
  background: var(--blue); color: #fff;
  font-size: 17px; font-weight: 600;
  transition: background .15s, transform .1s;
}
.cta:active { background: var(--blue-press); transform: scale(.98); }

@media (min-width: 640px) {
  .app { padding-top: 24px; }
  .hero h1 { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* 마감 칸 = 알림 버튼 */
.v.alertable {
  justify-self: end;
  display: inline-flex; align-items: center; gap: 3px;
  padding: 6px 8px; margin-right: -8px;
  border-radius: 10px;
  font-size: 15px; font-weight: 600;
  color: var(--text-4);
  transition: background .15s, color .15s, transform .1s;
}
.v.alertable .bell { opacity: .7; }
.v.alertable:hover { background: var(--surface); }
.v.alertable:active { transform: scale(.94); background: var(--surface-strong); }
.v.alertable.on { color: var(--blue); background: var(--blue-soft); font-size: 13px; }
.v.alertable.on .bell { opacity: 1; fill: currentColor; }
.v.alertable.busy { opacity: .5; pointer-events: none; }

/* 내 알림 */
.mine-inner { padding: 22px 20px 8px; }
.mine h3 { font-size: 18px; font-weight: 700; }
.mine h3 span { color: var(--blue); margin-left: 2px; }
.mine .sub { margin-top: 4px; white-space: normal; }
#mineList { list-style: none; margin-top: 12px; }
#mineList li { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
#mineList li + li { border-top: 1px solid var(--divider); }
.mine-go { flex: 1; min-width: 0; text-align: left; }
.mine-go strong { display: block; font-size: 15px; font-weight: 600; }
.mine-go small { display: block; margin-top: 2px; font-size: 13px; color: var(--text-3); }
.mine-off { height: 34px; padding: 0 14px; border-radius: 10px; background: var(--surface); color: var(--text-2); font-size: 14px; font-weight: 600; }
.mine-off:disabled { opacity: .5; }

/* 토스트 */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100% - 40px); width: max-content;
  padding: 13px 18px; border-radius: 14px;
  background: rgba(25, 31, 40, .92); color: #fff;
  font-size: 15px; font-weight: 500; line-height: 1.4; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-color-scheme: dark) { .toast { background: rgba(70, 70, 80, .95); } }

/* 아이폰 안내 시트 */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 30; }
.sheet-backdrop[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 480px;
  padding: 28px 24px calc(20px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--bg);
  animation: up .25s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { font-size: 20px; line-height: 1.4; font-weight: 700; }
.sheet ol { margin: 18px 0 4px 20px; font-size: 16px; line-height: 1.9; color: var(--text-2); }
.sheet ol svg { vertical-align: -3px; }
.sheet .cta { width: 100%; margin-top: 20px; }

/* 야간 알림 설정 (토글) */
.setting { display: flex; align-items: center; gap: 16px; margin-top: 8px; padding: 16px 0 8px; border-top: 1px solid var(--divider); }
.setting-text { flex: 1; min-width: 0; }
.setting-text strong { display: block; font-size: 15px; font-weight: 600; }
.setting-text small { display: block; margin-top: 2px; font-size: 13px; line-height: 1.45; color: var(--text-3); }
.switch { flex: 0 0 auto; position: relative; width: 50px; height: 30px; border-radius: 15px; background: var(--surface-strong); transition: background .2s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--blue); }
.switch[aria-checked="true"] span { transform: translateX(20px); }

/* 홈에 추가 버튼 */
.install-btn {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px;
  height: 32px; padding: 0 10px; border-radius: 10px;
  background: var(--blue-soft); color: var(--blue); font-size: 13px; font-weight: 600;
}
.install-btn[hidden] { display: none; }
.install-btn:active { transform: scale(.96); }

/* 달력 (접었다 폈다) */
.dates { margin-top: 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 0 20px; height: 40px; }
.cal-toggle { display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 6px 0 0; font-size: 17px; font-weight: 700; }
.cal-chev { color: var(--text-3); transition: transform .2s; transform: rotate(180deg); }
.cal-toggle[aria-expanded="false"] .cal-chev { transform: rotate(0deg); }
.cal-nav { display: flex; gap: 4px; }
.cal-nav[hidden] { display: none; }
.cal-nav button { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--text-2); }
.cal-nav button:active { background: var(--surface); }
.cal-nav button:disabled { color: var(--text-4); opacity: .5; pointer-events: none; }
.calendar { padding: 4px 14px 14px; }
.calendar[hidden] { display: none; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-week span { text-align: center; font-size: 12px; font-weight: 500; color: var(--text-3); padding: 6px 0; }
.cal-week .sun { color: #f04452; } .cal-week .sat { color: var(--blue); }
.cal-day {
  position: relative; height: 44px; margin: 1px 3px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600; color: var(--text);
}
button.cal-day:active { background: var(--surface); }
.cal-day.sun { color: #f04452; } .cal-day.sat { color: var(--blue); }
.cal-day.off { color: var(--text-4); font-weight: 500; opacity: .6; }
.cal-day small { position: absolute; bottom: 3px; font-size: 9px; font-weight: 600; color: var(--blue); }
.cal-day.today:not(.selected) { background: var(--surface); }
.cal-day.selected { background: var(--blue); color: #fff; }
.cal-day.selected small { color: #fff; }
.date-strip[hidden] { display: none; }
.dates .date-strip { padding-top: 6px; }

/* 마감 + 알림받기 버튼 */
.closed-cell { justify-self: end; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.closed-label { font-size: 15px; font-weight: 600; color: var(--text-4); }
.alert-btn {
  display: inline-flex; align-items: center; gap: 3px;
  height: 26px; padding: 0 8px; border-radius: 8px;
  background: var(--surface); color: var(--text-2);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  transition: background .15s, color .15s, transform .1s;
}
.alert-btn:active { transform: scale(.94); background: var(--surface-strong); }
.alert-btn.on { background: var(--blue-soft); color: var(--blue); }
.alert-btn.on .bell { fill: currentColor; }
.alert-btn.busy { opacity: .5; pointer-events: none; }
.slot { min-height: 64px; }

/* 알림 설명 */
.how { list-style: none; margin-top: 8px; }
.how li { position: relative; padding-left: 12px; font-size: 13px; line-height: 1.6; color: var(--text-3); }
.how li::before { content: ""; position: absolute; left: 2px; top: .7em; width: 4px; height: 4px; border-radius: 50%; background: var(--text-4); }

/* 유튜브: 최근 영상 + 재생목록 */
.videos .yt { margin-bottom: 8px; }
.videos h3 { padding: 0 20px; margin-top: 20px; font-size: 17px; font-weight: 700; }
.recent-strip { display: flex; gap: 12px; overflow-x: auto; padding: 12px 20px 4px; scroll-padding-inline: 20px; scroll-snap-type: x proximity; scrollbar-width: none; }
.recent-strip::-webkit-scrollbar { display: none; }
.vcard { flex: 0 0 220px; scroll-snap-align: start; }
.vcard .thumb { display: block; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--surface); }
.vcard img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vcard strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 8px; font-size: 14px; font-weight: 600; line-height: 1.4; }
.vcard small { display: block; margin-top: 2px; font-size: 12px; color: var(--text-3); }
.playlists ul { list-style: none; padding: 8px 20px 0; }
.playlists a { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.playlists li + li a { border-top: 1px solid var(--divider); }
.pl-icon { flex: 0 0 40px; height: 40px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; font-size: 20px; }
.pl-text { flex: 1; min-width: 0; }
.pl-text strong { display: block; font-size: 15px; font-weight: 600; }
.pl-text small { display: block; margin-top: 2px; font-size: 13px; color: var(--text-3); }
.videos + .notice { margin-top: 16px; }

/* 홈 추가 시트 */
.sheet-icon { display: block; width: 56px; height: 56px; border-radius: 14px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.sheet-sub { margin-top: 8px; font-size: 15px; line-height: 1.5; color: var(--text-3); }
.sheet ol:empty { display: none; }
.sheet-later { display: block; width: 100%; height: 44px; margin-top: 8px; font-size: 15px; font-weight: 500; color: var(--text-3); }

/* ===== 회차 표 정렬 (값 칸 가운데 정렬 + 줄 높이 고정) ===== */
.col-head, .slot { grid-template-columns: 1.15fr repeat(3, 1fr); column-gap: 4px; }
.col-head.no-buoy, .slot.no-buoy { grid-template-columns: 1.15fr 1fr; }
.col-head span:not(:first-child) { text-align: center; }
.slot { align-items: start; min-height: 0; padding: 12px 4px; }
.slot .name strong { line-height: 28px; }
.slot .name small { margin-top: 0; line-height: 26px; }
.cell { display: flex; flex-direction: column; align-items: center; gap: 0; min-width: 0; }
.cell .val { height: 28px; display: flex; align-items: center; justify-content: center; font-weight: 700; white-space: nowrap; }
.cell.seats .val { font-size: 20px; letter-spacing: -0.02em; }
.cell.seats .unit { font-size: 14px; font-weight: 600; margin-left: 1px; }
.cell.buoy .val { font-size: 17px; }
.cell.buoy .unit { font-size: 13px; font-weight: 600; margin-left: 1px; }
.cell .ok { color: var(--blue); }
.cell .low { color: var(--orange); }
.cell .closed { color: var(--text-4); font-size: 15px; font-weight: 600; }
.cell .unknown { color: var(--text-4); font-size: 13px; font-weight: 500; }
.cell .alert-btn { width: 100%; max-width: 78px; height: 26px; justify-content: center; padding: 0 4px; }
.slot.off .off-label { text-align: center; line-height: 28px; }
.slot.skeleton .bar.short { justify-self: center; width: 56%; margin-top: 5px; }

/* 좁은 화면(아이폰 SE 등): 시간이 두 줄로 꺾이지 않게 */
@media (max-width: 374px) {
  .col-head, .slot { grid-template-columns: 1.1fr repeat(3, 1fr); column-gap: 2px; }
  .slot .name small { font-size: 11.5px; white-space: nowrap; letter-spacing: -0.02em; }
  .cell.seats .val { font-size: 18px; }
  .cell.buoy .val { font-size: 16px; }
  .cell .alert-btn { font-size: 11px; gap: 2px; }
  .cell .alert-btn .bell { width: 12px; height: 12px; }
}

/* 풀장 이벤트 (노수모·코스튬데이) */
.ev-dot { position: absolute; bottom: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--orange); }
.cal-day.selected .ev-dot { background: #fff; }
.ev-badge {
  display: inline-flex; align-items: center; vertical-align: 2px;
  margin-left: 6px; height: 20px; padding: 0 6px; border-radius: 6px;
  background: var(--orange-soft); color: var(--orange);
  font-size: 11px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap;
}
.hint a { color: var(--blue); font-weight: 600; text-decoration: none; }
