/* familybook — 줄자가 주인공이다. 아이 키를 재던 줄자처럼 나이를 고른다. 나머지는 조용하게. */
:root {
  --paper: #f4f6f5;
  --ink: #17263a;
  --tape: #f6c10a;
  --leaf: #2f7d5b;
  --alert: #c8402f;
  --line: #d3dad8;
  --muted: #5a6778;
  --tick: calc(100% / 12);
  font-family: Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
a { color: inherit; text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }

/* 틀 */
.top { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; }
.top h1 { font-size: 1.125rem; font-weight: 800; letter-spacing: -0.01em; }
.tabs { display: flex; gap: 0.25rem; }
.tabs button { border: 0; background: none; padding: 0.5rem 0.9rem; border-radius: 999px; font-weight: 600; color: var(--muted); }
.tabs button[aria-current="page"] { background: var(--ink); color: var(--paper); }
main { padding: 0 0 5.5rem; max-width: 70rem; margin: 0 auto; }
.pad { padding: 0 1rem; }

@media (max-width: 40rem) {
  .tabs { position: fixed; inset: auto 0 0 0; z-index: 2; justify-content: space-around; background: var(--paper);
    border-top: 2px solid var(--ink); padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom)); }
  .tabs button { flex: 1; }
}

.error { color: var(--alert); font-weight: 600; }
.banner { padding: 0.75rem 1rem; border-block: 2px solid var(--alert); margin-bottom: 1rem; }
.hint { color: var(--muted); }

