@font-face {
  font-family: "Bricolage";
  src: url("/fonts/bricolage.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --paper: #ffffff;
  --wash: #f2f3f5;
  --ink: #15171c;
  --ink-2: #5d6370;
  --line: #e2e4e9;
  --sun: #d9342b;   /* 달력의 일요일 */
  --sat: #2458d6;   /* 달력의 토요일 */
  --mark: #ffe14a;  /* 형광펜 */
  --on-mark: #15171c;
  --shadow: 0 10px 40px rgba(21, 23, 28, .18);
  --nav-h: 58px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131418;
    --wash: #1e2026;
    --ink: #f2f2ee;
    --ink-2: #9aa0ad;
    --line: #2b2e37;
    --sun: #ff6f61;
    --sat: #7aa2ff;
    --shadow: 0 10px 40px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Bricolage", "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
img { display: block; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--sat); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ── 상단 ── */
.top {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-t) + 6px) 16px 0;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.brand { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.top-actions { display: flex; gap: 2px; margin-right: -8px; }
.icon-btn { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
.icon-btn:active { background: var(--wash); }
.icon-btn .dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--sun); }
.text-btn { height: 36px; padding: 0 12px; border-radius: 18px; font-weight: 600; font-size: 14px; }
.text-btn:active { background: var(--wash); }

.chips { display: flex; gap: 6px; padding: 6px 0 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border-radius: 17px;
  background: var(--wash); font-size: 14px; font-weight: 600; color: var(--ink-2);
}
.chip.on { background: var(--ink); color: var(--paper); }

main { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 24px); }
.view { max-width: 720px; margin: 0 auto; }

