
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css');

/* =========================================================
   단어 앱 테마 시스템 v1
   구조(레이아웃·컴포넌트)는 하나, 테마는 아래 변수만 바꾼다.
   계열 1. 다이어리: diary-light / diary-dark
   계열 2. 하늘(시간대): sky-noon / sky-dusk / sky-night / sky-dawn
   자세한 규칙: docs/design-system.md
   ========================================================= */

/* ---------- 1. 테마 변수 ---------- */
.screen {
  /* 기본값 = 다이어리 라이트 */
  --bg: #FAF8F3;          --bg-grid: #ECE8DF;     --grid-on: 1;
  --surface: #FAF8F3;     --surface-2: #F1EDE4;   --canvas: #FFFFFF;
  --fg: #111110;          --fg2: #5C5A55;         --fg3: #8F8C85;
  --panel-fg: #111110;    --panel-fg2: #5C5A55;   --panel-low: #5C5A55;
  --panel-border: 1.5px solid #111110; --panel-radius: 26px; --panel-inset: 14px;
  --tile-border: 1.5px solid #111110;  --radius: 18px;
  --line: rgba(17,17,16,.14);
  --accent: #D23B2A;      /* 빨간 펜 */
  --mark: #FFE45C;        /* 형광펜 */
  --btn-bg: #111110;      --btn-fg: #FAF8F3;
  --fab-bg: #111110;      --fab-fg: #FAF8F3;
  --ib-bg: transparent;   --ib-border: 1.5px solid currentColor;
  --num-weight: 600;
}
.screen[data-theme="diary-dark"] {
  --bg: #1A1917;          --bg-grid: #26241F;
  --surface: #1A1917;     --surface-2: #24221F;   --canvas: #201F1C;
  --fg: #EEEAE2;          --fg2: #A19C91;         --fg3: #77736B;
  --panel-fg: #EEEAE2;    --panel-fg2: #A19C91;   --panel-low: #A19C91;
  --panel-border: 1.5px solid #EEEAE2; --tile-border: 1.5px solid #EEEAE2;
  --line: rgba(238,234,226,.16);
  --accent: #FF7A66;      --mark: #5C4C12;
  --btn-bg: #EEEAE2;      --btn-fg: #1A1917;
  --fab-bg: #EEEAE2;      --fab-fg: #1A1917;
}
/* 하늘 계열 공통 */
.screen[data-family="sky"] {
  --grid-on: 0; --panel-border: 0; --panel-radius: 0 0 34px 34px; --panel-inset: 0;
  --tile-border: 0; --num-weight: 300; --ib-border: 0;
}
.screen[data-theme="sky-noon"] {      /* 정오: 페리윙클 → 연보라 핑크 · 밝은 하늘 = 어두운 글자 */
  --bg: #F1F1F6; --surface: #FFFFFF; --surface-2: #ECECF4; --canvas: #FFFFFF;
  --fg: #1C2142; --fg2: #5E6488; --fg3: #8C90AA;
  --panel-fg: #1C2142; --panel-fg2: #4E5580; --panel-low: #4E5580;
  --line: rgba(28,33,66,.1); --accent: #5A4FCF; --mark: #E3DBFF;
  --btn-bg: #1C2142; --btn-fg: #FFFFFF; --fab-bg: #1C2142; --fab-fg: #FFFFFF;
  --ib-bg: rgba(28,33,66,.08);
}
.screen[data-theme="sky-dusk"] {      /* 초저녁: 남회색 → 베이지 살구 */
  --bg: #F2EFEB; --surface: #FFFFFF; --surface-2: #EEE9E3; --canvas: #FFFFFF;
  --fg: #1E2232; --fg2: #6E6A68; --fg3: #9A9590;
  --panel-fg: #F8F4F0; --panel-fg2: #E3DAD3; --panel-low: #6B5548;
  --line: rgba(30,34,50,.1); --accent: #A85F38; --mark: #F6DCC8;
  --btn-bg: #1E2232; --btn-fg: #FFFFFF; --fab-bg: #FFFFFF; --fab-fg: #1E2232;
  --ib-bg: rgba(255,255,255,.14);
}
.screen[data-theme="sky-night"] {     /* 밤: 짙은 남색 + 별 → 회보라 */
  --bg: #0B0D1A; --surface: #161A2E; --surface-2: #1E2340; --canvas: #161A2E;
  --fg: #EEF0FA; --fg2: #9CA1C0; --fg3: #6E7394;
  --panel-fg: #EEF0FA; --panel-fg2: #A3A8C8; --panel-low: #CFCBE6;
  --line: rgba(238,240,250,.1); --accent: #C9B8F2; --mark: #3B3470;
  --btn-bg: #EEF0FA; --btn-fg: #0B0D1A; --fab-bg: #EEF0FA; --fab-fg: #0B0D1A;
  --ib-bg: rgba(255,255,255,.12);
}
.screen[data-theme="sky-dawn"] {      /* 새벽: 안개 낀 회청 → 옅은 분홍 · 밝은 하늘 = 어두운 글자 */
  --bg: #EFEEF2; --surface: #FFFFFF; --surface-2: #E9E8EE; --canvas: #FFFFFF;
  --fg: #1F2536; --fg2: #626879; --fg3: #8E92A0;
  --panel-fg: #1F2536; --panel-fg2: #4C5468; --panel-low: #4C5468;
  --line: rgba(31,37,54,.1); --accent: #A0536A; --mark: #F1DCE2;
  --btn-bg: #1F2536; --btn-fg: #FFFFFF; --fab-bg: #1F2536; --fab-fg: #FFFFFF;
  --ib-bg: rgba(31,37,54,.08);
}

