/* ===== Planner — 수채화 스크랩북 (더스티 블루) ===== */
:root {
  --paper: #F5F2EC;
  --card: #FBFAF6;
  --card-line: #ECE6DA;
  --ink: #2F3E46;
  --sub: #5E6C73;
  --faint: #8E9A9F;
  --deep: #4E6E7C;
  --accent: #6F8F9C;
  --mid: #8FADBA;
  --soft: #B9CDD5;
  --wash: #DCE7EC;
  --kraft: #F3E6D2;
  --kraft-ink: #5E5446;
  --tape: rgba(233,216,188,0.9);
  --stripeA: rgba(143,173,186,0.75);
  --stripeB: rgba(185,205,213,0.75);
  --dash: #CBD8DD;
  --stain: rgba(143,173,186,0.34);
  --stain2: rgba(231,201,184,0.38);
  --sun: #B5574B;
  --shadow: 0 5px 16px rgba(47,62,70,0.10);
  --nav-bg: rgba(251,250,246,0.94);
  --danger: #B5574B;
  --font: 'Gowun Dodum', -apple-system, 'Apple SD Gothic Neo', sans-serif;
  --script: 'Caveat', cursive;
  --hand: 'Nanum Pen Script', cursive;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #1C2226; --card: #252D32; --card-line: #323B40; --ink: #E7E3DA; --sub: #A9B3B7; --faint: #7E8A8F;
  --deep: #A9C3CE; --accent: #7E9EAB; --mid: #6E8C99; --soft: #4F6A75; --wash: #2C3A40; --kraft: #3A352C; --kraft-ink: #D9CDB8;
  --tape: rgba(150,135,110,0.7); --stripeA: rgba(110,140,153,0.7); --stripeB: rgba(79,106,117,0.7); --dash: #3B474D;
  --stain: rgba(110,140,153,0.22); --stain2: rgba(150,115,100,0.2); --sun: #D98A7E; --shadow: 0 5px 16px rgba(0,0,0,0.35);
  --nav-bg: rgba(37,45,50,0.95); --danger: #E0897D; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1C2226; --card: #252D32; --card-line: #323B40; --ink: #E7E3DA; --sub: #A9B3B7; --faint: #7E8A8F;
    --deep: #A9C3CE; --accent: #7E9EAB; --mid: #6E8C99; --soft: #4F6A75; --wash: #2C3A40; --kraft: #3A352C; --kraft-ink: #D9CDB8;
    --tape: rgba(150,135,110,0.7); --stripeA: rgba(110,140,153,0.7); --stripeB: rgba(79,106,117,0.7); --dash: #3B474D;
    --stain: rgba(110,140,153,0.22); --stain2: rgba(150,115,100,0.2); --sun: #D98A7E; --shadow: 0 5px 16px rgba(0,0,0,0.35);
    --nav-bg: rgba(37,45,50,0.95); --danger: #E0897D; color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper); color: var(--ink); font-family: var(--font);
  font-size: 15px; line-height: 1.5; min-height: 100vh; overflow-x: hidden;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
input, select, textarea { font-size: 16px; }
[hidden] { display: none !important; }

/* watercolor stains */
.stains { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.stains i { position: absolute; border-radius: 50%; display: block; }
.stains i:nth-child(1) { right: -80px; top: -70px; width: 260px; height: 240px; background: radial-gradient(circle, var(--stain) 0%, transparent 70%); }
.stains i:nth-child(2) { left: -110px; top: 45%; width: 280px; height: 280px; background: radial-gradient(circle, var(--stain) 0%, transparent 70%); }
.stains i:nth-child(3) { right: -60px; bottom: 60px; width: 230px; height: 230px; background: radial-gradient(circle, var(--stain2) 0%, transparent 70%); }

/* layout */
#app { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 22px) 18px calc(env(safe-area-inset-bottom) + 110px); }
.view { display: flex; flex-direction: column; gap: 16px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.head h1 { margin: 0; font-family: var(--script); font-weight: 600; font-size: 46px; line-height: 1; color: var(--deep); }
.head .sub { font-family: var(--hand); font-size: 23px; color: var(--sub); margin-top: 2px; display: block; }
.head .tools { display: flex; gap: 2px; align-items: center; }
.icon-btn { width: 44px; height: 44px; border: none; background: transparent; color: var(--deep); display: inline-flex; align-items: center; justify-content: center; border-radius: 22px; font-size: 22px; }
.icon-btn:active { background: var(--wash); }
.icon-btn svg { width: 22px; height: 22px; }

.card { position: relative; background: var(--card); border: 1px solid var(--card-line); box-shadow: var(--shadow); padding: 16px; }
.tilt-l { transform: rotate(-0.5deg); }
.tilt-r { transform: rotate(0.5deg); }
.tape { position: absolute; width: 74px; height: 21px; background: var(--tape); top: -10px; pointer-events: none; }
.tape.stripe { background: repeating-linear-gradient(90deg, var(--stripeA) 0 6px, var(--stripeB) 6px 12px); }
.tape.tl { left: -10px; transform: rotate(-22deg); }
.tape.tr { right: 26px; transform: rotate(4deg); }
.tape.tc { left: 50%; margin-left: -37px; transform: rotate(-3deg); }
.note-kraft { background: var(--kraft); color: var(--kraft-ink); box-shadow: 0 3px 10px rgba(47,62,70,0.1); padding: 14px; position: relative; }
.note-wash { background: var(--wash); box-shadow: 0 3px 10px rgba(47,62,70,0.08); padding: 16px; position: relative; }
.hand { font-family: var(--hand); }
.script { font-family: var(--script); }
.muted { color: var(--sub); }
.small { font-size: 12px; }
.dashline { border-top: 1px dashed var(--dash); }

.btn { height: 46px; padding: 0 18px; border-radius: 23px; border: none; background: var(--accent); color: #fff; font-size: 15px; font-weight: 700; }
.btn.block { width: 100%; height: 52px; border-radius: 26px; box-shadow: 0 6px 16px rgba(78,110,124,0.25); }
.btn.ghost { background: transparent; color: var(--deep); border: 1px solid var(--mid); font-weight: 400; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); font-weight: 400; }
.btn:disabled { opacity: 0.55; }
.pill { height: 34px; padding: 0 14px; border-radius: 17px; border: 1px dashed var(--mid); background: transparent; color: var(--deep); font-size: 13px; }

/* tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--nav-bg); border-top: 1px solid var(--card-line);
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.tabbar button { border: none; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--faint); font-size: 11px; padding: 4px 0; min-height: 48px; }
.tabbar button[aria-current="page"] { color: var(--deep); font-weight: 700; }
.tabbar svg { width: 24px; height: 24px; }
@media (min-width: 900px) { .tabbar { max-width: 560px; margin: 0 auto; border-left: 1px solid var(--card-line); border-right: 1px solid var(--card-line); border-radius: 16px 16px 0 0; } }

/* banner */
.banner { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--kraft); color: var(--kraft-ink); font-size: 14px; border-radius: 4px; }
.banner .grow { flex: 1; }
.banner .btn { height: 36px; font-size: 13px; padding: 0 14px; }

/* ===== calendar ===== */
.cal-nav { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 6px; }
.cal-nav .month { font-family: var(--script); font-size: 27px; font-weight: 600; color: var(--deep); background: none; border: none; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; color: var(--sub); padding-bottom: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 1px; }
.cal-day { height: 48px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding-top: 3px; border: none; background: transparent; border-radius: 8px; }
.cal-day .n { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 15px; border-radius: 50%; }
.cal-day.out .n { color: var(--faint); opacity: 0.6; }
.cal-day.sun .n { color: var(--sun); }
.cal-day.today .n { background: radial-gradient(circle at 40% 40%, var(--soft) 0%, var(--mid) 100%); font-weight: 700; color: #1F2D33; }
.cal-day.sel:not(.today) .n { box-shadow: inset 0 0 0 1.5px var(--mid); }
.cal-day .dots { display: flex; gap: 3px; height: 5px; }
.cal-day .dots span { width: 5px; height: 5px; border-radius: 50%; }
.ev-head { display: flex; align-items: baseline; justify-content: space-between; padding-bottom: 4px; }
.ev-head .d { font-family: var(--hand); font-size: 27px; }
.ev-row { display: flex; align-items: center; gap: 12px; min-height: 46px; border-top: 1px dashed var(--dash); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; padding: 6px 0; font-size: 15px; }
.ev-row .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ev-row .time { min-width: 48px; font-size: 13px; color: var(--sub); flex: none; white-space: nowrap; }
.ev-empty { border-top: 1px dashed var(--dash); padding: 14px 0 6px; color: var(--sub); font-size: 14px; }
.fab { position: fixed; right: max(22px, calc(50% - 258px)); bottom: calc(env(safe-area-inset-bottom) + 92px); width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--card); background: var(--accent); color: #fff; font-size: 30px; line-height: 1; box-shadow: 0 6px 16px rgba(47,62,70,0.25); z-index: 15; }

/* ===== todo ===== */
.todo-table { width: 100%; }
.todo-hrow, .todo-row { display: flex; align-items: center; }
.todo-hrow { height: 34px; border-bottom: 1px solid var(--dash); font-size: 11px; color: var(--sub); }
.todo-row { min-height: 48px; border-bottom: 1px dashed var(--dash); }
.todo-name { flex: 1 1 auto; min-width: 0; font-size: 14px; padding-right: 4px; word-break: keep-all; overflow-wrap: anywhere; line-height: 1.35; }
.todo-cell { width: 31px; flex: none; align-self: stretch; display: flex; align-items: center; justify-content: center; }
.todo-cell.today { background: rgba(185,205,213,0.32); }
.todo-score { width: 32px; flex: none; text-align: right; font-size: 12px; color: var(--deep); font-weight: 700; }
.hcell { width: 31px; flex: none; text-align: center; }
.hcell.today { color: var(--ink); font-weight: 700; }
.chk { width: 25px; height: 25px; padding: 0; border-radius: 50%; border: 1.5px solid var(--mid); background: transparent; display: flex; align-items: center; justify-content: center; }
.chk.on { border: none; background: radial-gradient(circle at 40% 35%, #A9C2CC 0%, #6F8F9C 100%); }
.chk.on svg { display: block; }
.chk svg { display: none; width: 13px; height: 13px; }
.chk:disabled { border-color: var(--dash); opacity: 0.6; }
.todo-edit { display: flex; gap: 2px; }
.todo-edit button { width: 34px; height: 34px; border: none; background: transparent; color: var(--deep); font-size: 16px; }
.add-row { display: flex; gap: 8px; padding-top: 10px; }
.add-row input { flex: 1; min-width: 0; height: 42px; border: 1px solid var(--card-line); background: var(--paper); border-radius: 21px; padding: 0 14px; }
.duo { display: flex; gap: 12px; }
.duo > * { flex: 1 1 0; }
.big-num { font-size: 26px; font-weight: 700; }

/* stats */
.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-tiles .card { padding: 12px; }
.stat-tiles .v { font-size: 22px; font-weight: 700; }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.heat span { height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 11px; }
.bars { display: flex; align-items: flex-end; justify-content: space-around; height: 130px; border-bottom: 1px solid var(--dash); }
.bars .b { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; }
.bars .b i { width: 30px; border-radius: 8px 8px 0 0; background: var(--accent); display: block; }
.bar-labels { display: flex; justify-content: space-around; font-size: 11px; color: var(--sub); }
.hbar { height: 8px; border-radius: 4px; background: var(--wash); overflow: hidden; }
.hbar i { display: block; height: 8px; border-radius: 4px; background: var(--accent); }
.stopped .hbar i { background: var(--faint); }

/* ===== diary ===== */
.save-state { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--sub); margin-top: 3px; }
.sec h2 { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; font-family: var(--hand); font-weight: 400; font-size: 31px; color: var(--deep); }
.sec h2 svg { width: 22px; height: 22px; }
.field { padding: 10px 0; border-top: 1px dashed var(--dash); display: flex; flex-direction: column; gap: 4px; }
.field > label, .field > .lbl { font-size: 12px; color: var(--sub); }
textarea.auto, input.line { width: 100%; word-break: keep-all; overflow-wrap: anywhere; border: none; background: transparent; resize: none; padding: 2px 0; line-height: 1.6; outline: none; overflow: hidden; }
textarea.auto::placeholder, input.line::placeholder { color: var(--faint); }
.log { display: flex; gap: 10px; align-items: flex-start; }
.log input.t { width: 54px; flex: none; border: none; background: transparent; color: var(--deep); font-weight: 700; font-size: 14px; padding: 4px 0; }
.log textarea { flex: 1; }
.log .x { width: 32px; height: 32px; border: none; background: transparent; color: var(--faint); font-size: 18px; flex: none; }
.log select { border: 1px solid var(--card-line); background: var(--paper); border-radius: 12px; font-size: 13px; height: 28px; padding: 0 6px; flex: none; margin-top: 3px; }
.meals { display: flex; flex-direction: column; gap: 6px; }
.meals .m { background: var(--card); opacity: 0.92; padding: 8px 12px; display: flex; align-items: flex-start; gap: 12px; }
.meals .m label { font-size: 12px; color: var(--sub); flex: none; width: 30px; padding-top: 4px; }
.meals .m textarea { flex: 1; min-width: 0; }
.send-state { text-align: center; font-size: 12px; color: var(--sub); }
.motto { display: flex; justify-content: center; align-items: center; gap: 8px; font-family: var(--script); font-size: 22px; color: var(--accent); }
mark { background: rgba(185,205,213,0.6); color: inherit; border-radius: 2px; }
.list-item { display: block; width: 100%; text-align: left; border: none; background: transparent; padding: 12px 0; border-top: 1px dashed var(--dash); }
.list-item .d { font-family: var(--hand); font-size: 22px; }
.list-item .p { font-size: 13px; color: var(--sub); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 10px; background: var(--kraft); color: var(--kraft-ink); margin-left: 6px; vertical-align: middle; font-family: var(--font); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px; }
.chips button { flex: none; height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--card-line); background: var(--card); font-size: 13px; }
.chips button[aria-pressed="true"] { border-color: var(--deep); color: var(--deep); font-weight: 700; }
.search-input { width: 100%; height: 44px; border-radius: 22px; border: 1px solid var(--card-line); background: var(--card); padding: 0 16px; }

/* ===== settings ===== */
.set-group h3 { margin: 6px 4px 6px; font-size: 12px; color: var(--sub); font-weight: 700; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 8px 0; border-top: 1px dashed var(--dash); font-size: 15px; }
.set-row:first-child { border-top: none; }
.set-row .r { color: var(--sub); font-size: 14px; text-align: right; }
.set-row select { border: 1px solid var(--card-line); background: var(--paper); border-radius: 10px; height: 36px; padding: 0 8px; font-size: 14px; max-width: 60%; }
.switch { width: 50px; height: 30px; border-radius: 15px; border: none; background: var(--dash); padding: 3px; display: flex; flex: none; transition: background .15s; }
.switch i { width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] i { transform: translateX(20px); }
.caldot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 8px; }

/* sheet / modal */
.overlay { position: fixed; inset: 0; background: rgba(28,34,38,0.42); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--card); border-radius: 20px 20px 0 0; padding: 18px 18px calc(env(safe-area-inset-bottom) + 20px); box-shadow: 0 -8px 30px rgba(0,0,0,0.15); }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 20px; } }
.sheet h2 { margin: 0 0 12px; font-family: var(--hand); font-weight: 400; font-size: 30px; color: var(--deep); }
.form-row { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; }
.form-row > label { font-size: 12px; color: var(--sub); }
.form-row input, .form-row select, .form-row textarea { width: 100%; min-height: 44px; border: 1px solid var(--card-line); background: var(--paper); border-radius: 12px; padding: 8px 12px; }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.sheet-actions .btn { flex: 1 1 140px; }

/* lock */
.lock { position: fixed; inset: 0; z-index: 100; background: var(--paper); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; }
.lock h1 { font-family: var(--script); font-size: 48px; color: var(--deep); margin: 0; }
.pin-dots { display: flex; gap: 14px; height: 18px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--deep); display: block; }
.pin-dots i.f { background: var(--deep); }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; }
.keypad button { height: 64px; border-radius: 32px; border: 1px solid var(--card-line); background: var(--card); font-size: 24px; }
.keypad button.empty { visibility: hidden; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 100px); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 20px; font-size: 14px; z-index: 200; max-width: 86vw; text-align: center; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--soft); border-top-color: var(--deep); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* desktop */
@media (min-width: 900px) {
  #app { max-width: 980px; }
  .cal-layout { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: start; }
  .diary-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
  .diary-layout > .col { display: flex; flex-direction: column; gap: 16px; }
  .fab { right: calc(50% - 470px); }
}
@media (max-width: 899px) {
  .cal-layout, .diary-layout, .diary-layout > .col { display: flex; flex-direction: column; gap: 16px; }
}
