:root {
  color-scheme: light;
  --bg: #f3eee5;
  --bg-soft: #f8f4ed;
  --paper: #fffdf8;
  --paper-strong: #ffffff;
  --ink: #273129;
  --muted: #778077;
  --muted-strong: #5d675e;
  --line: rgba(48, 56, 49, 0.12);
  --line-strong: rgba(48, 56, 49, 0.2);
  --accent: #c96341;
  --accent-deep: #a84b2f;
  --accent-soft: #f4dfd4;
  --sage: #6f8f76;
  --sage-soft: #dfe9df;
  --gold: #b88435;
  --danger: #a7463a;
  --shadow-sm: 0 1px 2px rgba(49, 44, 35, 0.05), 0 8px 24px rgba(49, 44, 35, 0.05);
  --shadow-md: 0 16px 60px rgba(47, 41, 31, 0.14);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --font: "Avenir Next", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", ui-sans-serif, sans-serif;
  --serif: "Iowan Old Style", "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1d2420;
  --bg-soft: #232b26;
  --paper: #29312c;
  --paper-strong: #303a33;
  --ink: #f1eee7;
  --muted: #9da89f;
  --muted-strong: #c4cbc5;
  --line: rgba(239, 236, 228, 0.12);
  --line-strong: rgba(239, 236, 228, 0.22);
  --accent: #df7d58;
  --accent-deep: #f09069;
  --accent-soft: #48342c;
  --sage: #8faf96;
  --sage-soft: #31443a;
  --gold: #d2a35a;
  --danger: #e27b6f;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.12), 0 12px 32px rgba(0, 0, 0, 0.16);
  --shadow-md: 0 24px 72px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(208, 151, 112, 0.12), transparent 28rem),
    radial-gradient(circle at 88% 85%, rgba(111, 143, 118, 0.12), transparent 30rem),
    var(--bg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 42%, transparent);
  outline-offset: 2px;
}

svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sprite {
  position: fixed;
  width: 0;
  height: 0;
  overflow: hidden;
}

.app-shell {
  display: grid;
  grid-template-columns: 278px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 18px 18px;
  overflow-y: auto;
  background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  overflow: hidden;
  background: var(--ink);
  border-radius: 12px 12px 12px 4px;
  box-shadow: 0 8px 18px rgba(42, 46, 40, 0.18);
}

.brand-mark span {
  position: absolute;
  display: block;
  width: 19px;
  height: 1.5px;
  background: var(--paper);
  border-radius: 2px;
  transform-origin: center;
}

.brand-mark span:nth-child(1) {
  transform: translateY(-5px) rotate(-8deg);
}

.brand-mark span:nth-child(2) {
  width: 15px;
  transform: rotate(-8deg);
}

.brand-mark span:nth-child(3) {
  width: 11px;
  transform: translateY(5px) rotate(-8deg);
}

.brand strong {
  display: block;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.09em;
  line-height: 1.1;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.15em;
}

.icon-button,
.mini-button,
.editor-back {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--muted-strong);
  background: transparent;
  border: 0;
  border-radius: 11px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.icon-button:hover,
.mini-button:hover,
.editor-back:hover {
  color: var(--ink);
  background: var(--line);
}

.icon-button:active,
.mini-button:active,
.editor-back:active {
  transform: scale(0.95);
}

.sidebar-close,
.menu-button {
  display: none;
}

.profile-switch {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  margin: 26px 0 18px;
  padding: 12px;
  text-align: left;
  background: color-mix(in srgb, var(--paper) 74%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: border-color 160ms ease, transform 160ms ease;
}

.profile-switch:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.profile-switch > svg {
  width: 16px;
  height: 16px;
  margin-left: auto;
  color: var(--muted);
}

.profile-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.profile-copy small {
  color: var(--muted);
  font-size: 11px;
}

.profile-copy strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #fff;
  background: var(--sage);
  border: 2px solid color-mix(in srgb, var(--paper) 86%, transparent);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(37, 47, 39, 0.13);
  font-size: 17px;
  line-height: 1;
}

