:root {
  color-scheme: light;
  --bg: #f4f8ff;
  --surface: #ffffff;
  --surface-2: #edf5ff;
  --surface-3: #f8fbff;
  --text: #162033;
  --muted: #66758f;
  --line: #d8e5f5;
  --accent: #1f7ae0;
  --accent-deep: #155db1;
  --accent-soft: #ddecff;
  --danger: #d94848;
  --focus: #7bb7ff;
  --shadow: 0 18px 48px rgba(39, 89, 148, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* SQL 极简文档版补充：保留原蓝色 UI，移除图片/云盘模块后用于目录、分享和备份弹窗。 */
.tree-section-title {
  margin: 18px 12px 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.tree-caret {
  width: 18px;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}

.tree-item {
  padding-left: calc(8px + var(--tree-depth, 0) * 20px);
}

.shared-badge.readonly,
.shared-badge.compact.readonly {
  border-color: #b8d7ff;
  background: #eef6ff;
  color: #1262b9;
}

.lock-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 1px solid #f6cf73;
  border-radius: 999px;
  background: #fff4cd;
  color: #9a6700;
  font-size: 12px;
  font-weight: 800;
}

.history-card {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.history-card.current-stay {
  border-color: #f3c84b;
  background: #fff9df;
}

.history-card strong {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
}

.history-card strong > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-latest-badge,
.history-stay-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border: 1px solid #f3c84b;
  border-radius: 999px;
  background: #fff1a8;
  color: #8a5a00;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.history-latest-badge {
  border-color: #9ed1ff;
  background: #e7f3ff;
  color: #0f63b7;
}

.history-card p {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trash-row,
.member-row,
.backup-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.member-row {
  grid-template-columns: 1fr auto auto auto;
  margin-bottom: 8px;
}

.member-row span,
.member-row small,
.backup-row small,
.trash-row small {
  color: var(--muted);
  font-weight: 700;
}

.backup-center-card {
  width: min(1120px, calc(100vw - 96px));
  max-height: min(820px, calc(100vh - 80px));
  overflow: auto;
}

.backup-row {
  grid-template-columns: 1fr auto;
}

.danger-text {
  color: #df2b35 !important;
}

.save-state[data-mode="error"] {
  color: #df2b35;
}

.save-state[data-mode="warn"] {
  color: #0f63bf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

body.locked .topbar,
body.locked .app-shell {
  filter: blur(1px);
  pointer-events: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-screen[hidden] {
  display: none;
}

body.login-mode .topbar,
body.login-mode .app-shell {
  display: none;
}

.auth-loading {
  display: none;
  align-items: center;
  gap: 14px;
  color: var(--text);
}

.auth-loading .brand-mark {
  width: 52px;
  height: 52px;
}

.auth-loading-copy {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

body.auth-pending .auth-loading {
  display: flex;
}

body.auth-pending .login-card {
  display: none;
}

.login-card {
  display: grid;
  width: min(380px, 100%);
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.login-card input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  outline: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

h1,
h2,
p {
  margin: 0;
}

.topbar {
  position: relative;
  z-index: 120;
  display: grid;
  grid-template-columns: 292px minmax(360px, 1fr) auto;
  align-items: center;
  gap: 22px;
  height: 72px;
  padding: 0 20px 0 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  overflow: visible;
}

.topbar-brand,
.topbar-actions,
.editor-actions,
.panel-heading,
.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-actions {
  justify-content: flex-end;
}

.secondary-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--accent-deep);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 900;
}

.secondary-button:hover {
  border-color: var(--focus);
  background: #eef6ff;
}

.dialog-head .icon-button {
  width: 34px;
  height: 34px;
  color: var(--muted);
  background: var(--surface-2);
}

.topbar-brand {
  justify-content: flex-start;
  align-items: center;
}

.topbar-actions {
  position: relative;
  grid-column: 3;
  z-index: 130;
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.brand-copy {
  display: grid;
  align-content: center;
  min-height: 54px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  font-size: 21px;
  line-height: 1.1;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.save-state {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.role-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--accent-deep);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.role-badge[data-role="super_admin"] {
  color: #ffffff;
  border-color: var(--accent-deep);
  background: var(--accent-deep);
}

.role-badge[data-role="admin"] {
  color: var(--accent-deep);
  border-color: #b8d7ff;
  background: #eef6ff;
}

.role-badge[data-role="viewer"] {
  color: var(--muted);
  background: var(--surface-3);
}

.snapshot-state {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.avatar-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent-deep);
  font-weight: 900;
}

.user-menu {
  position: relative;
}

.avatar-menu {
  position: absolute;
  z-index: 200;
  top: calc(100% + 12px);
  right: -4px;
  display: grid;
  width: 184px;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.avatar-menu[hidden] {
  display: none;
}

.avatar-menu button {
  min-height: 40px;
  border-radius: 7px;
  padding: 0 12px;
  color: var(--text);
  background: transparent;
  font-size: 15px;
  font-weight: 850;
  text-align: left;
}

.avatar-menu button:hover {
  color: var(--accent-deep);
  background: var(--surface-2);
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: 18px 14px 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 6px;
}

.primary-button {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 13px;
  font-weight: 800;
}

.create-folder {
  color: var(--accent-deep);
  background: var(--surface-2);
}

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

.panel-heading {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

body:not(.super-admin) #backupCenterButton {
  display: none !important;
}

.drawer-entry {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 46px;
  border-radius: 8px;
  padding: 0 12px;
  color: #ffffff;
  background: var(--accent-deep);
  font-weight: 900;
  text-align: left;
}

.drawer-entry.subtle {
  color: var(--accent-deep);
  background: transparent;
  border: 1px solid transparent;
}

.drawer-entry.subtle:hover,
.drawer-entry.subtle.active {
  background: var(--surface-2);
  border-color: var(--line);
}

.workspace {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  padding: 18px;
  gap: 14px;
  overflow: hidden;
}

.writing-surface,
.history-panel,
.folder-page,
.trash-page {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.folder-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 18px;
  overflow: hidden;
}

.folder-page[hidden] {
  display: none;
}

.editor-area[hidden] {
  display: none;
}

.folder-header,
.folder-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.folder-header {
  justify-content: space-between;
}

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

.folder-stats article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
}

.folder-stats span {
  display: block;
  color: var(--accent-deep);
  font-size: 26px;
  font-weight: 900;
}

.folder-stats p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.folder-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.folder-list .empty-state {
  align-self: start;
}

.folder-row {
  justify-content: flex-start;
  position: relative;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-3);
  text-align: left;
}

.folder-row:hover,
.folder-row.active {
  border-color: var(--focus);
  background: var(--surface-2);
}

.folder-row > span:nth-child(2) {
  flex: 0 0 auto;
  min-width: 0;
}

.folder-row > div {
  flex: 1;
  min-width: 0;
}

.folder-row > .tree-more {
  flex: 0 0 28px;
  margin-left: auto;
}

.folder-row strong,
.folder-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-row strong {
  display: flex;
  align-items: center;
  gap: 8px;
}

.folder-row strong > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-row small {
  display: block;
}

.folder-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.muted-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: right;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.title-row button {
  flex: 0 0 auto;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 900;
}

.editor-actions button {
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 900;
}

.editor-actions {
  flex: 0 1 auto;
  justify-content: flex-end;
  flex-wrap: wrap;
  min-width: 0;
}

.tool-button {
  border: 1px solid var(--line);
  color: var(--accent-deep);
  background: var(--surface-2);
}

.tool-button:hover:not(:disabled),
.create-folder:hover,
.create-file:hover {
  border-color: var(--focus);
  filter: brightness(0.99);
}

.icon-tool {
  display: inline-grid;
  place-items: center;
  width: 38px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  text-align: center;
}

.tool-button:disabled {
  opacity: 0.42;
}

.text-tool {
  min-width: 48px;
}

.font-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.font-control input {
  width: 96px;
}

.tree-item:hover,
.tree-item.active {
  border-color: var(--focus);
  background: var(--surface-2);
}

.tree-item.located {
  box-shadow: inset 3px 0 0 var(--accent);
}

.tree-item.drag-armed,
.folder-row.drag-armed {
  cursor: grab;
}

.tree-item.drag-armed *,
.folder-row.drag-armed * {
  cursor: inherit;
}

.tree-item.dragging,
.folder-row.dragging {
  cursor: grabbing;
  opacity: 0.45;
}

.tree-item.drop-target,
.folder-row.drop-target {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.tree-item.drop-target-folder,
.folder-row.drop-target-folder {
  border-color: var(--accent);
  background: #e7f2ff;
  box-shadow:
    inset 0 0 0 1px var(--accent),
    0 8px 18px rgba(31, 122, 224, 0.12);
}

.tree-item.drop-blocked,
.folder-row.drop-blocked {
  border-color: #fca5a5;
  background: #fff1f2;
  box-shadow: inset 0 0 0 1px #fca5a5;
}

.tree-item.drop-before::before,
.folder-row.drop-before::before,
.tree-item.drop-after::after,
.folder-row.drop-after::after {
  content: "";
  position: absolute;
  z-index: 5;
  right: 4px;
  left: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 2px #dbeafe;
  pointer-events: none;
}

.tree-item.drop-before::before,
.folder-row.drop-before::before {
  top: -5px;
}

.tree-item.drop-after::after,
.folder-row.drop-after::after {
  bottom: -5px;
}

.editor-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.editor-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 300px);
  align-items: end;
  column-gap: 16px;
  row-gap: 8px;
  min-height: 62px;
}

.path-stack {
  grid-column: 1 / -1;
  min-width: 0;
}

.editor-header .editor-actions {
  margin-left: auto;
  max-width: min(760px, 100%);
  transform: translateY(-10px);
}

.folder-header .editor-actions {
  flex: 1;
}

.path-stack {
  max-width: none;
  min-width: 0;
}

#currentPath {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

#titleInput {
  flex: 0 1 min(520px, 42vw);
  min-width: 220px;
  border: 0;
  border-bottom: 1px solid transparent;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 26px;
  font-weight: 900;
}

#titleInput:focus {
  border-bottom-color: var(--focus);
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 300px);
  gap: 16px;
  min-height: 0;
  flex: 1;
}

.writing-surface {
  min-height: 430px;
  overflow: hidden;
}

#editor {
  width: 100%;
  height: 100%;
  min-height: 430px;
  padding: 24px;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 17px;
  line-height: 1.72;
}

