/* System typography and a quiet, grouped diary layout. All assets are local. */
:root {
  color-scheme: light dark;
  --bg: #ffffff; --surface: #ffffff; --text: #111111; --muted: #666666; --subtle: #767676;
  --line: #e5e5e5; --accent: #111111; --accent-soft: #f3f3f3; --input: #f4f4f4; --danger: #a54d40;
  --shadow: 0 12px 45px #00000008; --radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #111111; --surface: #1c1c1c; --text: #f5f5f5; --muted: #aaaaaa; --subtle: #999999; --line: #333333; --accent: #f5f5f5; --accent-soft: #292929; --input: #252525; --danger: #efa397; --shadow: 0 12px 45px #0002; }
}
:root[data-theme="dark"] { --bg: #111111; --surface: #1c1c1c; --text: #f5f5f5; --muted: #aaaaaa; --subtle: #999999; --line: #333333; --accent: #f5f5f5; --accent-soft: #292929; --input: #252525; --danger: #efa397; --shadow: 0 12px 45px #0002; color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
html, body { width: 100%; min-width: 0; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
a { color: var(--accent); }
button, input, select { color: inherit; }
button { border: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
.icon { flex: 0 0 auto; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -100px; left: 16px; padding: 12px; background: var(--surface); z-index: 100; }
.skip-link:focus { top: 10px; }
.app-frame { width: 100%; max-width: 1080px; min-width: 0; min-height: 100svh; margin: auto; padding: env(safe-area-inset-top) 48px env(safe-area-inset-bottom); display: flex; flex-direction: column; }
.brand { display: flex; justify-content: space-between; align-items: center; padding: 32px 0 27px; border-bottom: 1px solid var(--line); }
.brand-link { display: inline-flex; align-items: center; gap: 11px; color: var(--text); font-size: 16px; font-weight: 650; letter-spacing: -.35px; text-decoration: none; }
.brand, .brand-link, .brand-link > span, .page-heading > div { min-width: 0; }
.brand-link { max-width: 100%; }
.brand-icon { display: block; width: 40px; height: 40px; object-fit: cover; border-radius: 10px; flex-shrink: 0; }
.diary-main { width: 100%; min-width: 0; max-width: 728px; margin: 46px auto 0; flex: 1; padding-bottom: 30px; }
.entry-detail, .entry-body, #entries-list, .month-section, .entry-group { min-width: 0; max-width: 100%; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
h1 { font-size: clamp(32px, 5vw, 42px); line-height: 1.18; letter-spacing: -1.6px; font-weight: 720; margin-bottom: 0; }
.toolbar-actions { display: flex; gap: 7px; align-items: center; }
.icon-button { width: 44px; height: 44px; display: inline-flex; justify-content: center; align-items: center; border-radius: 50%; background: transparent; color: var(--muted); padding: 10px; flex: 0 0 auto; }
.toolbar-actions .icon-button { background: var(--surface); border: 1px solid var(--line); }
.icon-button:hover { color: var(--accent); background: var(--accent-soft); }
.status-line { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; margin-top: 15px; min-height: 18px; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--text); flex: 0 0 auto; }
.status-dot.offline { background: var(--muted); }
.offline-ready { margin-left: auto; font-size: 10px; }
.search-wrap { margin-top: 26px; display: flex; align-items: center; gap: 10px; background: var(--input); border: 1px solid transparent; border-radius: 12px; padding: 0 13px; color: var(--muted); }
.search-wrap:focus-within { border-color: var(--accent); }
.search-wrap > .icon { width: 18px; height: 18px; }
#search { height: 47px; width: 100%; border: none; background: transparent; outline: none; padding: 0; font-size: 13px; min-width: 0; }
#search::-webkit-search-cancel-button { display: none; }
#search::placeholder { color: var(--muted); opacity: 1; }
.clear-search { width: 32px; height: 40px; padding: 6px; border-radius: 6px; }
.list-summary { color: var(--muted); font-size: 10px; display: flex; justify-content: space-between; margin: 13px 2px 27px; }
.month-section { margin-bottom: 29px; }
.month-heading { display: flex; justify-content: space-between; align-items: center; margin: 0 3px 10px; }
.month-heading h2 { font-size: 16px; font-weight: 680; letter-spacing: -.35px; margin: 0; }
.month-heading > span { color: var(--muted); font-size: 10px; }
.entry-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 2px 6px #00000003; }
.entry-row { display: flex; gap: 17px; align-items: center; padding: 21px 20px; color: var(--text); text-decoration: none; position: relative; min-height: 112px; }
.entry-row + .entry-row::before { content: ''; height: 1px; background: var(--line); position: absolute; left: 117px; right: 20px; top: 0; }
.entry-row:hover { background: color-mix(in srgb, var(--accent-soft) 32%, var(--surface)); }
.entry-row:focus-visible { outline-offset: -4px; z-index: 1; border-radius: 10px; }
.entry-preview { width: 80px; height: 64px; position: relative; flex: 0 0 80px; isolation: isolate; }
.preview-inner { position: relative; z-index: 2; width: 64px; height: 64px; background: var(--input); color: var(--subtle); display: grid; place-items: center; border-radius: 11px; overflow: hidden; }
.preview-mini { position: absolute; right: 0; width: 24px; height: 30px; z-index: 1; display: grid; place-items: center; overflow: hidden; border: 2px solid var(--surface); border-radius: 7px; background: var(--input); color: var(--subtle); }
.preview-mini-1 { top: 0; }
.preview-mini-2 { bottom: 0; }
.preview-mini > .icon { width: 14px; height: 14px; }
.preview-inner img, .preview-mini img, .gallery-image img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; z-index: 1; }
.entry-copy { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.entry-title { font-weight: 650; font-size: 15px; line-height: 1.35; letter-spacing: -.18px; margin-bottom: 4px; }
.entry-excerpt { font-size: 12px; color: var(--muted); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.entry-date { color: var(--muted); font-size: 10px; margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.heart { width: 12px; height: 12px; stroke: #b76b65; fill: #b76b65; }
.row-chevron { color: var(--subtle); margin-left: 2px; }
.row-chevron .icon { width: 14px; height: 14px; }
.list-end { text-align: center; color: var(--muted); font-size: 11px; padding: 0 0 10px; }
.list-end p { margin: 18px 0 12px; }
.button { min-height: 44px; padding: 11px 18px; border: 1px solid transparent; border-radius: 10px; display: inline-flex; gap: 10px; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; text-decoration: none; }
.button .icon { width: 17px; height: 17px; }
.primary { background: var(--accent); color: var(--surface); }
.primary:hover { filter: brightness(.93); }
.secondary { background: var(--surface); border-color: var(--line); color: var(--accent); }
.secondary:hover { background: var(--accent-soft); }
.text-button { background: transparent; color: var(--accent); min-height: 44px; font-size: 12px; font-weight: 600; padding: 7px 0; display: inline-flex; align-items: center; gap: 7px; }
.text-button:hover { text-decoration: underline; }
.text-button .icon { width: 15px; height: 15px; }
.notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 15px; border-radius: 10px; padding: 9px 14px; background: var(--accent-soft); font-size: 12px; margin-bottom: 22px; }
.notice > span { min-width: 0; flex: 1 1 160px; }
.error-notice { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.notice .text-button { flex-shrink: 0; }
.demo-banner { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 13px; background: var(--accent-soft); color: var(--accent); border: 1px dashed color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 10px; font-size: 9px; letter-spacing: 1px; font-weight: 700; margin-bottom: 24px; }
.demo-banner span { letter-spacing: 0; font-size: 10px; font-weight: 400; }
.demo-banner button { margin-left: auto; background: transparent; color: var(--accent); padding: 10px 0; min-height: 32px; text-decoration: underline; font-size: 10px; letter-spacing: 0; }
.empty-state { text-align: center; padding: 48px 22px; color: var(--muted); }
.empty-state > .icon { width: 40px; height: 40px; margin-bottom: 20px; color: var(--accent); }
.empty-state h2, .empty-state h1 { color: var(--text); font-size: 23px; letter-spacing: -.7px; margin-bottom: 10px; }
.empty-state p { max-width: 370px; margin: 0 auto 22px; font-size: 14px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; text-decoration: none; min-height: 44px; }
.back-link .icon { width: 18px; height: 18px; }
.detail-main { margin-top: 27px; }
.detail-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 36px; }
.entry-detail > h1 { max-width: 620px; font-size: clamp(30px, 5vw, 40px); letter-spacing: -1.1px; line-height: 1.2; margin-bottom: 13px; }
.detail-date { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 30px; }
.gallery { display: flex; width: 100%; min-width: 0; max-width: 100%; gap: 12px; overflow-x: auto; overscroll-behavior-inline: contain; padding: 4px 2px 14px; margin: 0; scroll-snap-type: x proximity; }
.gallery-item { padding: 0; background: transparent; text-align: left; width: 120px; flex: 0 0 120px; align-self: flex-start; scroll-snap-align: start; }
.gallery-image { display: grid; place-items: center; width: 120px; height: 120px; background: var(--input); color: var(--muted); border-radius: 14px; overflow: hidden; position: relative; }
.gallery-image > .icon { width: 28px; height: 28px; }
.gallery-caption { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 11px; line-height: 1.45; color: var(--muted); margin: 8px 2px 0; }
.pending-badge { position: absolute; bottom: 8px; left: 0; right: 0; text-align: center; font-size: 9px; }
.media-summary { display: flex; gap: 5px; align-items: center; font-size: 10px; color: var(--muted); padding: 4px 0 23px; border-bottom: 1px solid var(--line); margin-bottom: 27px; }
.media-summary .icon { width: 13px; height: 13px; }
.media-summary span { margin-left: auto; font-style: italic; }
.entry-body { font-size: 17px; line-height: 1.9; letter-spacing: -.1px; max-width: 650px; }
.entry-body p { white-space: pre-wrap; margin-bottom: 24px; }
.entry-body a { text-decoration-thickness: 1px; text-underline-offset: 3px; }
.entry-body code { font-size: .9em; padding: 2px 4px; background: var(--input); border-radius: 4px; }
.welcome { width: 100%; max-width: 400px; margin: 64px auto; flex: 1; }
.login-card { background: var(--surface); padding: 36px 32px 25px; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 22px; line-height: 1.25; letter-spacing: -.7px; margin-bottom: 11px; }
.login-card > p { font-size: 12px; color: var(--muted); line-height: 1.8; margin-bottom: 25px; }
label { display: block; font-size: 11px; font-weight: 600; margin-bottom: 7px; }
input:not(#search), select { min-height: 46px; width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 14px; }
.connection { margin-top: 15px; font-size: 11px; color: var(--muted); }
.connection summary { cursor: pointer; min-height: 32px; padding: 7px 0; }
.connection label { margin-top: 10px; }
.connection input { font-size: 12px; }
.hint { color: var(--muted); font-size: 11px; line-height: 1.7; margin: 8px 0; }
.error-text { color: var(--danger); font-size: 12px; margin: 8px 0; }
.error-text:empty { display: none; }
.login-submit { margin-top: 15px; width: 100%; }
.demo-option { border-top: 1px solid var(--line); text-align: center; padding-top: 20px; margin-top: 25px; display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); }
.demo-option small { font-size: 9px; margin-top: -3px; }
.settings-dialog { width: min(480px, calc(100vw - 32px)); max-height: 88svh; padding: 24px; border: 1px solid var(--line); border-radius: 21px; background: var(--surface); color: var(--text); box-shadow: 0 25px 100px #0004; }
dialog::backdrop { background: #00000066; backdrop-filter: blur(5px); }
.settings-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.settings-heading h2 { font-size: 24px; letter-spacing: -.8px; margin: 0; }
.settings-dialog section { border-bottom: 1px solid var(--line); padding: 20px 0; }
.settings-dialog h3 { display: flex; align-items: center; gap: 7px; font-size: 14px; margin-bottom: 10px; }
.settings-dialog h3 .icon { width: 16px; height: 16px; }
.settings-dialog p { font-size: 12px; color: var(--muted); }
.settings-dialog .hint { font-size: 11px; }
.settings-dialog select { font-size: 13px; }
.settings-dialog .text-button { display: block; }
.danger-text { color: var(--danger); }
.danger { background: var(--danger); color: var(--surface); }
.clear-confirm { background: var(--bg); border-radius: 10px; padding: 15px; margin-top: 12px; }
.build-note { text-align: center; font-size: 10px !important; margin: 20px 0 0; line-height: 1.9; }
.connection-origin { word-break: break-all; }
.viewer { border: 0; padding: 0; margin: 0; max-width: 100%; max-height: none; width: 100%; height: 100dvh; position: fixed; inset: 0; background: #080808; color: #fafafa; overflow: hidden; }
.viewer::backdrop { background: #080808; backdrop-filter: none; }
.viewer-top { position: absolute; z-index: 3; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: calc(12px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 18px max(22px, env(safe-area-inset-left)); background: linear-gradient(#0009, transparent); pointer-events: none; }
.viewer-counter { font-size: 12px; font-variant-numeric: tabular-nums; }
.viewer .icon-button { color: #fafafa; background: #292929ba; pointer-events: auto; }
.viewer .icon-button:hover { background: #484848; }
.viewer-stage { position: absolute; inset: calc(75px + env(safe-area-inset-top)) 0 calc(125px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: center; touch-action: none; overflow: hidden; }
.viewer-stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; user-select: none; -webkit-user-select: none; }
.viewer-stage.zoomed { cursor: grab; }
.viewer-stage video { max-width: 100%; max-height: 100%; touch-action: auto; }
.viewer-prev, .viewer-next { position: absolute; top: 45%; z-index: 2; }
.viewer-prev { left: max(12px, env(safe-area-inset-left)); }
.viewer-next { right: max(12px, env(safe-area-inset-right)); }
.viewer .icon-button:disabled { opacity: .15; }
.viewer-bottom { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; padding: 18px 70px calc(20px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, #000c); pointer-events: none; }
.viewer-caption { font-size: 13px; line-height: 1.6; margin: 0 auto 7px; max-width: 700px; max-height: 67px; overflow: auto; pointer-events: auto; }
.viewer-hint { color: #b8b8b8; font-size: 10px; }
.media-message { max-width: 360px; text-align: center; color: #d4d4d4; padding: 24px; font-size: 14px; }
.media-message > .icon { width: 36px; height: 36px; margin-bottom: 15px; }
.media-message .button { color: #eeeeee; background: #333333; border-color: #555555; margin-top: 12px; }
.boot { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
#toasts { position: fixed; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: min(440px, calc(100% - 32px)); z-index: 20; pointer-events: none; }
.toast { padding: 13px 18px; margin-top: 8px; background: var(--text); color: var(--surface); border-radius: 12px; box-shadow: var(--shadow); font-size: 12px; }
.loading { animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .5; } }
@media (max-width: 700px) {
  .app-frame { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  .brand { padding: 21px 0 20px; }
  .brand-link { font-size: 15px; }
  .brand-icon { width: 36px; height: 36px; border-radius: 10px; }
  .diary-main { margin-top: 31px; }
  .offline-ready { display: none; }
  .search-wrap { margin-top: 22px; }
  .entry-row { padding: 19px 15px; gap: 14px; }
  .entry-row + .entry-row::before { left: 109px; right: 15px; }
  .entry-title { font-size: 14px; }
  .entry-excerpt { font-size: 12px; line-height: 1.55; }
  .entry-group { border-radius: 15px; }
  .row-chevron { display: none; }
  .welcome { margin: 36px auto; padding: 0; }
  .login-card { padding: 27px 24px 24px; }
  .detail-main { margin-top: 18px; }
  .detail-nav { margin-bottom: 27px; }
  .entry-detail > h1 { font-size: 31px; }
  .entry-body { font-size: 16px; line-height: 1.85; }
  .media-summary span { display: none; }
  .demo-banner { padding: 8px 10px; }
  .demo-banner button { width: 100%; margin: 0; text-align: left; padding: 3px 0; }
  .viewer-bottom { padding-left: 22px; padding-right: 22px; }
  .viewer-stage { bottom: calc(130px + env(safe-area-inset-bottom)); }
  .viewer-prev, .viewer-next { top: auto; bottom: calc(119px + env(safe-area-inset-bottom)); width: 40px; height: 40px; }
  .settings-dialog { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
.boot-icon { display: block; border-radius: 13px; margin-bottom: 15px; }