.avatar-large {
  width: 44px;
  height: 44px;
  font-size: 20px;
}

.primary-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 43px;
  padding: 8px 11px;
  color: var(--muted-strong);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 11px;
  transition: background 140ms ease, color 140ms ease;
}

.nav-item:hover {
  color: var(--ink);
  background: var(--line);
}

.nav-item.active {
  color: var(--accent-deep);
  background: var(--accent-soft);
  font-weight: 600;
}

.nav-item svg {
  width: 18px;
  height: 18px;
}

.nav-count {
  min-width: 20px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.nav-item.active .nav-count {
  color: var(--accent-deep);
}

.sidebar-section {
  margin-top: 24px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.mini-button {
  width: 26px;
  height: 26px;
  border-radius: 8px;
}

.mini-button svg {
  width: 15px;
  height: 15px;
}

.notebook-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.notebook-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 6px 12px;
  color: var(--muted-strong);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 9px;
}

.notebook-item:hover,
.notebook-item.active {
  color: var(--ink);
  background: var(--line);
}

.notebook-item.active {
  font-weight: 600;
}

.notebook-dot {
  width: 7px;
  height: 7px;
  background: var(--notebook-color, var(--sage));
  border-radius: 50%;
}

.notebook-count {
  color: var(--muted);
  font-size: 11px;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 8px 0;
}

.tag-chip {
  padding: 5px 9px;
  color: var(--muted-strong);
  background: color-mix(in srgb, var(--paper) 64%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.tag-chip:hover,
.tag-chip.active {
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-color: transparent;
}

.tag-empty {
  color: var(--muted);
  font-size: 11px;
}

.sidebar-footer {
  display: grid;
  gap: 3px;
  margin-top: auto;
  padding-top: 24px;
}

.footer-action {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 7px 11px;
  color: var(--muted-strong);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 9px;
}

.footer-action:hover {
  color: var(--ink);
  background: var(--line);
}

.footer-action svg {
  width: 17px;
  height: 17px;
}

.local-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 13px 11px 2px;
  color: var(--muted);
  font-size: 10px;
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #78a67b;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(120, 166, 123, 0.14);
}

.sidebar-backdrop {
  display: none;
}

.main-panel {
  min-width: 0;
  padding: 0 clamp(24px, 5vw, 72px) 72px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 86px;
  padding: 16px 0;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 94%, transparent) 60%, transparent);
  backdrop-filter: blur(12px);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(520px, 48vw);
  height: 44px;
  padding: 0 12px 0 15px;
  color: var(--muted);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow-sm);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.search-box:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent);
}

.search-box svg {
  width: 18px;
  height: 18px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  padding: 0;
  background: transparent;
  border: 0;
  outline: 0;
}

.search-box input::placeholder {
  color: var(--muted);
}

.search-box kbd {
  padding: 2px 6px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: inherit;
  font-size: 10px;
  white-space: nowrap;
}

.search-clear {
  display: none;
  place-items: center;
  width: 25px;
  height: 25px;
  padding: 0;
  color: var(--muted);
  background: var(--line);
  border: 0;
  border-radius: 50%;
}

.search-clear svg {
  width: 13px;
  height: 13px;
}

.search-box.has-value .search-clear {
  display: grid;
}

.search-box.has-value kbd {
  display: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.primary-button,
.outline-button,
.text-danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 16px;
  border-radius: 11px;
  font-weight: 600;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.primary-button {
  color: #fffdf8;
  background: var(--accent);
  border: 1px solid transparent;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 24%, transparent);
}

.primary-button:hover {
  background: var(--accent-deep);
  transform: translateY(-1px);
}

.primary-button:active,
.outline-button:active {
  transform: translateY(1px);
}

.primary-button svg,
.outline-button svg {
  width: 17px;
  height: 17px;
}

.outline-button {
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
}

