:root {
  color-scheme: light;
  --paper: #f4efe3;
  --paper-deep: #e9ddc8;
  --ink: #2a2118;
  --muted: #776a59;
  --line: #d9d0c3;
  --line-strong: #7aa395;
  --surface: rgba(255, 250, 240, 0.9);
  --surface-solid: #fff9ed;
  --accent: #2f6f63;
  --accent-soft: #e7efe5;
  --cinnabar: #2f6f63;
  --gold: #7d9a61;
  --shadow: 0 18px 54px rgba(68, 45, 20, 0.1);
  --shadow-soft: 0 10px 30px rgba(68, 45, 20, 0.08);
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  --serif: "PingFang SC", "Hiragino Sans GB", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  touch-action: pan-x pan-y;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 0%, rgba(47, 111, 99, 0.14), transparent 26rem),
    radial-gradient(circle at 92% 10%, rgba(125, 154, 97, 0.12), transparent 28rem),
    linear-gradient(90deg, rgba(47, 111, 99, 0.08), transparent 28%, rgba(125, 154, 97, 0.08)),
    repeating-linear-gradient(0deg, rgba(107, 85, 54, 0.035) 0 1px, transparent 1px 7px),
    var(--paper);
  font-family: var(--serif);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.36), transparent 38%, rgba(126, 83, 36, 0.08)),
    repeating-linear-gradient(90deg, rgba(104, 76, 42, 0.025) 0 1px, transparent 1px 7px);
  pointer-events: none;
}

button,
input {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(71, 107, 82, 0.45);
  outline-offset: 2px;
}

button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 252, 246, 0.95);
}

button:active {
  transform: translateY(1px);
}

.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(246, 238, 222, 0.9);
  font-family: var(--sans);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 12px;
  align-items: baseline;
}

.brand-lockup::before {
  display: grid;
  grid-row: 1 / span 2;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(47, 111, 99, 0.48);
  border-radius: 6px;
  color: var(--cinnabar);
  content: "食";
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  background: rgba(255, 247, 232, 0.75);
}

.app-bar strong {
  color: #21170f;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0;
}

.app-bar span,
.meta,
.empty,
.result-summary {
  color: var(--muted);
  font: 13px/1.45 var(--sans);
}

.mode-switch {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(47, 111, 99, 0.18);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.64);
}

.mode-switch button {
  min-height: 30px;
  padding: 0 12px;
}

.account-tools {
  display: flex;
  gap: 6px;
  align-items: center;
}

.user-button {
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-button.is-signed-in {
  border-color: rgba(47, 111, 99, 0.46);
  color: var(--accent);
  background: rgba(231, 239, 229, 0.82);
}

.sync-button {
  flex: 0 0 auto;
  border-color: rgba(47, 111, 99, 0.22);
  color: var(--muted);
}

.sync-button.is-ready {
  border-color: rgba(47, 111, 99, 0.42);
  color: var(--accent);
  background: rgba(231, 239, 229, 0.72);
}

.sync-button:disabled {
  cursor: progress;
  opacity: 0.72;
}

.shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 16px max(14px, env(safe-area-inset-right)) 26px max(14px, env(safe-area-inset-left));
}

.search-panel {
  display: grid;
  grid-template-columns: minmax(168px, 0.3fr) minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(212, 195, 166, 0.72);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.72);
  font-family: var(--sans);
  box-shadow: 0 10px 28px rgba(74, 52, 25, 0.08);
}

