:root {
  color-scheme: light;
  --canvas: #f3f6f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-muted: #eef3f6;
  --ink: #18222d;
  --ink-soft: #344250;
  --muted: #6d7b89;
  --line: #dce4ea;
  --line-strong: #c8d3dc;
  --rail: #1c2730;
  --rail-soft: #283640;
  --rail-text: #d8e0e5;
  --accent: #159a86;
  --accent-strong: #0d7667;
  --accent-soft: #dff4ef;
  --cyan: #168ca0;
  --violet: #7057c7;
  --amber: #d48a16;
  --danger: #d84d55;
  --danger-soft: #fdebed;
  --shadow-sm: 0 1px 2px rgba(24, 34, 45, 0.06);
  --shadow-md: 0 12px 32px rgba(24, 34, 45, 0.12);
  --radius: 8px;
  --font: Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background: var(--canvas);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

a {
  color: inherit;
}

svg {
  display: block;
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.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;
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  color: #ffffff;
  background: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  font-size: 16px;
  font-weight: 760;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-name {
  margin: 0;
  font-size: 17px;
  font-weight: 720;
  line-height: 1.2;
}

.brand-caption {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(21, 154, 134, 0.18);
  outline-offset: 1px;
}

.button-primary {
  color: #ffffff;
  background: var(--accent);
}

.button-primary:hover {
  background: var(--accent-strong);
}

.button-secondary {
  color: var(--ink-soft);
  background: var(--surface);
  border-color: var(--line);
}

.button-secondary:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.button-quiet {
  color: var(--muted);
  background: transparent;
}

.button-quiet:hover {
  color: var(--ink);
  background: var(--surface-muted);
}

.button-danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f6cbd0;
}

.button-danger:hover {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}

.button-small {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

.icon-button {
  position: relative;
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.icon-button:hover,
.icon-button.is-active {
  color: var(--ink);
  background: var(--surface-muted);
  border-color: var(--line);
}

.icon-button.danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f6cbd0;
}

[data-tooltip]::after {
  position: absolute;
  z-index: 50;
  top: calc(100% + 7px);
  left: 50%;
  max-width: 180px;
  padding: 5px 7px;
  color: #ffffff;
  background: #111820;
  border-radius: 4px;
  content: attr(data-tooltip);
  font-size: 11px;
  font-weight: 550;
  line-height: 1.3;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -3px);
  transition: opacity 120ms ease, transform 120ms ease;
  white-space: nowrap;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.field {
  display: grid;
  gap: 7px;
}

.field-label {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 680;
}

.input-shell {
  position: relative;
  display: flex;
  align-items: center;
}

.input-shell > svg {
  position: absolute;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

.input-shell input {
  width: 100%;
  height: 42px;
  padding: 9px 42px 9px 39px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.input-shell input::placeholder,
input::placeholder,
textarea::placeholder {
  color: #99a5af;
}

.input-action {
  position: absolute;
  right: 5px;
  width: 32px;
  height: 32px;
}

.form-stack {
  display: grid;
  gap: 18px;
}

.auth-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
  background: var(--canvas);
}

.auth-shell {
  display: grid;
  width: min(920px, 100%);
  min-height: 560px;
  grid-template-columns: minmax(0, 1.06fr) minmax(360px, 0.94fr);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.auth-visual {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px;
  color: var(--rail-text);
  background: var(--rail);
  overflow: hidden;
}

.auth-visual::before,
.auth-visual::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.auth-visual::before {
  inset: 88px 42px 92px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.auth-visual::after {
  top: 118px;
  right: 74px;
  bottom: 122px;
  left: 74px;
  border-right: 1px solid rgba(21, 154, 134, 0.35);
  border-left: 1px solid rgba(22, 140, 160, 0.3);
}

.auth-visual .brand-caption {
  color: #8fa0ab;
}

.auth-message {
  position: relative;
  z-index: 1;
  max-width: 390px;
}

.auth-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 18px;
  color: #82d8ca;
  font-size: 12px;
  font-weight: 700;
}

.auth-message h1 {
  margin: 0;
  color: #ffffff;
  font-size: 34px;
  line-height: 1.2;
}

.auth-message p {
  margin: 18px 0 0;
  color: #aebbc4;
  font-size: 15px;
  line-height: 1.8;
}

.auth-features {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.auth-feature {
  min-width: 0;
  padding: 14px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

.auth-feature svg {
  width: 19px;
  height: 19px;
  margin-bottom: 13px;
  color: #82d8ca;
}

.auth-feature strong,
.auth-feature span {
  display: block;
}

.auth-feature strong {
  color: #eef4f6;
  font-size: 12px;
}

.auth-feature span {
  margin-top: 3px;
  color: #83939e;
  font-size: 10px;
}

.auth-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 54px;
  background: var(--surface);
}

.auth-panel h2 {
  margin: 0;
  font-size: 25px;
}

.auth-panel > p {
  margin: 8px 0 30px;
  color: var(--muted);
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.auth-actions-single {
  grid-template-columns: 1fr;
}

.form-message {
  min-height: 21px;
  margin: -5px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.auth-footnote {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 28px;
  color: var(--muted);
  font-size: 11px;
}

.auth-footnote svg {
  width: 15px;
  height: 15px;
  color: var(--accent);
}

.app-shell {
  display: grid;
  width: 100vw;
  height: 100vh;
  grid-template-columns: 64px 288px minmax(0, 1fr);
  overflow: hidden;
  background: var(--surface);
}

.rail {
  display: flex;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  padding: 12px 10px;
  color: var(--rail-text);
  background: var(--rail);
}

.rail .brand-mark {
  margin-bottom: 22px;
}

.rail-nav,
.rail-footer {
  display: grid;
  gap: 8px;
}

.rail-nav {
  width: 100%;
}

.rail-footer {
  width: 100%;
  margin-top: auto;
}

.rail-button {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  margin: 0 auto;
  place-items: center;
  color: #8fa0ab;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.rail-button:hover,
.rail-button.is-active {
  color: #ffffff;
  background: var(--rail-soft);
  border-color: rgba(255, 255, 255, 0.06);
}

.rail-button.is-active::before {
  position: absolute;
  left: -10px;
  width: 3px;
  height: 22px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  content: "";
}

.rail-button[data-tooltip]::after {
  top: 50%;
  left: calc(100% + 12px);
  transform: translate(-3px, -50%);
}

.rail-button[data-tooltip]:hover::after,
.rail-button[data-tooltip]:focus-visible::after {
  transform: translate(0, -50%);
}

.workspace-sidebar {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: var(--surface-soft);
  border-right: 1px solid var(--line);
}

.sidebar-head {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--line);
}

.workspace-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.workspace-title {
  min-width: 0;
}

.workspace-title strong,
.workspace-title span {
  display: block;
}

.workspace-title strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-title span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  background: var(--accent);
  border-radius: 50%;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field svg {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  height: 36px;
  padding: 8px 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.search-field kbd {
  position: absolute;
  right: 8px;
  padding: 1px 5px;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 10px;
}

.new-note-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 8px;
  margin-top: 10px;
}

.new-note-row input {
  min-width: 0;
  height: 36px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.sidebar-scroll {
  min-height: 0;
  flex: 1;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.sidebar-section {
  padding: 15px 10px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  min-height: 28px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.notebook-list,
.note-list,
.detail-list {
  display: grid;
  gap: 3px;
  margin: 5px 0 0;
  padding: 0;
  list-style: none;
}

.notebook-item,
.note-item {
  width: 100%;
  min-width: 0;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}

.notebook-item {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
}

.notebook-item svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: var(--muted);
}

.notebook-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notebook-item:hover,
.notebook-item.is-active,
.note-item:hover,
.note-item.is-active {
  background: var(--surface);
  border-color: var(--line);
}

.notebook-item.is-active {
  color: var(--accent-strong);
  font-weight: 680;
}

.note-item {
  display: grid;
  gap: 6px;
  padding: 10px;
}

.note-item-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.note-item-title strong {
  overflow: hidden;
  flex: 1;
  font-size: 13px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item-title svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  color: var(--amber);
}

.note-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
}

.note-actions {
  display: flex;
  gap: 3px;
}

.note-actions button {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
}

.note-actions button:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.note-actions svg {
  width: 14px;
  height: 14px;
}

.empty-state {
  padding: 26px 14px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 28px;
  height: 28px;
  margin: 0 auto 10px;
  color: var(--line-strong);
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  color: var(--ink-soft);
  font-size: 12px;
}

.empty-state span {
  margin-top: 4px;
  font-size: 11px;
}

.sidebar-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 10px;
  background: var(--surface-soft);
  border-top: 1px solid var(--line);
}

.sidebar-footer .button {
  min-width: 0;
}

.workspace-main {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 58px auto minmax(0, 1fr) 180px;
  background: var(--surface);
}

.topbar {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.mobile-menu {
  display: none;
}

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

.breadcrumbs span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumbs svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  color: var(--line-strong);
}

.sync-state {
  display: inline-flex;
  min-width: 78px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.sync-state svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.user-chip {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.user-avatar {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid #c6e8e1;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
}

.user-name {
  max-width: 96px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.segmented .icon-button {
  width: 30px;
  height: 28px;
  flex-basis: 30px;
}

.note-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.title-input {
  min-width: 180px;
  flex: 1;
  height: 34px;
  padding: 5px 8px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 18px;
  font-weight: 730;
}

.title-input:hover,
.title-input:focus {
  background: var(--surface);
  border-color: var(--line);
}

.compact-field {
  position: relative;
  display: flex;
  align-items: center;
}

.compact-field > svg {
  position: absolute;
  left: 8px;
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

.compact-field input,
.compact-field select {
  height: 34px;
  padding: 7px 9px 7px 29px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 12px;
}

.compact-field input {
  width: 180px;
}

.compact-field select {
  width: 150px;
}

.toggle-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
}

.toggle-button.is-active {
  color: var(--amber);
  background: #fff7e5;
  border-color: #f1d8a5;
}

.toggle-button.star.is-active {
  color: var(--violet);
  background: #f0edff;
  border-color: #d8d0fa;
}

.editor-stage {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--canvas);
}

.editor-pane,
.preview-pane {
  min-width: 0;
  min-height: 0;
}

.editor-pane {
  position: relative;
  border-right: 1px solid var(--line);
}

.pane-label {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
  text-transform: uppercase;
}

.pane-label svg {
  width: 13px;
  height: 13px;
}

.markdown-editor {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  padding: 42px 34px;
  color: var(--ink-soft);
  background: #fbfcfd;
  border: 0;
  outline: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.8;
}

.markdown-preview {
  height: 100%;
  overflow: auto;
  padding: 42px 42px 64px;
  color: var(--ink-soft);
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.markdown-preview > :first-child {
  margin-top: 0;
}

.editor-empty {
  display: grid;
  min-height: 240px;
  place-content: center;
  justify-items: center;
  color: var(--muted);
  text-align: center;
}

.editor-empty svg {
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
  color: var(--line-strong);
}

.editor-empty strong {
  color: var(--ink-soft);
  font-size: 14px;
}

.editor-empty span {
  max-width: 280px;
  margin-top: 5px;
  font-size: 11px;
}

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

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

.markdown-preview h2 {
  margin: 30px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 21px;
}

.markdown-preview h3 {
  margin: 24px 0 10px;
  font-size: 17px;
}

.markdown-preview p,
.markdown-preview ul,
.markdown-preview ol,
.markdown-preview blockquote {
  margin: 12px 0;
}

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

.markdown-preview blockquote {
  padding: 9px 15px;
  color: var(--muted);
  background: var(--surface-soft);
  border-left: 3px solid var(--accent);
}

.markdown-preview code {
  padding: 2px 5px;
  color: var(--violet);
  background: #f2f0fa;
  border-radius: 4px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.92em;
}

.markdown-preview pre {
  overflow: auto;
  padding: 18px;
  color: #dce7eb;
  background: var(--rail);
  border: 1px solid #2c3b45;
  border-radius: 7px;
}

.markdown-preview pre code {
  padding: 0;
  color: inherit;
  background: transparent;
}

.markdown-preview table {
  width: 100%;
  margin: 18px 0;
  border-collapse: collapse;
}

.markdown-preview th,
.markdown-preview td {
  padding: 9px 11px;
  border: 1px solid var(--line);
  text-align: left;
}

.markdown-preview th {
  background: var(--surface-soft);
}

.markdown-preview img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.rich-toolbar {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  padding: 6px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.format-button {
  display: inline-grid;
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
}

.format-button:hover,
.format-button.is-active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: #c6e8e1;
}

.format-button:disabled,
.format-select:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.format-button svg {
  width: 16px;
  height: 16px;
}

.format-select {
  width: 94px;
  height: 31px;
  flex: 0 0 94px;
  padding: 4px 8px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 650;
}

.format-divider {
  width: 1px;
  height: 21px;
  flex: 0 0 1px;
  margin: 0 4px;
  background: var(--line);
}

.word-count {
  min-width: 54px;
  margin-left: auto;
  padding: 0 8px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
}

.document-scroll {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 28px clamp(18px, 5vw, 72px) 64px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.document-editor {
  width: min(880px, 100%);
  min-height: calc(100vh - 330px);
  margin: 0 auto;
  padding: 54px clamp(34px, 7vw, 82px) 80px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  outline: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.82;
}

.document-editor:focus {
  border-color: #b8d8d1;
  box-shadow: 0 0 0 3px rgba(21, 154, 134, 0.08), var(--shadow-sm);
}

.document-editor[contenteditable="false"] {
  background: var(--surface-soft);
}

#editor-placeholder {
  position: absolute;
  top: 28px;
  left: 50%;
  width: min(880px, 100%);
  min-height: min(480px, calc(100vh - 330px));
  height: calc(100% - 56px);
  pointer-events: none;
  transform: translateX(-50%);
}

.rich-text > :first-child,
.document-body > :first-child {
  margin-top: 0;
}

.rich-text > :last-child,
.document-body > :last-child {
  margin-bottom: 0;
}

.rich-text h1,
.rich-text h2,
.rich-text h3,
.rich-text h4,
.document-body h1,
.document-body h2,
.document-body h3,
.document-body h4 {
  color: var(--ink);
  line-height: 1.38;
}

.rich-text h1,
.document-body h1 {
  margin: 0 0 24px;
  font-size: 30px;
}

.rich-text h2,
.document-body h2 {
  margin: 34px 0 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  font-size: 22px;
}

.rich-text h3,
.document-body h3 {
  margin: 26px 0 10px;
  font-size: 18px;
}

.rich-text h4,
.document-body h4 {
  margin: 22px 0 8px;
  font-size: 15px;
}

.rich-text p,
.rich-text ul,
.rich-text ol,
.rich-text blockquote,
.rich-text pre,
.rich-text table,
.document-body p,
.document-body ul,
.document-body ol,
.document-body blockquote,
.document-body pre,
.document-body table {
  margin: 14px 0;
}

.rich-text ul,
.rich-text ol,
.document-body ul,
.document-body ol {
  padding-left: 27px;
}

.rich-text li + li,
.document-body li + li {
  margin-top: 5px;
}

.rich-text a,
.document-body a {
  color: var(--cyan);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.rich-text blockquote,
.document-body blockquote {
  padding: 11px 17px;
  color: var(--muted);
  background: var(--surface-soft);
  border-left: 3px solid var(--accent);
}

.rich-text code,
.document-body code {
  padding: 2px 5px;
  color: var(--violet);
  background: #f2f0fa;
  border-radius: 4px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.92em;
}

.rich-text pre,
.document-body pre {
  overflow: auto;
  padding: 18px;
  color: #dce7eb;
  background: var(--rail);
  border: 1px solid #2c3b45;
  border-radius: 7px;
}

.rich-text pre code,
.document-body pre code {
  padding: 0;
  color: inherit;
  background: transparent;
}

.rich-text table,
.document-body table {
  width: 100%;
  border-collapse: collapse;
}

.rich-text th,
.rich-text td,
.document-body th,
.document-body td {
  min-width: 92px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

.rich-text th,
.document-body th {
  background: var(--surface-soft);
}

.rich-text img,
.document-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 18px auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.rich-text figure {
  margin: 18px 0;
}

.rich-text hr,
.document-body hr {
  margin: 28px 0;
  border: 0;
  border-top: 1px solid var(--line-strong);
}

.detail-dock {
  display: grid;
  min-height: 0;
  grid-template-rows: 42px minmax(0, 1fr);
  background: var(--surface-soft);
  border-top: 1px solid var(--line);
}

.detail-tabs {
  display: flex;
  align-items: end;
  gap: 2px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.detail-tab {
  display: inline-flex;
  height: 41px;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.detail-tab svg {
  width: 15px;
  height: 15px;
}

.detail-tab:hover,
.detail-tab.is-active {
  color: var(--ink);
}

.detail-tab.is-active {
  border-bottom-color: var(--accent);
}

.detail-panel {
  display: none;
  min-height: 0;
  overflow: auto;
  padding: 12px 16px;
}

.detail-panel.is-active {
  display: block;
}

.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.detail-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.detail-list {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.detail-item {
  display: flex;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

button.detail-item {
  text-align: left;
}

.detail-item > svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  color: var(--cyan);
}

.detail-copy {
  min-width: 0;
  flex: 1;
}

.detail-copy strong,
.detail-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-copy strong {
  color: var(--ink-soft);
  font-size: 11px;
}

.detail-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.detail-item .icon-button {
  width: 28px;
  height: 28px;
  flex-basis: 28px;
}

.detail-item .icon-button svg {
  width: 14px;
  height: 14px;
}

.sidebar-overlay {
  display: none;
}

dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

dialog::backdrop {
  background: rgba(18, 27, 34, 0.48);
}

.dialog-head,
.dialog-body,
.dialog-actions {
  padding: 18px 20px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin: 0;
  font-size: 17px;
}

.dialog-body {
  display: grid;
  gap: 16px;
}

.dialog-body input {
  width: 100%;
  height: 40px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.dialog-help {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  background: var(--surface-soft);
  border-top: 1px solid var(--line);
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(340px, calc(100vw - 36px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  animation: toast-in 180ms ease;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  color: var(--accent);
}

.toast.error svg {
  color: var(--danger);
}

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

.page-shell {
  min-height: 100vh;
  background: var(--canvas);
}

.page-topbar {
  display: flex;
  height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.page-content {
  width: min(980px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 70px;
}

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

.page-heading h1 {
  margin: 0;
  font-size: 28px;
}

.page-heading p {
  margin: 7px 0 0;
  color: var(--muted);
}

.tag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.tag-card {
  display: flex;
  min-width: 0;
  min-height: 76px;
  align-items: center;
  gap: 13px;
  padding: 15px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.tag-card:hover {
  border-color: #a8cfc7;
  box-shadow: 0 8px 22px rgba(24, 34, 45, 0.08);
  transform: translateY(-2px);
}

.tag-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 7px;
}

.tag-copy {
  min-width: 0;
  flex: 1;
}

.tag-copy strong,
.tag-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-copy strong {
  font-size: 14px;
}

.tag-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.tag-count {
  min-width: 34px;
  padding: 4px 7px;
  color: var(--cyan);
  background: #e6f5f7;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 750;
  text-align: center;
}

.share-shell {
  min-height: 100vh;
  background: var(--canvas);
}

.share-topbar {
  display: flex;
  height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 28px;
  color: var(--rail-text);
  background: var(--rail);
}

.share-topbar .brand-caption {
  color: #8fa0ab;
}

.share-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #aebbc4;
  font-size: 11px;
}

.share-state svg {
  width: 15px;
  height: 15px;
  color: #82d8ca;
}

.share-document {
  width: min(880px, calc(100% - 40px));
  min-height: calc(100vh - 62px);
  margin: 0 auto;
  padding: 48px 0 80px;
}

.share-document article {
  padding: 48px 58px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.share-title {
  margin: 0 0 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  font-size: 30px;
  line-height: 1.3;
}

.share-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 38px;
  padding-top: 18px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 11px;
}

.share-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  color: var(--violet);
  background: #f0edff;
  border-radius: 99px;
}

.share-auth-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background: var(--canvas);
}

.share-auth-card {
  width: min(410px, 100%);
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.share-auth-icon {
  display: grid;
  width: 44px;
  height: 44px;
  margin-bottom: 20px;
  place-items: center;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 8px;
}

.share-auth-card h1 {
  margin: 0;
  font-size: 23px;
}

.share-auth-card > p {
  margin: 8px 0 24px;
  color: var(--muted);
}

.share-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.not-found {
  display: grid;
  min-height: calc(100vh - 62px);
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.not-found svg {
  width: 42px;
  height: 42px;
  margin: 0 auto 14px;
  color: var(--line-strong);
}

.not-found strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
}

.not-found span {
  display: block;
  margin-top: 6px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 58px 260px minmax(0, 1fr);
  }

  .note-meta {
    flex-wrap: wrap;
  }

  .title-input {
    flex-basis: calc(100% - 84px);
  }

  .workspace-main {
    grid-template-rows: 58px auto minmax(0, 1fr) 170px;
  }
}

@media (max-width: 900px) {
  .auth-shell {
    grid-template-columns: 1fr;
    max-width: 480px;
  }

  .auth-visual {
    min-height: 230px;
    padding: 28px;
  }

  .auth-message h1 {
    font-size: 27px;
  }

  .auth-message p {
    margin-top: 10px;
  }

  .auth-features {
    display: none;
  }

  .auth-panel {
    padding: 36px;
  }

  .app-shell {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .workspace-sidebar {
    position: fixed;
    z-index: 30;
    top: 0;
    bottom: 0;
    left: 54px;
    width: min(320px, calc(100vw - 54px));
    box-shadow: var(--shadow-md);
    transform: translateX(-110%);
    transition: transform 180ms ease;
  }

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

  .sidebar-overlay {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: block;
    visibility: hidden;
    background: rgba(18, 27, 34, 0.38);
    border: 0;
    opacity: 0;
    transition: opacity 180ms ease, visibility 180ms ease;
  }

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

  .mobile-menu {
    display: inline-grid;
  }

  .workspace-main {
    grid-column: 2;
  }

  .breadcrumbs .desktop-only,
  .sync-state span,
  .user-name {
    display: none;
  }

  .document-scroll {
    padding: 20px 18px 48px;
  }

  .document-editor {
    min-height: calc(100vh - 325px);
    padding: 42px 44px 64px;
  }
}

@media (max-width: 680px) {
  .auth-body {
    padding: 0;
  }

  .auth-shell {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .auth-visual {
    min-height: 188px;
  }

  .auth-message p {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    display: none;
  }

  .workspace-sidebar {
    left: 0;
    width: min(330px, 88vw);
  }

  .workspace-main {
    grid-column: 1;
    grid-template-rows: 56px auto minmax(0, 1fr) 168px;
  }

  .topbar {
    padding: 0 10px;
  }

  .toolbar-divider,
  .breadcrumbs {
    display: none;
  }

  .toolbar {
    margin-left: auto;
  }

  .sync-state {
    min-width: 28px;
  }

  .note-meta {
    gap: 7px;
    padding: 9px 10px;
  }

  .title-input {
    min-width: 100%;
    flex-basis: 100%;
  }

  .compact-field {
    flex: 1;
  }

  .compact-field input,
  .compact-field select {
    width: 100%;
  }

  .segmented {
    margin-left: auto;
  }

  .rich-toolbar {
    padding-right: 8px;
    padding-left: 8px;
  }

  .word-count {
    position: sticky;
    right: 0;
    background: var(--surface);
  }

  .document-scroll {
    padding: 12px 8px 34px;
  }

  .document-editor {
    min-height: calc(100vh - 315px);
    padding: 34px 24px 56px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }

  #editor-placeholder {
    top: 12px;
    min-height: calc(100vh - 315px);
    height: calc(100% - 24px);
  }

  .detail-tabs {
    overflow-x: auto;
    padding: 0 7px;
  }

  .detail-tab {
    flex: 0 0 auto;
  }

  .detail-list {
    grid-template-columns: 1fr;
  }

  .page-topbar,
  .share-topbar {
    padding: 0 16px;
  }

  .page-content,
  .share-document {
    width: min(100% - 24px, 980px);
    padding-top: 28px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .share-document article {
    padding: 30px 24px;
  }

  .share-title {
    font-size: 25px;
  }
}

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