.outline-button:hover {
  background: var(--bg-soft);
  border-color: color-mix(in srgb, var(--ink) 28%, transparent);
}

.avatar-button {
  padding: 0;
  border: 0;
}

.content {
  max-width: 1320px;
  margin: 0 auto;
  padding-top: clamp(12px, 3vw, 36px);
}

.content-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.content-header h1 {
  margin-bottom: 7px;
  font-family: var(--serif);
  font-size: clamp(32px, 4.2vw, 52px);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.08;
}

.view-subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 14px;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 5px;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 8px 0 11px;
  color: var(--muted);
  background: color-mix(in srgb, var(--paper) 66%, transparent);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 11px;
}

.sort-control select {
  max-width: 88px;
  padding: 0;
  color: var(--muted-strong);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 11px;
}

.layout-toggle {
  display: flex;
  padding: 3px;
  background: color-mix(in srgb, var(--paper) 66%, transparent);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.layout-toggle button {
  display: grid;
  place-items: center;
  width: 29px;
  height: 28px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.layout-toggle button.active {
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 1px 4px rgba(43, 42, 36, 0.08);
}

.layout-toggle svg {
  width: 15px;
  height: 15px;
}

.result-summary {
  min-height: 19px;
  margin: -12px 0 18px;
  color: var(--muted);
  font-size: 11px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.notes-grid.list-layout {
  grid-template-columns: 1fr;
  gap: 9px;
}

.note-card {
  position: relative;
  display: flex;
  min-height: 230px;
  flex-direction: column;
  padding: 20px;
  overflow: hidden;
  color: inherit;
  text-align: left;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--note-color) 5%, transparent), transparent 50%),
    var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  animation: card-in 240ms ease both;
}

.note-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--note-color);
  content: "";
  opacity: 0.74;
}

.note-card:hover {
  z-index: 1;
  border-color: var(--line-strong);
  box-shadow: 0 16px 42px rgba(50, 45, 36, 0.1);
  transform: translateY(-3px);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
}

.note-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.note-owner {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
}

.note-owner-avatar {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: #fff;
  background: var(--owner-color);
  border-radius: 50%;
  font-size: 10px;
}

.card-actions {
  display: flex;
  gap: 1px;
  opacity: 0.45;
  transition: opacity 150ms ease;
}

.note-card:hover .card-actions {
  opacity: 1;
}

.card-action {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
}

.card-action:hover {
  color: var(--ink);
  background: var(--line);
}

.card-action.active {
  color: var(--gold);
}

.card-action svg {
  width: 15px;
  height: 15px;
}