.search-heading {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.search-heading span {
  color: var(--cinnabar);
  font: 12px/1.2 var(--sans);
}

.search-heading strong {
  overflow: hidden;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-box {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: rgba(255, 253, 247, 0.92);
  box-shadow: inset 0 1px 3px rgba(86, 57, 23, 0.08);
}

.search-box span {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid rgba(47, 111, 99, 0.22);
  border-radius: 50%;
  color: var(--cinnabar);
  font-weight: 700;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 16px;
}

.search-box input::placeholder {
  color: rgba(119, 106, 89, 0.82);
}

.result-summary {
  justify-self: end;
  white-space: nowrap;
}

.smart-panel {
  display: grid;
  grid-column: 1 / -1;
  gap: 12px;
  margin: 0;
}

.smart-panel:empty {
  display: none;
}

.need-panel,
.filter-panel,
.tool-drawer,
.directory-panel {
  border: 1px solid rgba(217, 208, 195, 0.9);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.78);
  box-shadow: 0 10px 28px rgba(74, 52, 25, 0.06);
}

.panel-head strong,
.directory-head strong {
  color: var(--accent);
  font-size: 16px;
}

.reading-controls,
.detail-actions,
.detail-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.reading-controls button,
.detail-actions button,
.filter-group button,
.relation-chips button,
.detail-tabs button,
.recent-strip button,
.directory-grid button,
.tag-add-button,
.tag-delete-button,
.tag-add-form button {
  min-height: 31px;
  padding: 0 10px;
  font: 13px/1.2 var(--sans);
}

.need-panel {
  padding: 13px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-head button:disabled {
  opacity: 0.45;
}

.need-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 9px;
}

.need-card {
  position: relative;
  display: grid;
  gap: 4px;
  min-height: 72px;
  padding: 10px 32px 10px 11px;
  text-align: left;
}

.need-card span {
  color: var(--ink);
  font-weight: 700;
}

.need-card small {
  color: var(--muted);
  font: 12px/1.35 var(--sans);
}

.need-card b {
  position: absolute;
  top: 9px;
  right: 10px;
  color: var(--accent);
  font: 700 13px/1 var(--sans);
}

.need-card.is-active,
.filter-group button[aria-pressed="true"],
.reading-controls button[aria-pressed="true"],
.mode-switch button[aria-pressed="true"],
.detail-tabs button[aria-pressed="true"] {
  border-color: rgba(47, 111, 99, 0.48);
  color: var(--accent);
  background: linear-gradient(90deg, rgba(47, 111, 99, 0.14), rgba(125, 154, 97, 0.08));
}

.tool-drawer {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.search-panel .tool-drawer {
  border-color: rgba(217, 208, 195, 0.66);
  background: rgba(255, 250, 240, 0.48);
  box-shadow: none;
}

.recent-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 7px;
  align-items: center;
  overflow: hidden;
  max-width: 100%;
  padding: 4px 2px 8px;
  white-space: nowrap;
}

.recent-strip strong {
  color: var(--accent);
  font: 700 13px/1.35 var(--sans);
}

.subtle-button {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--muted);
  background: rgba(255, 250, 240, 0.5);
}

.recent-strip button:not(.subtle-button) {
  overflow: hidden;
  max-width: 8.5em;
  flex: 0 1 auto;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-section {
  border-top: 1px solid rgba(217, 208, 195, 0.76);
  padding-top: 8px;
}

.drawer-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.drawer-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
}

.drawer-section summary::-webkit-details-marker {
  display: none;
}

.drawer-section summary::after {
  content: "展开";
  color: var(--muted);
  font: 12px/1.2 var(--sans);
}

.drawer-section[open] summary::after {
  content: "收起";
}

.drawer-section summary span {
  color: var(--muted);
  font: 12px/1.35 var(--sans);
}

.tool-drawer .panel-head {
  margin: 6px 0 10px;
}

.tool-drawer .panel-head span {
  color: var(--muted);
  font: 12px/1.5 var(--sans);
}

.tool-drawer .filter-panel {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 8px 0 2px;
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding: 12px;
}

