/* Infokai Files — stylesheet */

:root {
  --bg: #0b1020;
  --panel: rgba(255, 255, 255, .045);
  --menu-bg: #141d31;
  --panel-solid: #131a2c;
  --line: rgba(255, 255, 255, .10);
  --text: #e8ecf6;
  --muted: #96a0b8;
  --accent: #5b8cff;
  --accent2: #37d6a3;
  --danger: #ff6b6b;
  --radius: 14px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 12% -10%, rgba(91, 140, 255, .18), transparent 60%),
    radial-gradient(900px 520px at 88% 4%, rgba(55, 214, 163, .12), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #06101f;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 8px 22px rgba(91, 140, 255, .32);
}
.mark.big { width: 52px; height: 52px; border-radius: 15px; font-size: 24px; margin: 0 auto 14px; }


/* ---------- layout ---------- */
.wrap {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 18px 18px 48px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
  backdrop-filter: blur(8px);
}

.card.center { text-align: center; padding: 44px 24px; }
.card.center h1 { font-size: 46px; margin: 0 0 8px; }
.muted { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: rgba(255, 255, 255, .10); text-decoration: none; border-color: rgba(255, 255, 255, .18); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #4a76e8);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px rgba(91, 140, 255, .28);
}
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 4px 10px; font-size: 12.5px; }
.btn.danger {
  background: rgba(255, 107, 107, .10);
  border-color: rgba(255, 107, 107, .34);
  color: #ffb3b3;
}
.btn.danger:hover {
  background: rgba(255, 107, 107, .20);
  border-color: rgba(255, 107, 107, .52);
  color: #ffd0d0;
}
.btn.wide { width: 100%; padding: 12px; font-size: 15px; }