#editor[readonly] {
  cursor: text;
  background: #fbfdff;
}

#editor.copyable-readonly {
  color: #263752;
  caret-color: transparent;
  user-select: text;
  -webkit-user-select: text;
}

#editor.copyable-readonly::selection {
  color: #0f2747;
  background: #cfe5ff;
}

.history-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 14px;
}

.history-hint,
.dialog-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font-size: 18px;
  line-height: 1;
}

#collapseSidebarButton {
  width: 42px;
  height: 42px;
  font-size: 20px;
}

dialog {
  width: min(440px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

#teamDialog {
  width: min(500px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgba(19, 36, 61, 0.42);
  backdrop-filter: blur(3px);
}

.dialog-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
}

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

.session-dialog-card {
  gap: 14px;
}

.session-countdown {
  min-height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid #cfe2fa;
  border-radius: 8px;
  color: #1764b7;
  background: #f3f8fe;
  font-size: 24px;
  font-weight: 800;
}

.session-dialog.urgent .session-countdown {
  border-color: #f2cb68;
  color: #9a6500;
  background: #fff8df;
}

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

.draft-recovery-content {
  width: 100%;
  max-height: min(48vh, 420px);
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #f8fbff;
  font: 14px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}

.dialog-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

#nameInput,
#moveSelect,
.team-grid input,
.team-grid select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  outline: 0;
  background: var(--surface);
}