/* ---------- 2. 기본 ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Pretendard', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ja { font-family: var(--ja-font); }
ruby rt { font-size: .38em; opacity: .7; font-family: 'Pretendard', sans-serif; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- 3. 폰 프레임 + 화면 ---------- */
.screen {
  position: relative; width: 390px; height: 844px; border-radius: 44px; overflow: hidden;
  box-shadow: 0 0 0 10px #18191B, 0 30px 60px rgba(0,0,0,.25);
  background-color: var(--bg); color: var(--fg);
  transition: background-color 1s ease, color 1s ease;
  display: flex; flex-direction: column;
}
.screen::before { /* 다이어리 격자 */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: var(--grid-on); transition: opacity 1s;
  background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px), linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 22px 22px; background-position: -1px -1px;
}
.body { position: relative; flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.body::-webkit-scrollbar { display: none; }

/* ---------- 4. 패널: 다이어리는 테두리 상자, 하늘은 그라데이션 하늘 ---------- */
.panel {
  position: relative; flex: none;
  margin: calc(var(--panel-inset) + 44px) var(--panel-inset) 0;
  border: var(--panel-border); border-radius: var(--panel-radius);
  color: var(--panel-fg); overflow: hidden; padding: 14px 0 20px;
  transition: color 1s ease;
}
.screen[data-family="sky"] .panel { margin: 0; padding-top: 58px; padding-bottom: 56px; } /* 마지막 글줄이 밝은 지평선 띠에 걸리지 않게 */
.panel > * { position: relative; z-index: 1; }
.panel > .sky, .panel > .stars { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 1s ease; pointer-events: none; }
.sky--noon  { background: linear-gradient(180deg, #7D8EE0 0%, #97A3E6 40%, #C4BDEA calc(100% - 70px), #EED9E6 100%); }
.sky--dusk  { background: linear-gradient(180deg, #1E2540 0%, #353E5C 45%, #5E6178 calc(100% - 80px), #B5A39C calc(100% - 34px), #E7C3A0 100%); }
.sky--night { background: linear-gradient(180deg, #050821 0%, #0E1647 45%, #262C66 calc(100% - 70px), #6A5F8E 100%); }
.sky--dawn  { background: linear-gradient(180deg, #7A8DB8 0%, #93A0C2 45%, #BDBACC calc(100% - 70px), #E6D4D9 100%); }
/* 지평선(밝은 띠)은 패널 높이와 상관없이 아래쪽 70~80px에만 둔다 → 짧은 패널에서도 글자 뒤가 어둡게 유지 */
.screen[data-theme="sky-noon"]  .sky--noon,
.screen[data-theme="sky-dusk"]  .sky--dusk,
.screen[data-theme="sky-night"] .sky--night,
.screen[data-theme="sky-dawn"]  .sky--dawn,
.screen[data-theme="sky-night"] .stars { opacity: 1; }
.screen[data-family="sky"] .panel::after { /* 필름 노이즈 */
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: .14; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.panel .label { color: var(--panel-fg2); }
.screen[data-theme="sky-dusk"] .panel, .screen[data-theme="sky-night"] .panel { text-shadow: 0 0 14px rgba(20,24,44,.45); } /* 밝은 글자용 은은한 스크림 */
.panel .low { color: var(--panel-low); }   /* 패널 아래쪽(하늘이 밝아지는 곳) 글자 */

/* ---------- 5. 패널 안 요소 ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 16px; }
.topbar__title { font-size: 15px; font-weight: 600; text-align: center; flex: 1; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--ib-bg); border: var(--ib-border); display: inline-flex; align-items: center; justify-content: center; color: inherit; flex: none; }
.nav { display: flex; justify-content: center; gap: 34px; }
.nav a { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; color: var(--panel-fg2); position: relative; }
.nav a[aria-current="page"] { color: var(--panel-fg); }
.nav a[aria-current="page"]::after { content: ''; position: absolute; bottom: -8px; left: 4px; right: 4px; height: 1.5px; background: currentColor; }
.hero { padding: 26px 24px 0; display: flex; flex-direction: column; gap: 8px; }
.num { font-size: 56px; line-height: 1; font-weight: var(--num-weight); letter-spacing: -.02em; display: flex; gap: 6px; }
.num sup { font-size: 15px; font-weight: 400; color: var(--panel-fg2); margin-top: 6px; }
.title { margin: 0; font-size: 26px; font-weight: var(--num-weight); letter-spacing: -.02em; line-height: 1.3; }
.screen[data-family="sky"] .title { font-weight: 400; }
.msg { margin: 0; font-size: 15px; line-height: 1.6; color: var(--panel-fg2); }
.msg b { color: var(--panel-fg); font-weight: 600; }
.chart { padding: 18px 18px 0; }
.chart svg { width: 100%; height: 120px; display: block; color: var(--panel-fg); }
.chart .today { fill: var(--accent); }
.screen[data-family="sky"] .chart .today { fill: currentColor; }
.axis { display: flex; justify-content: space-between; padding: 8px 4px 0; }
.axis .label { color: var(--panel-fg2); }
.axis .label.today-l { font-weight: 600; }

/* ---------- 6. 아래 영역 공통 ---------- */
.label { font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--fg2); }
.lower { padding: 14px 14px 32px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.lower--fab { padding-bottom: 104px; }
.sec { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 4px 0; }
.sec h2 { margin: 0; font-size: 15px; font-weight: 600; }
.sec a { font-size: 13px; color: var(--fg2); }
.tile { background: var(--surface); border: var(--tile-border); border-radius: var(--radius); padding: 16px; transition: background-color 1s; }
.tile--inv { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }
.tile--inv .label, .tile--inv .sub { color: inherit; opacity: .7; }
.sub { font-size: 13px; color: var(--fg2); line-height: 1.5; }
.v { font-size: 30px; font-weight: var(--num-weight); letter-spacing: -.02em; }
.v small { font-size: 14px; color: var(--fg2); margin-left: 2px; font-weight: 400; }
.accent { color: var(--accent); }
.mark { background: linear-gradient(transparent 58%, var(--mark) 58%, var(--mark) 92%, transparent 92%); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }

.btn { min-height: 56px; padding: 0 22px; border-radius: 999px; border: 0; background: var(--btn-bg); color: var(--btn-fg); font-weight: 600; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.btn--ghost { background: transparent; color: var(--fg); border: var(--tile-border); }
.screen[data-family="sky"] .btn--ghost { border: 1px solid var(--line); background: var(--surface); }
.go { width: 44px; height: 44px; border-radius: 50%; background: var(--btn-bg); color: var(--btn-fg); display: flex; align-items: center; justify-content: center; flex: none; }

.chip { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; color: var(--fg); flex: none; }
.screen[data-family="diary"] .chip { border: 1.5px solid var(--fg); }
.chip[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }

/* 선택 가능한 카드 (옵션) */
.opt { width: 100%; text-align: left; background: var(--surface); border: var(--tile-border); border-radius: var(--radius); padding: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.screen[data-family="sky"] .opt { border: 1px solid var(--line); }
.opt b { font-size: 16px; font-weight: 600; }
.opt[aria-pressed="true"] { outline: 2px solid var(--fg); outline-offset: -2px; }
.screen[data-family="diary"] .opt[aria-pressed="true"] { box-shadow: 3px 3px 0 var(--fg); outline: 0; }
.opt .dot { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--fg3); flex: none; }
.opt[aria-pressed="true"] .dot { border: 6px solid var(--fg); }

/* 목록 행 */
.rows { display: flex; flex-direction: column; }
.row { display: flex; gap: 14px; align-items: flex-start; padding: 16px 4px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row__k { width: 72px; flex: none; padding-top: 3px; }
.row__v { flex: 1; min-width: 0; }

/* 스위치 */
.switch { appearance: none; width: 48px; height: 28px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); position: relative; cursor: pointer; flex: none; margin: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--fg3); transition: transform .15s, background .15s; }
.switch:checked { background: var(--btn-bg); border-color: var(--btn-bg); }
.switch:checked::after { transform: translateX(20px); background: var(--btn-fg); }

/* 학습 평가 버튼 */
.grades { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; }
.g { min-height: 60px; border-radius: 18px; background: var(--surface); border: var(--tile-border); color: var(--fg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 14px; font-weight: 600; }
.screen[data-family="sky"] .g { border: 1px solid var(--line); border-radius: 999px; }
.g small { font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--fg3); letter-spacing: .04em; font-weight: 400; }
.g--again { color: var(--accent); }
.g--good { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }
.g--good small { color: inherit; opacity: .6; }

/* 낙서: 획은 항상 테마 글자색(currentColor)으로 그린다 */
.doodle-svg { color: inherit; }
.doodle-frame { background: var(--surface-2); border-radius: 14px; display: flex; align-items: center; justify-content: center; flex: none; color: var(--fg); }

.fab { position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%); width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--fab-bg); color: var(--fab-fg); box-shadow: 0 8px 24px rgba(0,0,0,.18); display: flex; align-items: center; justify-content: center; z-index: 3; transition: background-color 1s, color 1s; }
.is-hidden, [hidden] { display: none !important; }

/* ---------- 7. 미리보기 페이지 (앱 밖) ---------- */
.preview-page { min-height: 100vh; background: #E3E4E7; padding: 32px 16px 120px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.tsw { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; background: #fff; border: 1px solid #D3D5DA; border-radius: 999px; padding: 6px; font-family: 'Pretendard', sans-serif; color: #18191B; max-width: 410px; }
.tsw button { min-height: 34px; padding: 0 12px; border-radius: 999px; border: 0; background: transparent; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.tsw button i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.12); }
.tsw button[aria-pressed="true"] { background: #18191B; color: #fff; }
.in-frame .preview-page { min-height: 0; padding: 10px; background: transparent; }

/* 개인정보 처리방침 — 앱 화면과 공유 웹이 같이 쓴다(.screen[data-screen="privacy"]). 오픈소스 라이선스(t-licenses) 모양을 따른다 */
:where(.screen[data-screen="privacy"]) .intro { font-size: 13px; line-height: 1.6; color: var(--fg2); padding: 0 4px; margin: 0; }
:where(.screen[data-screen="privacy"]) .group { background: var(--surface); border: var(--tile-border); border-radius: var(--radius); padding: 2px 16px; }
.screen[data-family="sky"]:where([data-screen="privacy"]) .group { border: 1px solid var(--line); }
:where(.screen[data-screen="privacy"]) .summary .row { padding: 14px 0; }
:where(.screen[data-screen="privacy"]) .summary .row__k { width: 64px; }
:where(.screen[data-screen="privacy"]) .summary .row__v { font-size: 14px; line-height: 1.55; }
:where(.screen[data-screen="privacy"]) .doc { padding: 14px 16px; font-size: 14px; line-height: 1.7; color: var(--fg); }
:where(.screen[data-screen="privacy"]) .doc p { margin: 0 0 8px; }
:where(.screen[data-screen="privacy"]) .doc p:last-child { margin-bottom: 0; }
:where(.screen[data-screen="privacy"]) .doc ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
:where(.screen[data-screen="privacy"]) .doc ul + p { margin-top: 10px; }
:where(.screen[data-screen="privacy"]) .doc b { font-weight: 600; }
:where(.screen[data-screen="privacy"]) .doc li::marker { color: var(--fg3); }
:where(.screen[data-screen="privacy"]) .meta { display: flex; justify-content: space-between; padding: 0 4px; }

/* 앱에 넣은 글꼴 (packages/ui/fonts, tools/subset_fonts.py로 필요한 글자만 남김, 모두 SIL OFL 1.1)
   일본어 글꼴은 설정 > 일본어 글꼴에서 고른다: <html data-ja-font="zen-kaku|zen-maru">, 없으면 Noto Sans JP.
   줄인 범위 밖의 글자(드문 한자)는 기기 고딕(히라기노)으로 보인다. */
@font-face { font-family: 'Noto Sans JP'; src: url('/fonts/noto-sans-jp.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Zen Kaku Gothic New'; src: url('/fonts/zen-kaku-gothic-new-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Zen Kaku Gothic New'; src: url('/fonts/zen-kaku-gothic-new-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Zen Maru Gothic'; src: url('/fonts/zen-maru-gothic-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Zen Maru Gothic'; src: url('/fonts/zen-maru-gothic-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('/fonts/ibm-plex-mono-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('/fonts/ibm-plex-mono-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }

:root { --ja-font: 'Noto Sans JP', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', sans-serif; }
:root[data-ja-font="zen-kaku"] { --ja-font: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', sans-serif; }
:root[data-ja-font="zen-maru"] { --ja-font: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', sans-serif; }

/* 웹 전용: 폰 프레임(.screen 390×844) 대신 읽기 좋은 폭의 한 장짜리 페이지 */
html, body { background: #FAF8F3; }
.screen.web { width: auto; height: auto; min-height: 100vh; max-width: 720px; margin: 0 auto; border-radius: 0; box-shadow: none; overflow: visible; }
.screen.web .body { overflow: visible; }
.screen.web .panel { margin-top: 14px; }
.screen.web .topbar { padding: 0 20px; }
.screen.web .brand { display: inline-flex; align-items: center; gap: 2px; color: var(--panel-fg); }
.screen.web .brand .mk { width: 30px; height: 30px; }
.screen.web .brand .wm { width: 70px; height: 24px; }