.filter-head {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.filter-head strong {
  color: var(--accent);
  font-size: 16px;
}

.filter-head span {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font: 12px/1.45 var(--sans);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.filter-group > span {
  flex: 0 0 100%;
  color: var(--accent);
  font: 700 13px/1.3 var(--sans);
}

.directory-panel {
  padding: 12px;
}

.directory-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.directory-head span {
  color: var(--muted);
  font: 13px/1.4 var(--sans);
}

.directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 8px;
}

.directory-grid button {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 9px 11px;
  text-align: left;
}

.directory-grid button strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.directory-grid button span {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font: 12px/1.35 var(--sans);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.content {
  display: grid;
  grid-template-columns: 160px minmax(260px, 340px) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  min-height: calc(100vh - 164px);
}

.category-pane,
.entry-list,
.entry-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.category-pane {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 112px);
  overflow: auto;
  padding: 13px;
}

.pane-title {
  margin: 0 0 10px;
  color: var(--cinnabar);
  font-size: 15px;
  font-weight: 700;
}

.category-tabs {
  display: grid;
  gap: 8px;
  scrollbar-width: thin;
}

.category-tabs button {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  font-family: var(--serif);
  text-align: left;
}

button[aria-pressed="true"],
.entry-button.is-active {
  border-color: rgba(47, 111, 99, 0.42);
  background: linear-gradient(90deg, rgba(47, 111, 99, 0.13), rgba(125, 154, 97, 0.08));
}

.entry-list {
  max-height: calc(100vh - 166px);
  overflow: auto;
  scrollbar-width: thin;
}

.entry-list-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.97);
  color: var(--muted);
  font: 13px/1.4 var(--sans);
}

.entry-button {
  position: relative;
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 78px;
  padding: 11px 13px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
  background: transparent;
  box-shadow: none;
}

.entry-button::before {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 3px;
  border-radius: 0 4px 4px 0;
  content: "";
  background: transparent;
  transition: background-color 180ms ease;
}

.entry-button.is-active::before {
  background: var(--accent);
}

.entry-button:last-child {
  border-bottom: 0;
}

.entry-button strong {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.snippet {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font: 13px/1.5 var(--sans);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.entry-detail {
  min-height: calc(100vh - 166px);
  overflow: auto;
  padding: clamp(20px, 3vw, 34px);
  background:
    linear-gradient(90deg, rgba(47, 111, 99, 0.08), transparent 22%),
    var(--surface-solid);
}

.mobile-detail-nav {
  display: none;
}

.floating-back-button {
  display: none;
}

.detail-actions {
  justify-content: flex-start;
  margin-bottom: 14px;
}

.detail-tabs {
  margin: 12px 0 14px;
  padding: 4px;
  border: 1px solid rgba(47, 111, 99, 0.18);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.64);
}

.entry-detail h1 {
  margin: 0 0 10px;
  color: #21170f;
  font-family: var(--serif);
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: 0;
}

.favorite-star {
  min-width: 0;
  min-height: 0;
  margin-left: 10px;
  padding: 0 4px;
  border: 0;
  color: rgba(47, 111, 99, 0.55);
  background: transparent;
  box-shadow: none;
  font-size: 0.58em;
  vertical-align: 0.16em;
}

.favorite-star.is-on {
  color: var(--accent);
}

.entry-detail .category {
  display: inline-block;
  margin: 0 8px 12px 0;
  padding: 4px 9px;
  border: 1px solid rgba(71, 107, 82, 0.22);
  border-radius: 6px;
  color: var(--accent);
  background: var(--accent-soft);
  font: 13px/1.4 var(--sans);
}

.alias-row {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--muted);
  font: 14px/1.5 var(--sans);
}

.structured-summary,
.safety-card,
.personal-note {
  border: 1px solid rgba(217, 208, 195, 0.86);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.7);
}

.structured-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
}

