:root {
  color-scheme: dark;
  --bg: #111715;
  --panel: #151c19;
  --raised: #1d2722;
  --hover: #233029;
  --line: #2b3730;
  --text: #e1e7e2;
  --muted: #93a298;
  --accent: #99dfb9;
  --accent-bg: #243d30;
  --danger: #f3a59e;
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
textarea {
  font: inherit;
}
button,
a,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  border: 0;
  color: inherit;
  background: none;
  min-height: 44px;
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
input,
textarea {
  color: var(--text);
  outline: none;
}
a {
  color: var(--accent);
}
svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
h1,
h2,
h3,
p {
  margin: 0;
}
button {
  transition:
    background 0.15s,
    color 0.15s;
}
button:hover {
  background: var(--hover);
}
.app-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 1600px;
  margin: auto;
}
.app-header {
  height: 88px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 38px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  font-size: 21px;
  font-weight: 650;
  letter-spacing: 1px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 13px;
  font-family: serif;
  font-size: 25px;
}
.brand-caption {
  display: block;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 3px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}
.local-badge {
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 12px;
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  border-radius: 10px;
  color: var(--muted);
}
.workspace {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}
.library {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  padding: 32px 26px 0;
  background: var(--panel);
}
.library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 2.5px;
  color: var(--muted);
  margin-bottom: 9px;
}
h1 {
  font-size: 25px;
  font-weight: 600;
  letter-spacing: 1px;
}
.new-button {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 22px;
  background: var(--accent-bg);
  color: var(--accent);
  padding: 0 13px;
  border-radius: 10px;
}
.new-button span {
  font-size: 14px;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg);
  border: 1px solid #3a4b40;
  border-radius: 12px;
  min-height: 53px;
  padding: 0 10px 0 13px;
  flex-shrink: 0;
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #99dfb914;
}
.search-box > span {
  display: flex;
  color: var(--muted);
}
.search-box input {
  width: 100%;
  min-width: 0;
  background: none;
  border: 0;
  font-size: 16px;
  padding: 12px 0;
}
.search-box input::placeholder {
  color: #86938b;
  font-size: 14px;
}
.search-box button {
  width: 32px;
  min-width: 32px;
  color: var(--muted);
  font-size: 22px;
  border-radius: 7px;
}
.search-hint {
  font-size: 12px;
  color: var(--muted);
  height: 32px;
  padding-top: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filters {
  display: flex;
  gap: 12px;
  padding: 12px 0 17px;
}
.segmented {
  background: var(--bg);
  padding: 4px;
  display: flex;
  flex: 1;
  border-radius: 10px;
  gap: 3px;
}
.segmented button {
  flex: 1;
  min-height: 36px;
  font-size: 14px;
  border-radius: 7px;
  color: var(--muted);
}
.segmented .selected {
  color: var(--accent);
  background: var(--accent-bg);
  box-shadow: 0 1px 3px #0002;
}
.tag-filter {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex-shrink: 0;
  padding: 0 0 18px;
  scrollbar-width: thin;
}
.tag-chip {
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 13px;
  white-space: nowrap;
  padding: 0 11px;
  min-height: 36px;
  color: var(--muted);
}
.tag-chip.active {
  border-color: #557d65;
  color: var(--accent);
  background: #99dfb90b;
}
.results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 19px 0 12px;
  font-size: 12px;
  color: var(--muted);
}
.note-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 -12px;
  padding: 0 12px 20px;
  scrollbar-width: thin;
}
.note-card {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-bottom-color: var(--line);
  padding: 18px 12px;
  border-radius: 9px;
  display: block;
  margin: 3px 0;
}
.note-card:hover {
  background: #1d2922;
}
.note-card.active {
  background: #24342a;
  border: 1px solid #405745;
}
.note-card-head {
  display: flex;
  gap: 10px;
  align-items: center;
}
.note-card-head > svg {
  width: 17px;
  color: var(--muted);
}
.note-card h3 {
  font-size: 16px;
  font-weight: 550;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.note-card .star {
  width: 15px;
  color: var(--accent);
}
.note-excerpt {
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin: 9px 0 12px;
  overflow-wrap: anywhere;
}
.note-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}
.note-meta time {
  margin-left: auto;
  white-space: nowrap;
}
.mini-tag {
  padding: 3px 6px;
  background: #31433760;
  border-radius: 4px;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #afc2b2;
}
.library-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 61px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}
.library-footer button {
  font-size: 12px;
  color: var(--muted);
  padding: 0 3px;
}
.editor-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  position: relative;
}
.editor-empty {
  margin: auto;
  text-align: center;
  padding: 35px 25px;
  max-width: 520px;
}
.empty-mark {
  display: inline-grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border: 1px solid #35483b;
  background: linear-gradient(145deg, #263b2c, #16211a);
  border-radius: 24px;
  font-family: serif;
  color: var(--accent);
  font-size: 43px;
  margin-bottom: 30px;
  transform: rotate(-5deg);
}
.editor-empty h2 {
  font-size: 24px;
  letter-spacing: 1px;
  font-weight: 500;
  line-height: 1.6;
}
.editor-empty p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
  margin: 13px 0 28px;
}
.primary-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 25px;
  border-radius: 9px;
  padding: 0 20px;
  background: var(--accent);
  color: #14271b;
  font-weight: 550;
  font-size: 14px;
  min-height: 45px;
}
.primary-button:hover {
  background: #b0edcb;
}
.empty-tips {
  margin-top: 64px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: #7f9385;
  font-size: 12px;
}
.list-empty {
  padding: 38px 10px;
  text-align: center;
}
.list-empty h3 {
  font-size: 16px;
  font-weight: 500;
}
.list-empty p {
  font-size: 14px;
  line-height: 1.8;
  margin: 12px 0;
  color: var(--muted);
}
mark {
  color: var(--accent);
  background: #49624477;
  border-radius: 2px;
}
.editor-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 30px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.editor-breadcrumb {
  color: var(--muted);
  font-size: 13px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.save-status {
  font-size: 12px;
  color: var(--muted);
}
.key-toggle.active {
  color: var(--accent);
}
.key-toggle.active svg {
  fill: #99dfb933;
}
.editor-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 900px;
  margin: auto;
  padding: 35px 52px 0;
}
.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.note-title {
  font-size: 29px;
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1.5;
  min-width: 0;
  max-width: 100%;
  text-align: left;
  padding: 0;
  overflow-wrap: anywhere;
}
.title-row .icon-button {
  opacity: 0.5;
}
.editor-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 13px 0 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.editor-tags button {
  font-size: 13px;
  min-height: 32px;
}
.editor-tags .tag-chip {
  color: #b6c9bd;
}
.add-tag {
  color: var(--muted);
  padding: 0 8px;
}
.editor-text-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
}
.editor-text {
  resize: none;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  font-family:
    "SFMono-Regular", Consolas, "PingFang SC", "Microsoft YaHei", monospace;
  font-size: 16px;
  line-height: 1.95;
  letter-spacing: 0.1px;
  padding: 5px 0 36px;
  scrollbar-width: thin;
  tab-size: 2;
}
.editor-text::placeholder {
  color: #6b7d70;
}
.editor-footnote {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid var(--line);
  background: var(--panel);
  gap: 8px;
  padding: 9px 18px calc(9px + env(safe-area-inset-bottom));
  flex-shrink: 0;
}
.toolbar button {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  border-radius: 8px;
  padding: 0 15px;
  color: #bac8be;
}
.toolbar .divider {
  height: 23px;
  width: 1px;
  background: var(--line);
  margin: 0 8px;
}
.back-button {
  display: none;
}
.completion {
  position: absolute;
  z-index: 3;
  bottom: 12px;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: #243229;
  border: 1px solid #526a59;
  border-radius: 12px;
  padding: 7px;
  box-shadow: 0 8px 40px #0006;
}
.completion p {
  font-size: 12px;
  color: var(--muted);
  padding: 8px;
}
.completion button {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  border-radius: 7px;
  padding: 10px;
  font-size: 14px;
}
.completion button:first-of-type {
  background: #354a3b;
}
.completion[hidden] {
  display: none;
}
dialog {
  color: var(--text);
  background: #1b241e;
  border: 1px solid #405046;
  border-radius: 18px;
  padding: 27px;
  width: min(480px, calc(100% - 32px));
  max-height: 85dvh;
  box-shadow: 0 28px 120px #0008;
}
dialog::backdrop {
  background: #050b08b8;
  backdrop-filter: blur(5px);
}
.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 20px;
}
.modal-heading h2 {
  font-size: 20px;
  font-weight: 550;
}
.modal-label {
  font-size: 14px;
  color: var(--muted);
  display: block;
  margin-bottom: 9px;
}
.modal-input {
  width: 100%;
  border: 1px solid #4a5b4e;
  border-radius: 9px;
  background: var(--bg);
  padding: 13px;
  font-size: 16px;
}
.modal-input:focus {
  border-color: var(--accent);
}
.modal-description {
  font-size: 14px;
  line-height: 1.8;
  color: var(--muted);
  margin: 14px 0;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}
