:root {
  --bg: #f2f4ef;
  --paper: #fcfdf9;
  --ink: #202a22;
  --muted: #536153;
  --line: #dbe2d6;
  --accent: #254d36;
  --accent-ink: #fff;
  --sidebar: #1d3227;
  --sidebar-ink: #eef5eb;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Georgia", "Songti SC", "SimSun", serif;
}

body { font-size: 1rem; }
button, input, textarea, select { min-width: 0; }
button { font-weight: 600; }
button:disabled { opacity: .58; cursor: wait; }
button:focus-visible, .writing:focus-visible { outline: 2px solid #609568; outline-offset: 3px; }
.auth { background: radial-gradient(ellipse at 20% 15%, #e2ecd5, var(--bg) 56%); }
.auth .card { padding: clamp(1.25rem, 7vw, 2rem); }
.auth h1 { font-size: 2.7rem; margin-top: 1.15rem; }
.auth .lead { margin: 0 0 1.8rem; }
.auth input { font-size: 1rem; }
.auth-actions { display: grid; gap: .55rem; }
.auth-actions button { min-height: 44px; }
.mark { color: #1e392a; background: #cfe5b8; font-size: 1.1rem; }

.shell { min-height: 100dvh; height: auto; grid-template-columns: 14.5rem minmax(0, 1fr); grid-template-rows: auto; }
.navigation {
  align-self: start;
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 2rem 1.125rem 1.125rem;
  gap: 2rem;
  border: 0;
  background: var(--sidebar);
  color: var(--sidebar-ink);
}
.navigation .brand { margin: 0 .375rem; }
.navigation-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 2rem; }
.navigation-toggle { display: none; }
.brand strong { font-size: 1.2rem; }
.brand em { color: #bccdbd; overflow-wrap: anywhere; }
.navigation nav { display: grid; gap: .4rem; }
.navigation nav button {
  display: flex;
  align-items: center;
  gap: .75rem;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  white-space: nowrap;
  color: var(--sidebar-ink);
}
.navigation nav button span { width: 1.2rem; text-align: center; font-size: 1.15rem; }
.navigation nav button:hover { background: #30483a; }
.navigation nav button[aria-current] { background: #d8ebc5; color: #203929; }
.account-actions { margin-top: auto; display: flex; gap: .45rem; justify-content: space-between; }
.account-actions button { color: #d6e4d6; font-size: .875rem; }
.account-actions button:hover { color: white; }

.workspace { display: block; }
.workspace-view { width: min(74rem, 100%); margin: 0 auto; padding: clamp(1.2rem, 4.4vw, 3.5rem); }
.workspace-view h1 { font-size: clamp(2rem, 4vw, 3rem); margin: 0; }
.workspace-view h2 { font-size: 1.35rem; margin: 0; }
.view-header, .overview-header, .card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.view-header { margin-bottom: 1.65rem; }
.overview-header {
  align-items: end;
  padding: clamp(1.3rem, 4vw, 2.7rem);
  min-height: 11rem;
  margin-bottom: 1.4rem;
  border: 1px solid #cfdcc6;
  border-radius: 1.35rem;
  background: linear-gradient(115deg, #e5eddc, #dbe8ce);
}
.date-label { margin: 0 0 .65rem; color: #3f5943; font-size: .925rem; }
.overview-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1rem; }
.overview-card, .record-card, .empty-state {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 1rem;
}
.overview-card { min-width: 0; padding: 1.3rem; }
.overview-card .card-heading { border-bottom: 1px solid var(--line); padding-bottom: .65rem; }
.overview-card .hint { margin: 1rem 0 .2rem; }
.overview-item {
  width: 100%;
  display: block;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  padding: .85rem .2rem;
}
.overview-item:last-child { border-bottom: 0; }
.overview-item:hover, button.text:hover { text-decoration: underline; }
.overview-item span { display: block; color: var(--muted); font-size: .875rem; font-weight: 400; margin-top: .3rem; }
.overview-item strong, .record-card h2, .reminder-card strong { overflow-wrap: anywhere; }
.section-search { max-width: 24rem; margin-bottom: 1rem; }
.diary-entries, .reminder-entries, .vault-entries { display: grid; gap: .9rem; }
.record-card { padding: 1.25rem; min-width: 0; }
.record-card time, .record-meta { font-size: .875rem; color: var(--muted); }
.diary-card h2 { margin: .55rem 0; }
.diary-card p, .reminder-card p { color: var(--muted); overflow-wrap: anywhere; white-space: pre-wrap; }
.diary-card p { margin: .55rem 0 0; line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.diary-card .card-heading button { align-self: start; }
.empty-state { color: var(--muted); margin: 0; padding: 1.25rem; }
.reminder-tools, .check-field, .reminder-buttons { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.check-field { margin: 0; cursor: pointer; }
.check-field input { width: auto; margin: 0; accent-color: var(--accent); }
.reminder-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .75rem; align-items: center; }
.reminder-card time { display: block; margin-top: .4rem; }
.reminder-card p { margin: .55rem 0 0; }
.reminder-status { display: inline-block; color: #80521a; margin-left: .5rem; font-size: .875rem; }
.reminder-status.completed { color: var(--muted); }
.vault-entries { grid-template-columns: repeat(auto-fit, minmax(min(19rem, 100%), 1fr)); }
.vault-card-title { min-width: 0; }
.vault-card .card-heading button { flex: 0 0 auto; }
.vault-card .record-meta { display: inline-block; margin-top: .3rem; }
.vault-details { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .4rem .7rem; margin: .85rem 0 0; }
.vault-details dt { color: var(--muted); }
.vault-details dd { margin: 0; overflow-wrap: anywhere; }
.vault-copy-actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: .55rem; }
.copy-feedback { color: var(--accent); font-size: .875rem; margin: 0 0 .6rem; }
.copy-feedback:empty { margin: 0; }
.secret-row + .copy-feedback:not(:empty) { margin-top: .5rem; }
.vault-unlock { width: min(100%, 30rem); }
.vault-unlock label { margin: 1.25rem 0; }

.notes-pane { display: grid; min-height: 100dvh; grid-template-columns: 19rem minmax(0, 1fr); }
.notes-side { display: flex; flex-direction: column; gap: .75rem; padding: 1.45rem 1.125rem; border-right: 1px solid var(--line); }
.notes-side h1 { font-size: 1.5rem; margin: 0; }
.notes-side .list { max-height: calc(100dvh - 10rem); }
.notes-content { display: flex; min-width: 0; }
.notes-content .editor { height: min(100dvh, 82rem); }
.notes-content #body { padding-top: .7rem; }
.modal { z-index: 2; }
dialog {
  width: min(37rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  background: var(--paper);
  color: var(--ink);
  padding: 0;
  box-shadow: 0 22px 65px rgb(20 41 29 / .22);
}
dialog::backdrop { background: rgb(17 38 25 / .53); }
.dialog-form { padding: 1.4rem; }
.dialog-form h2 { margin: 0; }
.dialog-form textarea { display: block; resize: vertical; margin-top: .375rem; line-height: 1.6; }
.form-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .8rem; }
.form-columns label { min-width: 0; }
select {
  display: block;
  width: 100%;
  margin-top: .375rem;
  padding: .625rem .75rem;
  border: 1px solid var(--line);
  border-radius: .625rem;
  background: white;
  color: var(--ink);
  font: inherit;
}
.record-actions { display: flex; gap: .8rem; justify-content: end; margin-top: .9rem; }
.secret-row { display: flex; align-items: center; gap: .45rem; }
.secret-row button { white-space: nowrap; }
.danger { color: var(--danger) !important; }
.notice-tray { position: fixed; bottom: 1rem; right: 1rem; z-index: 3; display: grid; gap: .5rem; width: min(24rem, calc(100% - 2rem)); }
.notice { background: var(--sidebar); color: white; text-align: left; padding: .9rem; box-shadow: var(--shadow); }

@media (max-width: 920px) {
  .shell { grid-template-columns: 11.5rem minmax(0, 1fr); }
  .navigation { padding-inline: .75rem; }
  .notes-pane { grid-template-columns: 13.5rem minmax(0, 1fr); }
  .notes-side .card-heading { flex-wrap: wrap; }
  .reminder-card { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 680px) {
  .shell { display: block; }
  .navigation {
    height: auto;
    min-height: 60px;
    z-index: 1;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: .65rem;
    padding: .5rem .75rem;
  }
  .navigation .brand { margin: 0; min-width: 0; flex: 1; }
  .navigation .mark { flex: none; }
  .navigation .brand div { min-width: 0; }
  .navigation .brand em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .navigation-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    flex: none;
    min-width: 88px;
    min-height: 44px;
    padding: .5rem .75rem;
    border: 1px solid #54705e;
    background: transparent;
    color: var(--sidebar-ink);
  }
  .navigation-toggle-icon { font-size: 1.25rem; line-height: 1; width: 1.25rem; }
  .navigation-panel {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    max-height: calc(100vh - 64px);
    max-height: calc(100dvh - 64px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: .8rem .75rem;
    gap: .75rem;
    background: var(--sidebar);
    border-bottom: 1px solid #54705e;
    box-shadow: 0 12px 22px rgb(0 0 0 / .18);
  }
  .navigation[data-menu-open="true"] .navigation-panel { display: flex; }
  .navigation nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .navigation nav button {
    justify-content: center;
    min-height: 44px;
    padding: .35rem .2rem;
    border-color: #385447;
    font-size: .875rem;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
  }
  .navigation nav button span { display: none; }
  .account-actions { margin: 0; gap: .6rem; border-top: 1px solid #385447; padding-top: .5rem; }
  .account-actions button { min-height: 44px; white-space: nowrap; }
  .overview-grid { grid-template-columns: 1fr; }
  .notes-pane { display: block; min-height: calc(100dvh - 7rem); }
  .notes-side { border-right: 0; border-bottom: 1px solid var(--line); }
  .notes-side .list { max-height: 11rem; }
  .notes-content .editor { min-height: 25rem; height: 58dvh; }
  .notes-content .empty { padding: 2rem 1rem; }
}
@media (max-width: 375px) {
  .workspace-view { padding: 1rem .8rem; }
  .view-header { flex-wrap: wrap; }
  .form-columns { grid-template-columns: 1fr; gap: 0; }
}