#nameInput:focus,
#moveSelect:focus,
.team-grid input:focus,
.team-grid select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(123, 183, 255, 0.2);
}

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

.team-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.share-member-list {
  display: grid;
  max-height: 220px;
  gap: 8px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
}

.share-member-list[hidden] {
  display: none;
}

.share-member-option {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  min-height: 52px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 850;
}

.share-member-option:has(input:checked) {
  border-color: var(--focus);
  background: #eef6ff;
}

.share-member-option input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  justify-self: center;
}

.share-member-option span {
  display: grid;
  min-width: 0;
  gap: 3px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-member-option small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.share-member-option small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#backupCenterDialog {
  width: min(760px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  border: 0;
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
}

#backupCenterDialog * {
  box-sizing: border-box;
}

.backup-center-card {
  width: 100%;
  max-width: 100%;
  max-height: calc(100vh - 32px);
  grid-template-rows: auto auto auto minmax(0, 1fr);
  overflow: hidden;
}

.backup-center-card .dialog-head h2 {
  font-size: 26px;
  line-height: 1.1;
}

.backup-center-card .dialog-subtitle {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
}

.backup-actions,
.backup-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.backup-tabs {
  padding: 3px;
  border-radius: 8px;
  background: var(--surface-2);
}

.backup-tab {
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 16px;
  color: var(--accent-deep);
  background: transparent;
  font-size: 13px;
  font-weight: 900;
}

