:root {
  --bg: #F5EEDF;
  --card: #FBF7EE;
  --line: #E2D6BF;
  --line-soft: #E8DDC8;
  --sand: #EFE4CE;
  --ink: #33281F;
  --ink-2: #4E4237;
  --muted: #6F6255;
  --accent: #A8492A;
  --accent-ink: #FBF7EE;
  --dash: #B9A88C;
  --ui: 'Noto Sans KR', system-ui, sans-serif;
  --title: 'Gowun Batang', serif;
  --content: 'Gowun Batang', serif;
  --scale: 1;
  --shadow: 0 6px 18px rgba(80, 55, 30, 0.07);
}
* { box-sizing: border-box; }
html { font-size: calc(100% * var(--scale)); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; }
#view { padding: calc(env(safe-area-inset-top) + 1.5rem) 1.25rem 7.5rem; outline: none; }
#view.no-tabbar { padding-bottom: 2rem; }

/* tab bar */
#tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px; height: calc(4.75rem + env(safe-area-inset-bottom)); padding: .5rem .5rem env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: space-around; align-items: flex-start; z-index: 20; }
#tabbar a { width: 3.75rem; display: flex; flex-direction: column; align-items: center; gap: .2rem; color: var(--muted); font-size: .72rem; }
#tabbar a svg { width: 1.5rem; height: 1.5rem; }
#tabbar a.on { color: var(--accent); font-weight: 700; }
#tabbar a.fab { width: 3.5rem; height: 3.5rem; margin-top: -1.5rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); justify-content: center; box-shadow: 0 8px 18px rgba(168, 73, 42, .32); }
#tabbar a.fab svg { width: 1.6rem; height: 1.6rem; stroke-width: 2; }

/* type */
.serif { font-family: var(--title); }
.content { font-family: var(--content); }
h1, h2, h3 { margin: 0; }
.h-app { font-family: var(--title); font-size: 2rem; font-weight: 700; letter-spacing: -.01em; }
.h-page { font-family: var(--title); font-size: 1.5rem; font-weight: 700; }
.eyebrow { font-size: .75rem; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-s { display: flex; flex-direction: column; gap: .5rem; }
.row { display: flex; align-items: center; gap: .5rem; }
.spacer { flex: 1; }

/* top bars */
.topbar { display: flex; align-items: center; gap: .25rem; margin: -.5rem -.5rem .75rem; }
.icon-btn { width: 2.75rem; height: 2.75rem; border: none; background: transparent; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); }
.icon-btn:hover { background: var(--sand); }
.home-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 1rem; }

