:root {
  color-scheme: light;
  --paper: #f6f5ef;
  --sheet: #fffefa;
  --ink: #202c25;
  --muted: #626962;
  --rule: #e1e2d8;
  --green: #2e533e;
  --wash: #e8eee3;
  --error: #9b372d;
  --serif: "Instrument Serif", "Noto Serif SC", "Songti SC", "SimSun", serif;
  font: 15px/1.55 "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 1px solid var(--rule); background: var(--sheet); border-radius: 8px; padding: 8px 13px; cursor: pointer; }
button:hover { border-color: #a9b6a7; }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 2px solid #51785d; outline-offset: 3px; }
.primary { background: var(--green); color: white; border-color: var(--green); font-weight: 650; }
.primary:hover { background: #244433; }
.quiet, .tertiary { border-color: transparent; background: transparent; }
.tertiary { color: var(--green); }
.error-text { color: var(--error); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.topbar { border-bottom: 1px solid var(--rule); background: var(--sheet); }
.top-inner { max-width: 1240px; padding: 0 34px; margin: auto; height: 65px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 11px; font: 700 25px/1 var(--serif); letter-spacing: .05em; }
.brand-mark { position: relative; width: 27px; height: 29px; background: var(--green); border-radius: 6px 8px 8px 6px; }
.brand-mark::before { position: absolute; content: ''; inset: 6px 6px auto 10px; height: 2px; background: #e6eddd; box-shadow: 0 5px #e6eddd; }
.brand-mark::after { position: absolute; content: ''; inset: 4px auto 4px 4px; border-left: 1px solid #abc1a9; }
.top-actions, .row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.sync-status { font-size: 13px; background: var(--wash); color: var(--green); border-color: transparent; }
.sync-status::before { display: inline-block; content: ''; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: currentColor; vertical-align: 2px; }
.sync-status[data-kind="warn"] { color: #754e1e; background: #f4ead7; }
.lock-control { padding-inline: 9px; }

.gate { min-height: calc(100dvh - 66px); display: grid; align-items: center; padding: 38px 24px 64px; }
.welcome { display: grid; grid-template-columns: 140px minmax(0, 390px); align-items: center; gap: 45px; width: fit-content; max-width: 100%; margin: auto; padding: 48px; border: 1px solid var(--rule); border-radius: 20px; background: var(--sheet); }
.welcome h1 { margin: 0 0 11px; font: 700 clamp(27px, 6vw, 38px)/1.24 var(--serif); }
.welcome p { margin: 0 0 24px; color: var(--muted); }
.notebook { position: relative; width: 108px; height: 140px; justify-self: center; padding: 38px 24px 0 31px; display: flex; flex-direction: column; gap: 9px; background: #dce7d6; border: 1px solid #a5b8a2; border-radius: 9px 15px 15px 9px; box-shadow: 6px 7px 0 #eaede4; transform: rotate(-8deg); }
.notebook::before { content: ''; position: absolute; inset: 0 auto 0 13px; border-left: 1px solid #a5b8a2; }
.notebook i { height: 1px; background: #8aa088; }
.notebook i:last-of-type { width: 65%; }
.notebook b { position: absolute; bottom: -9px; right: 14px; height: 24px; width: 13px; background: #497054; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%); }
.welcome .form-actions { justify-content: start; }
.welcome form { margin-bottom: 11px; }

.workspace { display: grid; grid-template-columns: 195px minmax(0, 760px); gap: clamp(35px, 6vw, 88px); max-width: 1240px; margin: 0 auto; padding: 42px 34px 70px; }
.sidebar { border-right: 1px solid var(--rule); padding-right: 20px; }
.nav { display: grid; gap: 6px; }
.nav button { display: flex; align-items: center; gap: 10px; text-align: left; background: transparent; border-color: transparent; }
.nav button:hover, .nav [aria-current="page"] { background: var(--wash); color: var(--green); }
.nav [aria-current="page"] { font-weight: 650; }
.nav-icon { position: relative; display: grid; place-items: center; width: 15px; height: 15px; border: 1.5px solid currentColor; border-radius: 3px; flex-shrink: 0; }
.timeline-icon::before { width: 7px; height: 1px; content: ''; background: currentColor; box-shadow: 0 3px currentColor, 0 -3px currentColor; }
.trash-icon { width: 12px; height: 11px; border-top: 0; border-radius: 0 0 3px 3px; margin: 3px 1px 0 2px; }
.trash-icon::before { content: ''; width: 15px; height: 1.5px; background: currentColor; position: absolute; top: -2px; }
.settings-icon { border-radius: 50%; }
.settings-icon::before { content: ''; width: 4px; height: 4px; background: currentColor; border-radius: 50%; }
.side-tags { margin-top: 34px; }
.side-tags h2 { font-size: 12px; color: var(--muted); margin: 0 0 8px 12px; }
#tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-block; max-width: 100%; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--wash); border: 1px solid transparent; border-radius: 20px; padding: 3px 10px; color: var(--green); }
.tag[aria-pressed="true"] { border-color: var(--green); }

.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 23px; }
.page-heading h1 { margin: 0; font: 700 clamp(32px, 5vw, 49px)/1.15 var(--serif); letter-spacing: .025em; }
.today { margin: 0 0 8px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.write-button { flex-shrink: 0; padding: 9px 16px; }
.filters { display: flex; gap: 10px; margin-bottom: 17px; }
.search-field, .date-filter { display: flex; align-items: center; gap: 10px; border: 1px solid var(--rule); padding: 0 12px; background: var(--sheet); border-radius: 8px; min-height: 43px; }
.search-field { flex: 1; min-width: 0; }
.search-field input, .date-filter input { background: transparent; border: 0; width: 100%; min-width: 0; min-height: 39px; padding: 0; }
.search-field:focus-within, .date-filter:focus-within { outline: 2px solid #51785d; outline-offset: 2px; }
.search-field input:focus, .date-filter input:focus { outline: 0; }
.date-filter { width: 154px; }
.search-icon { width: 12px; height: 12px; border: 1.5px solid var(--muted); border-radius: 50%; flex-shrink: 0; position: relative; }
.search-icon::after { content: ''; position: absolute; inset: auto -4px -2px auto; width: 5px; height: 1.5px; background: var(--muted); transform: rotate(45deg); }
.filter-current { margin-bottom: 10px; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.empty { border: 1px dashed #c7d2c3; border-radius: 12px; padding: 60px 20px; text-align: center; color: var(--muted); background: #ffffff72; }
.empty h2 { font: 700 23px/1.35 var(--serif); color: var(--ink); margin: 0 0 6px; }
.empty p { margin: 0 0 15px; }
.empty p:last-child { margin: 0; }
.day-section:not(:first-child) { margin-top: 24px; }
.day-heading { display: flex; align-items: center; gap: 12px; margin: 24px 0 10px; font-size: 14px; color: var(--muted); font-weight: 650; }
.day-heading::after { flex: 1; content: ''; height: 1px; background: var(--rule); }
.entry { margin-top: 10px; padding: 17px 20px; border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); overflow-wrap: anywhere; }
.entry h3 { margin: 0 0 8px; font: 700 24px/1.32 var(--serif); }
.entry-body { white-space: pre-wrap; margin: 0 0 12px; line-height: 1.75; }
.entry-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.entry-footer .row-actions { gap: 1px; margin-left: auto; }
.entry-footer button { padding: 5px 9px; font-size: 13px; }
.row-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.entry-status { color: var(--muted); font-size: 12px; white-space: nowrap; }
.entry-status.error-text { color: var(--error); }
.entry-sync-error { flex-basis: 100%; order: 2; font-size: 12px; color: var(--error); }
.entry .resolve { color: #754e1e; background: #f4ead7; border: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 575px; gap: 7px; margin: 12px 0; }
.photo-grid button { position: relative; display: grid; place-items: center; aspect-ratio: 4/3; min-width: 0; padding: 0; overflow: hidden; background: var(--wash); color: var(--green); font-size: 13px; }
.photo-grid button img { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; }
.more { display: block; margin: 20px auto 0; }

.settings-card { border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); padding: 19px 21px; margin: 0 0 12px; overflow-wrap: anywhere; }
.settings-card h2, .settings-card h3 { margin: 0; font-size: 17px; }
.settings-card h3 { font-size: 15px; }
.settings-card p { margin: 5px 0 13px; color: var(--muted); }
.settings-card .error-text { color: var(--error); margin: 8px 0 0; }
.lock-options { margin-top: 8px; }
.settings-card select { border: 1px solid var(--rule); border-radius: 7px; padding: 6px 10px; background: var(--sheet); }
.devices-list { padding: 0; margin: 0; list-style: none; }
.devices-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.devices-list li:last-child { border: none; }
.device-label { display: grid; gap: 3px; overflow-wrap: anywhere; }
.windows-backup { margin-top: 18px; border-top: 1px solid var(--rule); padding-top: 16px; }
.backup-result, #backup-schedule { white-space: pre-wrap; }

dialog { color: var(--ink); background: var(--sheet); border: 1px solid var(--rule); border-radius: 16px; padding: 0; width: min(600px, calc(100% - 26px)); max-height: min(90dvh, 850px); box-shadow: 0 14px 55px #19271e38; }
dialog::backdrop { background: #1b2b2490; }
.dialog-inner { padding: 21px 23px 24px; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 15px; }
.dialog-header h2 { margin: 0; font: 700 26px/1.25 var(--serif); }
.icon-close { width: 38px; height: 38px; padding: 0; font-size: 23px; line-height: 1; background: var(--paper); }
.dialog-inner p { margin: 0 0 12px; }
#dialog-error { margin: 12px 0 0; }
.fields { display: grid; gap: 11px; }
.field { display: grid; gap: 5px; min-width: 0; font-size: 14px; font-weight: 640; }
.field input:not([type="checkbox"]), .field textarea { border: 1px solid #d0d4c8; background: #fff; border-radius: 7px; width: 100%; padding: 9px 11px; font-size: 16px; font-weight: 400; }
.field input[type="file"] { padding: 7px; }
.field textarea { min-height: 145px; resize: vertical; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: end; gap: 8px; margin-top: 7px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 13px; }
.check { display: flex; gap: 8px; align-items: start; }
.check input { width: 18px; height: 18px; accent-color: var(--green); }
.recovery-code { display: block; width: 100%; margin: 4px 0; background: var(--wash); color: var(--green); border: 1px solid var(--rule); padding: 10px; border-radius: 7px; font: 14px/1.4 "IBM Plex Mono", monospace; word-break: break-all; resize: none; }
.edit-photos { display: grid; gap: 4px; }
.edit-photos > div { display: flex; justify-content: space-between; gap: 8px; align-items: center; background: var(--paper); padding: 4px 9px; border-radius: 6px; }
.edit-photos span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edit-photos button { flex: none; padding: 2px 8px; }
.original-photo { display: block; max-width: 100%; max-height: 62dvh; margin: 0 auto 14px; border-radius: 7px; object-fit: contain; }
.version-card { background: var(--paper); border: 1px solid var(--rule); border-radius: 7px; margin-bottom: 8px; padding: 10px 12px; overflow-wrap: anywhere; }
.version-card h3 { margin: 0 0 5px; font-size: 14px; }
.version-card p { margin: 0; white-space: pre-wrap; }
.notice { position: fixed; inset: auto max(19px, env(safe-area-inset-right)) 21px auto; z-index: 2; max-width: min(440px, calc(100% - 38px)); padding: 10px 14px; border-radius: 9px; box-shadow: 0 7px 22px #223c2b30; color: #fff; background: var(--green); }

@media (max-width: 720px) {
  .top-inner { height: 56px; padding: 0 16px; }
  .brand { font-size: 22px; gap: 8px; }
  .brand-mark { width: 23px; height: 25px; }
  .workspace { display: block; padding: 24px 15px calc(84px + env(safe-area-inset-bottom)); }
  .sidebar { border: 0; padding: 0; }
  .nav { position: fixed; z-index: 1; inset: auto 0 0; grid-template-columns: repeat(3, 1fr); gap: 4px; border-top: 1px solid var(--rule); padding: 5px 9px calc(5px + env(safe-area-inset-bottom)); background: var(--sheet); }
  .nav button { justify-content: center; gap: 7px; min-height: 44px; padding: 6px; }
  .side-tags { display: none; }
  .page-heading { margin-bottom: 17px; }
  .today { margin-bottom: 4px; }
  .date-filter { width: 128px; padding-inline: 6px; }
  .search-field input, .date-filter input { font-size: 16px; }
  .search-field input::placeholder { font-size: 13px; }
  .entry { padding: 13px 14px; }
  .entry h3 { font-size: 21px; }
  .notice { bottom: calc(65px + env(safe-area-inset-bottom)); }
  .gate { min-height: calc(100dvh - 57px); padding-inline: 15px; }
  .welcome { grid-template-columns: minmax(0, 325px); gap: 30px; padding: 28px 23px; }
  .notebook { width: 69px; height: 92px; padding: 24px 12px 0 20px; gap: 6px; }
  .notebook::before { inset-inline-start: 8px; }
  .notebook b { height: 18px; }
  .dialog-inner { padding: 17px 15px; }
}