.backup-tab.active {
  color: #ffffff;
  background: var(--accent);
}

.backup-list {
  display: grid;
  min-height: 0;
  max-height: none;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 2px 4px 0;
}

.backup-user-section {
  display: grid;
  gap: 4px;
}

.backup-tree-root {
  display: grid;
  grid-template-columns: 16px 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #f7fbff;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.backup-tree-root .tree-caret {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  min-width: 16px;
  line-height: 1;
  transform-origin: center;
}

.backup-tree-root .tree-folder-icon {
  width: 22px;
  height: 22px;
}

.backup-tree-root:hover {
  border-color: #80b7ff;
  background: #dfefff;
}

.backup-user-section.collapsed .backup-tree-root .tree-caret {
  transform: rotate(-90deg);
}

.backup-user-section.collapsed .backup-tree-children {
  display: none;
}

.backup-tree-root strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backup-count {
  border-radius: 999px;
  min-width: 22px;
  padding: 2px 7px;
  color: var(--accent-deep);
  background: #dcecff;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.backup-tree-children {
  display: grid;
  gap: 4px;
  margin-left: 18px;
  padding-left: 17px;
  border-left: 1px solid var(--line);
}

.backup-tree-children[hidden] {
  display: none;
}

.backup-tree-children:empty {
  display: none;
}

.backup-user-section h3 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
}

.backup-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) 108px;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 8px 7px 0;
  background: transparent;
}

.backup-row:hover {
  border-color: #b9d7ff;
  background: #f6fbff;
}

.backup-branch {
  width: 10px;
  height: 1px;
  background: var(--line);
}

.backup-row-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.backup-row .secondary-button,
.backup-row .backup-download-button {
  display: inline-grid;
  place-items: center;
  justify-self: end;
  align-self: center;
  width: 104px;
  height: 32px;
  min-width: 0;
  padding: 0 10px;
  line-height: 1;
  white-space: nowrap;
}

.backup-row strong,
.backup-row p,
.backup-row small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backup-row strong {
  color: var(--text);
  font-size: 14px;
}

.backup-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.backup-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.member-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.member-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
}