/* ---------- breadcrumbs ---------- */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--muted);
  word-break: break-word;
}
.crumbs .sep { color: #4d5872; margin: 0 2px; }
.crumbs a { color: #cfd8ec; }
.crumbs a:last-child { color: var(--text); font-weight: 600; }

/* ---------- compact toolbar (single row) ---------- */
.card.tools { padding: 12px 14px; }
.tools .toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.tb-group { display: flex; align-items: center; gap: 10px; margin: 0; }
.tb-sep { width: 1px; height: 24px; background: var(--line); flex: 0 0 auto; }
.tb-hint {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.tb-hint i { color: var(--accent); }
.tools .btn { padding: 7px 11px; font-size: 13px; }
.tools .textin { width: 170px; min-width: 130px; padding: 8px 11px; font-size: 13.5px; }
.tools .filepick input[type="file"] { font-size: 12.5px; max-width: 205px; }
.tools .filepick input[type="file"]::file-selector-button {
  padding: 6px 11px;
  margin-right: 9px;
  font-size: 12.5px;
}
.textin {
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .28);
  color: var(--text);
  font-size: 14px;
  min-width: 220px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textin:focus {
  border-color: rgba(91, 140, 255, .75);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, .16);
}
.textin::placeholder { color: #5f6a84; }
.filepick input[type="file"] {
  font-size: 13.5px;
  color: var(--muted);
  max-width: 340px;
}
.filepick input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  cursor: pointer;
}
.filepick input[type="file"]::file-selector-button:hover { background: rgba(255, 255, 255, .12); }

/* ---------- table ---------- */
.tablewrap { overflow-x: auto; }
table.files {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}
table.files th {
  text-align: left;
  font-size: 11.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 10px 12px;
  border-bottom: 1px solid var(--line);
}
table.files td {
  padding: 11px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .055);
  vertical-align: middle;
}
table.files tr:last-child td { border-bottom: none; }
table.files tbody tr:hover { background: rgba(255, 255, 255, .035); }

.col-size { width: 92px; white-space: nowrap; color: var(--muted); }
.col-date { width: 140px; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-act { width: 336px; text-align: left; white-space: nowrap; }
.actions { display: flex; gap: 8px; justify-content: flex-start; align-items: center; }
.actions form { display: flex; margin: 0; }

/* icon-only action buttons */
.btn.iconbtn {
  width: 32px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
}
.btn.iconbtn i { pointer-events: none; }

.entry {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  word-break: break-word;
}
.entry:hover { color: var(--accent); text-decoration: none; }
.entry .ico { font-size: 15px; width: 18px; text-align: center; opacity: .9; }

/* file-type icon colors */
.ti-pdf { color: #ff8080; }
.ti-word { color: #7fa9ff; }
.ti-excel { color: #5ed49b; }
.ti-ppt { color: #ffb066; }
.ti-img { color: #c58cff; }
.ti-zip { color: #e0c46c; }
.ti-audio { color: #8cd8e0; }
.ti-video { color: #f091c3; }
.row-dir .entry { font-weight: 600; }
.row-dir .slash { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

/* ---------- meta + footer ---------- */
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
  padding: 0 4px;
}
.meta .path { margin-left: auto; font-family: ui-monospace, Menlo, Consolas, monospace; opacity: .8; }

.foot {
  text-align: center;
  color: #5c6780;
  font-size: 12.5px;
  padding: 24px 0 34px;
}

/* ---------- flash ---------- */
.flash {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}
.flash.ok { background: rgba(55, 214, 163, .10); border-color: rgba(55, 214, 163, .30); color: #8ff0cd; }
.flash.err { background: rgba(255, 107, 107, .10); border-color: rgba(255, 107, 107, .30); color: #ffb3b3; }

/* ---------- login ---------- */
.login-shell {
  min-height: calc(100vh - 170px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card.login {
  width: 100%;
  max-width: 400px;
  padding: 34px 30px;
}
.login-head { text-align: center; margin-bottom: 24px; }
.login-head h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.01em; }
.login-head p { margin: 0; font-size: 14px; }

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 7px;
  letter-spacing: .02em;
}
.field input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .28);
  color: var(--text);
  font-size: 14.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: rgba(91, 140, 255, .75);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, .16);
}
.field input::placeholder { color: #5f6a84; }

@media (max-width: 620px) {
  .wrap { padding: 16px 14px 50px; }
  .col-date { display: none; }
  table.files th.col-date { display: none; }
}

/* ---------- confirmation modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 8, 18, .70);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .17s ease;
}
.modal-backdrop[hidden] { display: none; }
.modal-backdrop.is-open { opacity: 1; }

.modal {
  width: 100%;
  max-width: 424px;
  padding: 28px 26px 22px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, .11);
  background:
    radial-gradient(520px 200px at 50% -20%, rgba(255, 107, 107, .10), transparent 70%),
    linear-gradient(180deg, #161e33, #111827);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), 0 2px 0 rgba(255, 255, 255, .04) inset;
  text-align: center;
  transform: translateY(10px) scale(.96);
  opacity: 0;
  transition: transform .19s cubic-bezier(.2, .9, .3, 1.2), opacity .17s ease;
}
.modal-backdrop.is-open .modal { transform: none; opacity: 1; }

.modal-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 21px;
  color: #ffb3b3;
  background: rgba(255, 107, 107, .12);
  border: 1px solid rgba(255, 107, 107, .30);
  box-shadow: 0 0 0 6px rgba(255, 107, 107, .06);
}
.modal-icon.is-folder {
  color: #ffc98a;
  background: rgba(255, 176, 102, .12);
  border-color: rgba(255, 176, 102, .32);
  box-shadow: 0 0 0 6px rgba(255, 176, 102, .06);
}

.modal h2 {
  margin: 0 0 9px;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -.01em;
}
.modal p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.modal-actions .btn {
  flex: 1 1 0;
  padding: 11px 18px;
  font-size: 14.5px;
  border-radius: 10px;
}

.btn.danger-solid {
  background: linear-gradient(135deg, #ff6b6b, #e13d3d);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(255, 107, 107, .28);
}
.btn.danger-solid:hover { filter: brightness(1.07); background: linear-gradient(135deg, #ff7b7b, #e84a4a); }
.btn.danger-solid:active { transform: translateY(1px); }

body.modal-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .modal, .modal-backdrop { transition: none; }
}

/* ---------- editor screen ---------- */
.editor-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0 -18px 10px;
  padding: 8px 18px 9px;
  background: rgba(10, 15, 28, .94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.editor-file .crumbs { margin-bottom: 8px; }
.editor-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.editor-title h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
.editor-title .ico { color: var(--accent2); }
.badge {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #9fb2d8;
  background: rgba(91, 140, 255, .14);
  border: 1px solid rgba(91, 140, 255, .30);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.editor-buttons { display: flex; gap: 10px; align-items: center; }

.editor-card {
  padding: 0;
  border-radius: 14px;
}
.plain-editor {
  display: block;
  width: 100%;
  min-height: 58vh;
  padding: 18px;
  border: 0;
  outline: none;
  resize: vertical;
  background: #0b1120;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.65;
}
.md-source { display: none; }

.editor-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 12.5px;
}
kbd {
  font-family: inherit;
  font-size: 11.5px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .07);
}

/* toast (editor notifications) */
.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  z-index: 120;
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #16203a;
  color: var(--text);
  font-size: 13.5px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .18s ease, transform .18s ease;
}
.toast[hidden] { display: none; }
.toast.is-open { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(55, 214, 163, .35); color: #8ff0cd; }
.toast.err { border-color: rgba(255, 107, 107, .40); color: #ffb3b3; }

/* ---------- EasyMDE (markdown) dark theme ---------- */
.EasyMDEContainer .editor-toolbar {
  background: #0f1526;
  border-color: var(--line);
  border-radius: 12px 12px 0 0;
  opacity: 1;
}
.EasyMDEContainer .editor-toolbar button {
  color: #c2cadb !important;
  border-color: transparent !important;
  background: transparent;
}
.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar button.active {
  background: rgba(255, 255, 255, .09);
  border-color: var(--line) !important;
}
.EasyMDEContainer .editor-toolbar i.separator {
  border-left-color: var(--line);
  border-right-color: transparent;
}
.EasyMDEContainer .CodeMirror {
  background: #0b1120;
  color: var(--text);
  border-color: var(--line);
  border-radius: 0 0 12px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.7;
}
/* EasyMDE scales headings with vw units — keep a calm, fixed scale */
.EasyMDEContainer .CodeMirror .cm-header { color: #cfe0ff; }
.EasyMDEContainer .CodeMirror .cm-header-1 { font-size: 1.3rem; }
.EasyMDEContainer .CodeMirror .cm-header-2 { font-size: 1.15rem; }
.EasyMDEContainer .CodeMirror .cm-header-3 { font-size: 1.02rem; }
.EasyMDEContainer .CodeMirror .cm-strong { color: #ffd08a; }
.EasyMDEContainer .CodeMirror .cm-link { color: var(--accent2); }
.EasyMDEContainer .CodeMirror .cm-url { color: #7f8ba8; }
.EasyMDEContainer .CodeMirror-scroll { min-height: 55vh; }
.EasyMDEContainer .CodeMirror-cursor { border-left-color: var(--text); }
.EasyMDEContainer .CodeMirror-selected { background: rgba(91, 140, 255, .26) !important; }
.EasyMDEContainer .editor-statusbar { color: var(--muted); }
.EasyMDEContainer .editor-statusbar span { color: var(--muted); }
.EasyMDEContainer .editor-preview,
.EasyMDEContainer .editor-preview-side {
  background: #0b1120;
  color: var(--text);
}
.EasyMDEContainer .editor-preview a { color: var(--accent); }
.EasyMDEContainer .editor-preview img { max-width: 100%; }

/* ---------- toolbar: new file + dropzone ---------- */
.btn.newfile {
  background: linear-gradient(135deg, rgba(91, 140, 255, .22), rgba(55, 214, 163, .16));
  border-color: rgba(91, 140, 255, .38);
  color: #dfe8ff;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(91, 140, 255, .14);
}
.btn.newfile:hover {
  background: linear-gradient(135deg, rgba(91, 140, 255, .32), rgba(55, 214, 163, .24));
  border-color: rgba(91, 140, 255, .58);
  box-shadow: 0 8px 22px rgba(91, 140, 255, .22);
}
.btn.newfile i { color: var(--accent2); }

.dropzone {
  border-radius: 10px;
  transition: background .15s ease, box-shadow .15s ease;
}
.dropzone.is-over {
  background: rgba(91, 140, 255, .08);
  box-shadow: 0 0 0 1.5px rgba(91, 140, 255, .55);
}
.dropzone.is-busy { opacity: .55; pointer-events: none; }

.drop-overlay {
  position: fixed;
  inset: 14px;
  z-index: 95;
  display: grid;
  place-items: center;
  pointer-events: none;
  border: 2px dashed rgba(91, 140, 255, .60);
  border-radius: 18px;
  background: rgba(8, 12, 24, .82);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .14s ease;
}
.drop-overlay[hidden] { display: none; }
.drop-overlay.is-open { opacity: 1; }
.drop-overlay-inner {
  display: grid;
  justify-items: center;
  gap: 9px;
  text-align: center;
  color: var(--text);
}
.drop-overlay-inner i { font-size: 42px; color: var(--accent); }
.drop-overlay-inner strong { font-size: 18px; letter-spacing: -.01em; }
.drop-overlay-inner span { color: var(--muted); font-size: 13.5px; }
.drop-overlay-inner code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
}

/* ---------- form modal (new file) ---------- */
.modal-form { text-align: left; }
.modal-form .modal-icon { margin-left: auto; margin-right: auto; }
.modal-form h2 { text-align: center; }
.modal-sub { text-align: center; margin-bottom: 20px; }
.modal .field { margin-bottom: 14px; }
.modal .modal-actions { margin-top: 20px; }

.modal-icon.is-file {
  color: #9fd0ff;
  background: rgba(91, 140, 255, .12);
  border-color: rgba(91, 140, 255, .30);
  box-shadow: 0 0 0 6px rgba(91, 140, 255, .06);
}

.selectwrap { position: relative; display: block; }
.selectwrap::after {
  content: "";
  position: absolute;
  right: 15px;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}
.selectin {
  width: 100%;
  padding: 11px 38px 11px 13px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .28);
  color: var(--text);
  font-size: 14.5px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
.selectin:focus {
  border-color: rgba(91, 140, 255, .75);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, .16);
}
.selectin option { background: #131a2c; color: var(--text); }

/* ---------- sign-out icon ---------- */
.btn.signout {
  width: 32px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border-color: rgba(255, 255, 255, .10);
  flex: 0 0 auto;
}
.btn.signout:hover {
  color: #ffb3b3;
  background: rgba(255, 107, 107, .10);
  border-color: rgba(255, 107, 107, .32);
}
.tools .btn.signout { padding: 0; }
.editor-buttons .btn.signout { padding: 0; }

/* ---------- editor split + shared outline panel ---------- */
.editor-split {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  min-height: 460px;
}
.editor-host { flex: 1 1 auto; min-width: 0; }

.outline-panel {
  position: sticky;
  top: 84px;
  flex: 0 0 auto;
  width: 236px;
  max-height: calc(100vh - 104px);
  min-width: 30px;
  max-width: 60vw;
  display: flex;
  flex-direction: column;
  padding: 10px 8px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
  overflow: hidden;
}
.outline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 18px;
}
.outline-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}
.outline-toggle {
  padding: 2px 5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.outline-toggle:hover { background: rgba(255, 255, 255, .08); color: var(--text); }

.outline-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: auto;
  margin-right: 2px;
}

/* drag handle */
.outline-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
}
.outline-resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 3px;
  width: 2px;
  height: 26px;
  transform: translateY(-50%);
  border-radius: 2px;
  background: rgba(255, 255, 255, .18);
  opacity: 0;
  transition: opacity .15s ease;
}
.outline-panel:hover .outline-resizer::after { opacity: 1; }
.outline-resizer:hover::after { background: var(--accent); opacity: 1; }
body.is-resizing { cursor: col-resize; user-select: none; }

/* collapsed to a slim rail */
.outline-panel.is-collapsed { width: 30px !important; padding: 8px 4px; }
.outline-panel.is-collapsed .outline-label,
.outline-panel.is-collapsed .outline-toggle,
.outline-panel.is-collapsed .outline-list { display: none; }
.outline-panel.is-collapsed .outline-head { justify-content: center; }

.outline-item {
  display: block;
  width: 100%;
  flex: 0 0 auto;   /* never squeeze: long outlines scroll, they don't squash */
  padding: 5px 8px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #b9c4da;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.outline-item:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.outline-item.active {
  background: rgba(91, 140, 255, .14);
  border-left-color: var(--accent);
  color: #dbe6ff;
}
.outline-item.lvl-1 { font-weight: 600; color: #d7dfef; }
.outline-item.lvl-2 { padding-left: 18px; }
.outline-item.lvl-3 { padding-left: 30px; font-size: 12.5px; }
.outline-item.lvl-4 { padding-left: 40px; font-size: 12px; }
.outline-item.lvl-5 { padding-left: 48px; font-size: 12px; }
.outline-item.lvl-6 { padding-left: 56px; font-size: 12px; }
.outline-empty { margin: 0; font-size: 12.5px; color: var(--muted); }

/* ---------- preview page with outline ---------- */
.viewer-shell {
  display: flex;
  gap: 12px;
  height: calc(100vh - 100px);
  min-height: 420px;
}
.viewer-frame-wrap {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.viewer-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }

@media (max-width: 900px) {
  .editor-split { flex-direction: column; }
  .outline-panel { width: auto !important; max-width: none; max-height: 170px; }
  .outline-resizer { display: none; }
  .viewer-shell { flex-direction: column; height: auto; }
  .viewer-frame-wrap { height: 70vh; }
}

/* images rendered inside the editor */
.cm-inline-img {
  display: inline-block;
  max-width: 100%;
  max-height: 340px;
  margin: 6px 0;
  border-radius: 9px;
  vertical-align: middle;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .38);
  cursor: zoom-in;
}

.cm-hash-hidden { display: inline-block; width: 0; }

/* ---------- theme switch ---------- */
.theme-switch {
  position: fixed;
  top: 10px;
  right: 14px;
  z-index: 80;
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(11, 16, 32, .72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .28);
}
.theme-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.theme-btn:hover { background: rgba(255, 255, 255, .10); color: var(--text); }
.theme-btn.is-active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #06101f;
}

/* ---------- light theme ---------- */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-solid: #ffffff;
  --menu-bg: #ffffff;
  --line: rgba(15, 23, 42, .12);
  --text: #16203a;
  --muted: #5f6b85;
  --accent: #3563e9;
  --accent2: #0f9d76;
  --danger: #d64545;
}
html[data-theme="light"] body {
  background:
    radial-gradient(1100px 620px at 12% -10%, rgba(53, 99, 233, .10), transparent 60%),
    radial-gradient(900px 520px at 88% 4%, rgba(15, 157, 118, .08), transparent 55%),
    var(--bg);
}
html[data-theme="light"] .theme-switch {
  background: rgba(255, 255, 255, .85);
  box-shadow: 0 8px 22px rgba(16, 24, 40, .12);
}
html[data-theme="light"] .theme-btn:hover { background: rgba(15, 23, 42, .06); }
html[data-theme="light"] .theme-btn.is-active { color: #fff; }

html[data-theme="light"] .card {
  background: #fff;
  border-color: rgba(15, 23, 42, .10);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

html[data-theme="light"] .btn {
  background: #fff;
  border-color: rgba(15, 23, 42, .14);
  color: var(--text);
}
html[data-theme="light"] .btn:hover {
  background: #f1f4fa;
  border-color: rgba(15, 23, 42, .22);
}
html[data-theme="light"] .editor-bar {
  background: rgba(255, 255, 255, .92);
  border-bottom-color: rgba(15, 23, 42, .10);
}
html[data-theme="light"] .btn.primary {
  background: linear-gradient(135deg, var(--accent), #2f56d0);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px rgba(53, 99, 233, .28);
}
html[data-theme="light"] .btn.primary:hover { color: #fff; }
html[data-theme="light"] .btn.danger-solid {
  background: linear-gradient(135deg, #ff6b6b, #e13d3d);
  border-color: transparent;
  color: #fff;
}
html[data-theme="light"] .btn.danger-solid:hover {
  background: linear-gradient(135deg, #ff7b7b, #e84a4a);
  color: #fff;
}
html[data-theme="light"] .btn.ghost { background: transparent; }
html[data-theme="light"] .btn.danger,
html[data-theme="light"] .btn.iconbtn.danger {
  background: rgba(214, 69, 69, .07);
  border-color: rgba(214, 69, 69, .28);
  color: #b42318;
}
html[data-theme="light"] .btn.danger:hover {
  background: rgba(214, 69, 69, .13);
  border-color: rgba(214, 69, 69, .45);
}
html[data-theme="light"] .btn.signout { background: #fff; color: var(--muted); }
html[data-theme="light"] .btn.newfile {
  background: linear-gradient(135deg, rgba(53, 99, 233, .14), rgba(15, 157, 118, .12));
  border-color: rgba(53, 99, 233, .32);
  color: #1e3a8a;
}
html[data-theme="light"] .btn.newfile:hover {
  background: linear-gradient(135deg, rgba(53, 99, 233, .22), rgba(15, 157, 118, .18));
  border-color: rgba(53, 99, 233, .48);
}

html[data-theme="light"] table.files td { border-bottom-color: rgba(15, 23, 42, .07); }
html[data-theme="light"] table.files tbody tr:hover { background: rgba(15, 23, 42, .03); }
html[data-theme="light"] .entry { color: var(--text); }
html[data-theme="light"] .entry:hover { color: var(--accent); }

html[data-theme="light"] .crumbs a { color: #475569; }
html[data-theme="light"] .crumbs a:last-child { color: var(--text); }
html[data-theme="light"] .crumbs .sep { color: #94a3b8; }

html[data-theme="light"] .textin,
html[data-theme="light"] .selectin,
html[data-theme="light"] .field input {
  background: #fff;
  border-color: rgba(15, 23, 42, .16);
  color: var(--text);
}
html[data-theme="light"] .textin::placeholder,
html[data-theme="light"] .field input::placeholder { color: #94a3b8; }
html[data-theme="light"] .selectin option { background: #fff; color: var(--text); }
html[data-theme="light"] .selectwrap::after { border-top-color: #64748b; }
html[data-theme="light"] .filepick input[type="file"] { color: var(--muted); }
html[data-theme="light"] .filepick input[type="file"]::file-selector-button {
  background: #fff;
  border-color: rgba(15, 23, 42, .16);
  color: var(--text);
}

html[data-theme="light"] .modal {
  background: #fff;
  border-color: rgba(15, 23, 42, .10);
  box-shadow: 0 30px 80px rgba(16, 24, 40, .25);
}
html[data-theme="light"] .modal-backdrop { background: rgba(15, 23, 42, .45); }

html[data-theme="light"] .toast {
  background: #fff;
  color: var(--text);
  box-shadow: 0 14px 40px rgba(16, 24, 40, .18);
}
html[data-theme="light"] .toast.ok { color: #047857; }
html[data-theme="light"] .toast.err { color: #b42318; }

html[data-theme="light"] .flash.ok {
  background: rgba(16, 185, 129, .10);
  border-color: rgba(16, 185, 129, .30);
  color: #047857;
}
html[data-theme="light"] .flash.err {
  background: rgba(214, 69, 69, .08);
  border-color: rgba(214, 69, 69, .30);
  color: #b42318;
}

html[data-theme="light"] .drop-overlay { background: rgba(244, 246, 251, .92); }
html[data-theme="light"] .drop-overlay-inner code {
  background: rgba(15, 23, 42, .05);
  border-color: var(--line);
}

html[data-theme="light"] .outline-panel {
  background: #fff;
  border-color: rgba(15, 23, 42, .10);
}
html[data-theme="light"] .outline-item { color: #475569; }
html[data-theme="light"] .outline-item:hover { background: rgba(15, 23, 42, .05); color: var(--text); }
html[data-theme="light"] .outline-item.active {
  background: rgba(53, 99, 233, .12);
  border-left-color: var(--accent);
  color: #1e3a8a;
}
html[data-theme="light"] .outline-item.lvl-1 { color: #0f172a; }
html[data-theme="light"] .outline-resizer::after { background: rgba(15, 23, 42, .22); }

html[data-theme="light"] .EasyMDEContainer .editor-toolbar {
  background: #f8fafc;
  border-color: var(--line);
}
html[data-theme="light"] .EasyMDEContainer .editor-toolbar button { color: #334155 !important; }
html[data-theme="light"] .EasyMDEContainer .editor-toolbar button:hover,
html[data-theme="light"] .EasyMDEContainer .editor-toolbar button.active {
  background: rgba(15, 23, 42, .06);
}
html[data-theme="light"] .EasyMDEContainer .CodeMirror {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}
html[data-theme="light"] .EasyMDEContainer .CodeMirror-cursor { border-left-color: var(--text); }
html[data-theme="light"] .EasyMDEContainer .CodeMirror-selected { background: rgba(53, 99, 233, .16) !important; }
html[data-theme="light"] .EasyMDEContainer .editor-statusbar,
html[data-theme="light"] .EasyMDEContainer .editor-statusbar span { color: var(--muted); }
html[data-theme="light"] .EasyMDEContainer .editor-preview,
html[data-theme="light"] .EasyMDEContainer .editor-preview-side {
  background: #fff;
  color: var(--text);
}
html[data-theme="light"] .EasyMDEContainer .CodeMirror .cm-header { color: #1e3a8a; }
html[data-theme="light"] .EasyMDEContainer .CodeMirror .cm-strong { color: #0f172a; }
html[data-theme="light"] .EasyMDEContainer .CodeMirror .cm-link { color: #0f766e; }
html[data-theme="light"] .EasyMDEContainer .CodeMirror .cm-url { color: #64748b; }
html[data-theme="light"] .cm-inline-img { box-shadow: 0 6px 18px rgba(16, 24, 40, .18); }


html[data-theme="light"] .plain-editor { background: #fff; color: var(--text); }
html[data-theme="light"] .badge {
  color: #1d4ed8;
  background: rgba(53, 99, 233, .10);
  border-color: rgba(53, 99, 233, .24);
}
html[data-theme="light"] .foot { color: #94a3b8; }
html[data-theme="light"] kbd { background: #eef2f9; }

/* ---------- floating flash message ---------- */
.flash-float {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 130;
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: min(760px, calc(100vw - 32px));
  padding: 12px 12px 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #16203a;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity .2s ease, transform .2s ease;
}
.flash-float.is-open { opacity: 1; transform: translate(-50%, 0); }
.flash-float.ok { border-color: rgba(55, 214, 163, .35); }
.flash-float.ok > i { color: #37d6a3; }
.flash-float.err { border-color: rgba(255, 107, 107, .40); }
.flash-float.err > i { color: #ff6b6b; }
.flash-float-text { overflow-wrap: anywhere; }

.flash-float-close {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.flash-float-close:hover { background: rgba(255, 255, 255, .10); color: var(--text); }

html[data-theme="light"] .flash-float {
  background: #fff;
  box-shadow: 0 18px 50px rgba(16, 24, 40, .18);
}
html[data-theme="light"] .flash-float.ok { border-color: rgba(16, 185, 129, .35); }
html[data-theme="light"] .flash-float.ok > i { color: #059669; }
html[data-theme="light"] .flash-float.err { border-color: rgba(214, 69, 69, .35); }
html[data-theme="light"] .flash-float.err > i { color: #d64545; }
html[data-theme="light"] .flash-float-close:hover { background: rgba(15, 23, 42, .07); }

/* ---------- up / home navigation ---------- */
.tb-nav { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.btn.navbtn {
  width: 32px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, .05);
  border-color: rgba(255, 255, 255, .12);
}
.btn.navbtn:hover { background: rgba(255, 255, 255, .11); text-decoration: none; }
.btn.navbtn.is-disabled {
  opacity: .35;
  pointer-events: none;
  cursor: default;
}
html[data-theme="light"] .btn.navbtn {
  background: #fff;
  border-color: rgba(15, 23, 42, .16);
}
html[data-theme="light"] .btn.navbtn:hover { background: #f1f4fa; }

/* ---------- bulk selection ---------- */
.col-check { width: 38px; padding-left: 10px !important; }
.col-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}
.col-edit { width: 44px; padding-right: 0 !important; }
.col-edit .btn.iconbtn { width: 30px; height: 28px; }

.btn.bulk-delete { flex: 0 0 auto; }
.btn.bulk-delete:disabled {
  opacity: .45;
  cursor: default;
  background: rgba(255, 255, 255, .04);
  border-color: rgba(255, 255, 255, .10);
  color: var(--muted);
  box-shadow: none;
}
.btn.bulk-delete:disabled i { color: var(--muted); }
.bulk-count { font-variant-numeric: tabular-nums; opacity: .85; }

html[data-theme="light"] .btn.bulk-delete:disabled {
  background: #f4f6fb;
  border-color: rgba(15, 23, 42, .10);
}

/* ---------- TinyMCE (WYSIWYG) ---------- */
.tox-tinymce {
  border-radius: 12px !important;
  border-color: var(--line) !important;
  overflow: hidden;
}
.tox .tox-menubar,
.tox .tox-toolbar,
.tox .tox-toolbar-overlord,
.tox .tox-toolbar__overflow,
.tox .tox-toolbar__primary {
  background: transparent !important;
}
body:not([data-theme="light"]) .tox .tox-toolbar-overlord,
body:not([data-theme="light"]) .tox .tox-menubar {
  background-color: #0f1526 !important;
}
html[data-theme="light"] .tox .tox-toolbar-overlord,
html[data-theme="light"] .tox .tox-menubar {
  background-color: #f8fafc !important;
}
.tox .tox-statusbar { font-size: 11.5px; }

/* ---------- rename + copy/move destination ---------- */
.btn.bulk-copy,
.btn.bulk-move { flex: 0 0 auto; }
.btn.bulk-copy:disabled,
.btn.bulk-move:disabled {
  opacity: .45;
  cursor: default;
  background: rgba(255, 255, 255, .04);
  border-color: rgba(255, 255, 255, .10);
  color: var(--muted);
  box-shadow: none;
}
html[data-theme="light"] .btn.bulk-copy:disabled,
html[data-theme="light"] .btn.bulk-move:disabled {
  background: #f4f6fb;
  border-color: rgba(15, 23, 42, .10);
}

.dest-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.dest-path {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, .22);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[data-theme="light"] .dest-path { background: #f7f9fd; }

.dest-list {
  min-height: 132px;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.dest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.dest-item:hover { background: rgba(255, 255, 255, .07); }
.dest-item i { color: #e8b45a; width: 16px; }
html[data-theme="light"] .dest-item:hover { background: rgba(15, 23, 42, .05); }
.dest-empty {
  margin: 0;
  padding: 22px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- quick preview modal ---------- */
.preview-modal {
  width: min(1180px, 94vw);
  max-width: none;
  padding: 0;
  text-align: left;
  overflow: hidden;
}
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px 12px 18px;
  border-bottom: 1px solid var(--line);
}
.preview-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-tools { display: flex; gap: 8px; flex: 0 0 auto; }
.preview-body {
  height: min(76vh, 820px);
  background: #0e1424;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.preview-image {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
}
html[data-theme="light"] .preview-body { background: #eef2f9; }

/* ---------- convert modal ---------- */
.convert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.convert-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .05s;
}
.convert-option:hover:not(:disabled) {
  background: rgba(91, 140, 255, .12);
  border-color: rgba(91, 140, 255, .45);
}
.convert-option:active:not(:disabled) { transform: translateY(1px); }
.convert-option:disabled { opacity: .6; cursor: default; }
.convert-option i { font-size: 18px; color: var(--accent); }
html[data-theme="light"] .convert-option { background: #f8fafc; }
html[data-theme="light"] .convert-option:hover:not(:disabled) { background: rgba(53, 99, 233, .10); }

/* ---------- full-page PDF view ---------- */
.pdf-shell {
  height: calc(100vh - 100px);
  min-height: 480px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.pdf-frame { width: 100%; height: 100%; border: 0; display: block; }

/* ---------- annotations ---------- */
.ann-bar {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 15, 28, .92);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.ann-bar.is-open { display: flex; }
.ann-bar-label {
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ann-swatch {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
  transition: transform .12s;
}
.ann-swatch:hover { transform: scale(1.15); }
.ann-swatch.is-active { box-shadow: 0 0 0 2px var(--accent); }
.ann-bar-sep { width: 1px; height: 18px; background: var(--line); }
.ann-note-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid rgba(91, 140, 255, .45);
  border-radius: 999px;
  background: rgba(91, 140, 255, .16);
  color: #dbe6ff;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.ann-note-btn:hover { background: rgba(91, 140, 255, .28); }

.note-editor { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.note-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
}
.note-toolbar button {
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.note-toolbar button:hover { background: rgba(255, 255, 255, .09); }
.note-sep { width: 1px; height: 16px; background: var(--line); margin: 0 4px; }
.note-colors { display: inline-flex; gap: 6px; }
.note-body {
  min-height: 96px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.6;
  outline: none;
}
.note-body:empty::before {
  content: 'Write your note…';
  color: var(--muted);
}

.ann-tip {
  position: fixed;
  z-index: 210;
  max-width: 340px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #16203a;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
}
.ann-tip[hidden] { display: none; }
.ann-tip p:first-child { margin-top: 0; }
.ann-tip p:last-child { margin-bottom: 0; }

html[data-theme="light"] .ann-bar { background: rgba(255, 255, 255, .95); }
html[data-theme="light"] .ann-note-btn { color: #1e3a8a; }
html[data-theme="light"] .ann-tip { background: #fff; box-shadow: 0 16px 40px rgba(16, 24, 40, .18); }
html[data-theme="light"] .note-toolbar { background: #f8fafc; }

/* ---------- markdown live preview (Obsidian-style) ---------- */
.cm-md-strong { font-weight: 700; color: #fff; }
.cm-md-em { font-style: italic; }
.cm-md-strike { text-decoration: line-through; opacity: .65; }
.cm-md-link {
  color: var(--accent2);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cm-md-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em;
  background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 5px;
  padding: 1px 5px;
}
.cm-md-bullet { color: var(--accent); font-weight: 700; }
.cm-md-hr {
  display: inline-block;
  width: 100%;
  height: 1px;
  background: var(--line);
  vertical-align: middle;
}
.cm-md-quote {
  border-left: 3px solid rgba(91, 140, 255, .5);
  padding-left: 10px !important;
  color: #b9c4da;
}

html[data-theme="light"] .cm-md-strong { color: #0f172a; }
html[data-theme="light"] .cm-md-link { color: #0f766e; }
html[data-theme="light"] .cm-md-code {
  background: rgba(15, 23, 42, .07);
  border-color: rgba(15, 23, 42, .10);
}
html[data-theme="light"] .cm-md-quote { color: #475569; }

.editor-warning {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 12px 2px 0;
  padding: 11px 14px;
  border: 1px solid rgba(255, 176, 102, .35);
  border-radius: 10px;
  background: rgba(255, 176, 102, .10);
  color: #ffc98a;
  font-size: 13px;
  line-height: 1.5;
}
.editor-warning i { margin-top: 2px; }
html[data-theme="light"] .editor-warning {
  border-color: rgba(180, 83, 9, .30);
  background: rgba(253, 186, 116, .18);
  color: #92400e;
}

.modal-actions-split { flex-wrap: wrap; gap: 8px; }
.modal-actions-split .btn { white-space: nowrap; }
.modal-actions-split .btn:first-child { margin-right: auto; }

/* ---------- API keys page ---------- */
.keys-card {
  max-width: 980px;
  margin: 28px auto 60px;
  padding: 26px 28px 30px;
}
.keys-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}
.keys-head h1 { margin: 0 0 8px; font-size: 22px; }
.keys-head p { margin: 0; max-width: 620px; font-size: 13.5px; line-height: 1.6; }
.keys-head code,
.keys-help code {
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: .92em;
}
.keys-create { flex: 0 0 auto; }
.keys-meta {
  margin: 20px 0 10px;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.keys-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.keys-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.keys-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .05);
  vertical-align: middle;
}
.keys-table tr:last-child td { border-bottom: 0; }
.key-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  word-break: break-all;
}
.keys-date { color: var(--muted); font-size: 13px; white-space: nowrap; }
.keys-actions-col { width: 130px; }
.keys-actions { display: flex; gap: 6px; justify-content: flex-end; }
.inline-form { display: inline; }
.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.pill.ok { background: rgba(88, 214, 141, .16); color: #7ee2a8; }
.pill.off { background: rgba(255, 135, 135, .14); color: #ff9b9b; }
.keys-empty { padding: 26px 0; color: var(--muted); }
.keys-help { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 16px; }
.keys-help summary { cursor: pointer; font-size: 13.5px; font-weight: 600; }
.keys-help pre {
  margin: 14px 0;
  padding: 14px 16px;
  background: rgba(0, 0, 0, .28);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.7;
}
.keys-help pre code { background: none; border: 0; padding: 0; }
html[data-theme="light"] .keys-head code,
html[data-theme="light"] .keys-help code { background: rgba(15, 23, 42, .05); border-color: rgba(15, 23, 42, .10); }
html[data-theme="light"] .keys-table td { border-bottom-color: rgba(15, 23, 42, .07); }
html[data-theme="light"] .keys-help pre { background: #f8fafc; }
html[data-theme="light"] .pill.ok { background: rgba(16, 140, 70, .12); color: #10783c; }
html[data-theme="light"] .pill.off { background: rgba(190, 40, 40, .10); color: #a52222; }

/* ---------- temporary link modal ---------- */
.tlink-result { margin: 4px 0 18px; }
.tlink-row { display: flex; gap: 8px; align-items: center; }
.tlink-url {
  flex: 1 1 auto;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, .28);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}
.tlink-url:focus { outline: none; border-color: var(--accent); }
.tlink-expiry { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
html[data-theme="light"] .tlink-url { background: #f8fafc; }

/* ---------- the empty page for accounts without access ---------- */
.lonely-body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0b1020;
  color: #c9d3e6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
.lonely { display: flex; align-items: center; justify-content: center; }
.lonely-text {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: .01em;
  color: #8a97b1;
}
.lonely-out {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: lowercase;
  color: #3c4761;
  text-decoration: none;
}
.lonely-out:hover { color: #7c8aa6; }
html[data-theme="light"] body.lonely-body { background: #f7f9fc; color: #475569; }
html[data-theme="light"] .lonely-text { color: #64748b; }
html[data-theme="light"] .lonely-out { color: #cbd5e1; }

/* ---------- sharing ---------- */
.tb-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.tb-badge.is-read { background: rgba(255, 176, 102, .14); color: #ffc98a; }
.tb-badge.is-write { background: rgba(88, 214, 141, .16); color: #7ee2a8; }
html[data-theme="light"] .tb-badge.is-read { background: rgba(180, 83, 9, .12); color: #92400e; }
html[data-theme="light"] .tb-badge.is-write { background: rgba(16, 140, 70, .12); color: #10783c; }

.share-list { margin: 14px 0 18px; }
.share-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .05);
}
.share-row:last-child { border-bottom: 0; }
.share-who { flex: 1 1 auto; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
.share-none { margin: 0; color: var(--muted); font-size: 13px; }
html[data-theme="light"] .share-row { border-bottom-color: rgba(15, 23, 42, .07); }

.shared-card { max-width: 900px; margin: 26px auto 60px; padding: 24px 26px 28px; }
.shared-card h1 { margin: 0 0 18px; font-size: 22px; }
.shared-empty { color: var(--muted); }
.shared-group { margin-bottom: 26px; }
.shared-owner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.shared-count { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 12px; }
.shared-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.shared-table td { padding: 10px 4px; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.shared-table tr:last-child td { border-bottom: 0; }
.shared-name a { color: var(--text); text-decoration: none; }
.shared-name a:hover { color: var(--accent2); }
.shared-name i { color: var(--accent); margin-right: 6px; }
.shared-perm { width: 110px; }
.shared-when { width: 110px; text-align: right; color: var(--muted); font-size: 13px; }
.shared-table .pill { background: rgba(255, 255, 255, .08); color: var(--muted); }
html[data-theme="light"] .shared-table td { border-bottom-color: rgba(15, 23, 42, .07); }

/* ---------- impersonation ---------- */
.imp-banner {
  position: sticky;
  top: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: linear-gradient(90deg, #7c3aed, #4f46e5);
  color: #fff;
  font-size: 13.5px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
}
.imp-banner .btn {
  margin-left: auto;
  background: rgba(255, 255, 255, .18);
  border-color: rgba(255, 255, 255, .35);
  color: #fff;
}
.imp-banner .btn:hover { background: rgba(255, 255, 255, .3); }

/* ---------- admin pages ---------- */
.admin-card { max-width: 1100px; margin: 26px auto 60px; padding: 24px 26px 28px; }
.admin-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.admin-head h1 { margin: 0 0 6px; font-size: 22px; }
.admin-head p { margin: 0; }
.admin-search { display: flex; gap: 8px; margin: 18px 0; }
.admin-search .textin { flex: 1 1 auto; }

.admin-form {
  margin: 16px 0 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
}
.admin-flags { display: flex; flex-wrap: wrap; gap: 14px 24px; margin: 6px 0 18px; }
.admin-flags label { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; }

.admin-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 22px; }
.admin-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted); text-decoration: none; font-size: 12.5px;
}
.admin-tab span { font-size: 11px; opacity: .7; }
.admin-tab.is-active { background: rgba(91, 140, 255, .16); border-color: rgba(91, 140, 255, .45); color: var(--text); }

.sr-card {
  position: relative;
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .02);
}
.sr-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.sr-title { margin: 0 0 4px; font-size: 15.5px; }
.sr-meta { margin: 0; font-size: 12.5px; color: var(--muted); }
.sr-body { margin: 12px 0 14px; font-size: 14px; line-height: 1.6; color: var(--text); }
.sr-row { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 12px; }
.sr-status { max-width: 260px; }
.sr-delete { position: absolute; right: 12px; bottom: 12px; }

.support-card { max-width: 620px; }
.login-alt a { color: var(--accent2); }

textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent); }
html[data-theme="light"] textarea { background: #fff; }
html[data-theme="light"] .admin-form,
html[data-theme="light"] .sr-card { background: #fff; }

.lonely-imp {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(124, 58, 237, .16);
  border: 1px solid rgba(124, 58, 237, .45);
  color: #cbb6ff;
  font-size: 12.5px;
}
.lonely-imp .btn { padding: 5px 12px; font-size: 12px; }
html[data-theme="light"] .lonely-imp { background: rgba(124, 58, 237, .08); color: #6d28d9; }

/* ---------- row actions: labelled, with an overflow menu ---------- */
.actions { display: flex; align-items: stretch; gap: 2px; }

.row-act {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 56px;
  padding: 6px 6px 5px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 9.5px;
  letter-spacing: .02em;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.row-act i { font-size: 13.5px; }
.row-act:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.row-act:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.more-wrap { position: relative; }
.more-menu {
  /* fixed, so the table's scroll container cannot clip it */
  position: fixed;
  z-index: 400;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #16203a;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .5);
}
.more-menu[hidden] { display: none; }
.more-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.more-item:hover { background: rgba(255, 255, 255, .08); }
.more-item.danger { color: #ff9b9b; }
.more-item.danger:hover { background: rgba(255, 80, 80, .12); }
.more-item i { width: 14px; text-align: center; opacity: .85; }

html[data-theme="light"] .row-act:hover { background: rgba(15, 23, 42, .06); }
html[data-theme="light"] .more-menu { background: #fff; box-shadow: 0 18px 44px rgba(16, 24, 40, .18); }
html[data-theme="light"] .more-item:hover { background: rgba(15, 23, 42, .06); }
html[data-theme="light"] .more-item.danger { color: #b42318; }
html[data-theme="light"] .more-item.danger:hover { background: rgba(180, 35, 24, .08); }

/* ---------- spreadsheet editor ---------- */
.sheet-wrap {
  height: calc(100vh - 210px);
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
#sheet-editor { width: 100%; height: 100%; }
.doc-mark { color: #2e7d32; }
.badge {
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
}

/* x-spreadsheet sizes its inline cell editor from the current text, which
   collapses to a few pixels on an empty cell so nothing typed is visible.
   A minimum width keeps the caret and the text on screen. */
#sheet-editor { color-scheme: light; }

/* The cell editor is a DOM input over a canvas. Some mobile browsers apply
   their own text colour here, which made typed text invisible, so every colour
   channel is pinned. */
#sheet-editor input {
  min-width: 90px;
  z-index: 20;
  color: #000 !important;
  -webkit-text-fill-color: #000 !important;
  caret-color: #000 !important;
  background: #fff !important;
  opacity: 1 !important;
  font-size: 13px !important;
  color-scheme: light;
}

/* The grid is a canvas with fixed light colours and no theme hook. Inverting it
   looked plausible but also inverted the cell editor, so whatever the user
   typed was drawn dark-on-dark. The sheet now stays on a light "paper"
   background in both themes; the reload of the row is not worth a cell you
   cannot read while typing. */
html[data-theme="dark"] .sheet-wrap {
  background: #ffffff;
  filter: none;
}

/* ---------- toolbar buttons with a caption ---------- */
.tb-icon {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 52px;
  padding: 6px 7px;
  font-size: 9px;
  letter-spacing: .02em;
  line-height: 1;
  white-space: nowrap;
  color: var(--muted);
}
.tb-icon i { font-size: 13.5px; }
.tb-icon:hover { color: var(--text); }
.tb-icon .act-label { opacity: .95; }

/* Keep the account/navigation icons together when the toolbar wraps. */
.tb-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.tb-right .tb-icon { border-color: transparent; }
.tb-right .tb-icon:hover { border-color: var(--line); }
.toolbar { row-gap: 8px; }
.tb-icon .act-label { white-space: nowrap; }

/* ---------- top bar: breadcrumbs + account actions ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.topbar .crumbs { margin-bottom: 0; flex: 1 1 auto; min-width: 0; }

.top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex: 0 0 auto;
}
.top-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.top-btn i { font-size: 12.5px; }
.top-btn:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.top-actions .btn.iconbtn.signout {
  width: auto;
  height: auto;
  padding: 6px 10px;
  gap: 6px;
  border: 0;
  background: transparent;
  white-space: nowrap;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.top-actions .btn.iconbtn.signout:hover { background: rgba(255, 255, 255, .07); color: var(--text); }

/* The labelled toolbar buttons must not inherit the fixed icon-button box. */
.btn.iconbtn.tb-icon {
  width: auto;
  height: auto;
  min-width: 52px;
  padding: 6px 7px;
  flex-direction: column;
  gap: 3px;
  font-size: 9px;
}
.btn.iconbtn.tb-icon i { font-size: 13.5px; }

html[data-theme="light"] .top-btn:hover,
html[data-theme="light"] .top-actions .btn.iconbtn.signout:hover { background: rgba(15, 23, 42, .06); }

/* The note editor's colour swatches were being overridden by the generic
   `.note-toolbar button` rule, which left them transparent. */
.note-toolbar .ann-swatch {
  width: 20px;
  height: 20px;
  min-width: 20px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 50%;
  background: var(--c);
}
.note-toolbar .ann-swatch:hover { transform: scale(1.12); }
.note-toolbar .ann-swatch.is-active { box-shadow: 0 0 0 2px var(--accent); }
.note-colors { align-items: center; }

/* only underline is offered in a note */
.note-underline { font-weight: 700; }

/* ---------- create controls live in the table header ---------- */
.name-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  text-transform: none;
  letter-spacing: 0;
}
.name-label {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 11.5px;
  flex: 0 0 auto;
}
.head-mkdir { display: flex; align-items: center; gap: 6px; margin: 0; }
.head-input {
  width: 168px;
  min-width: 120px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}
.name-head .btn {
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}
table.files th.col-name { padding-bottom: 10px; }

/* ---------- secondary pages: back / home bar ---------- */
.page-nav { display: flex; align-items: center; gap: 8px; }

/* ---------- mind map editor ---------- */
.mind-wrap {
  height: calc(100vh - 230px);
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #f7f9fc;
}
#mind-map { width: 100%; height: 100%; }
html[data-theme="dark"] .mind-wrap { background: #10182b; }

/* ---------- draw.io editor ---------- */
.drawio-wrap {
  height: calc(100vh - 230px);
  min-height: 480px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.drawio-frame { width: 100%; height: 100%; border: 0; display: block; }

/* ---------- infinite space editor ---------- */
.space-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.space-tools .btn { padding: 7px 12px; font-size: 12.5px; }
.space-sep { width: 1px; height: 22px; background: var(--line); }
.space-zoom { font-size: 12.5px; color: var(--muted); min-width: 42px; text-align: center; }
.space-wrap {
  height: calc(100vh - 280px);
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.space-wrap canvas { display: block; }

.space-tools .btn.is-active {
  background: rgba(91, 140, 255, .18);
  border-color: rgba(91, 140, 255, .5);
  color: var(--text);
}

/* ---------- space: Figma-like shell ---------- */
.space-shell {
  display: flex;
  gap: 12px;
  align-items: stretch;
  height: calc(100vh - 280px);
  min-height: 420px;
}
.space-side {
  width: 210px;
  flex: 0 0 210px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: auto;
  padding: 10px;
}
.space-props {
  width: 210px;
  flex: 0 0 210px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: auto;
  padding: 10px;
}
.space-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 6px 0 8px;
}
.space-pages, .space-layers { list-style: none; margin: 0 0 12px; padding: 0; }
.space-pages li, .space-layers li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.space-pages li:hover, .space-layers li:hover { background: rgba(255, 255, 255, .06); }
.space-pages li.is-active, .space-layers li.is-active { background: rgba(91, 140, 255, .18); }
.space-layers li i { opacity: .7; font-size: 11px; }
.space-empty { color: var(--muted); font-size: 12.5px; margin: 4px 0; }
.space-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.space-fields label { display: flex; flex-direction: column; gap: 3px; font-size: 10.5px; color: var(--muted); }
.space-fields input[type="number"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font-size: 12px;
}
.space-fields input[type="color"] {
  width: 100%;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
}
.space-fill { grid-column: span 1; }
.space-wrap { flex: 1 1 auto; height: auto; min-height: 0; }
html[data-theme="light"] .space-side,
html[data-theme="light"] .space-props { background: #fff; }

/* an explicit display would otherwise defeat the [hidden] attribute */
.space-fields[hidden] { display: none; }

/* jsMind inside our page */
#mind-map { background: transparent; }
#mind-map .jsmind-inner { background: transparent; }
#mind-map jmnode {
  border-radius: 10px;
  font-family: inherit;
}
html[data-theme="dark"] #mind-map jmnode {
  background-color: #1c2740;
  color: #dbe4f5;
  border: 1px solid rgba(255,255,255,.12);
}
html[data-theme="dark"] #mind-map jmnode.root {
  background-color: #3563e9;
  color: #fff;
  border-color: #3563e9;
}
html[data-theme="dark"] #mind-map jmnode.selected { background-color: #2b3a5c; }
html[data-theme="light"] #mind-map jmnode { background-color: #fff; color: #16203a; border: 1px solid #d5dced; }
html[data-theme="light"] #mind-map jmnode.root { background-color: #3563e9; color: #fff; border-color: #3563e9; }

/* ---------- theme switch inline in the account row ---------- */
.theme-inline { display: inline-flex; gap: 2px; align-items: center; }
.top-actions .theme-btn {
  background: transparent;
  border: 0;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}
.top-actions .theme-btn:hover { color: var(--text); }
.top-actions .theme-btn.is-active { color: var(--accent); }

/* ---------- site-wide dictation ---------- */
.dict-fab-wrap {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dict-fab-status {
  font-size: 12px;
  color: var(--muted);
  background: var(--panel, rgba(20, 28, 46, .9));
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 9px;
}
.dict-fab-status:empty { display: none; }
.dict-fab-lang {
  font: inherit;
  font-size: 11.5px;
  padding: 3px 5px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel, #1b2438);
  color: var(--text);
}
.dict-fab {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel, #1b2438);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.dict-fab.is-on {
  background: #b42318;
  border-color: #b42318;
  color: #fff;
  animation: dictFabPulse 1.2s infinite;
}
@keyframes dictFabPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(180,35,24,.5); } 50% { box-shadow: 0 0 0 8px rgba(180,35,24,0); } }

/* ---------- listing filters ---------- */
.type-filter {
  font: inherit;
  font-size: 12.5px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  max-width: 130px;
}
.name-filter { position: relative; display: inline-flex; align-items: center; }
.name-filter input {
  font: inherit;
  font-size: 12.5px;
  padding: 5px 24px 5px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  width: 165px;
}
.name-filter input::-webkit-search-cancel-button { display: none; }
#name-clear {
  position: absolute;
  right: 4px;
  width: 18px;
  height: 18px;
  line-height: 1;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}
#name-clear:hover { background: rgba(255, 255, 255, .28); }

/* keep the listing controls on one line */
.name-head { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.head-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}
.head-controls .head-mkdir { display: flex; align-items: center; gap: 6px; margin: 0; }
.head-controls .head-input { width: 150px; min-width: 110px; }
.head-controls .type-filter { flex: 0 0 auto; }
.head-controls .name-filter input { width: 140px; }
.head-controls .newfile { flex: 0 0 auto; }

/* ---------- outline speaker ---------- */
.outline-row { display: flex; align-items: center; gap: 4px; }
.outline-row .outline-item { flex: 1; text-align: left; }
.outline-speak {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 5px;
  cursor: pointer;
  padding: 0;
}
.outline-speak:hover { color: var(--text); background: rgba(255,255,255,.08); }
.outline-speak.is-speaking { color: var(--accent); }

/* ---------- text-to-speech settings ---------- */
.tts-panel {
  position: fixed;
  top: 64px;
  right: 14px;
  z-index: 90;
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
  padding: 12px 14px 14px;
}
.tts-panel[hidden] { display: none; }
.tts-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 13px; }
.tts-close { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; }
.tts-row { display: block; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.tts-row span { display: flex; justify-content: space-between; margin-bottom: 4px; }
.tts-row em { font-style: normal; color: var(--text); }
.tts-row select,
.tts-row input[type="range"] { width: 100%; }
.tts-row select {
  font: inherit; font-size: 12.5px; padding: 5px 6px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.tts-actions { display: flex; gap: 8px; margin-top: 4px; }
.tts-actions button {
  flex: 1; font: inherit; font-size: 12.5px; padding: 5px 8px; cursor: pointer;
  border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--text);
}
.tts-actions .tts-test { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- the line being read aloud ---------- */
.CodeMirror .tts-line,
.tts-line { background: rgba(91, 140, 255, .28) !important; }
.tts-el { background: rgba(91, 140, 255, .22); border-radius: 3px; box-shadow: 0 0 0 2px rgba(91, 140, 255, .25); }

/* ---------- speech transport ---------- */
.tts-transport {
  position: fixed;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35);
}
.tts-transport[hidden] { display: none; }
.tts-transport button {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; cursor: pointer;
  background: transparent; color: var(--text); font-size: 13px;
}
.tts-transport button:hover { background: rgba(255, 255, 255, .1); }
.tts-transport #tts-play { background: var(--accent); color: #fff; }
.tts-transport-label { font-size: 11.5px; color: var(--muted); min-width: 54px; text-align: center; }

/* outline indentation — the level class sits on the row now */
.outline-row.lvl-2 { padding-left: 12px; }
.outline-row.lvl-3 { padding-left: 24px; }
.outline-row.lvl-4 { padding-left: 34px; }
.outline-row.lvl-5 { padding-left: 44px; }
.outline-row.lvl-6 { padding-left: 52px; }
.outline-row.lvl-1 .outline-item { font-weight: 600; }
.outline-row.lvl-2 .outline-item,
.outline-row.lvl-3 .outline-item { font-size: 12.5px; }
.outline-row.lvl-4 .outline-item,
.outline-row.lvl-5 .outline-item,
.outline-row.lvl-6 .outline-item { font-size: 12px; opacity: .92; }

/* ---------- editor side panel (activity rail + views) ---------- */
.side-bar {
  position: relative;
  display: flex;
  width: 250px;
  flex: 0 0 250px;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: rgba(12, 18, 32, .6);
  border-radius: 10px;
  overflow: hidden;
}
.side-bar.is-collapsed .side-views { display: none; }
.side-bar.is-collapsed { width: 48px !important; flex-basis: 48px !important; }

.side-rail {
  flex: 0 0 44px;
  width: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  border-right: 1px solid var(--line);
  background: rgba(8, 12, 22, .55);
}
.rail-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 7px; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 15px;
}
.rail-btn:hover { color: var(--text); background: rgba(255, 255, 255, .07); }
.rail-btn.is-active { color: var(--text); background: rgba(91, 140, 255, .18); }

.side-views { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side-view { display: none; flex-direction: column; min-height: 0; flex: 1; }
.side-view.is-active { display: flex; }

.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 10px 7px;
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.side-action { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 2px 4px; }
.side-action:hover { color: var(--text); }
.side-body { flex: 1; min-height: 0; overflow: auto; padding: 0 6px 10px; }

.tree-row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 6px;
  font-size: 12.5px; color: var(--text); cursor: pointer;
  white-space: nowrap; overflow: hidden;
}
.tree-row:hover { background: rgba(255, 255, 255, .06); }
.tree-row.is-current { background: rgba(91, 140, 255, .18); }
.tree-row .caret { font-size: 9px; opacity: .55; transition: transform .12s; width: 9px; }
.tree-row.is-open .caret { transform: rotate(90deg); }
.tree-row .caret-space { width: 9px; display: inline-block; }
.tree-row .tree-name { overflow: hidden; text-overflow: ellipsis; }
.tree-row .tree-path { margin-left: auto; font-size: 10.5px; color: var(--muted); }
.tree-row i.fa-regular, .tree-row i.fa-solid.fa-file-lines { opacity: .8; }
.tree-loading, .tree-empty { padding: 8px; font-size: 12px; color: var(--muted); }

.side-input {
  width: 100%; font: inherit; font-size: 12.5px;
  padding: 5px 8px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: 6px;
  background: rgba(255, 255, 255, .04); color: var(--text);
}
.side-results { display: flex; flex-direction: column; }

.side-field { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 12px; }
.side-field span { display: flex; justify-content: space-between; margin-bottom: 4px; }
.side-field em { font-style: normal; color: var(--text); }
.side-field input[type="range"] { width: 100%; }
.side-check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; margin-bottom: 8px; color: var(--text); }
.side-note { font-size: 11px; color: var(--muted); margin-top: 10px; }
.side-bar .outline-list { padding: 0 6px 10px; overflow: auto; }

/* the dock fills the editor column */
.editor-split { align-items: stretch; min-height: calc(100vh - 250px); }
.editor-card { display: flex; flex-direction: column; }
.side-bar { align-self: stretch; }
.editor-split > .editor-host { min-height: 0; }

/* the dock stretches to the editor's height (overrides the old outline panel) */
.editor-split { align-items: stretch !important; }
.side-bar {
  position: static !important;
  top: auto !important;
  height: auto !important;
  max-height: none !important;
  align-self: stretch !important;
  display: flex;
}
.side-bar .side-views { min-height: 0; height: auto; }
.side-bar .side-view.is-active { min-height: 0; }
.side-bar .side-body { max-height: none; }

/* rail and views sit side by side */
.side-bar { flex-direction: row !important; align-items: stretch !important; }
.side-bar .side-rail { flex: 0 0 44px; align-self: stretch; height: auto; }
.side-bar .side-views { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

/* ---------- multi-tab workspace ---------- */
.ws { display: flex; flex-direction: column; gap: 10px; }
.ws-tabs {
  display: flex; align-items: stretch; gap: 2px;
  overflow-x: auto; border-bottom: 1px solid var(--line); padding-bottom: 2px;
}
.ws-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 9px 6px 11px; border-radius: 8px 8px 0 0;
  font-size: 12.5px; color: var(--muted); cursor: pointer;
  border: 1px solid transparent; border-bottom: 0; white-space: nowrap;
}
.ws-tab:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.ws-tab.is-active { color: var(--text); background: var(--panel); border-color: var(--line); }
.ws-tab.is-dirty .ws-tab-name::after { content: " ●"; color: var(--accent); font-size: 9px; }
.ws-tab-close {
  border: 0; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px;
}
.ws-tab-close:hover { color: #e11d48; }
.ws-body { display: flex; gap: 10px; min-height: calc(100vh - 260px); }
.ws-editor { flex: 1; min-width: 0; display: flex; }
.ws-editor textarea { flex: 1; width: 100%; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.ws-status { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); }
.ws-link { margin-left: auto; color: var(--accent); text-decoration: none; }

/* the tab editor must own its box */
.ws-editor { display: block; }
.ws-editor #ws-text,
.ws-editor textarea.md-source {
  display: block;
  width: 100%;
  height: calc(100vh - 300px);
  min-height: 320px;
  box-sizing: border-box;
  resize: vertical;
}

/* one live iframe per tab */
.ws-frames { position: relative; flex: 1; min-width: 0; min-height: calc(100vh - 300px); }
.ws-frame {
  width: 100%;
  height: calc(100vh - 300px);
  min-height: 320px;
  border: 0;
  border-radius: 10px;
  background: transparent;
}
.ws-frame[hidden] { display: none; }

.ws-save {
  font: inherit; font-size: 12px; padding: 3px 10px; cursor: pointer;
  border: 1px solid var(--accent); border-radius: 6px;
  background: var(--accent); color: #fff;
}

.tree-row.is-selected { background: rgba(91, 140, 255, .28); }
.ws-empty { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 13px; }

/* ---------- explorer context menu ---------- */
.ctx-menu {
  position: fixed;
  z-index: 200;
  min-width: 190px;
  padding: 5px;
  background: var(--menu-bg, #141d31);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
}
.ctx-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 6px 9px;
  border: 0; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--text);
  font: inherit; font-size: 12.5px; text-align: left;
}
.ctx-item:hover { background: rgba(91, 140, 255, .18); }
.ctx-item.is-disabled { opacity: .4; cursor: default; }
.ctx-item i { width: 14px; opacity: .8; }
.ctx-toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--menu-bg, #141d31); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 14px; font-size: 12.5px; z-index: 220;
}

/* top actions + quick open */
.ws-tabbar { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.ws-tabbar .ws-tabs { flex: 1; min-width: 0; border-bottom: 0; }
.ws-top-actions { display: flex; gap: 4px; padding-right: 2px; }
.ws-icon {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 7px; cursor: pointer;
  background: transparent; color: var(--text); font-size: 12px;
}
.ws-icon:hover { background: rgba(91, 140, 255, .18); }

.ws-quick {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  width: min(640px, 92vw); z-index: 210;
  background: var(--menu-bg, #141d31); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 18px 40px rgba(0, 0, 0, .5); padding: 8px;
}
.ws-quick[hidden] { display: none; }
.ws-quick input {
  width: 100%; font: inherit; font-size: 13px; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 7px;
  background: rgba(255, 255, 255, .04); color: var(--text); margin-bottom: 6px;
}
.ws-quick-results { max-height: 320px; overflow: auto; }
.ws-quick-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 9px;
  border-radius: 6px; font-size: 12.5px; cursor: pointer;
}
.ws-quick-row:hover, .ws-quick-row.is-active { background: rgba(91, 140, 255, .2); }
.ws-quick-path { margin-left: auto; font-size: 11px; color: var(--muted); }
.ws-quick-empty { padding: 10px; font-size: 12.5px; color: var(--muted); }

/* the explorer fills the viewport */
.ws { min-height: calc(100vh - 170px); }
.ws-body { flex: 1 1 auto; min-height: calc(100vh - 260px); }
.ws-editor { flex: 1 1 auto; display: flex; flex-direction: column; }
.ws-frames { flex: 1 1 auto; min-height: 0; height: 100%; }
.ws-empty { display: flex; align-items: center; justify-content: center; height: 100%; min-height: 240px; color: var(--muted); font-size: 13px; }
.side-bar { align-self: stretch; height: auto; }

/* ---------- folder settings ---------- */
.fs-group { margin: 10px 0 14px; }
.fs-label { display: block; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.fs-opt { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text); margin-bottom: 4px; cursor: pointer; }
.fs-note { font-size: 11px; color: var(--muted); margin-top: 10px; }
#folder-settings-modal .modal-card { max-width: 430px; }

/* small dialog used by the explorer */
.ctx-backdrop {
  position: fixed; inset: 0; z-index: 240;
  display: grid; place-items: center;
  background: rgba(4, 8, 18, .55);
}
.ctx-dialog {
  width: min(380px, 92vw);
  background: var(--menu-bg, #141d31);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 16px 12px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, .55);
}
.ctx-dialog h3 { margin: 0 0 4px; font-size: 15px; }
.ctx-sub { margin: 0 0 12px; font-size: 11.5px; color: var(--muted); word-break: break-all; }
.ctx-field { display: block; margin-bottom: 10px; font-size: 11.5px; color: var(--muted); }
.ctx-field span { display: block; margin-bottom: 4px; }
.ctx-field input, .ctx-field select {
  width: 100%; font: inherit; font-size: 13px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 7px;
  background: rgba(255, 255, 255, .05); color: var(--text);
}
.ctx-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.ctx-btn {
  font: inherit; font-size: 12.5px; padding: 6px 12px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--text);
}
.ctx-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* explorer preview modal */
.ctx-preview {
  width: min(1000px, 94vw); height: min(760px, 88vh);
  display: flex; flex-direction: column;
  background: var(--menu-bg, #141d31);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  box-shadow: 0 28px 60px rgba(0, 0, 0, .6);
}
.ctx-preview header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
  font-size: 12.5px; color: var(--text);
}
.ctx-preview-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-preview-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.ctx-note { font-size: 11px; color: var(--muted); margin: 4px 0 0; }
.ctx-result { display: flex; gap: 6px; margin-top: 10px; }
.ctx-result input {
  flex: 1; font: inherit; font-size: 12px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 7px;
  background: rgba(255, 255, 255, .05); color: var(--text);
}

.side-actions { display: inline-flex; gap: 2px; }

/* theme control in the dock's settings view */
.side-theme { margin-top: 14px; }
.side-theme-opts { display: flex; gap: 6px; margin-top: 5px; }
.side-theme-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 12px; padding: 6px 8px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 7px;
  background: transparent; color: var(--text);
}
.side-theme-btn:hover { background: rgba(91, 140, 255, .15); }
.side-theme-btn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* drop target highlight */
.tree-row.is-drop {
  background: rgba(91, 140, 255, .30) !important;
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
}
