
:root {
      --ink: #273247;
      --muted: #78839a;
      --soft: #f4f7fb;
      --line: #dde4ef;
      --blue: #7e9ed2;
      --blue-deep: #5c7fb8;
      --coral: #f19a88;
      --yellow: #f7d98c;
      --mint: #a7d9c7;
      --lilac: #c6b8e8;
      --paper: #fffdf7;
      --shadow: 0 24px 60px rgba(47, 65, 96, .13);
      --cute-font: "ZCOOL KuaiLe", "YouYuan", "幼圆", "PingFang SC", sans-serif;
      --hand-font: "ZCOOL XiaoWei", "ZCOOL KuaiLe", "YouYuan", "幼圆", sans-serif;
    }

    * { box-sizing: border-box; }
    body {
      margin: 0;
      min-width: 320px;
      color: var(--ink);
      font-family: var(--cute-font);
      background:
        radial-gradient(circle at 12% 12%, rgba(255,255,255,.9) 0 2px, transparent 3px),
        radial-gradient(circle at 80% 28%, rgba(255,255,255,.7) 0 1px, transparent 2px),
        #edf2f8;
      background-size: 48px 48px, 70px 70px, auto;
    }

    button, input, textarea { font: inherit; }
    button { border: 0; cursor: pointer; color: inherit; }
    .app { max-width: 1440px; min-height: 100vh; margin: 0 auto; padding: 24px 30px 44px; }

    .topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
    .brand { display: flex; align-items: center; gap: 12px; }
    .brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--blue-deep); color: white; font-size: 23px; box-shadow: 0 9px 18px rgba(92,127,184,.25); transform: rotate(-4deg); }
    .brand h1 { margin: 0; font-size: 19px; letter-spacing: .04em; font-family: var(--hand-font); }
    .brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
    .top-actions { display: flex; align-items: center; gap: 10px; }
    .date-pill { color: var(--muted); font-size: 13px; background: rgba(255,255,255,.65); border: 1px solid rgba(255,255,255,.9); border-radius: 999px; padding: 8px 13px; }
    .today-btn { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 13px; box-shadow: 0 7px 14px rgba(39,50,71,.18); transition: transform .2s, background .2s; }
    .today-btn:hover { transform: translateY(-1px); background: #36445e; }

    .workspace { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }
    .sidebar { display: grid; gap: 15px; }
    .panel { background: rgba(255,255,255,.79); border: 1px solid rgba(255,255,255,.9); border-radius: 16px; padding: 18px; box-shadow: 0 10px 30px rgba(64,83,115,.06); backdrop-filter: blur(8px); }
    .calendar-panel { background: #fff7fb; border-color: #f3cfdf; box-shadow: 0 12px 28px rgba(210,121,160,.11); }
    .mood-panel { background: #f1fbf8; border-color: #c6e9dc; box-shadow: 0 12px 28px rgba(82,171,143,.1); }
    .recent-panel { background: #f8f3ff; border-color: #dfd2f3; box-shadow: 0 12px 28px rgba(137,103,190,.1); }
    .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 15px; }
    .panel-heading h2 { margin: 0; font-size: 14px; letter-spacing: .04em; }
    .panel-heading span { color: var(--muted); font-size: 11px; }
    .month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
    .month-nav strong { font-size: 16px; }
    .nav-btn { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: #eef3fb; color: var(--blue-deep); font-size: 17px; transition: background .2s, transform .2s; }
    .nav-btn:hover { background: #e1eaf8; transform: translateY(-1px); }
    .calendar-week, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
    .calendar-week { margin-bottom: 6px; color: #a0a9b9; font-size: 10px; text-align: center; }
    .day-cell { min-width: 0; aspect-ratio: 1; position: relative; display: grid; place-items: center; border-radius: 9px; background: transparent; color: #5c677b; font-size: 12px; transition: background .2s, color .2s; }
    .day-cell:hover { background: #edf3fb; }
    .day-cell.muted { color: #c4cad4; }
    .day-cell.selected { background: var(--blue-deep); color: #fff; box-shadow: 0 5px 11px rgba(92,127,184,.26); }
    .day-cell.today:not(.selected) { color: var(--coral); font-weight: 700; }
    .day-cell.has-entry::after { content: ""; position: absolute; bottom: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--mood-color, var(--coral)); box-shadow: 0 0 0 2px rgba(255,255,255,.55); }
    .day-cell.selected.has-entry::after { background: var(--mood-color, #fff); box-shadow: 0 0 0 2px rgba(255,255,255,.8); }
    .mood-strip { display: flex; align-items: end; justify-content: space-between; height: 112px; padding: 11px 2px 5px; border-bottom: 1px dashed var(--line); }
    .mood-bar { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: end; gap: 6px; height: 100%; }
    .mood-bar i { width: 20px; max-height: 75px; min-height: 8px; border-radius: 8px 8px 4px 4px; background: var(--bar-color); opacity: .87; }
    .mood-bar small { color: var(--muted); font-family: var(--hand-font); font-size: 11px; white-space: nowrap; }
    .mood-legend { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px 4px; margin-top: 10px; color: var(--muted); font-size: 10px; }
    .mood-legend span { display: flex; align-items: center; gap: 4px; }
    .mood-legend b { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: var(--dot); }
    .recent-list { display: grid; gap: 9px; }
    .recent-item { display: grid; grid-template-columns: 35px minmax(0, 1fr); gap: 9px; align-items: center; padding: 7px 8px; border-radius: 10px; background: #fbfcfe; cursor: pointer; transition: background .2s, transform .2s; }
    .recent-item:hover { background: #f0f5fd; transform: translateX(2px); }
    .recent-date { text-align: center; color: var(--blue-deep); font-size: 11px; line-height: 1.15; font-weight: 700; }
    .recent-date em { display: block; color: #9fa9bb; font-size: 9px; font-style: normal; font-weight: 400; }
    .recent-copy { min-width: 0; }
    .recent-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
    .recent-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; color: var(--muted); font-size: 10px; }

    .book-stage { min-width: 0; padding: 10px 0 14px; }
    .book-wrap { position: relative; padding: 20px 18px 22px; border-radius: 22px; background: #d5e0ee; box-shadow: var(--shadow); }
    .book-wrap::before, .book-wrap::after { content: ""; position: absolute; left: 17px; right: 17px; height: 9px; border-radius: 50%; background: #c1cede; z-index: 0; }
    .book-wrap::before { top: 8px; }
    .book-wrap::after { bottom: 9px; }
    .book { position: relative; z-index: 1; display: grid; grid-template-columns: 42% 58%; min-height: 610px; overflow: hidden; border-radius: 12px; background: var(--paper); box-shadow: 0 4px 0 #bcc9d8; perspective: 1800px; }
    .page { position: relative; min-width: 0; overflow: hidden; background-color: var(--paper); }
    .page::after { content: ""; pointer-events: none; position: absolute; inset: 0; opacity: .42; background-image: radial-gradient(rgba(156,139,111,.11) .7px, transparent .8px); background-size: 5px 5px; mix-blend-mode: multiply; }
    .page-left { padding: 34px 31px 30px; border-right: 1px solid #ece7dc; background: #fffcf4; }
    .page-right { padding: 34px 39px 30px 38px; transform-origin: left center; transform-style: preserve-3d; backface-visibility: hidden; z-index: 2; }
    .page-inner { position: relative; z-index: 1; height: 100%; }
    .hole-punches { position: absolute; z-index: 2; top: 42px; bottom: 33px; display: flex; flex-direction: column; justify-content: space-between; }
    .page-left .hole-punches { left: 9px; }
    .page-right .hole-punches { right: 9px; }
    .hole-punches i { width: 7px; height: 7px; border-radius: 50%; background: #d2dce9; box-shadow: inset 0 1px 2px rgba(38,53,77,.18); }
    .page-kicker { display: flex; align-items: center; gap: 7px; color: var(--coral); font-size: 11px; letter-spacing: .12em; }
    .page-kicker::before { content: ""; width: 22px; height: 1px; background: var(--coral); }
    .page-left h2 { margin: 20px 0 5px; font-family: var(--hand-font); font-size: clamp(46px, 6vw, 72px); line-height: .95; letter-spacing: .02em; color: var(--ink); }
    .page-left h2 small { display: block; margin-top: 10px; color: var(--muted); font-family: var(--cute-font); font-size: 13px; letter-spacing: .08em; }
    .date-ribbon { display: inline-flex; align-items: center; gap: 8px; margin: 23px 0 26px; padding: 7px 11px; color: #59677e; border: 1px solid #dbe3ee; border-radius: 7px; background: #f8fbff; font-size: 11px; }
    .date-ribbon b { color: var(--blue-deep); font-size: 17px; }
    .polaroid { position: relative; width: 100%; max-width: 214px; margin: 0 auto; padding: 8px 8px 24px; background: #fff; box-shadow: 0 7px 16px rgba(97,82,65,.12); transform: rotate(-3deg); }
    .polaroid .photo { height: 150px; display: grid; place-items: center; overflow: hidden; border-radius: 7px; background: #d7ebf0; transition: background .35s ease; }
    .polaroid .photo img { width: 100%; height: 100%; display: block; object-fit: cover; }
    .polaroid figcaption { position: absolute; left: 12px; right: 12px; bottom: 5px; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; color: #8e8476; font-family: var(--hand-font); font-size: 13px; line-height: 1.15; }
    .polaroid figcaption small { color: #a69b8b; font-family: var(--cute-font); font-size: 9px; letter-spacing: .02em; }
    .tape { position: absolute; top: -11px; left: 33%; width: 74px; height: 22px; background: rgba(247,217,140,.7); transform: rotate(4deg); }
    .left-note { margin-top: 43px; color: #74819a; font-family: var(--hand-font); font-size: 17px; line-height: 1.8; text-align: center; }

    .entry-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
    .entry-meta { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
    .mood-emoji { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; background: #edf3fb; font-family: var(--cute-font); font-size: 24px; font-weight: 400; }
    .entry-status { padding: 5px 8px; border-radius: 6px; background: #edf7f2; color: #4f9a7c; font-size: 10px; }
    .entry-title { width: 100%; border: 0; outline: none; padding: 2px 0 11px; border-bottom: 1px solid #e9e0d2; color: var(--ink); background: transparent; font-family: var(--hand-font); font-size: clamp(24px, 3vw, 31px); }
    .entry-title::placeholder { color: #b9b1a5; }
    .rule-paper { min-height: 302px; margin-top: 17px; background: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, #e8edf2 32px); }
    .entry-content { width: 100%; min-height: 302px; resize: none; border: 0; outline: none; padding: 1px 2px 0 0; color: #4d5b71; background: transparent; font-family: var(--hand-font); font-size: 19px; line-height: 32px; }
    .entry-content::placeholder { color: #c8c2b7; }
    .entry-foot { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding-top: 12px; border-top: 1px dashed #e8e0d4; background: transparent; }
    .tool-group { display: flex; align-items: center; gap: 9px; }
    .tool-label { color: #9d968b; font-size: 10px; }
    .color-dot { width: 23px; height: 23px; border: 2px solid transparent; border-radius: 50%; background: var(--dot); box-shadow: inset 0 0 0 1px rgba(255,255,255,.55); transition: transform .2s, border-color .2s; }
    .color-dot:hover, .color-dot.active { border-color: #5e6a7f; transform: scale(1.12); }
    .save-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 15px; border: 2px solid #f6b3ce; border-radius: 12px; color: #fff; background: #e979aa; font-size: 12px; box-shadow: 0 8px 16px rgba(220,103,157,.25); transition: transform .2s, background .2s, box-shadow .2s; }
    .save-btn:hover { transform: translateY(-2px) rotate(-1deg); background: #db6397; box-shadow: 0 11px 20px rgba(220,103,157,.3); animation: saveWiggle .45s ease; }
    .save-btn.saved { border-color: #a9e1ca; background: #68b99a; box-shadow: 0 8px 16px rgba(73,164,126,.23); animation: savePop .45s ease; }
    @keyframes saveWiggle { 0%,100% { transform: translateY(-2px) rotate(-1deg); } 50% { transform: translateY(-2px) rotate(2deg); } }
    @keyframes savePop { 0% { transform: scale(.94) rotate(-2deg); } 65% { transform: scale(1.06) rotate(1deg); } 100% { transform: scale(1) rotate(0); } }

    .book-caption { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 13px 7px 0; color: #8c99ad; font-size: 11px; }
    .book-caption span { display: inline-flex; align-items: center; gap: 7px; }
    .book-caption b { color: var(--blue-deep); font-size: 14px; }
    .page-switch { display: inline-flex; gap: 6px; }
    .page-switch button { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 7px; background: rgba(255,255,255,.75); color: var(--blue-deep); }

    .mood-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-top: 6px; }
    .mood-option { display: grid; justify-items: center; gap: 4px; padding: 7px 2px; border-radius: 9px; background: #fbfcfe; color: #8d96a7; font-size: 10px; transition: transform .2s, background .2s, color .2s; }
    .mood-option span { font-family: var(--cute-font); font-size: 23px; font-weight: 400; line-height: 1; }
    .mood-option:hover { transform: translateY(-2px); }
    .mood-option.active { color: var(--ink); background: #fff5dd; box-shadow: inset 0 0 0 1px #f3dfaa; }
    .mood-option[data-mood="开心"].active { background: #fff5dd; }
    .mood-option[data-mood="平静"].active { background: #eaf6f2; }
    .mood-option[data-mood="难过"].active { background: #edf2fb; }
    .mood-option[data-mood="疲惫"].active { background: #f3effb; }
    .mood-option[data-mood="生气"].active { background: #fff0ed; }

    @media (max-width: 1040px) {
      .app { padding: 20px 20px 36px; }
      .workspace { grid-template-columns: 235px minmax(0, 1fr); gap: 17px; }
      .page-left { padding-left: 26px; padding-right: 26px; }
      .page-right { padding-left: 30px; padding-right: 30px; }
      .polaroid .photo { height: 125px; }
      .book { min-height: 570px; }
    }
    @media (max-width: 760px) {
      .app { padding: 15px 12px 26px; }
      .topbar { align-items: flex-start; margin-bottom: 16px; }
      .date-pill { display: none; }
      .workspace { display: flex; flex-direction: column; gap: 15px; }
      .sidebar { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
      .sidebar .panel:last-child { grid-column: 1 / -1; }
      .sidebar .panel { padding: 14px; }
      .calendar-week { margin-bottom: 4px; }
      .mood-strip { height: 105px; }
      .recent-list { grid-template-columns: repeat(3, 1fr); }
      .book-stage { width: 100%; padding-top: 0; }
      .book-wrap { padding: 12px 10px 15px; border-radius: 16px; }
      .book { display: block; min-height: 620px; }
      .page-left { display: none; }
      .page-right { min-height: 620px; padding: 27px 25px 25px 28px; }
      .page-right .hole-punches { right: 5px; top: 32px; bottom: 29px; }
      .entry-content, .rule-paper { min-height: 360px; }
      .entry-foot { position: static; margin-top: 13px; }
      .book-caption { margin-left: 2px; margin-right: 2px; }
    }
    @media (max-width: 470px) {
      .topbar { gap: 8px; }
      .brand h1 { font-size: 17px; }
      .brand p { font-size: 11px; }
      .today-btn { padding: 9px 10px; font-size: 12px; }
      .sidebar { grid-template-columns: 1fr; }
      .sidebar .panel:last-child { grid-column: auto; }
      .recent-list { grid-template-columns: 1fr; }
      .recent-item { padding: 7px 9px; }
      .page-right { min-height: 650px; padding: 24px 21px 22px 22px; }
      .entry-head { margin-bottom: 15px; }
      .entry-title { font-size: 25px; }
      .entry-content { font-size: 16px; }
      .tool-group { gap: 6px; }
      .save-btn { width: 100%; justify-content: center; }
      .entry-foot { gap: 11px; }
    }

@font-face { font-family: 'ZCOOL KuaiLe Local'; src: url('../assets/fonts/ZCOOLKuaiLe-Regular.woff2') format('woff2'); font-display: swap; font-weight: 400; }
@font-face { font-family: 'ZCOOL XiaoWei Local'; src: url('../assets/fonts/ZCOOLXiaoWei-Regular.woff2') format('woff2'); font-display: swap; font-weight: 400; }
:root { --cute-font: 'ZCOOL KuaiLe Local', 'ZCOOL KuaiLe', 'YouYuan', '幼圆', 'PingFang SC', sans-serif; --hand-font: 'ZCOOL XiaoWei Local', 'ZCOOL XiaoWei', 'ZCOOL KuaiLe Local', 'YouYuan', '幼圆', sans-serif; }
html { color-scheme: light; }
body { min-height: 100vh; min-width: 0; }
button, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(92,127,184,.35); outline-offset: 2px; }
.storage-alert { margin: 0 0 16px; padding: 10px 13px; border: 1px solid #e9b8ad; border-radius: 10px; color: #8f5146; background: #fff3ef; font-size: 12px; line-height: 1.55; }
.storage-alert[hidden] { display: none; }
html[data-theme="night"] .storage-alert { border-color: #7a544f; color: #f0c1b8; background: #463136; }
.privacy-note { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 18px; color: #8c99ad; font-size: 12px; line-height: 1.6; text-align: center; }
.privacy-note #syncStatus[data-state="online"] { color: #4b9a7a; }
.privacy-note #syncStatus[data-state="offline"] { color: #b98035; }
.privacy-note #syncStatus[data-state="conflict"], .privacy-note #syncStatus[data-state="error"] { color: #a9544b; }
.sync-conflict-notice { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 14px auto 24px; padding: 12px 16px; width: min(760px, calc(100% - 24px)); border: 1px solid #e5c892; border-radius: 10px; background: #fff5df; color: #845b20; font-size: 13px; }
.sync-conflict-notice[hidden] { display: none; }
.sync-conflict-notice button { min-height: 40px; padding: 8px 14px; border-radius: 8px; background: #fff; color: #7c5520; white-space: nowrap; }
.conflict-dialog { width: min(850px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 0; border: 1px solid #dbe3ee; border-radius: 16px; color: #273247; background: #fffdf8; box-shadow: 0 25px 70px rgba(38,50,71,.24); }
.conflict-dialog::backdrop { background: rgba(35,48,70,.38); }
.conflict-hint { margin: 14px 20px; font-size: 13px; line-height: 1.65; color: #66738b; }
.conflict-date-label { margin: 0 8px 0 20px; font-size: 13px; }
#conflictDate { min-height: 40px; margin-right: 20px; padding: 8px; border: 1px solid #dbe3ee; border-radius: 8px; background: #fff; color: #273247; font: inherit; }
.conflict-versions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 16px 20px; }
.conflict-versions section { min-width: 0; }
.conflict-versions h3 { margin: 0 0 6px; font-size: 15px; }
.conflict-versions p { margin: 0 0 8px; color: #78839a; font-size: 12px; min-height: 2.8em; }
.conflict-versions textarea { display: block; width: 100%; height: 220px; padding: 10px; resize: vertical; border: 1px solid #dbe3ee; border-radius: 8px; color: #273247; background: #fff; font-size: 16px; line-height: 1.65; }
.conflict-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 0 20px 8px; }
.conflict-actions button { min-height: 44px; font-size: 13px; }
@media (max-width: 600px) { .conflict-versions { grid-template-columns: minmax(0, 1fr); } .conflict-versions textarea { height: 170px; } .conflict-actions button { flex: 1 1 100%; } }
.privacy-note button { padding: 0; border: 0; color: #5c7fb8; background: transparent; cursor: pointer; font-size: inherit; text-decoration: underline; }
.entry-counter { margin-top: 5px; color: #8893a5; font-size: 12px; line-height: 1.5; text-align: right; }
.photo-fallback { display: grid; width: 100%; height: 100%; place-items: center; font-size: 56px; }
.photo-fallback[hidden] { display: none; }
.entry-status[data-state="dirty"], .entry-status[data-state="draft"] { color: #b98035 !important; background: #fff3db !important; }
.entry-status[data-state="error"] { color: #a04f45 !important; background: #fff0ed !important; }
.save-btn:disabled, .nav-btn:disabled, .page-switch button:disabled, .mood-option:disabled, .color-dot:disabled { opacity: .55; cursor: wait; transform: none !important; }
.tools-btn { min-height: 36px; padding: 8px 11px; border: 1px solid rgba(255,255,255,.8); border-radius: 9px; color: #5e6c83; background: rgba(255,255,255,.68); cursor: pointer; font-size: 12px; white-space: nowrap; }
.tools-btn:hover { background: #fff; }
html[data-theme="night"] .tools-btn { border-color: #3e526f; color: #d4dfed; background: #2b3e5c; }
.tools-dialog, .confirm-dialog { width: min(520px, calc(100vw - 28px)); padding: 0; border: 1px solid #dbe3ee; border-radius: 16px; color: #273247; background: #fffdf8; box-shadow: 0 25px 70px rgba(38,50,71,.24); }
.tools-dialog::backdrop, .confirm-dialog::backdrop { background: rgba(35,48,70,.38); backdrop-filter: blur(2px); }
html[data-theme="night"] .tools-dialog, html[data-theme="night"] .confirm-dialog { border-color: #485e7c; color: #edf3fb; background: #26364e; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid #e6eaf0; }
html[data-theme="night"] .dialog-head { border-bottom-color: #415570; }
.dialog-head h2 { margin: 0; font-family: var(--hand-font); font-size: 23px; font-weight: 400; }
.dialog-head button { width: 29px; height: 29px; border: 0; border-radius: 8px; color: #7f8ba0; background: #f1f4f8; cursor: pointer; font-size: 21px; line-height: 1; }
.tools-hint, .search-label, .search-count, .tools-dialog > .search-label, .backup-tools, .delete-current { margin-right: 20px; margin-left: 20px; }
.tools-hint { margin-top: 15px; color: #78839a; font-size: 11px; line-height: 1.6; }
.search-label { display: block; margin-top: 16px; color: #52617a; font-size: 11px; font-weight: 700; }
.search-controls { display: flex; gap: 8px; margin: 7px 20px 0; }
.search-controls input, .search-controls select { min-height: 36px; padding: 8px 10px; border: 1px solid #dbe3ee; border-radius: 8px; color: #273247; background: #fff; font-size: 11px; }
.search-controls input { flex: 1; min-width: 0; }
.search-results { display: grid; max-height: 210px; overflow: auto; margin: 2px 20px 0; border-top: 1px solid #edf0f4; }
.search-results .recent-item { background: transparent; }
.search-count { margin-top: 10px; margin-bottom: 0; color: #8a96aa; font-size: 10px; }
.secondary-btn, .primary-btn, .danger-btn { min-height: 34px; padding: 8px 11px; border-radius: 8px; cursor: pointer; font-size: 10px; }
.secondary-btn { border: 1px solid #dbe3ee; color: #5c6a81; background: #fff; }
.primary-btn { border: 1px solid #5c7fb8; color: #fff; background: #5c7fb8; }
.danger-btn { border: 1px solid #e5b9b3; color: #a9544b; background: #fff3f0; }
.tools-dialog > .secondary-btn { display: block; margin: 7px 20px 0; }
.backup-tools { margin-top: 17px; padding-top: 14px; border-top: 1px solid #e6eaf0; }
.backup-tools h3 { margin: 0; font-family: var(--hand-font); font-size: 17px; font-weight: 400; }
.backup-tools p { margin: 4px 0 10px; color: #8995a8; font-size: 10px; }
.backup-tools button + button { margin-left: 7px; }
.delete-current { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 17px; margin-bottom: 19px; padding-top: 13px; border-top: 1px dashed #e4e8ef; color: #8995a8; font-size: 10px; }
.toast { position: fixed; z-index: 20; right: 24px; bottom: 24px; max-width: min(340px, calc(100vw - 48px)); padding: 11px 14px; border: 1px solid #bdd4c9; border-radius: 9px; color: #356c59; background: #effaf5; box-shadow: 0 12px 26px rgba(42,77,67,.16); font-size: 11px; }
.toast[hidden] { display: none; }
html[data-theme="night"] .toast { border-color: #4c806b; color: #b7ebd4; background: #29483f; }
html[data-theme="night"] .search-controls input, html[data-theme="night"] .search-controls select, html[data-theme="night"] .secondary-btn { border-color: #4b607c; color: #edf3fb; background: #2d405f; }
html[data-theme="night"] .search-label, html[data-theme="night"] .backup-tools h3 { color: #dce6f2; }
html[data-theme="night"] .backup-tools, html[data-theme="night"] .delete-current { border-color: #425773; }
/* Keep the handwritten headings while making small controls easier to read. */
.panel-heading span, .calendar-week, .mood-legend, .recent-date, .recent-date em,
.recent-copy strong, .recent-copy small, .page-kicker, .date-ribbon,
.entry-meta, .entry-status, .mood-option, .tool-label, .book-caption { font-size: 12px; }
.entry-counter, .tools-btn, .tools-hint, .search-label, .search-count, .backup-tools p, .delete-current, .toast,
.search-controls input, .search-controls select, .secondary-btn, .primary-btn, .danger-btn { font-size: 12px; line-height: 1.5; }
.privacy-note { flex-wrap: wrap; padding: 0 12px 16px; font-size: 12px; line-height: 1.6; }
.privacy-note button { min-height: 36px; padding: 6px 4px; white-space: nowrap; }
.nav-btn { width: 36px; height: 36px; }
.entry-head { flex-wrap: wrap; gap: 8px 12px; }
.entry-meta { min-width: 0; }
.entry-status { flex-shrink: 0; white-space: nowrap; }
.tool-group { min-width: 0; max-width: 100%; flex-wrap: wrap; gap: 3px; }
.tool-label { flex-shrink: 0; line-height: 1.5; }
.color-dot { position: relative; display: grid; flex: 0 0 36px; width: 36px; height: 40px; place-items: center; padding: 0; border: 0; border-radius: 9px; background: transparent; box-shadow: none; touch-action: manipulation; }
.color-dot::before { content: ""; box-sizing: border-box; width: 23px; height: 23px; border: 2px solid transparent; border-radius: 50%; background: var(--dot); box-shadow: inset 0 0 0 1px rgba(255,255,255,.55); transition: transform .2s, border-color .2s; }
.color-dot:hover, .color-dot.active { transform: none; }
.color-dot:hover::before, .color-dot.active::before { border-color: #5e6a7f; transform: scale(1.08); }
.save-btn { font-size: 13px; }
.save-btn:hover { transform: translateY(-1px); animation: none; }
.save-btn.saved, .save-btn.saved:hover { transform: none; animation: save-confirm .32s ease-out; }
@keyframes save-confirm { from { box-shadow: 0 0 0 3px rgba(104,185,154,.3); } to { box-shadow: 0 8px 16px rgba(73,164,126,.23); } }
/* Equal paper widths keep the spine still throughout a physical page turn. */
.book { grid-template-columns: 1fr 1fr; height: 610px; min-height: 610px; perspective: none; }
.page-inner { min-height: 0; }
.left-note { display: -webkit-box; max-height: 61.2px; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.page-right > .page-inner { display: flex; flex-direction: column; }
.page-right .rule-paper { flex: 1; }
.page-right .entry-foot { position: static; margin-top: 12px; }
.page-right .rule-paper { display: flex; min-width: 0; min-height: 0; overflow: hidden; }
.page-right .entry-content { flex: 1 1 0%; min-width: 0; min-height: 0; width: 100%; height: auto; color: #40546c; overflow: auto; }
.polaroid { padding-bottom: 32px; }
.book > .page-left, .flip-snapshot.page-left { box-shadow: inset -12px 0 18px -18px rgba(77,61,43,.3); }
.book > .page-right, .flip-snapshot.page-right { box-shadow: inset 12px 0 18px -18px rgba(77,61,43,.25); }
.flip-layer.stf__parent { position: absolute; inset: 0; z-index: 5; width: 100%; height: 100%; min-width: 0 !important; min-height: 0 !important; max-width: none !important; visibility: hidden; pointer-events: none; }
.flip-layer .stf__wrapper, .flip-layer .stf__block { width: 100%; height: 100%; padding: 0 !important; }
.book.is-flipping > .page { visibility: hidden; }
.book.is-flipping .flip-layer { visibility: visible; }
.flip-leaf { overflow: hidden; background: var(--paper); }
.flip-snapshot { width: 100%; height: 100%; transform: none; transform-style: flat; backface-visibility: visible; }
.flip-snapshot *, .flip-snapshot *::before, .flip-snapshot *::after { animation: none !important; transition: none !important; }
.book[aria-busy="true"] .save-btn:disabled, .book[aria-busy="true"] .mood-option:disabled, .book[aria-busy="true"] .color-dot:disabled { opacity: 1; }
.page-switch { gap: 8px; flex-shrink: 0; }
.page-switch button { display: flex; justify-content: center; gap: 6px; width: auto; min-width: 76px; height: 36px; padding: 0 12px; font-size: 12px; }
.page-switch button:hover:not(:disabled) { background: #fff; box-shadow: 0 3px 10px rgba(92,127,184,.12); }
.book-caption .caption-note { margin-left: 10px; }
.swipe-hint { display: none; }
@media (min-width: 761px) and (max-width: 1180px) {
  .workspace { grid-template-columns: 220px minmax(0, 1fr); gap: 16px; }
  .book-wrap { padding-right: 12px; padding-left: 12px; }
  .page-left, .page-right { padding-left: 24px; padding-right: 24px; }
  .page-left h2 { font-size: 58px; }
  .entry-foot { flex-wrap: wrap; gap: 10px; }
  .tool-label { flex-basis: 100%; }
  .entry-title { font-size: 25px; }
  .book { height: 610px; min-height: 610px; }
  .book-caption .caption-note { display: none; }
}
@media (min-width: 761px) and (max-width: 980px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .book-stage { order: -1; }
  .sidebar { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .brand { min-width: 0; }
  .brand-mark { flex-shrink: 0; }
  .top-actions { max-width: 100%; flex-wrap: wrap; gap: 8px; margin-left: auto; }
  .book-stage { order: -1; }
  .book > .page-right, .flip-snapshot.page-right { box-shadow: none; }
  .book-caption { flex-wrap: wrap; row-gap: 12px; }
  .book-caption .caption-note { display: none; }
  .page-switch button { min-height: 44px; min-width: 96px; }
  .swipe-hint { display: block; margin: 10px 0 0; color: #8c99ad; font-size: 12px; line-height: 1.6; text-align: center; }
  .entry-title, .entry-content { font-size: max(16px, 1em); }
  .entry-title { font-size: 25px; }
  .book, .page-right { height: auto; min-height: 0; }
  .page-right > .page-inner { height: auto; min-height: 0; }
  .page-right .rule-paper { flex: 0 0 auto; min-height: 280px; }
  .page-right .entry-content { height: 280px; min-height: 280px; }
  .flip-snapshot.page-right { height: 100%; }
  .entry-foot { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; } }
@media (max-width: 760px) { .tools-btn { order: 3; } .privacy-note { flex-wrap: wrap; } }
@media (max-width: 470px) {
  .tools-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px; }
  .today-btn { min-height: 40px; }
  .tool-group { width: 100%; }
  .tool-label { flex-basis: 100%; }
  .delete-current { align-items: flex-start; flex-direction: column; }
  .delete-current .danger-btn { width: 100%; }
  .backup-tools button { margin-top: 4px; }
  .page-right .rule-paper { min-height: 260px; }
  .page-right .entry-content { height: 260px; min-height: 260px; }
}
@media (max-width: 380px) {
  .entry-head { flex-wrap: nowrap; min-height: 48px; }
  .entry-status { max-width: 90px; white-space: normal; line-height: 16px; }
  .brand { gap: 8px; }
  .brand-mark { width: 32px; height: 32px; flex-shrink: 0; font-size: 20px; }
  .brand h1 { font-size: 15px; }
  .brand p { display: none; }
  .today-btn { white-space: nowrap; }
  .top-actions { flex-shrink: 0; }
}
