:root {
  color-scheme: light;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --paper: #fffefa;
  --surface: #f8f7f2;
  --ink: #242922;
  --muted: #62685b;
  --line: #e4e5db;
  --green: #345743;
  --sidebar: #24372f;
  --side-text: #f0f3e9;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .65; cursor: wait; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #779e66;
  outline-offset: 3px;
}
h1, h2, p { margin: 0; }
.boot { padding: 2rem; }
.primary, .tool, .text-button, .folder-add, .sync, .nav-item, .segmented button {
  border: 0; border-radius: 7px; min-height: 38px;
}
.primary { padding: .55rem 1rem; background: var(--green); color: white; font-weight: 650; }
.primary:hover { background: #294836; }
.text-button { background: transparent; color: inherit; padding: .35rem .6rem; }
.text-button:hover, .tool:hover { background: #8882; }
.tool { background: var(--surface); border: 1px solid var(--line); padding: .4rem .8rem; color: var(--ink); }
.error { color: #a72b2b; font-size: .9rem; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.auth {
  display: grid; grid-template-columns: minmax(250px, 350px) minmax(260px, 360px);
  place-content: center; min-height: 100dvh; gap: 2.5rem; padding: 2rem;
  background: var(--surface);
}
.auth-brand {
  padding: 2.5rem; background: var(--sidebar); color: var(--side-text);
  border-radius: 16px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
}
.auth-brand h1 { font-family: "Songti SC", "Noto Serif CJK SC", Georgia, serif; font-size: 3.5rem; margin-top: 1rem; }
.auth-brand p { margin-top: .55rem; color: #d3decd; }
.auth-form { display: flex; flex-direction: column; justify-content: center; gap: 1rem; padding: 1rem 0; }
.auth-form h2, dialog h2 { font-size: 1.5rem; }
label { display: grid; gap: .4rem; font-size: .9rem; }
label input, label select {
  min-width: 0; width: 100%; min-height: 44px; border: 1px solid #c9cec2;
  border-radius: 7px; background: var(--paper); color: var(--ink); padding: .5rem .75rem; font-size: 1rem;
}
.workspace { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  height: 100dvh; position: sticky; top: 0; display: flex; flex-direction: column;
  padding: 1.5rem 1rem .75rem; background: var(--sidebar); color: var(--side-text);
}
.brand { display: flex; align-items: center; gap: .65rem; padding: 0 .4rem; font-size: 1.55rem; font-weight: 650; letter-spacing: .08em; }
.brand img { border: 1px solid #c0d3b45c; border-radius: 9px; }
.sidebar-actions { display: grid; grid-template-columns: 1fr auto; gap: .55rem; margin: 1.5rem 0 1.1rem; }
.sidebar .primary { background: #dbe6d4; color: #22372c; text-align: left; }
.sidebar .primary:hover { background: #edf2e9; }
.folder-add { background: #ffffff12; color: var(--side-text); padding: .4rem .45rem; white-space: nowrap; }
.folder-add span { font-size: .82rem; }
.folder-add:hover { background: #ffffff24; }
.sidebar-content { overflow: auto; flex: 1; }
.sidebar-content h2 { color: #b7c6b8; font-size: .82rem; padding: .65rem .55rem .35rem; font-weight: 600; }
#list-heading { margin-top: .95rem; }
.sidebar-content nav { display: grid; gap: 2px; }
.nav-row { display: flex; min-width: 0; align-items: center; gap: 2px; }
.nav-item {
  display: flex; gap: .5rem; align-items: center; text-align: left; width: 100%;
  min-width: 0; background: transparent; color: inherit; padding: .45rem .6rem; font-size: .92rem;
}
.nav-item span:last-child, #account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover, .nav-item[aria-current="true"] { background: #ffffff17; }
.nav-item[aria-current="true"] { box-shadow: inset 3px 0 #b9cfae; }
.nav-icon { color: #bfd1bb; }
.folder-rename { color: #c9d7c7; white-space: nowrap; font-size: .78rem; }
.nav-empty { color: #b7c6b8; padding: .45rem .65rem; font-size: .86rem; }
.profile { display: flex; align-items: center; gap: .55rem; border-top: 1px solid #ffffff25; padding: .75rem .2rem 0; }
.avatar { border-radius: 50%; width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center; background: #d7e3d1; color: var(--sidebar); }
#account-name { flex: 1; font-size: .9rem; }
.main-pane { min-width: 0; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.top-bar, .status-bar { display: flex; align-items: center; gap: 1rem; background: var(--surface); }
.top-bar { min-height: 60px; border-bottom: 1px solid var(--line); padding: 0 clamp(1rem, 4vw, 3rem); }
.location { font-size: .9rem; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync { flex-shrink: 0; display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .55rem; background: transparent; color: var(--muted); font-size: .85rem; }
.sync:hover { background: #eaece3; }
.indicator { width: 7px; height: 7px; border-radius: 50%; background: #6e9375; }
.sync[data-state="pending"] .indicator, .sync[data-state="offline"] .indicator { background: #a37c29; }
.sync[data-state="error"] .indicator { background: #b7473d; }
.status-bar { min-height: 42px; justify-content: flex-end; border-top: 1px solid var(--line); padding: .4rem clamp(1rem, 4vw, 3rem) max(.4rem, env(safe-area-inset-bottom)); font-size: .85rem; color: var(--muted); }
.status-bar strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.markdown-label { margin-right: auto; }
.empty { display: grid; place-content: center; justify-items: center; text-align: center; gap: .95rem; padding: 1.25rem; }
.empty h1 { font-family: "Songti SC", Georgia, serif; font-size: 2.2rem; }
.empty p { color: var(--muted); line-height: 1.6; }
.paper-icon { width: 56px; height: 69px; border: 1px solid #aab7a6; border-radius: 8px; display: grid; align-content: center; gap: 7px; padding: 12px; background: #f4f7ed; transform: rotate(-7deg); margin-bottom: .65rem; }
.paper-icon span { display: block; border-top: 1px solid #8a9e85; }
.paper-icon span:last-child { width: 70%; }
.editor-pane { display: flex; flex-direction: column; gap: 1.25rem; width: min(100%, 990px); margin: 0 auto; min-height: 0; padding: clamp(1rem, 4vw, 4rem) clamp(1rem, 6vw, 5rem) 0; }
.editor-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
.editor-section { flex: 1; min-width: 0; }
.doc-title { border: 0; padding: .15rem 0; background: transparent; color: var(--ink); width: 100%; font-size: clamp(1.5rem, 4vw, 2.85rem); font-weight: 650; letter-spacing: -.02em; }
#doc-meta { font-size: .83rem; color: var(--muted); margin-top: .4rem; }
.editor-tools { display: flex; flex-shrink: 0; align-items: center; gap: .5rem; }
.segmented { display: flex; gap: 3px; padding: 3px; background: #eef0e8; border-radius: 8px; }
.segmented button { min-height: 32px; background: transparent; padding: .2rem .6rem; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--paper); color: var(--green); box-shadow: 0 1px 2px #1f392126; }
.paper { flex: 1; min-height: 0; display: flex; }
#body, .preview { width: 100%; min-width: 0; border: 0; padding: .35rem .15rem 1.5rem; background: transparent; color: var(--ink); line-height: 1.9; font-size: 1.06rem; overflow: auto; overflow-wrap: anywhere; }
#body { resize: none; }
#body:focus { outline: none; }
#body::placeholder { color: #70776a; }
.preview p, .preview blockquote, .preview pre, .preview ul, .preview ol { margin: 0 0 1rem; }
.preview h1, .preview h2, .preview h3, .preview h4, .preview h5, .preview h6 { margin: 0 0 .65rem; line-height: 1.35; }
.preview blockquote { border-left: 3px solid #abbda6; padding-left: .85rem; color: var(--muted); }
.preview pre { padding: .8rem; background: #eef0e8; overflow-x: auto; }
.preview code { background: #eef0e8; }
.preview a { color: var(--green); }
.mobile-only, .scrim { display: none; }
dialog { width: min(420px, calc(100% - 2rem)); border: 1px solid var(--line); border-radius: 13px; background: var(--paper); color: var(--ink); padding: 1.35rem; }
dialog::backdrop { background: #1d2b25a6; }
dialog form { display: grid; gap: 1rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; }
@media (max-width: 760px) {
  .workspace { display: block; }
  .mobile-only { display: inline-flex; align-items: center; gap: .35rem; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 3; width: min(300px, 87vw); display: none; }
  .sidebar.open { display: flex; }
  .scrim { position: fixed; inset: 0; z-index: 2; display: block; width: 100%; border: 0; background: #152a2388; }
  .top-bar { gap: .5rem; }
  .editor-head { flex-wrap: wrap; gap: .65rem; }
  .editor-section { flex-basis: 100%; }
  .editor-pane { padding-top: 1rem; }
  .auth { grid-template-columns: minmax(0, 400px); gap: 1rem; padding: 1rem; }
  .auth-brand { padding: 1.35rem; }
  .auth-brand h1 { font-size: 2.1rem; margin-top: .6rem; }
  .empty h1 { font-size: 1.85rem; }
}

.vault-backup { display: grid; gap: .75rem; }
.vault-confirm { display: flex; align-items: center; gap: .5rem; }
.vault-confirm input { width: auto; min-height: auto; }
#vault-description { line-height: 1.6; color: var(--muted); }
.admin-link { color: var(--green); font-size: .9rem; text-underline-offset: .2em; }
.auth-form > .admin-link { align-self: center; }
.admin-page { min-height: 100dvh; background: var(--surface); }
.admin-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .75rem clamp(1rem, 5vw, 3rem); background: var(--sidebar); color: var(--side-text);
}
.admin-bar .brand { font-size: clamp(1.1rem, 3vw, 1.45rem); }
.admin-bar a { display: inline-flex; align-items: center; flex-shrink: 0; text-decoration: none; }
.admin-main { width: min(100%, 940px); margin: 0 auto; padding: clamp(1rem, 5vw, 3rem); display: grid; gap: 1rem; }
.admin-heading { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; align-items: center; }
.admin-heading p, .admin-caption { color: var(--muted); margin-top: .4rem; }
.admin-panel { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.admin-panel h2 { font-size: 1rem; margin-bottom: .75rem; }
.admin-copy { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; margin-top: .65rem; }
.admin-copy span, .admin-caption, #invite-empty { font-size: .88rem; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; font-size: .9rem; }
.admin-table th, .admin-table td { padding: .65rem .6rem; border-bottom: 1px solid var(--line); }
.admin-table th { color: var(--muted); font-weight: 600; }
