@font-face {
    font-family: 'GowunBatang-Regular';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2108@1.1/GowunBatang-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --default-font: 'GowunBatang-Regular', serif;
    /* 테마 변수는 note.js의 THEMES에서 덮어씁니다 */
    --bg: #FFCDD2;
    --surface: #FFF5F6;
    --text: #3A1F26;
    --sub: #8A5A66;
    --accent: #FF8FAB;
    --accent-text: #3A1F26;
    --line: #0000001f;
    --overlay: #00000026;
    --radius: .75rem;
    --topbar-h: 3.5rem;
    --nav-h: 0rem; /* 아래 탭이 없음 */
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--default-font);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    -webkit-tap-highlight-color: transparent;
    transition: background-color .3s;
}
body.no-scroll { overflow: hidden; }

button, input, select, textarea {
    font: inherit;
    color: inherit;
}
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hide { display: none !important; }

/* y접힘 / x접힘 */
.collapse-y {
    max-height: 0 !important;
    overflow: hidden;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-width: 0 !important;
}
.collapse-x {
    max-width: 0 !important;
    overflow: hidden;
}

/* 스크롤 막대는 숨김 (막대 자리만큼 오른쪽이 비어 구분선이 끊겨 보였음). 스크롤 자체는 그대로 */
.scroll { scrollbar-width: none; }
.scroll::-webkit-scrollbar { width: 0; height: 0; }
.scroll::-webkit-scrollbar-thumb { background: transparent; border-radius: 1rem; }
.scroll:hover::-webkit-scrollbar-thumb { background: var(--overlay); }

/* ---------- 탑바 ---------- */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) .5rem 0 .75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg);
    box-shadow: inset 0 -100px 0 var(--overlay);
}
.logo-cover {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.35rem;
    font-weight: bold;
    min-width: 0;
}
.logo-img { width: 1.6rem; height: 1.6rem; border-radius: .35rem; }
.logo-text { white-space: nowrap; }
.right-position { display: flex; align-items: center; }

