:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f27;
  --muted: #646b78;
  --line: #e2e5ea;
  --primary: #2b4a9b;
  --primary-ink: #ffffff;
  --primary-soft: #e8eefb;
  --open: #1f7a4d;
  --open-soft: #e5f4ec;
  --full: #a3384a;
  --full-soft: #f8e7ea;
  --past: #9aa0aa;
  --past-soft: #eef0f3;
  --danger: #b4233a;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b;
    --surface: #1b1f27;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --line: #2c323d;
    --primary: #7d9cf0;
    --primary-ink: #0f1420;
    --primary-soft: #222c44;
    --open: #5fcf96;
    --open-soft: #173226;
    --full: #f0899a;
    --full-soft: #3a1d24;
    --past: #6b717c;
    --past-soft: #20242c;
    --danger: #f0899a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; color: inherit; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 32px 16px 64px; }
.head { margin-bottom: 24px; }
.eyebrow { margin: 0; color: var(--primary); font-weight: 600; font-size: 14px; letter-spacing: .02em; }
h1 { margin: 4px 0 2px; font-size: clamp(24px, 4.5vw, 32px); letter-spacing: -.02em; }
h2 { margin: 2px 0; font-size: 20px; letter-spacing: -.01em; }
.title-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.title-row .btn { white-space: nowrap; }
.period { margin: 0 0 16px; font-size: 17px; font-weight: 600; color: var(--muted); }
.rules { margin: 0 0 16px; padding: 14px 16px 14px 32px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: 15px; }
.rules li + li { margin-top: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer;
  min-height: 44px;
}
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.primary:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: var(--surface); border-color: var(--line); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn:focus-visible, .slot:focus-visible, .tab:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.open { background: var(--open); }
.dot.full { background: var(--full); }
.dot.past { background: var(--past); }

/* 미리보기 안내 */
.preview-banner { margin: 0 0 12px; padding: 12px 14px; border-radius: 10px; font-size: 14px; font-weight: 600;
  background: color-mix(in srgb, #f5a623 18%, var(--surface)); border: 1px solid color-mix(in srgb, #f5a623 50%, transparent); }

/* 오픈 전 안내 */
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 40px 16px; text-align: center; }
.notice p { margin: 0; }
.notice-k { color: var(--primary); font-weight: 700; font-size: 15px; }
.notice-time { font-size: clamp(20px, 4vw, 26px); font-weight: 700; margin: 6px 0 8px !important; letter-spacing: -.01em; }

/* 캘린더 (넓은 화면) */
.grid-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 6px; vertical-align: middle; }
.grid tr:last-child td, .grid tr:last-child th { border-bottom: 0; }
.grid thead th { font-size: 15px; padding: 12px 6px; background: var(--primary-soft); }
.grid thead th:first-child { width: 128px; }
.grid tbody th { text-align: left; font-weight: 600; font-size: 14px; padding-left: 14px; }
.grid tbody th small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.grid tr.after td, .grid tr.after th { border-top: 2px solid var(--line); }
.empty { text-align: center; color: var(--past); font-size: 13px; }

.slot {
  width: 100%; min-height: 52px; border-radius: 10px; border: 1px solid transparent; padding: 6px 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  cursor: pointer; text-align: center; transition: transform .08s ease;
}
.slot .t { font-size: 13px; color: var(--muted); }
.slot .s { font-size: 14px; font-weight: 700; }
.slot.open { background: var(--open-soft); border-color: color-mix(in srgb, var(--open) 30%, transparent); }
.slot.open .s { color: var(--open); }
.slot.open:hover { transform: translateY(-1px); border-color: var(--open); }
.slot.full { background: var(--full-soft); cursor: not-allowed; }
.slot.full .s { color: var(--full); }
.slot.past { background: var(--past-soft); cursor: not-allowed; }
.slot.past .s, .slot.past .t { color: var(--past); }
.slot.after { min-height: 64px; }

/* 목록 (좁은 화면) */
.mobile { display: none; }
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 12px; }
.tab {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 0; cursor: pointer;
  font-weight: 600; font-size: 14px; line-height: 1.3;
}
.tab small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.tab[aria-selected="true"] small { color: inherit; opacity: .85; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list .slot { flex-direction: row; justify-content: space-between; padding: 12px 14px; text-align: left; }
.list .slot .k { font-weight: 600; font-size: 15px; }
.list .slot .t { display: block; font-size: 13px; }
.list .slot .s { text-align: right; }

@media (max-width: 720px) {
  .grid-wrap { display: none; }
  .mobile { display: block; }
  .wrap { padding-top: 24px; }
}

/* 대화상자 */
dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  border: 1px solid var(--line); border-radius: 16px; padding: 20px; background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgb(10 14 22 / .5); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.dlg-head p { margin: 0; }
.close { border: 0; background: transparent; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fields label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.fields .full { grid-column: 1 / -1; }
.fields input, .fields textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg);
  font-size: 16px; font-weight: 400;
}
.fields textarea { resize: vertical; min-height: 96px; }
.fields input:focus, .fields textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
.fields .hint { margin: -4px 0 0; font-size: 13px; color: var(--muted); }
.fields .check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: 13px; color: var(--muted); }
.fields .check input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--primary); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.error { color: var(--danger); font-size: 14px; margin: 12px 0 0; }
.done { text-align: center; padding: 8px 0 0; }
.done p { margin: 6px 0; }
.check-mark { font-size: 32px; color: var(--open); margin: 0 !important; }
.done .actions { justify-content: center; }
.mine-result { margin-top: 16px; padding: 14px; border-radius: 10px; background: var(--primary-soft); font-size: 15px; }
.mine-result p { margin: 2px 0; }
.mine-result .topic { white-space: pre-wrap; color: var(--muted); font-size: 14px; margin-top: 6px; }

@media (max-width: 520px) {
  .title-row .wide { display: none; }
}
@media (max-width: 420px) {
  .fields { grid-template-columns: 1fr; }
  dialog { padding: 16px; }
}