.structured-summary .tag-group {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.structured-summary strong {
  flex: 0 0 100%;
  color: var(--accent);
  font: 700 13px/1.3 var(--sans);
}

.tag-item {
  position: relative;
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.structured-summary .tag-chip {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-height: 28px;
  padding: 3px 7px;
  border: 1px solid rgba(47, 111, 99, 0.16);
  border-radius: 999px;
  background: rgba(231, 239, 229, 0.72);
  font: 12px/1.35 var(--sans);
}

.tag-chip > span {
  padding: 0;
  border: 0;
  background: transparent;
}

.tag-chip.is-active {
  border-color: rgba(47, 111, 99, 0.42);
  color: var(--accent);
  background: rgba(231, 239, 229, 0.95);
}

.tag-add-button {
  display: grid;
  place-items: center;
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 999px;
  color: var(--accent);
  font-weight: 700;
}

.tag-delete-button {
  min-height: 28px;
  padding: 0 8px;
  border-color: rgba(138, 90, 38, 0.26);
  color: #8a5a26;
  background: rgba(255, 247, 231, 0.92);
}

.tag-add-form {
  display: flex;
  flex: 0 0 100%;
  gap: 6px;
  min-width: 0;
  margin-top: 2px;
}

.tag-add-form input {
  min-width: 0;
  width: min(100%, 160px);
  height: 31px;
  border: 1px solid rgba(217, 208, 195, 0.9);
  border-radius: 6px;
  padding: 0 9px;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.86);
  font: 13px/1.2 var(--sans);
}

.safety-card {
  margin-top: 14px;
  padding: 9px 10px;
  border-color: rgba(154, 99, 47, 0.22);
  background: rgba(255, 247, 231, 0.78);
}

.safety-card.quiet {
  color: var(--muted);
  font: 13px/1.55 var(--sans);
}

.entry-detail .safety-card strong {
  display: inline;
  margin-right: 6px;
  color: #8a5a26;
  font: 700 12px/1.45 var(--sans);
}

.entry-detail .safety-card p {
  display: inline;
  margin: 0 0.8em 0 0;
  color: var(--muted);
  font: 12px/1.55 var(--sans);
}

.entry-section {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid rgba(212, 195, 166, 0.56);
}

.entry-section h2,
.section-toggle {
  color: var(--cinnabar);
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.35;
}

.entry-section h2 {
  margin: 0 0 8px;
}

.section-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-color: rgba(47, 111, 99, 0.24);
  background: rgba(250, 241, 224, 0.72);
}

.collapsible-body {
  display: none;
  padding-top: 10px;
}

.original-section.is-open .collapsible-body {
  display: block;
}

.entry-detail p {
  margin: 0 0 0.9em;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.92;
}

.note-ref {
  margin: 0 0.08em;
  color: var(--cinnabar);
  cursor: pointer;
  font-size: 0.64em;
  line-height: 0;
  vertical-align: super;
}

.note-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.note-list li {
  color: var(--muted);
  font: 14px/1.72 var(--sans);
}

.note-list sup {
  margin-right: 4px;
  color: var(--cinnabar);
  font-size: 0.76em;
  vertical-align: super;
}

.knowledge-graph {
  display: block;
  width: min(100%, 560px);
  margin: 4px auto 10px;
}

.knowledge-graph path {
  fill: none;
  stroke: rgba(47, 111, 99, 0.28);
  stroke-width: 1.4;
}

.knowledge-graph circle {
  fill: #f8f4ea;
  stroke: rgba(47, 111, 99, 0.42);
  stroke-width: 1.5;
}

.knowledge-graph .graph-center circle {
  fill: rgba(47, 111, 99, 0.16);
  stroke: var(--accent);
}

.knowledge-graph text {
  dominant-baseline: middle;
  fill: var(--ink);
  font: 13px/1 var(--serif);
  pointer-events: none;
  text-anchor: middle;
}

.knowledge-graph .edge-label {
  fill: var(--accent);
  font: 9px/1 var(--sans);
  opacity: 0.8;
}

.graph-node {
  cursor: pointer;
}

.graph-node:hover circle {
  fill: var(--accent-soft);
  stroke: var(--accent);
}

.relation-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.relation-chips button {
  display: grid;
  gap: 3px;
  width: min(100%, 280px);
  min-height: 46px;
  padding: 7px 10px;
  text-align: left;
}

.relation-chips button strong {
  color: var(--ink);
  font: 700 13px/1.2 var(--sans);
}

