/*
 * Attic 오늘 (웹앱) — 바탕화면 달력과 같은 벽걸이 달력 느낌
 * 바탕판 + 맨 위 짙은 띠 + 위쪽이 아치 모양인 종이, 애쉬 블루 기본 색
 * 색·글꼴 값은 shared/themes.js 가 정합니다.
 */
@font-face {
  font-family: "Bodoni Moda";
  src: url("fonts/BodoniModa.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --frame: #b9c6d3;
  --band: #2f3e57;
  --paper: #f8fafc;
  --ink: #1f2a3d;
  --muted: #7b8798;
  --line: rgba(40, 60, 90, 0.13);
  --accent: #6a88b0;
  --accent-ink: #ffffff;
  --pill: #e3ebf4;
  --sun: #b5737c;
  --sat: #4d6fa0;
  --text-font: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --number-font: "Bodoni Moda", "Bodoni MT", Didot, Georgia, serif;
  --base-size: 16px;
  --hover: color-mix(in srgb, var(--ink) 5%, transparent);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--text-font);
  font-size: var(--base-size);
  color: var(--ink);
  background: var(--frame);
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }

/* ── 바탕판 + 위쪽 띠 + 아치 종이 ── */
.frame {
  min-height: 100%;
  padding: calc(14px + var(--safe-top)) 10px 0;
  position: relative;
  display: flex;
  justify-content: center;
}
.frame::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: calc(8px + var(--safe-top));
  background: var(--band);
  z-index: 5;
}
.paper {
  width: 100%;
  max-width: 560px;
  min-height: calc(100dvh - 14px - var(--safe-top));
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 56px 56px 0 0 / 34px 34px 0 0;
  outline: 1px solid var(--line);
  outline-offset: -6px;
  padding: 14px 16px 0;
}

/* ── 머리: 오늘 날짜 크게 ── */
.top { display: flex; align-items: flex-start; justify-content: space-between; padding: 8px 6px 6px 10px; }
.date .eyebrow {
  font-family: var(--number-font);
  font-variation-settings: "opsz" 8;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-size: 0.85em;
}
.date h1 {
  margin: 2px 0 0;
  font-family: var(--number-font);
  font-variation-settings: "opsz" 8;
  font-weight: 700;
  font-size: 2.6em;
  line-height: 1;
}
.date .sub { color: var(--muted); font-size: 0.85em; letter-spacing: 0.08em; margin-top: 2px; }
.actions { display: flex; align-items: center; gap: 2px; }
.fetched { font-size: 0.75em; color: var(--muted); margin-right: 4px; white-space: nowrap; }
.fetched.error { color: var(--sun); }

.icon, .pill { border: 0; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon { width: 38px; height: 38px; border-radius: 50%; color: var(--muted); font-size: 22px; line-height: 1; }
.icon:active { background: var(--hover); }
#refresh.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pill {
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--pill);
  color: var(--ink);
  white-space: nowrap;
}
.pill.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.pill.ghost { background: transparent; border: 1px solid var(--line); }
.pill.danger { color: var(--sun); border-color: color-mix(in srgb, var(--sun) 45%, transparent); }
.pill.danger-fill { background: var(--sun); color: #fff; }
.pill:disabled { opacity: 0.55; }

.notice {
  margin: 4px 4px 8px;
  padding: 8px 14px;
  border-radius: 14px;
  background: var(--pill);
  font-size: 0.88em;
  text-align: center;
}
.ddays { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 6px 6px; }
.dday { display: inline-flex; gap: 6px; align-items: baseline; padding: 3px 12px; border-radius: 999px; background: var(--pill); font-size: 0.85em; }
.dday b { font-family: var(--number-font); font-variation-settings: "opsz" 8; color: var(--accent); }

/* ── 본문 ── */
.views { flex: 1; overflow-y: auto; padding: 0 6px 12px; }
.view h2 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 18px 0 6px;
  font-size: 0.8em;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px;
}
.view h2 .total { font-size: 1.35em; letter-spacing: 0; color: var(--ink); font-weight: 700; }
.list { display: flex; flex-direction: column; }
.empty { color: var(--muted); font-size: 0.9em; padding: 8px 2px; }