/* 누구의 사진 */
.who { display: flex; gap: 0.5rem; flex-wrap: wrap; padding: 0.25rem 1rem 0.9rem; }
.chip { border: 2px solid var(--ink); background: none; border-radius: 999px; padding: 0.3rem 0.95rem; font-weight: 700; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* 줄자: 한 칸이 한 살, 위쪽 눈금 열두 개가 열두 달 */
.tape { display: flex; overflow-x: auto; background: var(--tape); border-block: 2px solid var(--ink); scrollbar-width: none; }
.tape::-webkit-scrollbar { display: none; }
.tape button { flex: 0 0 5.75rem; height: 4.5rem; border: 0; border-left: 2px solid var(--ink); border-radius: 0;
  padding: 0 0 0.3rem 0.5rem; display: flex; align-items: flex-end; text-align: left;
  font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
  color: var(--ink); background-color: transparent;
  background-image: repeating-linear-gradient(to right, transparent 0 calc(var(--tick) - 1.5px), currentColor calc(var(--tick) - 1.5px) var(--tick));
  background-size: 100% 0.7rem; background-repeat: no-repeat; }
.tape button small { font-size: 0.8rem; font-weight: 700; margin: 0 0 0.25rem 0.1rem; }
.tape button[aria-pressed="true"] { background-color: var(--ink); color: var(--tape); }
.tape button:focus-visible { outline-offset: -5px; outline-color: currentColor; }

/* 두 돌 전: 한 칸이 한 달, 눈금 네 개가 네 주 */
.tape button.month { --tick: 25%; flex-basis: 5rem; }

.when { padding: 1.4rem 1rem 0.2rem; }
.when h2 { font-size: 2.4rem; line-height: 1.1; font-weight: 800; letter-spacing: -0.03em; }
.when p { color: var(--muted); }

/* 달마다 한 묶음 */
.month { display: flex; align-items: baseline; gap: 0.6rem; padding: 1.5rem 1rem 0.5rem; }
.month h3 { font-size: 1rem; font-weight: 800; }
.month span { color: var(--muted); font-size: 0.9rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: 3px; }
@media (min-width: 40rem) { .grid { grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); padding: 0 1rem; } }
.tile { position: relative; aspect-ratio: 1; padding: 0; border: 0; background: var(--line); overflow: hidden; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .dur { position: absolute; right: 0.3rem; bottom: 0.3rem; background: var(--ink); color: var(--paper);
  font-size: 0.75rem; font-weight: 700; padding: 0 0.35rem; border-radius: 3px; font-variant-numeric: tabular-nums; }
.tile:focus-visible { outline-offset: -3px; outline-color: var(--tape); }
.foot { padding: 1.5rem 1rem; color: var(--muted); min-height: 3rem; }

/* 사진 한 장 보기 */
.viewer { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0;
  background: #0d141d; color: #eef1f0; }
.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: #0d141d; }
.viewer .stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.viewer .stage img, .viewer .stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .close { position: absolute; top: 0.6rem; right: 0.6rem; z-index: 1; }
.viewer button, .viewer .link { border: 1.5px solid #eef1f0; background: #0d141d; color: #eef1f0; border-radius: 999px;
  padding: 0.35rem 0.9rem; font-weight: 600; text-decoration: none; }
.viewer button:disabled { opacity: 0.35; cursor: default; }
.viewer button.on { background: var(--tape); border-color: var(--tape); color: var(--ink); }
.viewer :focus-visible { outline-color: var(--tape); }
.viewer .bar { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom)); }
.viewer .info { flex: 1; min-width: 0; max-height: 44vh; overflow-y: auto; }
.viewer button.ghost { border: 0; background: none; padding: 0.2rem 0.45rem; font-size: 1.35rem; line-height: 1; border-radius: 8px; }
.viewer button.ghost.small { font-size: 0.8rem; color: #9aa7b6; margin-left: 0.4rem; }
.viewer .reacts { display: flex; flex-wrap: wrap; align-items: center; gap: 0.1rem 0.5rem; margin-left: -0.45rem; }
.viewer .who-reacted { font-size: 0.9rem; }
.viewer .palette { margin-left: -0.45rem; }
.viewer .comments p { margin-top: 0.35rem; overflow-wrap: anywhere; }
.viewer .comments b { font-weight: 700; }
.viewer .reply { display: flex; align-items: center; gap: 0.25rem; margin-top: 0.5rem; }
.viewer .reply input { flex: 1; margin: 0; border: 0; border-bottom: 1.5px solid #9aa7b6; border-radius: 0; background: none; color: inherit; padding: 0.35rem 0; }
.viewer .reply button.ghost { font-size: 0.95rem; font-weight: 700; color: var(--tape); }
.viewer .cap { display: flex; flex-wrap: wrap; gap: 0.1rem 0.9rem; color: #9aa7b6; font-size: 0.85rem; margin-top: 0.3rem; }
.viewer .text { white-space: pre-wrap; margin-top: 0.3rem; }
.viewer .file { color: #9aa7b6; font-size: 0.85rem; overflow-wrap: anywhere; }
.viewer .acts { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.6rem; }
.viewer .done { color: var(--tape); font-weight: 700; }
.viewer .note { color: #9aa7b6; font-size: 0.85rem; }

/* 올리기, 설정 */
.block { padding: 1.25rem 1rem 1.5rem; border-top: 2px solid var(--ink); max-width: 44rem; }
.block:first-child { border-top: 0; padding-top: 0.5rem; }
.block h2 { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 0.4rem; }
.block p + p, .block p + button, .block .meter + p, .block ol + p { margin-top: 0.5rem; }
.block ol { padding-left: 1.3rem; margin: 0.75rem 0 0; }
.block li + li { margin-top: 0.5rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.btn { border: 2px solid var(--ink); background: none; border-radius: 999px; padding: 0.4rem 1.1rem; font-weight: 700; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn:disabled { opacity: 0.5; cursor: default; }
code, pre, textarea.code { font-family: ui-monospace, "SF Mono", Consolas, "D2Coding", monospace; font-size: 0.85rem; }
code { background: #e6eaea; padding: 0.1rem 0.35rem; border-radius: 4px; overflow-wrap: anywhere; }
pre { background: var(--ink); color: #e9edf0; padding: 0.9rem 1rem; overflow: auto; max-height: 22rem; white-space: pre-wrap; margin: 0.6rem 0 0; }
details { margin-top: 0.9rem; }
summary { font-weight: 700; cursor: pointer; }

/* 권한이 얼마나 남았는지: 90일짜리 줄자, 눈금 하나가 열흘 */
.meter { --tick: calc(100% / 9); --fill: var(--tape); height: 1.4rem; margin-top: 0.75rem; border: 2px solid var(--ink); background-color: #fff;
  background-image: repeating-linear-gradient(to right, transparent 0 calc(var(--tick) - 1.5px), var(--ink) calc(var(--tick) - 1.5px) var(--tick)),
    linear-gradient(var(--fill), var(--fill));
  background-size: 100% 45%, var(--left, 0%) 100%; background-repeat: no-repeat; }
.meter.low { --fill: var(--alert); }

.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr)); gap: 3px; margin-top: 0.75rem; }
.strip img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--line); }

.person { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.person p { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.person .btn { padding: 0.25rem 0.85rem; }

label { display: block; font-weight: 700; margin-top: 0.9rem; }
input, textarea { width: 100%; margin-top: 0.3rem; padding: 0.6rem 0.75rem; border: 2px solid var(--ink); border-radius: 8px; background: #fff; }
textarea.code { min-height: 26rem; line-height: 1.5; white-space: pre; overflow: auto; tab-size: 2; }
.ok { color: var(--leaf); font-weight: 700; }

/* 로그인 */
.login { max-width: 22rem; margin: 0 auto; padding: 18vh 1.25rem 2rem; }
.login h1 { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.login .tape { margin: 1rem -1.25rem 1.5rem; height: 1.6rem; --tick: calc(100% / 24);
  background-image: repeating-linear-gradient(to right, transparent 0 calc(var(--tick) - 1.5px), var(--ink) calc(var(--tick) - 1.5px) var(--tick));
  background-size: 100% 45%; background-repeat: no-repeat; }
.login .btn { margin-top: 1.25rem; width: 100%; }