.member-row strong {
  display: block;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.member-row p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.member-row button {
  flex: 0 0 auto;
  min-height: 30px;
  border-radius: 7px;
  padding: 0 9px;
  color: var(--accent-deep);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 850;
}

.member-row button:disabled {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
}

.danger-fill {
  background: var(--danger);
}

.context-menu {
  position: fixed;
  z-index: 80;
  display: grid;
  min-width: 148px;
  gap: 3px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.context-menu[hidden] {
  display: none;
}

.context-menu button {
  min-height: 34px;
  border-radius: 7px;
  padding: 0 10px;
  color: var(--text);
  background: transparent;
  font-size: 13px;
  font-weight: 850;
  text-align: left;
}

.context-menu button:hover:not(:disabled) {
  color: var(--accent-deep);
  background: var(--surface-2);
}

.context-menu button.danger-text {
  color: var(--danger);
}

.context-menu button.muted,
.context-menu button:disabled {
  color: var(--muted);
  cursor: default;
}

.tree {
  display: block;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-tree {
  flex: 1;
  max-height: none;
  padding-right: 2px;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.tree-item {
  position: relative;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 32px;
  margin-bottom: 3px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 7px;
  color: var(--text);
  background: transparent;
  font-size: 14px;
  font-weight: 750;
  text-align: left;
}

.tree-root {
  min-height: 34px;
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 900;
}

.tree-folder:not(.tree-root) {
  color: #233453;
}

.tree-file {
  grid-template-columns: 16px minmax(0, 1fr) 24px;
  color: var(--muted);
  font-weight: 700;
}

.tree-caret {
  color: var(--muted);
  font-size: 12px;
}

.tree-folder-icon,
.tree-doc-icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 6px;
}

.tree-folder-icon {
  position: relative;
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.tree-folder-icon::before {
  content: "";
  width: 13px;
  height: 9px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.tree-folder-icon::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 7px;
  height: 3px;
  border-radius: 2px 2px 0 0;
  background: currentColor;
}

.tree-doc-icon {
  position: relative;
}

.tree-doc-icon::before {
  content: "";
  width: 12px;
  height: 15px;
  border: 2px solid #8aa0bf;
  border-radius: 3px;
  background: #ffffff;
}

.tree-label {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
  color: inherit;
  background: transparent;
}

.tree-name {
  min-width: 0;
  background: transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shared-badge {
  flex: 0 0 auto;
  min-width: max-content;
  border: 1px solid #b8d7ff;
  border-radius: 999px;
  padding: 1px 6px 2px;
  color: var(--accent-deep);
  background: #eef6ff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.35;
}

.tree-label .shared-badge.compact {
  min-width: 32px;
  padding: 1px 5px 2px;
  text-align: center;
  font-size: 10px;
  line-height: 1.25;
}

.tree-label .shared-badge.muted {
  border-color: #d7e0ec;
  color: #64748b;
  background: #f4f7fb;
}

.lock-badge {
  flex: 0 0 auto;
  min-width: max-content;
  border: 1px solid #f7d372;
  border-radius: 999px;
  padding: 1px 6px 2px;
  color: #9a6700;
  background: #fff5cc;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.35;
}

.folder-row .shared-badge {
  font-size: 12px;
}

.folder-row .lock-badge {
  margin-left: 6px;
  font-size: 12px;
}

.tree-more {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent !important;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  opacity: 0;
}

.tree-more:hover,
.tree-more:focus-visible {
  background: transparent !important;
  color: var(--accent-deep);
}

.tree-item:hover .tree-more,
.tree-item.active .tree-more {
  opacity: 1;
}

.tree-children {
  margin-left: 15px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.tree-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.tree-section-title {
  margin: 0 0 7px 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.trash-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 18px;
  overflow: hidden;
}

.trash-page[hidden] {
  display: none;
}

.trash-header,
.trash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.trash-list {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
}

.trash-row {
  justify-content: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
}

.trash-row > div:nth-child(2) {
  flex: 1;
  min-width: 0;
}

.trash-row strong {
  display: block;
  margin-bottom: 3px;
}

.trash-row p {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-item.drop-target-folder {
  border-color: var(--focus);
  background: #eef6ff;
}

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

body.sidebar-collapsed .sidebar {
  align-items: center;
  padding: 14px 8px;
}

body.sidebar-collapsed .sidebar-head div,
body.sidebar-collapsed .sidebar-tree,
body.sidebar-collapsed .sidebar-footer span:last-child {
  display: none;
}

body.sidebar-collapsed .drawer-entry {
  grid-template-columns: 1fr;
  width: 38px;
  min-height: 38px;
  padding: 0;
  place-items: center;
}

body.sidebar-collapsed #collapseSidebarButton {
  transform: rotate(180deg);
}

@media (max-width: 900px) {
  .topbar,
  .app-shell,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    height: auto;
    padding: 14px;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    padding: 14px;
  }

  .editor-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .muted-text {
    text-align: left;
  }

  #titleInput {
    width: 100%;
    font-size: 23px;
  }
}