/* inputs */
.searchbar { display: flex; align-items: center; gap: .6rem; height: 3rem; padding: 0 1rem; border-radius: 1.5rem; background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.searchbar.active { border: 1.5px solid var(--accent); color: var(--accent); }
.searchbar input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 1rem; color: var(--ink); }
.searchbar input::placeholder, .field::placeholder { color: #7A6C5E; }
.field { width: 100%; height: 2.9rem; padding: 0 1rem; border-radius: 1.45rem; border: 1px solid var(--line); background: var(--card); outline: none; }

/* chips */
.chips { display: flex; gap: .5rem; overflow-x: auto; margin: 0 -1.25rem; padding: .1rem 1.25rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.chip { flex: none; height: 2.25rem; padding: 0 .9rem; border-radius: 1.125rem; border: none; display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; font-weight: 500; white-space: nowrap; }
.chip.dark { background: var(--ink); color: var(--card); }
.chip.outline { background: transparent; border: 1px solid var(--line); color: var(--ink-2); font-weight: 400; }
.chip.dashed { background: transparent; border: 1.5px dashed var(--dash); color: var(--ink-2); }
.chip.sel { border: 1.5px solid currentColor; font-weight: 700; }
.chip svg { width: .9rem; height: .9rem; stroke-width: 2.6; }
.pill { display: inline-flex; align-items: center; font-size: .75rem; font-weight: 500; padding: .15rem .6rem; border-radius: .6rem; white-space: nowrap; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line-soft); border-radius: 1.25rem; padding: 1.1rem; }
.card.shadow { box-shadow: var(--shadow); }
.card.sand { background: var(--sand); border: none; }
a.card { display: block; }
.entry-card { display: flex; flex-direction: column; gap: .55rem; }
.entry-card .meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.entry-card .when { font-size: .75rem; font-weight: 700; color: var(--accent); letter-spacing: .04em; }
.entry-card .when.plain { color: var(--muted); font-weight: 400; }
.entry-card .title { font-family: var(--content); font-size: calc(1.2rem * var(--content-boost, 1)); font-weight: 700; line-height: 1.35; }
.entry-card .excerpt { margin: 0; font-family: var(--content); font-size: calc(.92rem * var(--content-boost, 1)); line-height: 1.7; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.thumbs { display: flex; gap: .5rem; }
.thumb { display: block; position: relative; width: 3.5rem; height: 3.5rem; border-radius: .75rem; overflow: hidden; background: var(--sand); flex: none; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; background: rgba(0,0,0,.18); }
.thumb .play svg { fill: currentColor; stroke: none; width: 1.2rem; height: 1.2rem; }
.thumb .more { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(51,40,31,.55); color: #fff; font-weight: 700; font-size: .85rem; }
.pill-row { display: flex; gap: .35rem; flex-wrap: wrap; }

mark { background: #F2D7A6; color: var(--ink); border-radius: 3px; padding: 0 2px; }

.list-row { display: flex; gap: .9rem; align-items: center; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: none; }
.list-row .day { flex: none; width: 2.75rem; display: flex; flex-direction: column; align-items: center; }
.list-row .day b { font-family: var(--title); font-size: 1.4rem; line-height: 1; }
.list-row .day span { font-size: .7rem; color: var(--muted); margin-top: .25rem; }
.list-row .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.list-row .txt b { font-family: var(--content); font-size: calc(1rem * var(--content-boost, 1)); font-weight: 700; }
.list-row .txt span { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.otd { display: flex; gap: .9rem; align-items: flex-start; }
.otd .ic { flex: none; width: 2.5rem; height: 2.5rem; border-radius: 50%; background: #F8F1E3; color: var(--accent); display: flex; align-items: center; justify-content: center; }
.otd p { margin: .2rem 0 0; font-family: var(--content); font-size: calc(.95rem * var(--content-boost, 1)); line-height: 1.6; }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); font-size: .92rem; line-height: 1.7; }
.empty .h { font-family: var(--title); font-size: 1.15rem; color: var(--ink); font-weight: 700; margin-bottom: .35rem; }

.btn { white-space: nowrap; flex: none; height: 3.25rem; padding: 0 1.4rem; border-radius: 1.625rem; border: none; background: var(--accent); color: var(--accent-ink); font-size: 1rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; box-shadow: 0 8px 18px rgba(168, 73, 42, .28); }
.btn.small { height: 2.5rem; padding: 0 1.1rem; font-size: .92rem; box-shadow: none; }
.btn.ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line); box-shadow: none; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.linkbtn { white-space: nowrap; border: none; background: transparent; color: var(--muted); font-size: .85rem; text-decoration: underline; text-underline-offset: 3px; min-height: 2.75rem; padding: 0 .4rem; }
.more-btn { display: block; margin: .5rem auto 0; }

/* segmented */
.seg { display: flex; padding: 3px; background: var(--sand); border-radius: .8rem; }
.seg button { flex: 1; height: 2.4rem; border: none; border-radius: .65rem; background: transparent; color: var(--muted); font-size: .85rem; }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(80, 55, 30, .12); }
.seg.dark button.on { background: var(--ink); color: var(--card); }

/* topic header */
.topic-head { margin: calc(-1 * (env(safe-area-inset-top) + 1.5rem)) -1.25rem 1rem; padding: calc(env(safe-area-inset-top) + 1rem) 1.25rem 1.1rem; border-radius: 0 0 1.75rem 1.75rem; display: flex; flex-direction: column; gap: .75rem; }
.topic-head h1 { font-family: var(--title); font-size: 2.1rem; font-weight: 700; }
.bars { display: flex; align-items: flex-end; gap: .35rem; height: 2.25rem; }
.bars span { flex: 1; border-radius: 3px; min-height: 3px; }
.bar-labels { display: flex; justify-content: space-between; font-size: .7rem; }
.group-h { font-size: .75rem; font-weight: 700; color: var(--muted); letter-spacing: .04em; margin-top: .4rem; }
.mini { display: flex; flex-direction: column; gap: .2rem; padding: .75rem .9rem; border-radius: 1rem; background: var(--card); border: 1px solid var(--line-soft); }
.mini .d { font-size: .75rem; color: var(--muted); }
.mini .t { font-family: var(--content); font-size: calc(1rem * var(--content-boost, 1)); font-weight: 700; }

/* write */
.write-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin: -.5rem -.25rem .5rem; }
.date-btn { border: none; background: transparent; font-size: .9rem; font-weight: 500; color: var(--ink-2); min-height: 2.75rem; padding: 0 .5rem; border-radius: .6rem; }
.date-btn:hover { background: var(--sand); }
.title-input { width: 100%; border: none; outline: none; background: transparent; padding: .5rem 0 .65rem; border-bottom: 1px solid var(--line); font-family: var(--content); font-size: calc(1.5rem * var(--content-boost, 1)); font-weight: 700; }
.body-input { width: 100%; min-height: 40vh; border: none; outline: none; resize: none; background: transparent; font-family: var(--content); font-size: calc(1.06rem * var(--content-boost, 1)); line-height: 1.9; padding: 0; }
.media-grid { display: flex; gap: .65rem; flex-wrap: wrap; }
.media-tile { position: relative; width: 4.75rem; height: 4.75rem; border-radius: .9rem; background: var(--sand); }
.media-tile .in { width: 100%; height: 100%; border-radius: .9rem; overflow: hidden; }
.media-tile img, .media-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile .x { position: absolute; top: -.5rem; right: -.5rem; width: 1.75rem; height: 1.75rem; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: flex; align-items: center; justify-content: center; padding: 0; }
.media-tile .x svg { width: .75rem; height: .75rem; stroke-width: 2.4; }
.media-tile .badge { position: absolute; right: .4rem; bottom: .3rem; color: #fff; font-size: .7rem; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.media-tile.add { border: 1.5px dashed var(--dash); background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; color: var(--muted); font-size: .75rem; }
.toolbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px; padding: .4rem .6rem calc(.6rem + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); display: flex; align-items: center; gap: .25rem; z-index: 20; }
.toolbar .icon-btn { color: var(--ink-2); }

/* entry view */
.stage { position: relative; border-radius: 1.4rem; overflow: hidden; background: #3E322A; box-shadow: 0 10px 24px rgba(80,55,30,.15); }
.stage img, .stage video { display: block; width: 100%; max-height: 62vh; object-fit: contain; background: #2a221c; }
.stage .count { position: absolute; right: .8rem; top: .7rem; background: rgba(0,0,0,.45); color: #fff; font-size: .75rem; font-weight: 700; padding: .15rem .5rem; border-radius: .6rem; }
.stage-thumbs { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.stage-thumbs button { padding: 0; border: none; background: transparent; border-radius: .75rem; }
.stage-thumbs button.on .thumb { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.entry-body { font-family: var(--content); font-size: calc(1.06rem * var(--content-boost, 1)); line-height: 1.9; white-space: pre-wrap; word-break: break-word; margin: 0; }

/* sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(51,40,31,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; background: var(--card); border-radius: 1.75rem 1.75rem 0 0; padding: .6rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 1rem; box-shadow: 0 -10px 30px rgba(51,40,31,.18); }
.sheet .handle { align-self: center; width: 2.5rem; height: 4px; border-radius: 2px; background: #D9CCB3; }

/* settings */
.group { background: var(--card); border: 1px solid var(--line-soft); border-radius: 1.25rem; overflow: hidden; }
.group > a, .group > button, .group > .item { width: 100%; display: flex; align-items: center; gap: .9rem; min-height: 3.75rem; padding: .4rem 1rem; border: none; border-bottom: 1px solid var(--sand); background: transparent; text-align: left; }
.group > :last-child { border-bottom: none; }
.group .ic { flex: none; width: 2.25rem; height: 2.25rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.group .ic svg { width: 1.1rem; height: 1.1rem; }
.group .lbl { flex: 1; font-size: .95rem; font-weight: 500; display: flex; flex-direction: column; }
.group .lbl small { font-size: .75rem; color: var(--muted); font-weight: 400; }
.chev { color: var(--muted); width: 1.1rem; height: 1.1rem; }

.font-opt { width: 100%; display: flex; align-items: center; gap: .9rem; min-height: 3.75rem; padding: .5rem 1rem; border-radius: 1rem; background: var(--card); border: 1.5px solid var(--line-soft); text-align: left; }
.font-opt.on { border-color: var(--accent); }
.radio { flex: none; width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 1.5px solid #C9B99B; display: flex; align-items: center; justify-content: center; }
.font-opt.on .radio { background: var(--accent); border-color: var(--accent); color: #fff; }
.radio svg { width: .8rem; height: .8rem; stroke-width: 3; }

.check { display: flex; align-items: center; gap: .75rem; min-height: 2.6rem; font-size: .95rem; }
.check input { accent-color: var(--accent); width: 1.2rem; height: 1.2rem; margin: 0; }
fieldset { margin: 0; padding: .9rem 1rem; border: 1px solid var(--line-soft); border-radius: 1.25rem; background: var(--card); }
legend { padding: 0 .4rem; font-size: .75rem; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.progress { height: .5rem; border-radius: .25rem; background: var(--sand); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width .2s; }

.color-dot { width: 1.75rem; height: 1.75rem; border-radius: 50%; border: 2px solid rgba(0,0,0,.08); flex: none; padding: 0; }
.tag-row { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--sand); }
.tag-row input { flex: 1; min-width: 0; height: 2.5rem; padding: 0 .75rem; border-radius: .75rem; border: 1px solid transparent; background: transparent; outline: none; font-size: .95rem; }
.tag-row input:focus { border-color: var(--line); background: var(--card); }

#toast { position: fixed; left: 50%; bottom: calc(6rem + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(1rem); background: var(--ink); color: var(--card); padding: .65rem 1.1rem; border-radius: 1.4rem; font-size: .88rem; opacity: 0; pointer-events: none; transition: all .25s; z-index: 60; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.overlay { position: fixed; inset: 0; z-index: 70; background: rgba(245,238,223,.92); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 2rem; text-align: center; }
.overlay .progress { width: 70%; max-width: 280px; }

.skeleton { height: 6rem; border-radius: 1.25rem; background: linear-gradient(90deg, var(--sand), #F4EBD9, var(--sand)); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

select.select { appearance: none; -webkit-appearance: none; padding-right: 2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236F6255' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .6rem center; background-size: .9rem; cursor: pointer; font-size: .85rem; }
.chip.select { font-weight: 500; }
.content-title { font-family: var(--content); }

/* 하루를 여러 이야기로 */
.wsec { background: var(--card); border: 1px solid var(--line-soft); border-radius: 1.25rem; padding: .85rem 1rem 1rem; display: flex; flex-direction: column; gap: .8rem; box-shadow: var(--shadow); }
.wsec-head { display: flex; align-items: center; gap: .55rem; }
.wsec-no { flex: none; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--sand); color: var(--ink-2); display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; }
.wsec .body-input { min-height: 8rem; }
.wsec .media-grid:empty { display: none; }
.wsec-tools { gap: .5rem; }
.wsec-tools .chip { cursor: pointer; }
.wsec-tools .chip svg { width: 1.05rem; height: 1.05rem; stroke-width: 1.8; }
.wsec-tags { border-top: 1px dashed var(--line); padding-top: .75rem; }
.icon-btn.sm { width: 2.5rem; height: 2.5rem; color: var(--muted); }
.icon-btn.sm svg { width: 1.1rem; height: 1.1rem; }
.add-section { width: 100%; margin-top: 1rem; min-height: 3.25rem; border-radius: 1.25rem; border: 1.5px dashed var(--dash); background: transparent; color: var(--ink-2); display: flex; align-items: center; justify-content: center; gap: .4rem; font-size: .95rem; font-weight: 500; }
.add-section:hover { background: var(--sand); }
.center { text-align: center; }
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.searchbar .icon-btn.sm { margin-right: -.6rem; width: 2.25rem; height: 2.25rem; }