/* ── 달력 ── */
.month-head { display: flex; align-items: center; padding: 10px 8px 4px; }
.month-title { flex: none; min-width: 124px; text-align: center; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.month-title small { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-right: 6px; }
#go-today { margin-left: auto; margin-right: 8px; background: var(--wash); }

.weekdays, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); padding: 0 8px; }
.weekdays span { padding: 6px 0 4px; text-align: center; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.weekdays span:first-child { color: var(--sun); }
.weekdays span:last-child { color: var(--sat); }

.cell {
  position: relative; display: block; width: 100%; text-align: left;
  padding: 4px 3px 5px; border-top: 1px solid var(--line); border-radius: 0;
}
.cell .num { display: inline-block; min-width: 20px; height: 20px; padding: 0 4px; font-size: 13px; font-weight: 600; line-height: 20px; text-align: center; border-radius: 4px; }
.cell.sun .num { color: var(--sun); }
.cell.sat .num { color: var(--sat); }
.cell.out .num { opacity: .32; }
.cell.today .num { background: var(--mark); color: var(--on-mark); font-weight: 800; }
.cell.sel .num { background: var(--ink); color: var(--paper); font-weight: 800; }
.cell .thumbs { position: relative; display: block; margin-top: 3px; }
.cell .thumb.second { display: none; }
.cell .thumb { display: block; aspect-ratio: 4 / 5; border-radius: 5px; overflow: hidden; background: transparent; }
.cell .thumb img, .cell .thumb .ph { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.cell.out .thumbs { opacity: .35; }
.cell.sel .thumb { outline: 2px solid var(--ink); outline-offset: 1px; }
.cell .more {
  position: absolute; right: 3px; bottom: 3px; min-width: 18px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: rgba(21, 23, 28, .82); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 16px; text-align: center;
}
.cell .heart { position: absolute; top: 6px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--sun); }

/* ── 일력(하루 목록의 머리) ── */
.day-col { margin-top: 10px; border-top: 2px dashed var(--line); }
.tear { display: flex; align-items: flex-end; gap: 12px; padding: 16px 16px 8px; }
.tear-num { font-size: 68px; font-weight: 800; line-height: .82; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.tear.sun .tear-num { color: var(--sun); }
.tear.sat .tear-num { color: var(--sat); }
.tear-meta { display: grid; gap: 2px; padding-bottom: 2px; }
.tear-meta b { font-size: 17px; font-weight: 800; }
.tear-meta span { font-size: 13px; color: var(--ink-2); }
.tear .dday { margin-left: auto; margin-bottom: 6px; }

/* ── 작품 줄 ── */
.list { padding: 0 16px; }
.row { display: grid; grid-template-columns: 58px minmax(0, 1fr) 44px; gap: 12px; align-items: center; width: 100%; padding: 10px 0; text-align: left; border-top: 1px solid var(--line); }
.list .row:first-child { border-top: 0; }
.poster { position: relative; display: block; width: 58px; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; background: var(--wash); }
.poster img, .poster .ph { width: 100%; height: 100%; object-fit: cover; }
.ph { display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 20px; }
.row-body { min-width: 0; display: grid; gap: 3px; }
.row-body > span { min-width: 0; }
.row-title { font-size: 16px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row-sub { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 1px; }
.tag { height: 20px; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; font-size: 11.5px; font-weight: 600; line-height: 18px; color: var(--ink-2); white-space: nowrap; }
.tag.where { border-color: var(--ink); color: var(--ink); }
.tag.re { border-style: dashed; }
.star { font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-left: 2px; }
.star::before { content: "★ "; color: #e9a400; }
.wish-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--ink-2); }
.wish-btn.on { color: var(--sun); }
.wish-btn.on svg { fill: currentColor; }
.wish-btn:active { background: var(--wash); }

.dday { flex: none; height: 22px; padding: 0 7px; border-radius: 4px; background: var(--wash); font-size: 12.5px; font-weight: 800; line-height: 22px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dday.near { background: var(--mark); color: var(--on-mark); }
.dday.now { background: var(--sun); color: #fff; }

.empty { padding: 36px 24px 44px; text-align: center; color: var(--ink-2); font-size: 14.5px; }
.empty b { display: block; margin-bottom: 4px; color: var(--ink); font-size: 16px; }
.note { padding: 14px 16px 0; font-size: 12.5px; color: var(--ink-2); }

/* ── 공개 예정 ── */
.group-head { position: sticky; top: calc(var(--safe-t) + 101px); z-index: 5; display: flex; align-items: baseline; gap: 8px; padding: 14px 16px 6px; background: var(--paper); }
.group-head .gd { font-size: 26px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.group-head .gw { font-size: 14px; font-weight: 700; }
.group-head.sun .gd, .group-head.sun .gw { color: var(--sun); }
.group-head.sat .gd, .group-head.sat .gw { color: var(--sat); }
.group-head .gm { font-size: 13px; color: var(--ink-2); }
.group-head .dday { margin-left: auto; align-self: center; }
.more-btn { display: block; width: calc(100% - 32px); margin: 16px; height: 46px; border-radius: 10px; background: var(--wash); font-weight: 700; }

/* ── 순위 ── */
.seg { display: flex; gap: 6px; padding: 14px 16px 2px; overflow-x: auto; scrollbar-width: none; }
.rank-row { grid-template-columns: 34px 58px minmax(0, 1fr); }
.rank-num { font-size: 28px; font-weight: 800; letter-spacing: -.04em; text-align: center; font-variant-numeric: tabular-nums; }
.rank-move { font-size: 12px; font-weight: 700; }
.rank-move.up { color: var(--sun); }
.rank-move.down { color: var(--sat); }
.rank-move.new { background: var(--mark); color: var(--on-mark); padding: 0 5px; border-radius: 3px; }

/* ── 아래 메뉴 ── */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--paper); border-top: 1px solid var(--line);
}
.nav button { display: grid; place-items: center; align-content: center; gap: 2px; color: var(--ink-2); font-size: 11.5px; font-weight: 600; }
.nav button.on { color: var(--ink); }
.nav button.on svg { stroke-width: 2.4; }

/* ── 시트 ── */
dialog { color: var(--ink); border: 0; padding: 0; }
dialog::backdrop { background: rgba(10, 11, 14, .5); }
.sheet {
  position: fixed; inset: auto 0 0 0; width: 100%; max-width: 100%; max-height: 90dvh; margin: 0;
  background: var(--paper); border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
  overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(var(--safe-b) + 18px);
}
.sheet[open] { animation: sheet-up .22s ease-out; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
.sheet-close { position: sticky; top: 8px; float: right; z-index: 2; margin: 8px 8px -52px 0; background: var(--paper); box-shadow: 0 0 0 1px var(--line); }
.sheet h2 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; }
.sheet h3 { font-size: 14px; font-weight: 800; margin-bottom: 6px; }
.sheet-pad { padding: 22px 18px 4px; }

.d-head { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 16px; padding: 22px 18px 0; }
.d-head .poster { width: 112px; border-radius: 8px; }
.d-head .ph { font-size: 34px; }
.d-title { padding-right: 44px; }
.d-orig { margin-top: 3px; font-size: 13.5px; color: var(--ink-2); }
.d-when { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; }
.d-facts { margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.d-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 16px 18px 0; }
.btn { height: 46px; display: flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; background: var(--wash); font-weight: 700; font-size: 15px; }
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.on { background: var(--sun); color: #fff; }
.btn.on svg { fill: currentColor; }
.d-sec { padding: 18px 18px 0; font-size: 14.5px; }
.d-sec p { color: var(--ink); line-height: 1.6; }
.d-sec .muted { color: var(--ink-2); font-size: 12.5px; }
.d-links { display: flex; flex-wrap: wrap; gap: 14px; }
.d-links a { color: var(--ink); font-weight: 600; font-size: 13.5px; text-underline-offset: 3px; }

.opt { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 48px; border-top: 1px solid var(--line); font-size: 15.5px; font-weight: 600; }
.opt .cnt { color: var(--ink-2); font-size: 13px; font-weight: 500; margin-left: 8px; }
.opt .box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); display: grid; place-items: center; }
.opt.on .box { background: var(--ink); border-color: var(--ink); }
.opt.on .box::after { content: ""; width: 9px; height: 5px; margin-top: -2px; border-left: 2.4px solid var(--paper); border-bottom: 2.4px solid var(--paper); transform: rotate(-45deg); }
.opt-group { margin-top: 16px; }
.info p { margin-top: 8px; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.info p b { color: var(--ink); }
.info a { color: var(--ink); }

/* ── 검색 ── */
.search { position: fixed; inset: 0; width: 100%; height: 100%; max-width: 100%; max-height: 100%; margin: 0; background: var(--paper); overflow-y: auto; }
.search-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-t) + 8px) 8px 8px 16px; background: var(--paper); border-bottom: 1px solid var(--line); }
.search-bar svg { flex: none; color: var(--ink-2); }
.search-bar input { flex: 1; min-width: 0; height: 44px; border: 0; outline: 0; background: none; color: var(--ink); font: inherit; font-size: 17px; }
.search-bar input::-webkit-search-cancel-button { display: none; }
.search-results { max-width: 720px; margin: 0 auto; }
.search-results .row-when { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 60; transform: translate(-50%, 12px); padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--paper); font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── 넓은 화면 ── */
@media (min-width: 900px) {
  body { padding-left: 88px; }
  .nav { top: 0; right: auto; bottom: 0; width: 88px; height: auto; grid-template-columns: 1fr; grid-auto-rows: 72px; align-content: start; padding: 76px 0 0; border-top: 0; border-right: 1px solid var(--line); }
  main { padding-bottom: 40px; }
  .top { padding-left: 32px; padding-right: 32px; }
  .top-row, .chips { max-width: 1120px; margin: 0 auto; }
  .view { max-width: 760px; }
  #view-cal { max-width: 1184px; display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 8px; padding: 0 24px; align-items: start; }
  .day-col { position: sticky; top: 110px; max-height: calc(100dvh - 126px); overflow-y: auto; margin-top: 16px; border-top: 0; border-left: 2px dashed var(--line); }
  .cell { padding: 6px 6px 8px; }
  .cell .thumbs { display: flex; gap: 4px; }
  .cell .thumb, .cell .thumb.second { display: block; flex: 1 1 0; max-width: 62px; aspect-ratio: 2 / 3; }
  .group-head { top: 101px; }
  .sheet { inset: 0; margin: auto; width: 560px; max-height: 86dvh; height: fit-content; border-radius: 18px; }
  .toast { bottom: 32px; }
  .search-bar { padding-left: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet[open] { animation: none; }
  .toast { transition: none; }
}