.relation-chips button span {
  color: var(--muted);
  font: 12px/1.35 var(--sans);
}

.personal-note {
  padding: 12px;
}

.personal-note textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.9);
  font: 15px/1.65 var(--sans);
}

.note-popover {
  position: fixed;
  z-index: 90;
  padding: 10px 12px;
  border: 1px solid rgba(47, 111, 99, 0.28);
  border-radius: 8px;
  background: var(--surface-solid);
  box-shadow: 0 16px 44px rgba(42, 33, 24, 0.22);
}

.note-popover strong {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font: 700 13px/1.4 var(--sans);
}

.note-popover p {
  margin: 0;
  color: var(--ink);
  font: 14px/1.65 var(--sans);
}

.notes-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(42, 33, 24, 0.28);
  backdrop-filter: blur(6px);
}

.notes-panel {
  width: min(680px, 100%);
  max-height: min(680px, calc(100vh - 36px));
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(47, 111, 99, 0.28);
  border-radius: 10px;
  background: var(--surface-solid);
  box-shadow: 0 24px 80px rgba(42, 33, 24, 0.24);
}

.notes-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.notes-panel header strong {
  color: var(--accent);
  font-size: 20px;
}

.notes-panel article {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.notes-panel article button {
  padding: 0;
  border: 0;
  color: var(--accent);
  background: transparent;
  box-shadow: none;
  font-weight: 700;
}

.notes-panel article p {
  margin: 6px 0 0;
  white-space: pre-wrap;
  font: 14px/1.7 var(--sans);
}

.account-overlay {
  position: fixed;
  inset: 0;
  z-index: 96;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(42, 33, 24, 0.28);
  backdrop-filter: blur(8px);
}

.account-panel {
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid rgba(47, 111, 99, 0.28);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(231, 239, 229, 0.5), transparent 48%),
    var(--surface-solid);
  box-shadow: 0 24px 80px rgba(42, 33, 24, 0.24);
}

.account-panel header,
.account-actions,
.auth-switch {
  display: flex;
  gap: 8px;
  align-items: center;
}

.account-panel header {
  justify-content: space-between;
  margin-bottom: 12px;
}

.account-panel header strong {
  color: var(--accent);
  font-size: 20px;
}

.auth-switch {
  padding: 4px;
  border: 1px solid rgba(47, 111, 99, 0.16);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.62);
}

.auth-switch button {
  flex: 1;
}

.account-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.account-form label {
  display: grid;
  gap: 5px;
  color: var(--accent);
  font: 700 13px/1.35 var(--sans);
}

.account-form input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 11px;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.92);
  font: 15px/1.2 var(--sans);
}

.account-form button[type="submit"] {
  margin-top: 2px;
  border-color: rgba(47, 111, 99, 0.4);
  color: #fff;
  background: var(--accent);
}

.account-status,
.account-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font: 13px/1.65 var(--sans);
}

.account-message {
  min-height: 1.45em;
  margin: 8px 0 0;
  color: var(--muted);
  font: 13px/1.45 var(--sans);
}

.account-message:empty {
  display: none;
}

.account-message[data-tone="error"] {
  color: #9b4b2a;
}

.account-message[data-tone="info"] {
  color: var(--accent);
}

.account-hint code {
  color: var(--accent);
}

.account-actions {
  flex-wrap: wrap;
  margin-top: 12px;
}