.note-card h3 {
  display: -webkit-box;
  margin-bottom: 10px;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 650;
  line-height: 1.32;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.note-excerpt {
  display: -webkit-box;
  margin-bottom: 18px;
  overflow: hidden;
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-line;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.note-card-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.note-tag {
  max-width: 110px;
  padding: 3px 7px;
  overflow: hidden;
  color: var(--muted-strong);
  background: color-mix(in srgb, var(--note-color) 8%, var(--bg-soft));
  border-radius: 999px;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.trash-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

.trash-actions button {
  flex: 1;
}

.trash-actions .card-restore,
.trash-actions .card-delete-forever {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 31px;
  padding: 5px 8px;
  color: var(--muted-strong);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 10px;
}

.trash-actions .card-delete-forever {
  color: var(--danger);
}

.trash-actions svg {
  width: 13px;
  height: 13px;
}

.notes-grid.list-layout .note-card {
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) minmax(280px, 2fr) auto;
  align-items: center;
  min-height: auto;
  padding: 15px 18px;
}

.notes-grid.list-layout .note-card-top {
  margin: 0;
}

.notes-grid.list-layout .note-card h3 {
  margin: 0 22px;
  font-size: 16px;
  -webkit-line-clamp: 1;
}

.notes-grid.list-layout .note-excerpt,
.notes-grid.list-layout .note-tags {
  display: none;
}

.notes-grid.list-layout .note-card-footer {
  margin: 0;
}

.notes-grid.list-layout .trash-actions {
  display: none;
}

.empty-state {
  display: flex;
  max-width: 430px;
  flex-direction: column;
  align-items: center;
  margin: clamp(60px, 12vh, 140px) auto 0;
  text-align: center;
}

.empty-illustration {
  position: relative;
  width: 138px;
  height: 120px;
  margin-bottom: 27px;
}

.paper {
  position: absolute;
  display: block;
  width: 82px;
  height: 100px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: var(--shadow-sm);
}

.paper-back {
  top: 4px;
  left: 26px;
  transform: rotate(7deg);
}

.paper-front {
  top: 12px;
  left: 37px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 25px 15px;
  transform: rotate(-3deg);
}

.paper-front i {
  display: block;
  height: 3px;
  background: var(--line-strong);
  border-radius: 2px;
}

.paper-front i:nth-child(2) {
  width: 78%;
}

.paper-front i:nth-child(3) {
  width: 56%;
}

.leaf {
  position: absolute;
  display: block;
  width: 24px;
  height: 13px;
  background: var(--sage-soft);
  border-radius: 100% 0 100% 0;
}

.leaf-one {
  top: 21px;
  right: 0;
  transform: rotate(-36deg);
}

.leaf-two {
  bottom: 12px;
  left: 5px;
  background: var(--accent-soft);
  transform: rotate(145deg);
}

.empty-state h2 {
  margin-bottom: 8px;
  font-family: var(--serif);
  font-size: 25px;
}

.empty-state p {
  margin-bottom: 23px;
  color: var(--muted);
}

.mobile-nav {
  display: none;
}

dialog {
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  box-shadow: var(--shadow-md);
}

dialog::backdrop {
  background: rgba(24, 28, 24, 0.44);
  backdrop-filter: blur(5px);
}

.sheet {
  width: min(620px, calc(100vw - 32px));
  max-height: min(86vh, 860px);
  padding: 26px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.settings-dialog {
  width: min(720px, calc(100vw - 32px));
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}

.dialog-head h2 {
  margin-bottom: 0;
  font-family: var(--serif);
  font-size: 27px;
  line-height: 1.25;
}

.dialog-note {
  margin: 18px 4px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.profile-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 12px;
  text-align: left;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 13px;
}

.profile-option:hover {
  border-color: var(--line-strong);
}

.profile-option.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.profile-option-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.profile-option-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-option-copy small {
  color: var(--muted);
  font-size: 10px;
}

.wide-button {
  width: 100%;
  margin-top: 12px;
}

.settings-section {
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

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

.settings-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 15px;
}

.settings-title-row h3 {
  margin-bottom: 4px;
  font-size: 14px;
}

.settings-title-row p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 11px;
}

.settings-icon {
  width: 21px;
  height: 21px;
  color: var(--muted);
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-actions .outline-button {
  flex: 1;
  min-width: 170px;
}

.member-manager-list {
  display: grid;
  gap: 8px;
}

.member-edit-row {
  display: grid;
  grid-template-columns: 42px minmax(100px, 1fr) 62px 46px auto auto;
  align-items: end;
  gap: 8px;
  padding: 10px;
  background: var(--bg-soft);
  border-radius: 11px;
}

.member-edit-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 2px;
  color: #fff;
  background: var(--member-color);
  border-radius: 50%;
}

.member-edit-row .field {
  gap: 3px;
}

.member-edit-row .field > span {
  font-size: 9px;
}

.member-edit-row input[type="text"] {
  height: 35px;
}

.member-edit-row .member-emoji-input {
  text-align: center;
}

.member-edit-row input[type="color"] {
  width: 100%;
  height: 35px;
  padding: 3px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.row-icon-button {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  padding: 0;
  color: var(--muted-strong);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.row-icon-button:hover {
  color: var(--ink);
}

.row-icon-button.danger:hover {
  color: var(--danger);
}

.row-icon-button svg {
  width: 15px;
  height: 15px;
}

.add-member-form {
  margin-top: 14px;
  padding: 15px;
  background: color-mix(in srgb, var(--bg-soft) 68%, transparent);
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
}

.field-grid {
  display: grid;
  gap: 10px;
}

.compact-grid {
  grid-template-columns: minmax(150px, 1fr) 72px 72px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  color: var(--muted);
  font-size: 10px;
}

.field input {
  width: 100%;
  min-height: 39px;
  padding: 8px 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.field input:focus {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}

.add-member-form .outline-button {
  min-height: 36px;
  margin-top: 10px;
  font-size: 11px;
}

.data-note {
  margin-top: 12px;
  padding: 15px;
  color: var(--muted-strong);
  background: var(--bg-soft);
  border-radius: 11px;
  font-size: 11px;
}

.data-note strong {
  display: block;
  margin-bottom: 4px;
}

.data-note p {
  margin-bottom: 0;
}

.note-editor {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  border-radius: 0;
}

.editor-shell {
  display: flex;
  width: 100%;
  height: 100dvh;
  flex-direction: column;
}

.editor-header {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: 10px clamp(15px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
}

.editor-back {
  width: 40px;
  height: 40px;
}

.editor-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.editor-actions .icon-button.active {
  color: var(--gold);
}

.save-button {
  min-height: 36px;
  margin-left: 7px;
  padding: 6px 17px;
  font-size: 12px;
}

.editor-content {
  display: flex;
  width: min(900px, 100%);
  min-height: 0;
  flex: 1;
  flex-direction: column;
  margin: 0 auto;
  padding: clamp(29px, 5vh, 55px) clamp(20px, 5vw, 60px) 0;
}

.note-title-input {
  width: 100%;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 5vw, 46px);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.18;
}

.note-title-input::placeholder {
  color: color-mix(in srgb, var(--muted) 55%, transparent);
}

.editor-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-top: 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.meta-select,
.meta-tags,
.meta-shared {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 31px;
  padding: 4px 9px;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 10px;
}

.meta-select svg,
.meta-tags svg {
  width: 13px;
  height: 13px;
}

.meta-select select,
.meta-tags input {
  min-width: 65px;
  padding: 0;
  color: var(--muted-strong);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 10px;
}

.meta-tags {
  flex: 1;
  min-width: 170px;
}

.meta-tags input {
  width: 100%;
}

.meta-shared {
  cursor: pointer;
}

.meta-shared input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-ui {
  position: relative;
  width: 28px;
  height: 17px;
  background: var(--line-strong);
  border-radius: 999px;
  transition: background 150ms ease;
}

.switch-ui::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  background: var(--paper);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(29, 33, 29, 0.2);
  content: "";
  transition: transform 150ms ease;
}

.meta-shared input:checked + .switch-ui {
  background: var(--sage);
}

.meta-shared input:checked + .switch-ui::after {
  transform: translateX(11px);
}

.editor-tabs {
  display: flex;
  gap: 18px;
  margin-top: 17px;
}

.editor-tabs button {
  padding: 5px 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  font-size: 11px;
}

.editor-tabs button.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 42px;
  margin: 5px -5px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.editor-toolbar::-webkit-scrollbar {
  display: none;
}

.editor-toolbar button {
  flex: 0 0 auto;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  color: var(--muted-strong);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 10px;
}

.editor-toolbar button:hover {
  color: var(--ink);
  background: var(--line);
}

.editor-toolbar button strong,
.editor-toolbar button em {
  font-family: Georgia, serif;
  font-size: 14px;
}

.toolbar-divider {
  width: 1px;
  height: 15px;
  margin: 0 6px;
  background: var(--line);
}

.editor-writing-area {
  position: relative;
  min-height: 0;
  flex: 1;
}

#noteContentInput {
  width: 100%;
  height: 100%;
  min-height: 240px;
  padding: 9px 0 30px;
  resize: none;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.95;
}

#noteContentInput::placeholder {
  color: color-mix(in srgb, var(--muted) 68%, transparent);
}

.markdown-preview {
  height: 100%;
  min-height: 240px;
  padding: 8px 0 30px;
  overflow-y: auto;
  color: var(--muted-strong);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.95;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  margin: 1.2em 0 0.45em;
  color: var(--ink);
  line-height: 1.35;
}

.markdown-preview h1 {
  font-size: 28px;
}

.markdown-preview h2 {
  font-size: 23px;
}

.markdown-preview h3 {
  font-size: 19px;
}

.markdown-preview p {
  margin-bottom: 0.85em;
}

.markdown-preview a {
  color: var(--accent-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.markdown-preview blockquote {
  margin: 1em 0;
  padding: 4px 0 4px 18px;
  color: var(--muted-strong);
  border-left: 3px solid var(--sage);
}

.markdown-preview ul,
.markdown-preview ol {
  padding-left: 1.4em;
}

.markdown-preview li {
  margin-bottom: 0.4em;
}

.markdown-preview hr {
  margin: 1.8em 0;
  border: 0;
  border-top: 1px solid var(--line-strong);
}

.markdown-preview code {
  padding: 2px 5px;
  background: var(--bg-soft);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85em;
}

.markdown-preview .task-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0.25em 0;
}

.markdown-preview .task-line input {
  margin-top: 0.55em;
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 49px;
  padding: 7px clamp(20px, 5vw, 60px);
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 10px;
}

.text-danger-button {
  min-height: 30px;
  padding: 4px 8px;
  color: var(--danger);
  background: transparent;
  border: 0;
  font-size: 10px;
}

.text-danger-button:hover {
  background: color-mix(in srgb, var(--danger) 8%, transparent);
}

.text-danger-button svg {
  width: 14px;
  height: 14px;
}

.toast-region {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 11px 14px;
  color: var(--paper);
  background: var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  font-size: 11px;
  animation: toast-in 180ms ease both;
}

.toast svg {
  width: 15px;
  height: 15px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
}

@media (max-width: 1120px) {
  .notes-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(310px, calc(100vw - 48px));
    transform: translateX(-105%);
    transition: transform 210ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 29;
    display: block;
    visibility: hidden;
    padding: 0;
    background: rgba(27, 31, 27, 0.35);
    border: 0;
    opacity: 0;
    transition: opacity 180ms ease, visibility 180ms ease;
  }

  body.sidebar-open .sidebar-backdrop {
    visibility: visible;
    opacity: 1;
  }

  .sidebar-close,
  .menu-button {
    display: inline-grid;
  }

  .main-panel {
    padding-right: clamp(18px, 4vw, 36px);
    padding-left: clamp(18px, 4vw, 36px);
  }

  .search-box {
    width: auto;
    flex: 1;
  }

  .search-box kbd {
    display: none;
  }

  .topbar {
    min-height: 75px;
  }

  .top-new-button span,
  .theme-button {
    display: none;
  }

  .top-new-button {
    width: 42px;
    padding: 0;
  }

  .top-new-button svg {
    width: 19px;
    height: 19px;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 14px;
  }

  .main-panel {
    padding: 0 16px calc(92px + env(safe-area-inset-bottom));
  }

  .topbar {
    min-height: 66px;
    padding-top: max(10px, env(safe-area-inset-top));
    gap: 7px;
  }

  .menu-button,
  .topbar .icon-button {
    width: 36px;
    height: 36px;
  }

  .search-box {
    height: 40px;
    border-radius: 11px;
  }

  .search-box input {
    font-size: 16px;
  }

  .top-new-button,
  .topbar .avatar-button {
    display: none;
  }

  .content {
    padding-top: 18px;
  }

  .content-header {
    display: block;
    margin-bottom: 20px;
  }

  .content-header h1 {
    margin-bottom: 5px;
    font-size: 34px;
  }

  .view-subtitle {
    max-width: 90%;
    font-size: 12px;
  }

  .view-actions {
    justify-content: space-between;
    margin-top: 17px;
    padding-bottom: 0;
  }

  .layout-toggle {
    margin-left: auto;
  }

  .result-summary {
    margin-top: -7px;
  }

  .notes-grid {
    grid-template-columns: 1fr;
    gap: 11px;
  }

  .note-card {
    min-height: 190px;
    padding: 17px;
  }

  .note-card h3 {
    font-size: 19px;
  }

  .note-excerpt {
    font-size: 12px;
    -webkit-line-clamp: 3;
  }

  .card-actions {
    opacity: 1;
  }

  .notes-grid.list-layout .note-card {
    display: flex;
    min-height: 130px;
    padding: 15px;
  }

  .notes-grid.list-layout .note-card-top {
    margin-bottom: 12px;
  }

  .notes-grid.list-layout .note-card h3 {
    margin: 0 0 9px;
    font-size: 17px;
  }

  .notes-grid.list-layout .note-excerpt {
    display: -webkit-box;
    margin-bottom: 12px;
    -webkit-line-clamp: 2;
  }

  .mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 25;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    min-height: calc(64px + env(safe-area-inset-bottom));
    padding: 5px 13px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(18px);
  }

  .mobile-nav-item {
    display: flex;
    height: 50px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 0;
    font-size: 9px;
  }

  .mobile-nav-item svg {
    width: 19px;
    height: 19px;
  }

  .mobile-nav-item.active {
    color: var(--accent-deep);
  }

  .mobile-create {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin: -24px auto 0;
    padding: 0;
    color: #fff;
    background: var(--accent);
    border: 5px solid var(--bg);
    border-radius: 50%;
    box-shadow: 0 9px 24px color-mix(in srgb, var(--accent) 32%, transparent);
  }

  .mobile-create svg {
    width: 21px;
    height: 21px;
  }

  .sheet {
    width: 100%;
    max-width: none;
    max-height: 88dvh;
    margin: auto 0 0;
    padding: 22px 17px calc(22px + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
    animation: sheet-up 220ms ease both;
  }

  @keyframes sheet-up {
    from {
      transform: translateY(20px);
      opacity: 0;
    }
  }

  .dialog-head {
    margin-bottom: 20px;
  }

  .dialog-head h2 {
    font-size: 24px;
  }

  .profile-grid {
    grid-template-columns: 1fr 1fr;
  }

  .profile-option {
    min-height: 64px;
    padding: 10px;
  }

  .settings-section {
    padding: 17px 0;
  }

  .settings-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .settings-actions .outline-button {
    min-width: 0;
  }

  .member-edit-row {
    grid-template-columns: 38px minmax(90px, 1fr) 54px 38px auto auto;
    gap: 5px;
    padding: 8px;
  }

  .member-edit-avatar {
    width: 36px;
    height: 36px;
  }

  .compact-grid {
    grid-template-columns: 1fr 62px 62px;
  }

  .note-editor {
    width: 100vw;
    height: 100dvh;
    margin: 0;
  }

  .editor-header {
    min-height: 58px;
    padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  }

  .editor-content {
    padding: 22px 18px 0;
  }

  .note-title-input {
    font-size: 31px;
  }

  .editor-meta {
    gap: 6px;
    margin-top: 14px;
    padding-bottom: 15px;
  }

  .meta-tags {
    flex-basis: 100%;
    order: 3;
  }

  .editor-tabs {
    margin-top: 12px;
  }

  .editor-toolbar {
    margin-top: 3px;
  }

  #noteContentInput,
  .markdown-preview {
    font-size: 16px;
    line-height: 1.9;
  }

  .editor-footer {
    padding-right: 18px;
    padding-bottom: max(7px, env(safe-area-inset-bottom));
    padding-left: 18px;
  }

  .toast-region {
    right: 16px;
    bottom: calc(80px + env(safe-area-inset-bottom));
    left: 16px;
    align-items: center;
  }

  .toast {
    width: max-content;
  }
}

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