:root {
  --bg: #EEF1F5;
  --surface: #FFFFFF;
  --ink: #161C2A;
  --muted: #6B7488;
  --faint: #A3AABA;
  --line: #DDE2EA;
  --accent: #FFB627;
  --accent-soft: #FFF3D6;
  --go: #12976A;
  --go-soft: #E2F5EC;
  --no: #E0484F;
  --no-soft: #FDE8E9;
  --wait: #7457F2;
  --wait-soft: #EEEAFE;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(22, 28, 42, .06), 0 8px 24px -12px rgba(22, 28, 42, .18);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; line-height: 1.5; font-size: 15px; word-break: keep-all; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--wait); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 상단 ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--ink); color: #fff; }
.topbar-inner { max-width: 1080px; margin: 0 auto; height: 56px; padding: 0 20px; display: flex; align-items: center; gap: 28px; }
.wordmark { font-weight: 850; font-size: 21px; letter-spacing: -0.04em; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.wordmark::before { content: ''; width: 22px; height: 15px; border-radius: 4px; background:
  radial-gradient(circle at 7px 0, var(--ink) 3px, transparent 3.5px),
  radial-gradient(circle at 7px 15px, var(--ink) 3px, transparent 3.5px), var(--accent); }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; padding: 7px 12px; border-radius: 999px; color: #C4CAD6; font-weight: 600; }
.nav a:hover { color: #fff; }
.nav a.on { background: rgba(255, 255, 255, .12); color: #fff; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.link-btn { background: none; border: 0; padding: 4px; cursor: pointer; color: inherit; opacity: .7; font-size: 13px; }
.link-btn:hover { opacity: 1; text-decoration: underline; }

/* ---------- 공통 ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 28px 20px 120px; }
h1 { font-size: 28px; font-weight: 850; letter-spacing: -0.035em; margin: 0; line-height: 1.25; }
h2 { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 4px; }
.sub { color: var(--muted); font-size: 14px; margin: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.section-head .count { color: var(--muted); font-size: 14px; font-weight: 600; }
.panel { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; background: var(--surface); border-radius: var(--radius-lg); border: 1.5px dashed var(--line); }
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 999px; padding: 11px 20px; font-weight: 750; cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform .08s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-accent { background: var(--accent); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-danger { background: transparent; color: var(--no); box-shadow: inset 0 0 0 1.5px var(--no-soft); }
.btn-small { padding: 7px 13px; font-size: 13px; }
.btn-block { width: 100%; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 0; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); border-radius: 999px; padding: 7px 14px; font-weight: 650; font-size: 14px; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--ink); color: #fff; box-shadow: none; }

.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--bg); color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 750; padding: 3px 9px; border-radius: 999px; }
.pill-go { background: var(--go-soft); color: var(--go); }
.pill-wait { background: var(--wait-soft); color: var(--wait); }
.pill-no { background: var(--no-soft); color: var(--no); }
.pill-plain { background: var(--bg); color: var(--muted); }
.pill-accent { background: var(--accent-soft); color: #8A5A00; }

.avatar { --c: #888; width: 28px; height: 28px; border-radius: 50%; background: var(--c); color: #fff; font-size: 12px; font-weight: 800; display: inline-grid; place-items: center; flex: none; box-shadow: 0 0 0 2px var(--surface); }
.avatars { display: flex; }
.avatars .avatar { margin-left: -7px; width: 26px; height: 26px; font-size: 11px; }
.avatars .avatar:first-child { margin-left: 0; }
.person { display: inline-flex; align-items: center; gap: 7px; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); border-radius: 999px; padding: 3px 12px 3px 3px; font-size: 14px; font-weight: 600; }
.person .avatar { width: 24px; height: 24px; font-size: 11px; box-shadow: none; }
.people { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- 입력 ---------- */
.field { display: grid; gap: 6px; margin-bottom: 18px; }
.field > label, .field > .label { font-weight: 700; font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); }
.input, .select, .textarea { width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius-md); background: var(--surface); padding: 11px 13px; outline: none; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--ink); }
.textarea { min-height: 110px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: inline-flex; background: var(--bg); border-radius: 999px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(22, 28, 42, .15); }
.error { color: var(--no); font-size: 14px; font-weight: 600; min-height: 20px; margin: 4px 0 10px; }

/* ---------- 로그인 ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.auth-card { width: min(400px, 100%); }
.auth-ticket { background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; }
.auth-top { background: var(--accent); padding: 26px 26px 22px; position: relative; }
.auth-top h1 { font-size: 34px; }
.auth-top p { margin: 6px 0 0; font-weight: 600; color: #5C3D00; }
.auth-body { padding: 22px 26px 26px; border-top: 2px dashed var(--line); position: relative; }
.auth-body::before, .auth-body::after { content: ''; position: absolute; top: -11px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); }
.auth-body::before { left: -10px; } .auth-body::after { right: -10px; }
.auth .seg { margin-bottom: 18px; }

/* ---------- 티켓 카드 ---------- */
.todo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; margin-bottom: 26px; }
.todo { display: flex; align-items: center; gap: 12px; background: var(--accent-soft); border-radius: var(--radius-md); padding: 10px 14px; text-decoration: none; font-weight: 700; font-size: 14px; }
.todo .todo-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; box-shadow: 0 0 0 4px rgba(255, 182, 39, .25); }
.todo small { color: #8A5A00; font-weight: 600; display: block; font-size: 13px; }
.todo .go { margin-left: auto; font-weight: 800; color: #8A5A00; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.search { flex: 1; min-width: 180px; max-width: 320px; }

.tickets { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.ticket { --notch: var(--bg); display: grid; grid-template-columns: 82px 1fr; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); text-decoration: none; position: relative; min-height: 132px; transition: transform .12s; }
.ticket:hover { transform: translateY(-2px); }
.ticket-stub { display: grid; place-content: center; text-align: center; border-right: 2px dashed var(--line); padding: 10px 4px; position: relative; border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
.ticket-stub::before, .ticket-stub::after { content: ''; position: absolute; right: -11px; width: 20px; height: 20px; border-radius: 50%; background: var(--notch); }
.ticket-stub::before { top: -10px; } .ticket-stub::after { bottom: -10px; }
.stub-month { font-size: 12px; font-weight: 700; color: var(--muted); }
.stub-day { font-size: 34px; font-weight: 850; letter-spacing: -0.04em; line-height: 1.05; }
.stub-dow { font-size: 12px; font-weight: 700; color: var(--muted); }
.stub-poll .stub-day { font-size: 15px; letter-spacing: -0.02em; line-height: 1.3; }
.ticket.is-confirmed .ticket-stub { background: var(--accent); }
.ticket.is-confirmed .stub-month, .ticket.is-confirmed .stub-dow { color: #6B4600; }
.ticket.is-done { opacity: .72; }
.ticket.is-done .ticket-stub { background: var(--bg); }
.ticket-body { padding: 14px 16px 14px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ticket-title { font-size: 17px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ticket-when { font-size: 13px; color: var(--muted); font-weight: 600; }
.ticket-foot { margin-top: auto; padding-top: 8px; display: flex; align-items: center; gap: 8px; }
.ticket-foot .cap { font-size: 13px; font-weight: 700; color: var(--muted); }
.ticket-foot .pill { margin-left: auto; }

/* ---------- 상세 ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; margin-bottom: 16px; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 330px; grid-template-areas: 'top side' 'main side'; column-gap: 22px; align-items: start; }
.detail-top { grid-area: top; }
.detail-main { grid-area: main; }
.detail > .side { grid-area: side; }
.detail-head .tag { margin-bottom: 8px; }
.host-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; margin-top: 8px; }
.host-line .avatar { width: 22px; height: 22px; font-size: 10px; box-shadow: none; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); margin-top: 18px; overflow: hidden; }
.fact { padding: 13px 16px; border-left: 1.5px solid var(--bg); }
.fact:first-child { border-left: 0; }
.fact-label { font-size: 12px; color: var(--muted); font-weight: 650; }
.fact-value { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; }
.intro { white-space: pre-wrap; margin: 0; }

.confirmed-banner { display: flex; align-items: center; gap: 16px; background: var(--accent); border-radius: var(--radius-lg); padding: 18px 20px; }
.confirmed-banner .big { font-size: 24px; font-weight: 850; letter-spacing: -0.03em; }
.confirmed-banner .small { font-weight: 650; color: #6B4600; font-size: 14px; }
.confirmed-banner .btn { margin-left: auto; }

.best { display: grid; gap: 10px; }
.best-card { border-radius: var(--radius-md); padding: 14px 16px; box-shadow: inset 0 0 0 1.5px var(--line); background: var(--surface); display: grid; gap: 6px; align-content: start; }
.date-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.date-chip { border: 0; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 14px; cursor: pointer; }
.best-card.top .date-chip { box-shadow: inset 0 0 0 1.5px #9BDABA; }
.date-chip:hover { box-shadow: inset 0 0 0 2px var(--ink); }
.best-card.top { box-shadow: inset 0 0 0 2px var(--go); background: var(--go-soft); }
.best-date { font-weight: 800; letter-spacing: -0.02em; }
.best-count { font-weight: 800; color: var(--go); font-size: 14px; }
.best-names { font-size: 13px; color: var(--muted); }
.best-no { font-size: 13px; color: var(--no); font-weight: 600; }
.best-card .btn { margin-top: 6px; justify-self: start; }

/* ---------- 달력 ---------- */
.cal-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 10px; }
.cal-nav strong { font-size: 17px; font-weight: 800; min-width: 120px; text-align: center; }
.cal-nav button { border: 0; background: var(--bg); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 16px; }
.cal-month-title { font-weight: 800; font-size: 14px; margin: 16px 0 6px; }
.cal-month-title:first-child { margin-top: 0; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-dow.sun { color: var(--no); } .cal-dow.sat { color: #3D6FE0; }
.cal-cell { border: 0; background: var(--bg); border-radius: var(--radius-sm); min-height: 54px; padding: 5px 6px; text-align: left; display: flex; flex-direction: column; gap: 2px; font-size: 13px; position: relative; }
button.cal-cell { cursor: pointer; }
.cal-cell.blank { background: transparent; }
.cal-cell.off { background: transparent; color: var(--faint); }
.cal-cell .d { font-weight: 750; }
.cal-cell.sun .d { color: var(--no); } .cal-cell.sat .d { color: #3D6FE0; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--ink); }
.cal-cell.sel { box-shadow: inset 0 0 0 2.5px var(--wait); }
.cal-cell .n { font-size: 12px; font-weight: 800; color: var(--go); }
.cal-cell.heat-1 { background: #E9F6EF; } .cal-cell.heat-2 { background: #C9EBD9; } .cal-cell.heat-3 { background: #9BDABA; } .cal-cell.heat-4 { background: #5CC195; }
.cal-cell.heat-4 .n, .cal-cell.heat-4 .d { color: #06402B; }
.cal-cell.is-confirmed { background: var(--accent); }
.cal-cell.x { background: var(--no-soft); }
.cal-cell.x .d { color: var(--no); }
.cal-cell.x::after { content: '안 됨'; font-size: 11px; font-weight: 800; color: var(--no); }
.cal-cell .marks { display: flex; flex-wrap: wrap; gap: 2px; }
.cal-cell .mark { font-size: 10px; font-weight: 800; padding: 0 4px; border-radius: 4px; background: var(--no); color: #fff; }
.cal-cell .ev { font-size: 11px; font-weight: 700; background: var(--accent); border-radius: 4px; padding: 0 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal.compact .cal-cell { min-height: 40px; align-items: center; justify-content: center; text-align: center; padding: 3px; }
.cal.compact .cal-cell.x::after { content: '×'; font-size: 13px; line-height: 1; }
.cal-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; align-items: center; }
.cal-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }
.day-detail { margin-top: 14px; padding-top: 14px; border-top: 1.5px solid var(--bg); display: grid; gap: 8px; }
.day-detail .line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- 참가 패널 ---------- */
.side { position: sticky; top: 76px; display: grid; gap: 14px; }
.join-status { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; }
.join-hint { font-size: 13px; color: var(--muted); margin: 2px 0 14px; }
.picker { max-height: 420px; overflow: auto; margin: 0 -6px 14px; padding: 0 6px; }
.side-actions { display: grid; gap: 8px; }
.link-card { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius-md); box-shadow: inset 0 0 0 1.5px var(--line); text-decoration: none; }
.link-card .ico { width: 38px; height: 38px; border-radius: 10px; background: var(--bg); display: grid; place-items: center; font-size: 18px; flex: none; }
.link-card .t { font-weight: 750; }
.link-card .u { font-size: 12px; color: var(--muted); word-break: break-all; }

/* ---------- 후기 ---------- */
.stars { display: inline-flex; gap: 2px; }
.stars button { border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--line); padding: 2px; }
.stars button.on { color: var(--accent); }
.star-static { color: #E19B00; font-weight: 800; }
.review { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 12px 0; border-top: 1.5px solid var(--bg); }
.review:first-child { border-top: 0; }
.review .who-line { font-weight: 700; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.review p { margin: 2px 0 0; font-size: 14px; white-space: pre-wrap; }

/* ---------- 기록 ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 24px; }
.stat { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 16px 18px; }
.stat .v { font-size: 26px; font-weight: 850; letter-spacing: -0.03em; }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 650; }
.month-label { font-weight: 800; color: var(--muted); font-size: 14px; margin: 22px 0 10px; }
.log { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; background: var(--surface); border-radius: var(--radius-md); padding: 12px 16px; text-decoration: none; margin-bottom: 8px; box-shadow: var(--shadow); }
.log-date { text-align: center; border-right: 2px dashed var(--line); padding-right: 12px; }
.log-date .stub-day { font-size: 24px; }
.log-title { font-weight: 800; letter-spacing: -0.02em; }
.log-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.log-quote { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------- 알림 ---------- */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; font-weight: 650; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--no); }

.loading { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---------- 모바일 ---------- */
@media (max-width: 860px) {
  .detail { grid-template-columns: 1fr; grid-template-areas: 'top' 'side' 'main'; row-gap: 18px; }
  .detail-main > .section:first-child { margin-top: 12px; }
  .side { position: static; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .fact:nth-child(3) { border-left: 0; }
  .fact:nth-child(n+3) { border-top: 1.5px solid var(--bg); }
}
@media (max-width: 640px) {
  .topbar-inner { gap: 12px; padding: 0 16px; }
  .nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--ink); justify-content: space-around; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); z-index: 30; }
  .nav a { flex: 1; text-align: center; }
  .page { padding: 20px 14px 110px; }
  h1 { font-size: 24px; }
  .tickets { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:last-child { grid-column: span 2; }
  .row2 { grid-template-columns: 1fr; }
  .cal-cell { min-height: 46px; padding: 4px; font-size: 12px; }
  .cal-cell .ev { display: none; }
  .confirmed-banner { flex-wrap: wrap; }
  .log { grid-template-columns: 54px 1fr; }
  .log > :last-child { grid-column: 2; }
  .toast { bottom: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