.secondary-button {
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
}
.danger-button {
  color: var(--danger);
}
.error-text {
  font-size: 13px;
  color: var(--danger);
  margin-top: 10px;
  min-height: 18px;
}
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}
.settings-row h3 {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 5px;
}
.settings-row p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.settings-row button {
  white-space: nowrap;
  color: var(--accent);
  font-size: 14px;
}
.settings-stats {
  display: flex;
  gap: 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 10px;
}
.settings-stats strong {
  font-size: 25px;
  font-weight: 500;
  display: block;
}
.settings-stats span {
  font-size: 12px;
  color: var(--muted);
}
.tag-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 15px;
}
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  padding: 13px 20px;
  background: #d1edda;
  color: #15281c;
  font-size: 14px;
  line-height: 1.6;
  box-shadow: 0 8px 35px #0005;
  border-radius: 12px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  max-width: min(90vw, 600px);
  width: max-content;
  transition:
    opacity 0.2s,
    transform 0.2s;
}
#toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (min-width: 1200px) {
  .workspace {
    grid-template-columns: 420px minmax(0, 1fr);
  }
  .library {
    padding: 34px 30px 0;
  }
  .editor-content {
    padding-top: 44px;
  }
}
@media (max-width: 760px) {
  .app-header {
    height: 70px;
    padding: 0 21px;
    padding-top: env(safe-area-inset-top);
  }
  .brand {
    font-size: 19px;
  }
  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 23px;
    border-radius: 11px;
  }
  .brand-caption {
    display: none;
  }
  .header-actions {
    gap: 9px;
  }
  .local-badge {
    font-size: 11px;
    padding: 5px 9px;
  }
  .workspace {
    display: flex;
  }
  .library {
    width: 100%;
    padding: 24px 22px 0;
    border-right: 0;
  }
  .library-heading {
    margin-bottom: 21px;
  }
  .eyebrow {
    font-size: 10px;
    margin-bottom: 7px;
  }
  h1 {
    font-size: 25px;
  }
  .search-box {
    min-height: 54px;
  }
  .filters {
    padding-top: 10px;
  }
  .segmented button {
    min-height: 44px;
  }
  .tag-filter {
    padding-bottom: 16px;
  }
  .tag-chip {
    min-height: 44px;
    font-size: 14px;
  }
  .results-heading {
    padding-top: 18px;
  }
  .note-card {
    padding: 18px 11px;
  }
  .note-excerpt {
    font-size: 14px;
  }
  .note-meta {
    font-size: 12px;
  }
  .library-footer {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .editor-pane {
    display: none;
    width: 100%;
  }
  body.editing .library,
  body.editing .app-header {
    display: none;
  }
  body.editing .editor-pane {
    display: flex;
  }
  .editor-topbar {
    padding: calc(9px + env(safe-area-inset-top)) 13px 9px;
    gap: 5px;
  }
  .back-button {
    display: inline-flex;
  }
  .editor-breadcrumb {
    font-size: 12px;
  }
  .save-status {
    font-size: 11px;
  }
  .editor-content {
    padding: 22px 23px 0;
  }
  .note-title {
    font-size: 25px;
  }
  .editor-tags {
    padding: 11px 0 15px;
    margin-bottom: 12px;
  }
  .editor-text {
    font-size: 16px;
    line-height: 1.9;
  }
  .editor-footnote {
    font-size: 11px;
    padding: 8px 0;
  }
  .toolbar {
    gap: 2px;
    padding: 5px 10px calc(5px + env(safe-area-inset-bottom));
    justify-content: space-between;
  }
  .toolbar button {
    padding: 0 9px;
    font-size: 13px;
    gap: 4px;
    flex-direction: column;
    min-height: 47px;
    justify-content: center;
  }
  .toolbar button svg {
    width: 19px;
    height: 19px;
  }
  .toolbar .divider {
    margin: 0 5px;
  }
  .completion {
    bottom: 4px;
  }
  .note-list {
    padding-bottom: 15px;
  }
  .editor-empty {
    display: none;
  }
  #toast {
    bottom: calc(76px + env(safe-area-inset-bottom));
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