.ev, .en {
  display: grid;
  grid-template-columns: 3px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 4px 9px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  cursor: pointer;
}
.ev:active, .en:active { background: var(--hover); }
.ev .bar, .en .bar { align-self: stretch; border-radius: 2px; }
.ev .when, .en .meta { font-size: 0.8em; color: var(--muted); }
.ev .what, .en .what { font-size: 1em; line-height: 1.35; }
.ev.past { opacity: 0.55; }
.en .amt { font-family: var(--number-font); font-variation-settings: "opsz" 8; font-weight: 700; white-space: nowrap; }
.en.pending { opacity: 0.6; }
.en.pending .meta::after { content: " · 보내는 중"; }
.kind-tag { display: inline-block; font-size: 0.75em; padding: 0 7px; border-radius: 999px; background: var(--pill); margin-right: 4px; }

.day-group { margin-top: 12px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; font-size: 0.9em; padding: 4px 0; }
.day-head .sum { font-family: var(--number-font); font-variation-settings: "opsz" 8; color: var(--muted); }
.day-head.sun { color: var(--sun); }

.month-bar { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 8px; }
.month-label { font-family: var(--number-font); font-variation-settings: "opsz" 8; font-weight: 700; font-size: 1.15em; letter-spacing: 0.06em; min-width: 9em; text-align: center; }
.sums { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin: 6px 0 10px; font-size: 0.9em; color: var(--muted); }
.sums b { color: var(--ink); font-family: var(--number-font); font-variation-settings: "opsz" 8; }
.search {
  width: 100%;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--pill) 55%, var(--paper));
}

/* ── 한 줄 입력 (엄지로 누르기 쉬운 아래쪽) ── */
.quick {
  position: sticky;
  bottom: 0;
  background: var(--paper);
  padding: 8px 4px 4px;
  border-top: 1px solid var(--line);
}
.quick-row { display: flex; gap: 8px; }
.quick-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--pill) 55%, var(--paper));
  font-size: 16px; /* 아이폰에서 누를 때 화면이 확대되지 않게 16px 이상 */
}
.quick-preview { min-height: 1.4em; font-size: 0.82em; color: var(--muted); padding: 4px 12px 0; }
.quick-preview.bad { color: var(--sun); }
.quick-preview.ok { color: var(--accent); }

/* ── 아래 탭 ── */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px 4px calc(8px + var(--safe-bottom));
  background: var(--paper);
}
.tab { border: 0; background: transparent; padding: 9px 0; border-radius: 12px; color: var(--muted); font-weight: 600; cursor: pointer; }
.tab[aria-current="page"] { background: var(--pill); color: var(--ink); }

/* ── 설정·고치기 창 ── */
dialog {
  border: 0;
  border-radius: 34px 34px 14px 14px / 22px 22px 14px 14px;
  background: var(--paper);
  color: var(--ink);
  padding: 0;
  width: min(460px, calc(100vw - 20px));
  max-height: calc(100dvh - 24px);
  outline: 1px solid var(--line);
  outline-offset: -6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}
dialog::backdrop { background: color-mix(in srgb, var(--band) 35%, transparent); }
.sheet { display: flex; flex-direction: column; gap: 12px; padding: 22px 20px 18px; }
.sheet-title { margin: 0; text-align: center; font-family: var(--number-font); font-variation-settings: "opsz" 8; font-weight: 700; letter-spacing: 0.2em; font-size: 1.1em; }
.sheet-title.small { font-family: var(--text-font); letter-spacing: 0.05em; }
.sheet h3 { margin: 6px 0 0; font-size: 0.78em; letter-spacing: 0.15em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.sheet label { display: flex; flex-direction: column; gap: 4px; font-size: 0.88em; color: var(--muted); }
.sheet input, .sheet select {
  color: var(--ink);
  background: color-mix(in srgb, var(--pill) 55%, var(--paper));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 16px;
  min-width: 0;
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dday-rows { display: flex; flex-direction: column; gap: 6px; }
.dday-row { display: grid; grid-template-columns: 1fr 150px; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.hint { margin: 0; font-size: 0.8em; color: var(--muted); }
.test-result { font-size: 0.88em; }
.test-result.ok { color: color-mix(in srgb, #3f8f5a 80%, var(--ink)); }
.test-result.bad { color: var(--sun); }
.confirm-text { font-size: 0.9em; }

/* PC 같은 넓은 화면: 가운데 종이 한 장 */
@media (min-width: 700px) {
  .frame { padding-top: 32px; }
  .paper { border-radius: 56px 56px 6px 6px / 34px 34px 6px 6px; min-height: calc(100dvh - 64px); box-shadow: 0 10px 30px rgba(0,0,0,0.12); }
}
