/* 문장서랍 — 기본 스타일 */
:root {
  --bg: #F5F4F0; --surface: #FFFFFF; --well: #F0EEE9; --fill: #E9E7E1; --seg-on: #FFFFFF;
  --ink: #1D1D1F; --sub: #4A4A4F; --muted: #6B6B70; --line: #E4E2DC; --line2: #EFEDE8;
  --chev: #B5B2AA; --danger: #B3261E; --sunday: #B23B3B; --ok: #3E7D5A;
  --nav: rgba(255,255,255,.92); --track: #D9D6CF; --on-accent: #FFFFFF;
  --accent: #2E4A8C; --soft: #E6EBF5;
  --g-line: #7C7C80; --paper: #FFFFFF;
  --sans: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  --serif: "Noto Serif KR", "AppleMyungjo", serif;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
html[data-mode="dark"] {
  --bg: #000000; --surface: #1C1C1E; --well: #2C2C2E; --fill: #1C1C1E; --seg-on: #3A3A3C;
  --ink: #F2F2F4; --sub: #C7C7CC; --muted: #9A9AA0; --line: #38383A; --line2: #2C2C2E;
  --chev: #5A5A5E; --danger: #FF6B5E; --sunday: #FF8A8A; --ok: #6FCF97;
  --nav: rgba(28,28,30,.92); --track: #39393D; --on-accent: #111114;
  --g-line: #8E8E93; --paper: #EDEBE6;
}
html[data-theme="남색"] { --accent: #2E4A8C; --soft: #E6EBF5; }
html[data-theme="숲"] { --accent: #2F6B4F; --soft: #E3EFE8; }
html[data-theme="와인"] { --accent: #8C2E4A; --soft: #F5E6EB; }
html[data-theme="호박"] { --accent: #8A5212; --soft: #F6EADB; }
html[data-theme="먹"] { --accent: #3A3A3C; --soft: #ECECEE; }
html[data-mode="dark"][data-theme="남색"] { --accent: #8FA8E8; --soft: #1E2A44; }
html[data-mode="dark"][data-theme="숲"] { --accent: #7CC3A0; --soft: #16302A; }
html[data-mode="dark"][data-theme="와인"] { --accent: #E58FA8; --soft: #3A1E28; }
html[data-mode="dark"][data-theme="호박"] { --accent: #E3A55B; --soft: #3A2A14; }
html[data-mode="dark"][data-theme="먹"] { --accent: #D1D1D6; --soft: #2C2C2E; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.6; word-break: keep-all; overflow-wrap: anywhere; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* 스플래시 */
.splash { position: fixed; inset: 0; z-index: 100; background: var(--bg); transition: opacity .25s ease; }
.splash.hide { opacity: 0; pointer-events: none; }
.splash-logo { position: absolute; left: 0; right: 0; top: calc(20vh); display: flex; flex-direction: column; align-items: center; gap: 20px; }
.splash-name { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.splash-quote { position: absolute; left: 44px; right: 44px; top: calc(20vh + 270px); display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; opacity: 0; animation: sdFade .8s .35s ease-out both; }
.splash-rule { width: 24px; height: 1px; background: var(--line); }
.splash-quote p { margin: 0; font-family: var(--serif); font-size: 22px; line-height: 1.75; white-space: pre-line; text-wrap: balance; }
.splash-credit { font-size: 13px; color: var(--muted); }
.sp-paper { fill: var(--paper); } .sp-line { stroke: var(--g-line); stroke-width: 1.4; }
.sp-text { stroke: var(--accent); } .sp-drawer { fill: var(--g-line); } .sp-handle { fill: var(--paper); }
.sp-card { transform-box: fill-box; animation: sdCard .9s .1s cubic-bezier(.25,.7,.3,1) both; }
@keyframes sdCard { from { transform: translateY(30px); } to { transform: translateY(0); } }
@keyframes sdFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .sp-card, .splash-quote { animation: none; opacity: 1; } }

/* 레이아웃 */
.screen { min-height: 100dvh; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; }
.screen-head { padding: calc(var(--safe-top) + 20px) 20px 8px; }
.screen-head h1 { margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.head-sub { font-size: 13px; color: var(--muted); padding-bottom: 6px; }
.content { flex: 1; padding: 6px 16px calc(var(--safe-bottom) + 110px); display: flex; flex-direction: column; gap: 10px; }

/* 탭바 */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--nav); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 8px 0 calc(var(--safe-bottom) + 6px); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 72px; font-size: 11px; color: var(--muted); }
.tabbar a.on { color: var(--accent); font-weight: 500; }
.tabbar svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fab { position: fixed; right: max(20px, calc(50vw - 300px)); bottom: calc(var(--safe-bottom) + 84px); z-index: 21; width: 58px; height: 58px; border-radius: 29px; border: 0; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(0,0,0,.22); cursor: pointer; }
.fab svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; fill: none; }

/* 입력 */
.search { display: flex; align-items: center; gap: 8px; background: var(--fill); border-radius: 12px; padding: 0 12px; height: 40px; margin-top: 12px; }
.search input { border: 0; background: transparent; outline: none; flex: 1; font-size: 16px; }
.seg { display: flex; background: var(--fill); border-radius: 10px; padding: 3px; gap: 3px; margin-top: 10px; }
.seg button { flex: 1; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--sub); font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--seg-on); color: var(--ink); font-weight: 500; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--sub); }
.input, .textarea, .select { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 12px 14px; font-size: 16px; color: var(--ink); outline: none; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); }
.textarea { resize: vertical; min-height: 120px; line-height: 1.7; }
.btn { height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; font-weight: 500; cursor: pointer; padding: 0 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }
.link { background: none; border: 0; color: var(--accent); font-size: 14px; cursor: pointer; padding: 6px 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; color: var(--sub); cursor: pointer; }
.chip.on { border-color: var(--accent); background: var(--soft); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--soft); color: var(--accent); border-radius: 6px; padding: 1px 7px; font-size: 12px; }

/* 카드 */
.day-label { font-size: 13px; font-weight: 700; padding: 10px 4px 0; }
.day-label span { font-weight: 400; color: var(--muted); }
.card { display: block; background: var(--surface); border-radius: 18px; padding: 16px 18px; box-shadow: 0 1px 2px rgba(0,0,0,.04); cursor: pointer; }
.card .kind { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.card .kind.q { color: var(--accent); }
.card .quote { margin: 0; font-family: var(--serif); font-size: 17px; line-height: 1.65; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.card .title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.card .body { margin: 0; font-size: 14px; color: var(--sub); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.card .thought { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line2); }
.card .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.card .meta .src { color: var(--accent); }
.badge { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 7px; background: var(--soft); color: var(--accent); }
.badge.warn { background: #FCEFD9; color: #7A4A00; }
html[data-mode="dark"] .badge.warn { background: #3A2A14; color: #F2C27A; }
.today { background: var(--surface); border-radius: 18px; padding: 16px 18px; }
.today .t { font-family: var(--serif); font-size: 16px; line-height: 1.7; white-space: pre-line; margin: 0; }
.today .c { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; font-size: 14px; line-height: 1.8; }

/* 그룹 목록 (설정·서랍) */
.group-label { font-size: 12px; color: var(--muted); padding: 10px 6px 4px; }
.group { background: var(--surface); border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 10px 16px; border-bottom: 1px solid var(--line2); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; font-size: 15px; cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row .r { color: var(--muted); font-size: 14px; }
.row.accent { color: var(--accent); font-weight: 500; }
.row.danger { color: var(--danger); }
.help { font-size: 12.5px; color: var(--muted); line-height: 1.55; padding: 0 16px 12px; }
.switch { width: 51px; height: 31px; border: 0; border-radius: 16px; padding: 2px; background: var(--track); display: flex; justify-content: flex-start; flex: none; cursor: pointer; }
.switch span { width: 27px; height: 27px; border-radius: 14px; background: #FFFFFF; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.switch[aria-checked="true"] { background: var(--accent); justify-content: flex-end; }

/* 노트 */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); padding: calc(var(--safe-top) + 6px) 8px 6px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line2); }
.topbar .back { display: flex; align-items: center; gap: 2px; color: var(--accent); font-size: 16px; height: 44px; padding: 0 8px; background: none; border: 0; cursor: pointer; }
.topbar input[type=date] { border: 0; background: var(--well); border-radius: 16px; height: 32px; padding: 0 12px; font-size: 14px; }
.note-page { background: var(--surface); min-height: 100dvh; }
.note-body { padding: 16px 20px calc(var(--safe-bottom) + 40px); display: flex; flex-direction: column; gap: 16px; max-width: 640px; margin: 0 auto; }
.title-input { border: 0; outline: none; font-size: 24px; font-weight: 700; background: transparent; padding: 0; }
.label-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 500; color: var(--muted); }
.label-row.q { color: var(--accent); }
.quote-box { width: 100%; border: 0; outline: none; resize: none; background: var(--well); border-radius: 14px; padding: 16px 18px; font-family: var(--serif); font-size: 18px; line-height: 1.7; min-height: 90px; }
.quote-locked { background: var(--well); border-radius: 14px; padding: 16px 18px; font-size: 14px; color: var(--muted); }
.thought-box { width: 100%; border: 0; outline: none; resize: none; background: transparent; padding: 0; font-size: 16px; line-height: 1.75; min-height: 120px; }
.box { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.box > summary { list-style: none; height: 46px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; background: var(--well); font-size: 14px; font-weight: 500; cursor: pointer; }
.box > summary::-webkit-details-marker { display: none; }
.box-in { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.saved { text-align: center; font-size: 12px; color: var(--muted); }
.notice { background: var(--soft); color: var(--ink); border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.6; }

/* 문장 고르기 */
.pick-line { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 14px; font-family: var(--serif); font-size: 16px; line-height: 1.6; cursor: pointer; }
.pick-line.on { border-color: var(--accent); background: var(--soft); }

/* 캘린더 */
.cal { background: var(--surface); border-radius: 20px; padding: 12px 10px 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 2px; text-align: center; }
.cal-w { font-size: 12px; color: var(--muted); padding-bottom: 6px; }
.cal-d { white-space: nowrap; overflow-wrap: normal; height: 46px; border: 0; border-radius: 23px; background: transparent; font-size: 15px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; }
.cal-d i { width: 5px; height: 5px; border-radius: 3px; background: transparent; }
.cal-d.has i { background: var(--accent); }
.cal-d.today { background: var(--soft); color: var(--accent); font-weight: 700; }
.cal-d.sel { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.cal-d.sel i { background: var(--on-accent); }
.cal-d.sun { color: var(--sunday); }
.cal-d.sel.sun { color: var(--on-accent); }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; color: var(--accent); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2.4; fill: none; stroke-linecap: round; }

/* 서랍 */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { border-radius: 18px; padding: 16px; background: var(--surface); }
.stat.main { background: var(--accent); color: var(--on-accent); }
.stat b { display: block; font-size: 24px; }
.stat span { font-size: 13px; opacity: .8; }

/* 로그인 */
.auth { min-height: 100dvh; max-width: 440px; margin: 0 auto; padding: calc(var(--safe-top) + 72px) 28px calc(var(--safe-bottom) + 32px); display: flex; flex-direction: column; gap: 12px; }
.auth h1 { margin: 10px 0 0; text-align: center; font-size: 28px; }
.auth .tagline { text-align: center; font-family: var(--serif); color: var(--sub); margin: 0 0 24px; }
.code-box { font-family: ui-monospace, Menlo, monospace; font-size: 22px; letter-spacing: 2px; text-align: center; background: var(--surface); border: 1px dashed var(--accent); border-radius: 14px; padding: 18px; user-select: all; }

/* 토스트·시트 */
.toast { position: fixed; left: 50%; top: calc(var(--safe-top) + 12px); transform: translate(-50%, -150%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 200; transition: transform .25s ease; max-width: 90vw; }
.toast.show { transform: translate(-50%, 0); }
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 150; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; border-radius: 20px 20px 0 0; padding: 20px 20px calc(var(--safe-bottom) + 20px); display: flex; flex-direction: column; gap: 12px; max-height: 90dvh; overflow: auto; }
.sheet h2 { margin: 0; font-size: 18px; }
.sheet .actions { display: flex; gap: 8px; }
.sheet .actions .btn { flex: 1; }
.steps { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.8; color: var(--sub); }
code.k { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--well); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