.top-bar-btn {
    position: relative;
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 50%;
    background: transparent;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.top-bar-btn:hover, .top-bar-btn.active { background-color: #0000002b; }
.top-bar-btn .badge {
    position: absolute;
    top: .3rem;
    right: .25rem;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 .25rem;
    border-radius: 1rem;
    background: var(--accent);
    color: var(--accent-text);
    font-size: .65rem;
    font-weight: bold;
    line-height: 1.05rem;
    font-family: system-ui, sans-serif;
}
.top-bar-btn .badge:empty { display: none; }

/* ---------- 버튼 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1rem;
    border-radius: .5rem;
    border: 1px solid var(--text);
    background: transparent;
    font-weight: bold;
    font-size: .9rem;
}
.btn:hover { filter: brightness(.92); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.danger { background: #E53935; color: #fff; border-color: transparent; }
.btn.danger-ghost { color: #E53935; border-color: #E53935; }
.btn.ghost { background: var(--surface); border-color: var(--line); }

.icon-btn {
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.icon-btn:hover { background: var(--overlay); }
.icon-btn.solid { background: var(--accent); color: var(--accent-text); }

/* ---------- 팝업 ---------- */
.popup-overlay {
    position: fixed;
    /* 키보드가 올라오면 보이는 높이만큼만 (ui.js fitToVisualViewport) */
    top: var(--vv-top, 0);
    left: 0;
    right: 0;
    height: var(--vv-h, 100%);
    z-index: 40;
    background: #00000055;
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.popup {
    width: 100%;
    max-width: 720px;
    height: 100%;
    max-height: 60rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 1px 1px 12px #0000006e;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: pop-in .2s ease;
}
@keyframes pop-in {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: none; opacity: 1; }
}
.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .5rem .5rem .5rem 1rem;
    min-height: 3.25rem;
    border-bottom: 1px solid var(--line);
}
.popup-header .title {
    font-size: 1.15rem;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.popup-header .actions { display: flex; }
.popup-header .fa-star.fas { color: #F9A825; }
.popup-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    overscroll-behavior: contain;
}

/* ---------- 메뉴 드로어 ---------- */
.menu-overlay {
    position: fixed;
    top: calc(var(--topbar-h) + env(safe-area-inset-top));
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    z-index: 30;
    display: flex;
    justify-content: flex-end;
    overflow: hidden;
    transition: visibility 0s;
}
/* 어두운 배경만 따로 서서히 (메뉴 판은 비치지 않게 항상 불투명) */
.menu-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: #00000040;
    transition: opacity .28s ease;
}
/* 닫힌 상태: 공용 .collapse-x(max-width: 0)를 쓰지 않고, 다 빠져나간 뒤에 숨김 */
.menu-overlay.collapse-x {
    max-width: 100vw !important;
    visibility: hidden;
    pointer-events: none;
    transition: visibility 0s .28s;
}
.menu-overlay.collapse-x::before { opacity: 0; }
.menu-screen {
    position: relative; /* 어두운 배경(::before) 위에 */
    width: min(22rem, 100vw);
    flex-shrink: 0;
    height: 100%;
    overflow-y: auto;
    padding: 1rem 1.1rem 2rem;
    background: var(--bg);
    box-shadow: -2px 0 10px var(--overlay);
    /* 오른쪽에서 미끄러져 들어오고, 같은 길로 나감 */
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    will-change: transform;
}
.menu-overlay.collapse-x .menu-screen { transform: translateX(100%); }
/* 기기의 '동작 줄이기' 설정과 상관없이 움직입니다. (사용자가 원한 효과인데 그 설정 때문에 꺼져 보였음)
   메뉴·선택창 모두 같은 방침 */
.menu-screen h3 { margin: 1.75rem 0 .25rem; }
.menu-screen > h3:first-child { margin-top: 0; } /* 메뉴 맨 위 제목만 (계정 칸처럼 묶음 안의 첫 제목은 그대로) */
.menu-screen > .notice-wrap:first-child > h3 { margin-top: 0; } /* 맨 위 공지 칸 */
.menu-screen > .notice-wrap[hidden]:first-child + h3 { margin-top: 0; } /* 공지 칸이 숨겨지면 그다음 제목이 맨 위 */
.config-caption { font-size: .85rem; color: var(--sub); margin-bottom: .5rem; }
.radio-group { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.radio-group label { display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
.radio-group input { accent-color: var(--accent); }
.menu-btn-group { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
/* 계정 (구글 로그인) */
.account-user { overflow-wrap: anywhere; }
.account-user i, .account-note i { opacity: .7; margin-right: .2rem; }
.account-note { font-size: .85rem; color: var(--sub); }
.account-withdraw { display: block; margin-top: .6rem; padding: .2rem 0; background: none; border: 0; font: inherit; font-size: .78rem; color: var(--sub); text-decoration: underline; cursor: pointer; }
.google-btn { min-height: 44px; margin-top: .25rem; }

/* ---------- 토스트 / 다이얼로그 ---------- */
.toast-zone {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .4rem;
    pointer-events: none;
}
.toast {
    padding: .6rem 1.1rem;
    border-radius: 2rem;
    background: var(--text);
    color: var(--surface);
    font-size: .9rem;
    box-shadow: 0 2px 10px #0004;
    animation: pop-in .2s ease;
    transition: opacity .4s;
    white-space: nowrap;
}
.toast.out { opacity: 0; }

.dialog-overlay {
    position: fixed;
    /* 입력 창(제목 고치기 등)이 키보드에 가리지 않게 보이는 높이만큼만 */
    top: var(--vv-top, 0);
    left: 0;
    right: 0;
    height: var(--vv-h, 100%);
    z-index: 70;
    background: #00000066;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.dialog {
    width: min(22rem, 100%);
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: 0 4px 20px #0005;
    animation: pop-in .15s ease;
}
.dialog-message { white-space: pre-line; margin-bottom: 1.25rem; }
.dialog-btns { display: flex; justify-content: flex-end; gap: .5rem; }

/* ---------- 전체 삭제 (메뉴 맨 아래) ---------- */
.danger-zone {
    margin-top: 2.5rem;
    padding-top: 1rem;
    border-top: 1px dashed #E5393566;
}
.danger-zone h3 { margin-top: 0; color: #E53935; }
.dialog-typed {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin: -.5rem 0 1.25rem;
    font-size: .88rem;
}
.dialog-typed b { color: #E53935; }
.dialog-typed input {
    padding: .55rem .65rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: var(--bg);
    outline: none;
}
.dialog-typed input:focus { border-color: #E53935; }
.btn:disabled { opacity: .35; cursor: not-allowed; filter: none; }

/* 메모 속 외부 링크 */
.ext-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
    word-break: break-all;
}
.ext-link::after {
    content: '\f35d'; /* fa-external-link-alt */
    display: inline-block; /* 밑줄이 아이콘까지 이어지지 않게 */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: .7em;
    margin-left: .3em;
    opacity: .6;
}
.dialog-message { overflow-wrap: anywhere; }

/* ---------- 아래에서 올라오는 선택창 ---------- */
.sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 65;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.sheet-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: #00000055;
    opacity: 0;
    transition: opacity .25s ease;
}
.sheet-overlay.open::before { opacity: 1; }
.sheet {
    position: relative;
    width: 100%;
    max-width: 30rem;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    padding: .5rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
    border-radius: 1.1rem 1.1rem 0 0;
    background: var(--surface);
    box-shadow: 0 -4px 20px #0003;
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    will-change: transform;
}
.sheet-overlay.open .sheet { transform: none; }
.sheet-handle { width: 2.5rem; height: .28rem; margin: 0 auto .6rem; border-radius: 1rem; background: var(--line); }
.sheet-title { font-weight: bold; margin-bottom: .75rem; }
.sheet-content { overflow-y: auto; }
.sheet-clear { display: block; margin: 1rem auto 0; }
/* ---------- 앱으로 설치 안내 ---------- */
.install-section .btn { margin-top: .25rem; }
.install-section .fa-check-circle { color: #43A047; }
/* 화면 아래 안내 한 줄 (화면 맨 아래) */
.install-banner {
    position: fixed;
    left: .75rem;
    right: .75rem;
    bottom: calc(var(--nav-h) + .6rem + env(safe-area-inset-bottom));
    z-index: 27;
    display: flex;
    align-items: center;
    gap: .6rem;
    max-width: 30rem;
    margin: 0 auto;
    padding: .55rem .4rem .55rem .7rem;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--line), 0 4px 16px #00000033;
    animation: install-banner-in .35s cubic-bezier(.2, .8, .2, 1);
}
@keyframes install-banner-in {
    from { transform: translateY(1.5rem); opacity: 0; }
    to { transform: none; opacity: 1; }
}
.install-banner-icon { width: 1.75rem; height: 1.75rem; border-radius: .4rem; flex-shrink: 0; }
.install-banner-text { flex: 1; min-width: 0; font-size: .85rem; line-height: 1.35; }
.install-banner .btn { padding: .4rem .75rem; font-size: .82rem; white-space: nowrap; flex-shrink: 0; }
/* 안내가 떠 있는 동안 알림은 그 위로 */
body.has-install-banner .toast-zone { bottom: calc(var(--nav-h) + 5rem + env(safe-area-inset-bottom)); }

.install-steps { margin: 0; padding-left: 1.4rem; display: flex; flex-direction: column; gap: .7rem; line-height: 1.6; }
.install-steps i, .share-icon { color: var(--accent); }
.share-icon { width: 1.25em; height: 1.25em; vertical-align: -.25em; }
.install-note { margin: 1rem 0 0; padding: .6rem .8rem; border-radius: .5rem; background: var(--bg); font-size: .82rem; }
.install-guide-btns { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.1rem; }

/* ---------- 공용 작은 것들 ---------- */
.text-btn {
    border: 0;
    background: transparent;
    padding: .25rem .4rem;
    font-size: .85rem;
    color: var(--sub);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.dialog-btns.wrap { flex-wrap: wrap; }
.dialog-btns.stack { flex-direction: column; align-items: stretch; }
.dialog-typed input { width: 100%; }
.dialog-typed input:focus { border-color: var(--accent); }
.empty-state {
    text-align: center;
    color: var(--sub);
    padding: 3.5rem 1rem;
}
.empty-state > i { font-size: 2.5rem; opacity: .5; }
.empty-state p { margin: .75rem 0 1.25rem; }
.empty-btns { display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; }

@media (max-width: 768px) {
    .popup-overlay { padding: 0; }
    .popup {
        max-width: none;
        max-height: none;
        border-radius: 0;
        padding-top: env(safe-area-inset-top);
    }
}

/* ---------- 검색 ---------- */
.search-banner {
    position: sticky;
    top: calc(var(--topbar-h) + env(safe-area-inset-top));
    z-index: 15;
    max-height: 5rem;
    background-color: var(--bg);
    box-shadow: inset 0 -100px 0 #00000014;
    transition: max-height .35s ease;
}
.search-inner {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: .5rem .75rem;
    padding: 0 .25rem 0 .75rem;
    border: 1px solid var(--text);
    border-radius: 2rem;
    background: var(--surface);
}
.search-inner > i { color: var(--sub); font-size: .9rem; }
#item-searcher {
    flex: 1;
    min-width: 0;
    border: 0;
    padding: .55rem 0;
    background: transparent;
    outline: none;
}
#item-searcher::-webkit-search-cancel-button { display: none; }
.search-deleter {
    border: 0;
    background: transparent;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
}

/* ---------- 목록 ---------- */
.main {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 .75rem calc(2rem + env(safe-area-inset-bottom));
}
/* 스크롤해도 위쪽 바(검색창이 열려 있으면 그 아래)에 붙어 있음 */
.type-tabs {
    position: sticky;
    top: calc(var(--topbar-h) + env(safe-area-inset-top) + var(--search-h, 0px));
    z-index: 10;
    display: flex;
    gap: .4rem;
    margin: 0 -.75rem;
    padding: .65rem .75rem;
    background: var(--bg);
}
.type-tabs button {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .4rem .8rem;
    border: 1px solid var(--line);
    border-radius: 2rem;
    background: var(--surface);
    font-size: .9rem;
    white-space: nowrap;
}
.type-tabs button[aria-selected="true"] {
    background: var(--accent);
    color: var(--accent-text);
    border-color: transparent;
    font-weight: bold;
}
.type-tabs .count { font-family: system-ui, sans-serif; font-size: .75rem; opacity: .7; }
.type-tabs .trash-tab { margin-left: auto; } /* 휴지통은 오른쪽 끝에 따로 */
/* 그래도 넘치면(숫자가 길 때 등) 옆으로 밀어서 보기 */
.type-tabs { overflow-x: auto; scrollbar-width: none; }
.type-tabs::-webkit-scrollbar { display: none; }
@media (max-width: 440px) { /* 탭 다섯 개가 좁은 폰에도 한 줄에 들어가게 */
    .type-tabs { gap: .3rem; }
    .type-tabs button { padding: .4rem .5rem; gap: .3rem; }
}

/* 휴지통 */
.trash-head { font-size: .82rem; color: var(--sub); }
.item-row.trashed .item-icon, .item-row.trashed .item-title { opacity: .55; }
.private-mark { font-size: .75em; opacity: .6; }

.item-list { display: flex; flex-direction: column; gap: .5rem; }
.item-row {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: 0 .75rem 0 0;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--line);
    cursor: pointer;
    overflow: hidden; /* 왼쪽 띠가 카드 모서리에 맞춰 잘리게 */
}
.item-row:hover { filter: brightness(.97); }
/* 왼쪽 끝에 붙어 위아래를 꽉 채우는 띠 (책은 표지, 메모는 아이콘) */
.item-icon {
    flex-shrink: 0;
    align-self: stretch;
    width: 3.1rem; /* 4.4rem 높이에서 1:1.43 */
    min-height: 4.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.item-body { flex: 1; min-width: 0; padding: .85rem 0; }
.item-title { font-weight: bold; overflow-wrap: anywhere; }
.item-title.clip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* 메모: 본문 첫 줄만, 넘치면 … */
.item-sub { font-size: .82rem; color: var(--sub); }
.item-sub.clip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-arrow { flex-shrink: 0; font-size: .75rem; opacity: .35; }

/* 선택창의 세로 선택지 */
.sheet-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 0; line-height: 1.5; padding-bottom: .1em; } /* 내용이 길어도 제목 줄이 눌려 글자 아래가 잘리지 않게 */
.sheet-options { display: flex; flex-direction: column; gap: .4rem; }
.sheet-option {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1rem;
    border: 0;
    border-radius: .75rem;
    background: var(--bg);
    text-align: left;
    font-size: 1rem;
}
.sheet-option i { width: 1.2rem; text-align: center; opacity: .75; }
.sheet-option.danger { color: #E53935; }

/* ---------- 메모 ---------- */
.memo-title { margin: 0 0 .75rem; font-size: 1.3rem; overflow-wrap: anywhere; }
.memo-content { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.memo-date { margin-top: 1.5rem; font-size: .78rem; color: var(--sub); text-align: right; }
.memo-editor { display: flex; flex-direction: column; gap: .6rem; }
.memo-title-input, .memo-content-input {
    width: 100%;
    padding: .6rem .7rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: transparent;
    outline: none;
}
.memo-title-input { font-weight: bold; font-size: 1.1rem; }
.memo-content-input { line-height: 1.7; resize: none; overflow: hidden; }
.memo-title-input:focus, .memo-content-input:focus { border-color: var(--accent); }
.editor-btns { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .4rem; }

/* ---------- 즐겨찾기 ---------- */
.fav-btn .fas.fa-star, .item-fav, .type-tabs .fa-star { color: #F9A825; }
.type-tabs button[aria-selected="true"] .fa-star { color: inherit; }
.item-fav { flex-shrink: 0; font-size: .85rem; }
/* 탭이 네 개라 좁은 화면에서 넘치면 옆으로 밀어서 봄 */
.type-tabs { overflow-x: auto; scrollbar-width: none; }
.type-tabs::-webkit-scrollbar { display: none; }
.type-tabs button { flex-shrink: 0; }
@media (max-width: 400px) {
    .popup-header .icon-btn { width: 2.05rem; }
}

/* ---------- 후원하기 (메뉴) ---------- */
/* 바깥 스크립트(위젯)를 쓰지 않고 Ko-fi 페이지로 가는 링크만 둡니다. */
.support-btn { background: #72A4F2; color: #fff; border-color: transparent; text-decoration: none; }
/* Ko-fi 공식 심볼 (img/kofi_symbol.png, Ko-fi 브랜드 자료에서 받은 것) */
.support-icon { height: 1.35em; width: auto; }

/* ---------- 책 ---------- */
.clip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.item-icon.book-cover { color: #fff; text-shadow: 0 1px 2px #0003; box-shadow: inset .25rem 0 0 #0002; font-size: 1.1rem; }
.item-sub i { font-size: .8em; opacity: .7; }
.popup-header .title i { margin-right: .25rem; opacity: .7; }

.book-head { display: flex; align-items: stretch; gap: .9rem; }
/* 책 표지 모양: 왼쪽에 책등 선 */
.book-spine {
    flex-shrink: 0;
    width: 4.2rem;
    min-height: 6rem; /* 1:1.43 */
    border-radius: .25rem .6rem .6rem .25rem;
    background: var(--cover);
    box-shadow: inset .45rem 0 0 #00000022, 0 2px 6px #0003;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: .45rem;
    color: #fff;
    font-size: 1.4rem;
    text-shadow: 0 1px 2px #0003;
}
.book-info { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.book-title { margin: 0 0 .25rem; font-size: 1.3rem; overflow-wrap: anywhere; }
.book-meta { font-size: .8rem; color: var(--sub); }
.book-btns { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.1rem 0 .5rem; }
.book-empty { margin: 0; padding: 1.5rem .25rem; color: var(--sub); }

.page-list { list-style: none; margin: .75rem 0 0; padding: 0; border-top: 2px solid var(--text); }
.page { display: flex; align-items: center; border-bottom: 1px dashed var(--line); }
.page-item {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .7rem .25rem;
    border: 0;
    background: transparent;
    text-align: left;
}
.page-no {
    flex-shrink: 0;
    min-width: 1.7rem;
    height: 1.7rem;
    padding: 0 .3rem;
    border-radius: 1rem;
    background: var(--bg);
    font-family: system-ui, sans-serif;
    font-size: .8rem;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.page-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* 본문 첫 줄 */

/* 장 구분선: ── 2장. 가을 ──── ⋯ */
.chapter-row { display: flex; align-items: center; gap: .6rem; padding: 1rem 0 .3rem .25rem; }
.chapter-row::after { content: ''; flex: 1; order: 1; height: 1px; background: var(--text); opacity: .35; }
.chapter-title { flex-shrink: 1; min-width: 0; font-weight: bold; font-size: .92rem; color: var(--text); overflow-wrap: anywhere; }
.chapter-row .icon-btn { order: 2; opacity: .5; font-size: .85rem; }
/* 읽기 화면: 장의 첫 쪽 본문 위에 장 제목 */
.chapter-head { margin: .25rem 0 1rem; font-size: 1.15rem; line-height: 1.4; overflow-wrap: anywhere; }
.page-mark { flex-shrink: 0; color: var(--accent); }
.page.marked .page-no { background: var(--accent); color: var(--accent-text); }
.page .icon-btn { opacity: .5; font-size: .85rem; }

/* 책 속의 메모: 위에 책으로 돌아가는 줄, 아래에 앞·뒤 쪽 */
.book-crumb {
    display: flex;
    align-items: center;
    gap: .45rem;
    width: 100%;
    margin-bottom: 1rem;
    padding: .5rem .75rem;
    border: 0;
    border-radius: .6rem;
    background: var(--bg);
    font-size: .88rem;
    text-align: left;
}
.book-crumb i { opacity: .7; font-size: .85em; }
.crumb-no { margin-left: auto; flex-shrink: 0; font-family: system-ui, sans-serif; font-size: .78rem; color: var(--sub); }
.page-nav { display: flex; justify-content: space-between; gap: .5rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
.editor-book { font-size: .85rem; color: var(--sub); }
.sheet-option .clip { flex: 1; }
.sheet-options { max-height: 55vh; overflow-y: auto; }

/* 책 정보 (선택창 안) */
.info-list { margin: 0; display: flex; flex-direction: column; }
.info-list > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: .7rem .1rem;
    border-bottom: 1px dashed var(--line);
}
.info-list > div:last-child { border-bottom: 0; }
.info-list dt { color: var(--sub); font-size: .9rem; }
.info-list dt i { width: 1.2rem; text-align: center; opacity: .75; }
.info-list dd { margin: 0; font-weight: bold; text-align: right; white-space: nowrap; }

/* ---------- 책 완결 / 연재 중지 ---------- */
/* 완료: 테마와 상관없이 환한 금빛 */
.item-row.book[data-status="done"] {
    background: linear-gradient(135deg, #FFFDE7, #FFE082);
    color: #3E2F00;
    box-shadow: 0 0 0 1px #FFC10799, 0 2px 10px #FFC10744;
}
.item-row.book[data-status="done"] .item-icon { background: #FFB300; color: #3E2F00; }
.item-row.book[data-status="done"] .item-sub { color: #7A5F00; }
/* 중단: 조금 어둡게, 꺼진 것처럼 */
.item-row.book[data-status="stopped"] {
    background: var(--overlay);
    box-shadow: 0 0 0 1px var(--line);
    opacity: .6;
    filter: grayscale(1);
}
.item-row.book[data-status="stopped"] .item-icon { background: var(--sub); color: var(--surface); }
.item-row.book[data-status="stopped"] .item-title { text-decoration: line-through; text-decoration-color: var(--sub); }

.status-banner {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .7rem .9rem;
    border-radius: var(--radius);
    font-weight: bold;
}
[data-status="done"] > .status-banner { background: linear-gradient(135deg, #FFFDE7, #FFE082); color: #3E2F00; box-shadow: 0 0 0 1px #FFC10799; }
[data-status="stopped"] > .status-banner { background: var(--overlay); color: var(--sub); }
/* 연재를 멈춘 책은 안쪽도 한 톤 가라앉힘 (고치는 것은 그대로 가능) */
[data-status="stopped"] > .book-head, [data-status="stopped"] > .page-list { opacity: .6; filter: grayscale(1); }

.status-actions { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.status-btn {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    padding: .75rem 1rem;
    border: 1px solid var(--line);
    border-radius: .75rem;
    background: var(--bg);
    text-align: left;
}
.status-btn b i { width: 1.2rem; text-align: center; }
.status-btn span { font-size: .8rem; color: var(--sub); padding-left: 1.5rem; }
.status-btn.done { background: linear-gradient(135deg, #FFFDE7, #FFE082); border-color: #FFC10799; color: #3E2F00; }
.status-btn.done span { color: #7A5F00; }
.status-btn.stopped { background: transparent; color: var(--sub); }

.confetti-layer {
    position: fixed;
    left: 50%;
    top: 40%;
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: 80;
}
.confetti {
    position: absolute;
    width: .55rem;
    height: .8rem;
    border-radius: 2px;
    opacity: 0;
    animation: confetti-fly var(--d) cubic-bezier(.15, .7, .3, 1) forwards;
}
@keyframes confetti-fly {
    0% { transform: translate(0, 0) rotate(0) scale(.4); opacity: 1; }
    75% { opacity: 1; }
    100% { transform: translate(var(--x), calc(var(--y) + 140px)) rotate(var(--r)) scale(1); opacity: 0; }
}

.status-banner { margin-bottom: 1rem; }
/* 완결한 책: 표지 아이콘은 금빛 위에서도 보이게 그대로 둠 */
.item-row.book[data-status="done"] .item-icon.book-cover { color: #fff; }
.item-row.book[data-status="stopped"] .item-icon.book-cover { background-color: var(--sub) !important; }
.item-row.book[data-status="stopped"] .has-cover { filter: grayscale(1); }
/* 표지 사진 */
.has-cover { background-size: cover; background-position: center; background-color: var(--line); }

.book-spine.has-cover { padding: 0; }

/* ---------- 아이폰: 입력칸을 눌러도 화면이 확대되지 않게 ---------- */
/* 아이폰(Safari)은 글자가 16px보다 작은 입력칸에 커서를 두면 화면을 확대합니다.
   아이폰에서만 입력칸 글자를 16px로 맞춰 확대를 막습니다. (다른 기기는 그대로) */
@supports (-webkit-touch-callout: none) {
    input:not([type="radio"]):not([type="checkbox"]):not([type="file"]), textarea, select { font-size: 16px !important; }
}

/* 쪽 정렬 (책 상세의 버튼 줄 오른쪽 끝) */
.page-sort { margin-left: auto; align-self: center; text-decoration: none; white-space: nowrap; }
.page-sort i { font-size: 1.05em; margin-right: .15rem; }

/* 임시 저장 상태 (편집 화면의 버튼 줄 왼쪽) */
/* 팝업 위쪽 고정 줄의 닫기 버튼 왼쪽 */
.draft-status { font-size: .74rem; color: var(--sub); white-space: nowrap; padding-right: .25rem; }
.popup-header:has(.draft-status) .title { flex-shrink: 0; }
.popup-header:has(.draft-status) .right-position { min-width: 0; }
.popup-header:has(.draft-status) .actions { min-width: 0; overflow: hidden; }
.editor-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 0; }
.editor-top:has(.draft-load) { min-height: 1.6rem; }
.draft-load-zone { margin-left: auto; }
.draft-load { color: var(--text); text-decoration-color: var(--accent); text-decoration-thickness: 2px; padding: 0; }
/* 아주 좁은 화면: 임시 저장 상태를 두 줄로 */
@media (max-width: 350px) {
    .draft-status { display: block; max-width: 8.2rem; white-space: normal; text-align: right; line-height: 1.25; font-size: .7rem; word-break: keep-all; }
}

/* 잠근 책 표시 */
.book-lock { font-size: .7em; opacity: .55; margin-left: .15rem; vertical-align: .05em; }

/* 편집 화면: 내용 칸 아래의 글자 수·크기 */
.memo-count { margin-top: -.25rem; font-family: system-ui, sans-serif; font-size: .74rem; color: var(--sub); text-align: right; }

/* 메모 조회: 제목 오른쪽의 '본문 복사' */
.memo-head { display: flex; align-items: flex-start; justify-content: flex-end; gap: .75rem; margin-bottom: .75rem; }
.memo-head:empty { display: none; }
.memo-head .memo-title { margin: 0; min-width: 0; }
.memo-copy { flex-shrink: 0; white-space: nowrap; margin-top: .3rem; padding: .1rem 0; text-decoration: none; }
.memo-copy i { margin-right: .1rem; }

/* 쪽 넘기기 줄: 글이 길어도 화면 아래에 붙어 있음 (글이 짧으면 팝업 맨 아래) */
.memo-view { min-height: 100%; display: flex; flex-direction: column; }
.memo-view .page-nav {
    position: sticky;
    bottom: 0;
    z-index: 2;
    align-items: center;
    /* 팝업 안쪽 여백(1rem)을 지나 양옆까지 채움. 바닥 여백은 아래 :has 규칙으로 없앰 */
    margin: auto -1rem 0;
    padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--surface);
}
/* 쪽 넘기기 줄이 있는 화면은 팝업의 바닥 여백을 없애 줄이 바닥에 딱 붙게 */
.popup-content:has(.memo-view .page-nav) { padding-bottom: 0; }
.memo-view .memo-date { margin-bottom: 1.25rem; }
.page-nav-no { font-family: system-ui, sans-serif; font-size: .78rem; color: var(--sub); }

/* ---------- 읽기 화면: 읽는 동안 위·아래 줄 숨기기 ---------- */
/* 위쪽 줄을 글 위에 겹쳐 띄워서, 숨기고 보일 때 글이 들썩이지 않게 함 */
.popup[data-variant="reader"], .popup[data-variant="editor"] { position: relative; }
.popup[data-variant="reader"] .popup-header, .popup[data-variant="editor"] .popup-header {
    position: absolute;
    top: env(safe-area-inset-top);
    left: 0;
    right: 0;
    z-index: 3;
    background: var(--surface);
    transition: transform .25s ease;
}
.popup[data-variant="reader"] .popup-content { padding-top: calc(var(--header-h, 3.35rem) + 1rem); }
.popup[data-variant="reader"].immersive .popup-header, .popup[data-variant="editor"].immersive .popup-header { transform: translateY(calc(-100% - env(safe-area-inset-top))); }
.popup[data-variant="reader"] .page-nav { transition: transform .25s ease; }
/* 읽는 동안 쪽 넘기기 줄은 내려가도, 위쪽 가장자리의 읽은 만큼 막대(3px)는 화면 아래에 남김 */
.popup[data-variant="reader"].immersive .page-nav { transform: translateY(calc(100% - 3px)); }
/* 낱장 메모: 쪽 넘기기 줄이 없으니 막대만 화면 맨 아래에 */
.memo-view .solo-progress { position: sticky; bottom: 0; z-index: 2; margin: auto -1rem 0; height: calc(3px + env(safe-area-inset-bottom)); }
.memo-view .solo-progress .read-progress { top: 0; }
.popup-content:has(.memo-view .solo-progress) { padding-bottom: 0; }
.read-progress { position: absolute; left: 0; right: 0; top: -1px; height: 3px; pointer-events: none; }
.read-progress i { display: block; height: 100%; background: var(--accent); transform: scaleX(var(--p, 0)); transform-origin: left; transition: transform .1s linear; }

/* ---------- 편집 화면: 위쪽 줄의 저장 버튼 ---------- */
.header-save, .header-cancel { padding: .35rem .75rem; font-size: .85rem; flex-shrink: 0; }
/* 편집 화면은 취소 버튼이 있으니 ✕는 숨김 (뒤로가기는 그대로 동작) */
.popup-header:has(.header-save) .close { display: none; }
.popup-header:has(.header-save) { padding-right: .75rem; }
.popup-header:has(.header-save) .actions { align-items: center; gap: .4rem; overflow: visible; }
.popup-header:has(.header-save) .draft-status { white-space: normal; word-break: keep-all; text-align: right; line-height: 1.25; max-width: 9.5rem; overflow: hidden; }

/* ---------- 편집 화면: 상자 없이 글 위에 바로 쓰는 모양 ---------- */
.popup[data-variant="editor"] .popup-content { padding-top: var(--header-h, 3.35rem); } /* 위쪽 줄의 실제 높이 (init.js에서 잼) */
.popup[data-variant="editor"] .memo-editor { gap: .35rem; }
/* 책 이름·불러오기 링크·제목: 위쪽 줄 바로 아래에 붙어 있다가, 아래로 써 내려가면 위쪽 줄과 함께 숨음 */
.popup[data-variant="editor"] .editor-head {
    position: sticky;
    top: 0; /* 팝업 안쪽 여백(=위쪽 줄 높이) 바로 아래에 붙음 */
    z-index: 2;
    margin: 0 -1rem;
    padding: .6rem 1rem .3rem;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    transition: transform .25s ease;
}
.popup[data-variant="editor"].immersive .editor-head { transform: translateY(calc(-100% - var(--header-h, 3.35rem) - env(safe-area-inset-top))); }
.popup[data-variant="editor"] .memo-title-input,
.popup[data-variant="editor"] .memo-content-input { border: 0; border-radius: 0; background: transparent; }
.popup[data-variant="editor"] .memo-title-input { padding: .3rem 0; font-size: 16.5px; font-weight: 600; }
.popup[data-variant="editor"] .memo-content-input { padding: .5rem 0 0; }

/* 편집 화면: 본문 칸이 화면 아래 끝까지 (글이 짧아도 빈 곳을 누르면 바로 이어 쓰기) */
.popup[data-variant="editor"] .memo-editor { min-height: 100%; }
.popup[data-variant="editor"] .memo-content-input { flex: 1 0 auto; }
/* 글자 수·크기는 제목 위 줄 오른쪽에 (책 이름 왼쪽, 불러오기 링크는 그 아래 줄) */
.popup[data-variant="editor"] .editor-top { flex-wrap: wrap; min-height: 1.3rem; }
.popup[data-variant="editor"] .memo-count { margin: 0 0 0 auto; text-align: right; white-space: nowrap; }
.popup[data-variant="editor"] .draft-load-zone { flex-basis: 100%; text-align: right; }
.popup[data-variant="editor"] .draft-load-zone:empty { display: none; }

/* 읽기 화면의 글 제목: 크게 띄우지 않고 본문 크기로 (편집 화면의 제목과 같은 크기) */
.memo-view .memo-title { font-size: 16.5px; font-weight: 600; line-height: 1.5; }
.memo-view .memo-head { margin-bottom: .6rem; align-items: center; }
.memo-view .memo-copy { margin-top: 0; }

/* 위쪽 줄의 제목(글 제목·책 제목·편집 화면 이름): 옆 아이콘 버튼과 비슷한 크기로 */
.popup-header .title { font-size: 1rem; }

/* 클라우드 백업 목록: 날짜 아래 작은 글씨 */
.sheet-option small.sub { color: var(--sub); font-size: .78rem; }

/* 메뉴의 저자명 */
.epub-author-name { font-weight: bold; overflow-wrap: anywhere; }
.epub-author-name.empty { font-weight: normal; color: var(--sub); font-size: .9rem; }

/* 메뉴의 개인정보처리방침·이용약관: 반투명 회색 알약 단추 + 화살표 */
.policy-links { display: flex; flex-wrap: wrap; gap: .4rem; margin: .1rem 0 .6rem; }
.policy-link {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .55rem .3rem .8rem;
    border-radius: 2rem;
    background: #8080802b; /* 중간 회색 반투명: 밝은 테마·어두운 테마 둘 다 보임 */
    box-shadow: 0 1px 3px #00000026, inset 0 0 0 1px #8080801f;
    color: var(--sub);
    font-size: .8rem;
    text-decoration: none;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.policy-link i { font-size: .65rem; opacity: .7; }
.policy-link:hover, .policy-link:active { background: #80808045; color: var(--text); }

/* 로그인 버튼 아래 약관 동의 안내 */
.login-agree { margin-top: .4rem; font-size: .75rem; color: var(--sub); line-height: 1.5; }
.login-agree a { color: inherit; }

/* 공지 (메뉴 맨 위) */
.menu-dot { position: absolute; top: .55rem; right: .55rem; width: .5rem; height: .5rem; border-radius: 50%; background: #E53935; box-shadow: 0 0 0 2px var(--bg); }
.notice-list { display: flex; flex-direction: column; gap: .4rem; margin-top: .4rem; }
.notice { border-radius: .7rem; background: #8080801a; padding: .55rem .75rem; }
.notice summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .4rem; font-size: .88rem; }
.notice summary::-webkit-details-marker { display: none; }
.notice-title { font-weight: 600; }
.notice-date { margin-left: auto; font-size: .75rem; color: var(--sub); white-space: nowrap; }
.notice-new { flex-shrink: 0; align-self: center; width: .45rem; height: .45rem; border-radius: 50%; background: #E53935; }
.notice-body { margin-top: .35rem; font-size: .82rem; color: var(--sub); line-height: 1.6; }
.notice-body p, .notice-body ul { margin: .25rem 0; }
.notice-body ul { padding-left: 1.1rem; }
.notice-body a { color: var(--text); }

/* ---------- 미니 창 (PC 크롬·엣지에서 다른 창 위에 떠 있는 세 줄짜리 글쓰기 창, js/mini.js) ---------- */
.header-mini { flex-shrink: 0; }
.mini-body { min-height: 100vh; display: flex; align-items: center; padding: 8px; overflow: hidden; }
.mini-box { flex: 1; min-width: 0; padding: .45rem .9rem; border: 1px solid var(--line); border-radius: 1.1rem; background: var(--surface); }
.mini-box:focus-within { border-color: var(--accent); }
.mini-input {
    display: block;
    width: 100%;
    height: calc(1.7em * 3); /* 딱 세 줄 */
    padding: 0;
    border: 0;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    line-height: 1.7;
    overflow-y: auto;
    scrollbar-width: none;
}
.mini-input::-webkit-scrollbar { display: none; }