mark {
  border-radius: 3px;
  color: inherit;
  background: #ead083;
  box-shadow: 0 0 0 2px #ead083;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 120;
  max-width: min(360px, calc(100vw - 28px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 860px) {
  body {
    overflow-x: hidden;
  }

  .app-bar {
    min-height: 60px;
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
    flex-wrap: wrap;
  }

  .brand-lockup {
    gap: 2px 9px;
  }

  .brand-lockup::before {
    width: 30px;
    height: 30px;
    font-size: 18px;
  }

  .shell {
    overflow: hidden;
    padding: 12px max(10px, env(safe-area-inset-right)) 18px max(10px, env(safe-area-inset-left));
  }

  .search-panel {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .filter-panel {
    grid-template-columns: 1fr;
  }

  .search-heading strong {
    white-space: normal;
  }

  .result-summary {
    justify-self: start;
    white-space: normal;
  }

  .content {
    grid-template-columns: clamp(92px, 26vw, 122px) minmax(0, 1fr);
    gap: 8px;
    min-height: calc(100dvh - 170px);
    width: 100%;
    transform: none;
    transition: none;
  }

  .category-pane,
  .entry-list,
  .entry-detail {
    max-height: calc(100dvh - 156px);
  }

  .category-pane {
    position: static;
    padding: 9px;
    transform: translateZ(0);
  }

  .pane-title {
    margin-bottom: 8px;
    font-size: 13px;
  }

  .category-tabs {
    gap: 6px;
  }

  .category-tabs button {
    min-height: 42px;
    padding: 0 7px;
    font-size: 13px;
    line-height: 1.25;
    text-align: center;
  }

  .entry-detail {
    display: none;
    overflow: auto;
    padding: 18px;
  }

  .content.is-entry-selected {
    display: block;
    min-height: 0;
  }

  .content.is-entry-selected .category-pane {
    display: none;
  }

  .content.is-entry-selected .entry-detail {
    display: block;
    min-height: calc(100dvh - 86px);
    max-height: none;
    padding: 18px;
    animation: detailIn 260ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .content.is-entry-selected::before {
    position: fixed;
    inset: 0;
    z-index: 50;
    content: "";
    background: rgba(42, 33, 24, 0);
    pointer-events: none;
    transition: background-color 220ms ease;
  }

  .content.is-entry-selected.is-list-drawer-open::before {
    background: rgba(42, 33, 24, 0.2);
    pointer-events: auto;
  }

  .content.is-entry-selected .entry-list {
    position: fixed;
    top: var(--detail-drawer-top, calc(70px + env(safe-area-inset-top)));
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    z-index: 60;
    width: min(78vw, 320px);
    max-height: none;
    transform: translateX(calc(-100% - 20px));
    transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .content.is-entry-selected.is-list-drawer-open .entry-list {
    transform: translateX(0);
  }

  .content.is-entry-selected .entry-button {
    min-height: 50px;
    padding: 9px 10px 9px 12px;
  }

  .content.is-entry-selected .entry-button .meta,
  .content.is-entry-selected .entry-button .snippet {
    display: none;
  }

  .content.is-entry-selected .entry-button strong {
    white-space: normal;
    display: -webkit-box;
    overflow: hidden;
    font-size: 15px;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .entry-list-header {
    display: flex;
  }

  .entry-list-header button {
    display: none;
    min-height: 28px;
  }

  .content.is-entry-selected .entry-list-header button {
    display: inline-flex;
  }

  .mobile-detail-nav {
    display: flex;
    margin: -4px 0 14px;
    color: var(--muted);
    font: 12px/1.45 var(--sans);
  }

  .floating-back-button {
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 45;
    display: block;
    min-height: 42px;
    padding: 0 15px;
    border-color: rgba(47, 111, 99, 0.44);
    color: #fff;
    background: rgba(47, 111, 99, 0.92);
    box-shadow: 0 12px 34px rgba(42, 33, 24, 0.24);
  }

  .entry-detail p {
    font-size: 18px;
    line-height: 1.86;
  }

  .detail-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .app-bar strong {
    font-size: 18px;
  }

  .content {
    grid-template-columns: clamp(82px, 25vw, 104px) minmax(0, 1fr);
  }

  .category-pane,
  .entry-list,
  .entry-detail {
    max-height: calc(100dvh - 172px);
  }

  .mode-switch {
    order: 3;
    width: 100%;
  }

  .mode-switch button {
    flex: 1;
  }

  .need-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@keyframes detailIn {
  from {
    opacity: 0.72;
    transform: translateX(12px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
