:root {
  --bg: #f4efe4;
  --panel: rgba(255, 252, 247, 0.88);
  --panel-strong: #fffaf1;
  --surface: rgba(255, 255, 255, 0.72);
  --editor-font-size: 16px;
  --line: rgba(49, 41, 28, 0.12);
  --line-strong: rgba(49, 41, 28, 0.18);
  --text: #2f261c;
  --muted: #756652;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: rgba(15, 118, 110, 0.1);
  --warning: #9a3412;
  --shadow: 0 18px 55px rgba(67, 45, 18, 0.12);
  --glow: rgba(15, 118, 110, 0.2);
  --radius: 24px;
  --font-sans: "IBM Plex Sans", "Segoe UI", sans-serif;
}

body[data-theme="dark"] {
  --bg: #0b1220;
  --panel: rgba(17, 28, 47, 0.9);
  --panel-strong: #0f1c34;
  --surface: rgba(21, 36, 62, 0.86);
  --line: rgba(148, 163, 184, 0.2);
  --line-strong: rgba(43, 59, 94, 0.92);
  --text: #d9e3f0;
  --muted: #8fa3c2;
  --accent: #60a5fa;
  --accent-strong: #1d4ed8;
  --accent-soft: rgba(96, 165, 250, 0.18);
  --warning: #fda4af;
  --shadow: 0 24px 54px rgba(8, 15, 35, 0.62);
  --glow: rgba(37, 99, 235, 0.26);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.85), transparent 30%),
    linear-gradient(135deg, #efe4cf 0%, #f7f2e9 45%, #e8f2ef 100%);
  transition: background 0.2s ease, color 0.2s ease;
}

body[data-theme="dark"] {
  background:
    radial-gradient(circle at top left, rgba(96, 165, 250, 0.16), transparent 26%),
    radial-gradient(circle at bottom right, rgba(29, 78, 216, 0.16), transparent 24%),
    linear-gradient(145deg, #0b1220 0%, #0d1728 42%, #111c2f 100%);
}

body {
  height: 100vh;
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

.hidden {
  display: none !important;
}

.eyebrow {
  display: none;
}

.label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  color: var(--muted);
}

.button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.78rem 1.15rem;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background-color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    color 0.18s ease;
}

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

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.button-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.button-sm svg {
  flex-shrink: 0;
}

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

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

body[data-theme="dark"] .button-primary {
  background: linear-gradient(145deg, rgba(96, 165, 250, 0.94), rgba(29, 78, 216, 1));
  border-color: rgba(191, 219, 254, 0.55);
  box-shadow: 0 16px 28px var(--glow);
}

body[data-theme="dark"] .button-primary:hover {
  background: linear-gradient(145deg, rgba(125, 181, 251, 0.96), rgba(37, 99, 235, 1));
  box-shadow: 0 20px 34px rgba(37, 99, 235, 0.34);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.66);
  border-color: var(--line);
  color: var(--text);
}

body[data-theme="dark"] .button-secondary {
  background: rgba(17, 24, 39, 0.82);
  border-color: rgba(148, 163, 184, 0.34);
  color: var(--text);
}

body[data-theme="dark"] .button-secondary:hover {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(191, 219, 254, 0.5);
}

.button-large {
  width: 100%;
  text-align: center;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

/* ── Login page ───────────────────────────────────────────── */

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #18181a;
}

.login-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3rem;
  user-select: none;
}

.login-wordmark {
  margin: 0;
  font-size: clamp(4rem, 14vw, 9rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  color: #18181a;
  text-shadow:
    2px 3px 5px rgba(0, 0, 0, 0.95),
    -1px -1px 0px rgba(255, 255, 255, 0.07);
}

.login-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.login-google-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1.1rem 0.55rem 0.75rem;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.8125rem;
  font-weight: 400;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.login-google-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.login-google-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.75);
}

.login-google-btn:hover svg {
  opacity: 1;
}

.login-error {
  margin: 0;
  font-size: 0.8125rem;
  color: rgba(253, 164, 175, 0.8);
}

.login-unconfigured {
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.15);
}

.login-env-hint {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.08);
  color: rgba(251, 191, 36, 0.85);
  font-size: 0.8125rem;
  line-height: 1.5;
  text-align: left;
}

.login-env-hint svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  opacity: 0.8;
}

.login-env-hint code {
  font-family: monospace;
  font-size: 0.8em;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

/* ── Password login ─────────────────────────────── */
.login-password-details {
  width: 100%;
}

.login-password-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}

.login-password-summary::-webkit-details-marker { display: none; }

.login-password-summary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.login-password-summary svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.login-password-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 1.1rem 1.25rem 1.25rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.login-field span {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.login-field input {
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  font-size: 0.9375rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.login-field input:focus {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
}

.login-submit-btn {
  margin-top: 0.25rem;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.login-submit-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.muted {
  color: var(--muted);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.875rem;
  text-align: center;
}

.alert-error {
  color: var(--warning);
  border-color: rgba(154, 52, 18, 0.25);
  background: rgba(255, 245, 240, 0.9);
}

body[data-theme="dark"] .alert-error {
  border-color: rgba(190, 24, 93, 0.45);
  background: rgba(69, 10, 10, 0.42);
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 1.2rem;
  padding: 1.2rem;
  overflow: hidden;
}

.sidebar,
.workspace-panel {
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

body[data-theme="dark"] .sidebar,
body[data-theme="dark"] .workspace-panel {
  background:
    linear-gradient(180deg, rgba(17, 28, 47, 0.96), rgba(15, 28, 52, 0.92));
  border-color: var(--line-strong);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(191, 219, 254, 0.05);
}

.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.brand-block,
.sidebar-actions {
  padding: 0.8rem 1rem;
}

.workspace-topbar {
  padding: 0.4rem 0.9rem;
}

.statusbar {
  padding: 0.2rem 0.9rem;
  font-size: 0.74rem;
}

.brand-block h1,
.workspace-topbar h2 {
  margin: 0;
  font-size: 1rem;
}

.workspace-topbar .label {
  display: none;
}

#current-file-path {
  margin: 0;
  font-size: 0.72rem;
}

body[data-theme="dark"] .brand-block h1,
body[data-theme="dark"] .workspace-topbar h2,
body[data-theme="dark"] .modal-header h3 {
  color: #c8d5e8;
}

.sidebar-path {
  margin: 0;
  color: var(--muted);
  word-break: break-word;
}

.sidebar-actions {
  padding-top: 0;
}

.sidebar-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.sidebar-toolbar .button {
  flex: 1 1 0;
  min-width: 0;
}

.sidebar-tree-controls {
  display: none;
}

.sidebar-toolbar-icons {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.25rem;
  align-items: center;
}

.sidebar-toolbar-sep {
  flex: 1;
}

.sidebar-tree-icon {
  color: var(--muted);
}

.sidebar-tree-icon.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

body[data-theme="dark"] .sidebar-tree-icon {
  background: rgba(17, 24, 39, 0.78);
  border-color: rgba(148, 163, 184, 0.22);
}

body[data-theme="dark"] .sidebar-tree-icon:hover {
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(191, 219, 254, 0.28);
}

body[data-theme="dark"] .sidebar-tree-icon.is-active {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(191, 219, 254, 0.32);
  color: #c6d5e9;
}

.context-menu {
  position: fixed;
  z-index: 50;
  width: min(280px, calc(100vw - 24px));
  padding: 0.5rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(16px);
}

.context-menu-header {
  display: grid;
  gap: 0.15rem;
  padding: 0.45rem 0.55rem 0.65rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.35rem;
}

.context-menu-title {
  font-size: 0.94rem;
}

.context-menu-path {
  font-size: 0.76rem;
  color: var(--muted);
  word-break: break-word;
}

.context-menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.context-menu-item:hover {
  background: var(--accent-soft);
}

.context-menu-item-muted {
  color: var(--muted);
}

.context-menu-item-danger {
  color: var(--warning);
  font-weight: 600;
}

body[data-theme="dark"] .context-menu {
  border-color: rgba(148, 163, 184, 0.22);
  background: linear-gradient(180deg, rgba(17, 28, 47, 0.98), rgba(15, 28, 52, 0.96));
  box-shadow: 0 24px 48px rgba(3, 8, 20, 0.5);
}

body[data-theme="dark"] .context-menu-header {
  border-color: rgba(148, 163, 184, 0.16);
}

body[data-theme="dark"] .context-menu-item {
  color: #c5d2e3;
}

body[data-theme="dark"] .context-menu-item:hover {
  background: rgba(59, 130, 246, 0.14);
}

body[data-theme="dark"] .context-menu-item-muted {
  color: #94a7c3;
}

.settings-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.settings-input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0.72rem 0.8rem;
  color: var(--text);
}

.settings-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-path-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
}

.settings-browse-button {
  white-space: nowrap;
}

body[data-theme="dark"] .settings-input {
  background: rgba(17, 24, 39, 0.78);
  border-color: rgba(148, 163, 184, 0.28);
}

.small-note {
  margin: 0;
  font-size: 0.78rem;
}

.tree-root {
  overflow: auto;
  padding: 0 0.6rem 1rem 0.75rem;
}

.tree-scope-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.5rem;
  align-items: center;
  margin: 0 0 0.75rem;
}

.tree-scope-up {
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 0.28rem 0.55rem;
  cursor: pointer;
}

.tree-scope-label {
  min-width: 0;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-root.is-drop-target-root {
  outline: 1px dashed rgba(15, 118, 110, 0.45);
  outline-offset: -6px;
  background: rgba(15, 118, 110, 0.06);
}

body[data-theme="dark"] .tree-root {
  background:
    linear-gradient(180deg, rgba(11, 18, 32, 0), rgba(11, 18, 32, 0.22));
}

body[data-theme="dark"] .tree-root.is-drop-target-root {
  outline-color: rgba(96, 165, 250, 0.5);
  background: rgba(59, 130, 246, 0.1);
}

body[data-theme="dark"] .tree-scope-up {
  background: rgba(17, 24, 39, 0.78);
  color: #c3d0e1;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

body[data-theme="dark"] .tree-scope-up:hover {
  background: rgba(59, 130, 246, 0.14);
}

.tree-list {
  list-style: none;
  margin: 0;
  padding-left: 0.85rem;
}

.tree-list-root {
  padding-left: 0;
}

.tree-item {
  margin: 0.08rem 0;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tree-toggle,
.tree-link {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0.28rem 0.35rem;
  border-radius: 10px;
}

.tree-toggle {
  width: 1.8rem;
  color: var(--muted);
  cursor: pointer;
}

.tree-link {
  flex: 1;
  text-align: left;
  cursor: pointer;
}

.tree-link:hover,
.tree-link.is-active,
.tree-toggle:hover {
  background: var(--accent-soft);
}

body[data-theme="dark"] .tree-link,
body[data-theme="dark"] .tree-toggle {
  transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

body[data-theme="dark"] .tree-link:hover,
body[data-theme="dark"] .tree-toggle:hover {
  background: rgba(59, 130, 246, 0.16);
}

body[data-theme="dark"] .tree-link.is-active {
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.28), rgba(29, 78, 216, 0.24));
  box-shadow: inset 0 0 0 1px rgba(191, 219, 254, 0.22);
}

.tree-row.is-draggable {
  cursor: grab;
}

.tree-row.is-draggable:active {
  cursor: grabbing;
}

.tree-row.is-dragging {
  opacity: 0.45;
}

.tree-row.is-drop-target {
  background: rgba(15, 118, 110, 0.12);
  outline: 1px dashed rgba(15, 118, 110, 0.45);
}

body[data-theme="dark"] .tree-row.is-drop-target {
  background: rgba(59, 130, 246, 0.16);
  outline-color: rgba(96, 165, 250, 0.5);
}

.tree-link.is-disabled {
  color: var(--muted);
}

.tree-link.is-disabled {
  opacity: 0.6;
}

.workspace-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
}

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

body[data-theme="dark"] .workspace-topbar,
body[data-theme="dark"] .statusbar,
body[data-theme="dark"] .modal-header,
body[data-theme="dark"] .modal-actions {
  border-color: rgba(148, 163, 184, 0.18);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.profiles-menu {
  position: relative;
}

.profiles-dropdown {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  width: min(320px, calc(100vw - 2rem));
  padding: 0.7rem;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(16px);
  z-index: 40;
}

.profiles-dropdown-header {
  display: grid;
  gap: 0.12rem;
  padding: 0.35rem 0.45rem 0.7rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.45rem;
}

.profiles-dropdown-list {
  display: grid;
  gap: 0.35rem;
  max-height: min(55vh, 420px);
  overflow: auto;
}

.profiles-dropdown-item {
  width: 100%;
  display: grid;
  gap: 0.18rem;
  text-align: left;
  border: 0;
  border-radius: 16px;
  padding: 0.75rem 0.8rem;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.profiles-dropdown-item span {
  font-size: 0.82rem;
  color: var(--muted);
  word-break: break-word;
}

.profiles-dropdown-item:hover {
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.profiles-dropdown-empty {
  padding: 0.75rem 0.8rem;
  font-size: 0.86rem;
  line-height: 1.45;
}

.user-chip {
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  color: var(--muted);
}

body[data-theme="dark"] .user-chip {
  background: rgba(17, 24, 39, 0.85);
  border-color: rgba(148, 163, 184, 0.28);
  color: #b9c9df;
}

.icon-button {
  width: 2.75rem;
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-button svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
}

.icon-button-small {
  width: 2.35rem;
  height: 2.35rem;
}

.icon-button:hover {
  background: var(--accent-soft);
}

body[data-theme="dark"] .icon-button {
  background: rgba(17, 24, 39, 0.84);
  border-color: rgba(148, 163, 184, 0.3);
  box-shadow: inset 0 1px 0 rgba(191, 219, 254, 0.05);
}

body[data-theme="dark"] .icon-button:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(191, 219, 254, 0.42);
}

body[data-theme="dark"] .profiles-dropdown {
  border-color: rgba(148, 163, 184, 0.22);
  background: linear-gradient(180deg, rgba(17, 28, 47, 0.98), rgba(15, 28, 52, 0.96));
  box-shadow: 0 24px 48px rgba(3, 8, 20, 0.5);
}

body[data-theme="dark"] .profiles-dropdown-header {
  border-color: rgba(148, 163, 184, 0.16);
}

body[data-theme="dark"] .profiles-dropdown-item {
  color: #c5d2e3;
}

body[data-theme="dark"] .profiles-dropdown-item span {
  color: #94a7c3;
}

body[data-theme="dark"] .profiles-dropdown-item:hover {
  background: rgba(59, 130, 246, 0.14);
}

.editor-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: var(--panel-strong);
}

.editor-stage.is-drop-target-link {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
  background: var(--accent-soft);
}

body[data-theme="dark"] .editor-stage {
  background:
    linear-gradient(180deg, rgba(15, 28, 52, 0.98), rgba(11, 18, 32, 0.96));
}

.editor-zoom {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.editor-zoom-label {
  min-width: 3.4rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.editor-stage #editor,
.toastui-editor-defaultUI {
  height: 100%;
}

/* ── JSON Editor panel ──────────────────────────────────────── */
.json-editor-panel {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* Override jsoneditor default colours to match our themes */
.jsoneditor,
.jsoneditor-menu {
  border-color: var(--line) !important;
}

.jsoneditor-menu {
  background-color: var(--surface) !important;
  color: var(--text) !important;
}

.jsoneditor-menu button,
.jsoneditor-menu .jsoneditor-separator {
  color: var(--text) !important;
}

.jsoneditor-tree,
.jsoneditor .ace_editor,
.jsoneditor-text {
  background-color: var(--panel-strong) !important;
  color: var(--text) !important;
  font-family: var(--font-sans) !important;
}

.jsoneditor-field,
.jsoneditor-value {
  color: var(--text) !important;
}

.jsoneditor-value.jsoneditor-string  { color: #059669 !important; }
.jsoneditor-value.jsoneditor-number  { color: #0369a1 !important; }
.jsoneditor-value.jsoneditor-boolean { color: #7c3aed !important; }
.jsoneditor-value.jsoneditor-null    { color: var(--muted) !important; }

/* dark + obsidian tweaks */
body[data-theme="dark"] .jsoneditor-value.jsoneditor-string,
body[data-theme="obsidian"] .jsoneditor-value.jsoneditor-string  { color: #34d399 !important; }
body[data-theme="dark"] .jsoneditor-value.jsoneditor-number,
body[data-theme="obsidian"] .jsoneditor-value.jsoneditor-number  { color: #60a5fa !important; }
body[data-theme="dark"] .jsoneditor-value.jsoneditor-boolean,
body[data-theme="obsidian"] .jsoneditor-value.jsoneditor-boolean { color: #a78bfa !important; }

.jsoneditor-navigation-bar {
  background: var(--panel) !important;
  color: var(--muted) !important;
  border-bottom-color: var(--line) !important;
}

.jsoneditor-statusbar {
  background: var(--panel) !important;
  color: var(--muted) !important;
  border-top-color: var(--line) !important;
}

.jsoneditor-search input {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}

.jsoneditor tr:hover > .jsoneditor-tree td {
  background: var(--accent-soft) !important;
}

.file-preview {
  height: 100%;
  width: 100%;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  overflow: auto;
}

.upload-stage {
  height: 100%;
  padding: 1.4rem;
  overflow: auto;
}

.upload-card {
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  gap: 1rem;
}

.upload-card h3 {
  margin: 0.25rem 0 0;
}

.upload-dropzone {
  border: 1px dashed var(--line-strong);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.5);
  padding: 1.4rem;
  display: grid;
  gap: 0.8rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.upload-dropzone strong {
  font-size: 1.06rem;
}

.upload-dropzone.is-dragover,
.upload-dropzone:hover,
.upload-dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.08);
}

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.upload-file-list {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  padding: 0.9rem 1rem;
}

.upload-file-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.upload-file-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.1rem;
  border-bottom: 1px solid var(--line);
}

.upload-file-item:last-child {
  border-bottom: 0;
}

.upload-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-file-size,
.upload-file-empty {
  color: var(--muted);
  font-size: 0.88rem;
}

.file-preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 18px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
  background: rgba(255, 255, 255, 0.68);
}

.file-preview-pdf {
  width: 100%;
  height: 100%;
  min-height: 420px;
  border: 0;
  border-radius: 18px;
  background: #fff;
}

body[data-theme="dark"] .file-preview-image {
  background: rgba(17, 24, 39, 0.78);
  box-shadow: 0 24px 44px rgba(3, 8, 20, 0.4);
}

body[data-theme="dark"] .file-preview-pdf {
  background: #0f172a;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.14);
}

body[data-theme="dark"] .upload-dropzone {
  background: rgba(17, 24, 39, 0.56);
  border-color: rgba(148, 163, 184, 0.28);
}

body[data-theme="dark"] .upload-dropzone.is-dragover,
body[data-theme="dark"] .upload-dropzone:hover,
body[data-theme="dark"] .upload-dropzone:focus-visible {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(96, 165, 250, 0.58);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

body[data-theme="dark"] .upload-file-list {
  background: rgba(17, 24, 39, 0.68);
  border-color: rgba(148, 163, 184, 0.2);
}

.overlay-card {
  position: absolute;
  inset: 1.4rem;
  border-radius: 24px;
  border: 1px dashed var(--line);
  display: grid;
  place-content: center;
  text-align: center;
  padding: 2rem;
  background: rgba(255, 251, 245, 0.86);
}

body[data-theme="dark"] .overlay-card {
  background: rgba(15, 23, 42, 0.88);
  border-color: rgba(148, 163, 184, 0.24);
  box-shadow: inset 0 1px 0 rgba(191, 219, 254, 0.04);
}

.overlay-card strong {
  font-size: 1.05rem;
}

.statusbar {
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.toastui-editor-defaultUI {
  border: 0 !important;
  font-family: var(--font-sans);
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* No overflow:hidden here — it would clip absolutely-positioned
     toolbar dropdowns. Clipping is handled by .toastui-editor-main below. */
}

.toastui-editor-main {
  flex: 1 1 auto;
  height: auto !important;
  min-height: 0;
  overflow: hidden;
}

.toastui-editor-md-container,
.toastui-editor-ww-container {
  height: 100% !important;
  min-height: 0;
}

/* Force scroll on the actual ProseMirror / CodeMirror wrapper.
   .toastui-editor-main-container is position:absolute inside
   .toastui-editor-main (position:relative); without height:100% it grows
   to its content height and never creates a scroll container. */
.toastui-editor-main-container {
  height: 100% !important;
  overflow: hidden !important;
}

.toastui-editor.ww-mode,
.toastui-editor.md-mode {
  height: 100% !important;
  overflow: hidden !important;
}

.ProseMirror.toastui-editor-contents {
  height: 100% !important;
  overflow-y: auto !important;
  box-sizing: border-box !important;
}

.toastui-editor-toolbar,
.toastui-editor-defaultUI-toolbar {
  border-bottom-color: var(--line) !important;
  background: var(--surface) !important;
  padding: 2px 4px !important;
}

/* zoom scales layout + background sprites proportionally — unlike
   transform:scale which only scales visually and leaves layout space intact */
.toastui-editor-toolbar .toastui-editor-toolbar-group,
.toastui-editor-defaultUI-toolbar .toastui-editor-toolbar-group {
  zoom: 0.78;
}

.toastui-editor-contents {
  font-size: var(--editor-font-size);
}

/* ── Hide default mode switch, use topbar button instead ── */
.toastui-editor-mode-switch {
  display: none !important;
}

.editor-mode-toggle {
  min-width: 96px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

/* ── Diagrams ─────────────────────────────────────────────── */
/* ── Tables ───────────────────────────────────────────────── */

.toastui-editor-contents table,
.toastui-editor-md-preview table {
  border-collapse: collapse !important;
  border-spacing: 0 !important;
  width: auto;
  margin: 1rem 0;
  border: 1.5px solid var(--line-strong) !important;
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.92em;
}

.toastui-editor-contents th,
.toastui-editor-contents td,
.toastui-editor-md-preview th,
.toastui-editor-md-preview td {
  border: 1px solid var(--line-strong) !important;
  padding: 0.42rem 0.72rem !important;
  text-align: left;
  vertical-align: top;
  min-width: 5rem;
}

.toastui-editor-contents thead tr,
.toastui-editor-md-preview thead tr {
  background: var(--accent-soft) !important;
}

.toastui-editor-contents th,
.toastui-editor-md-preview th {
  font-weight: 600;
  color: var(--text) !important;
  background: var(--accent-soft) !important;
}

.toastui-editor-contents tbody tr:nth-child(even),
.toastui-editor-md-preview tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.025);
}

body[data-theme="dark"] .toastui-editor-contents tbody tr:nth-child(even),
body[data-theme="dark"] .toastui-editor-md-preview tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

body[data-theme="dark"] .toastui-editor-contents th,
body[data-theme="dark"] .toastui-editor-md-preview th {
  background: rgba(96, 165, 250, 0.12) !important;
}

body[data-theme="obsidian"] .toastui-editor-contents th,
body[data-theme="obsidian"] .toastui-editor-md-preview th {
  background: rgba(124, 111, 205, 0.15) !important;
}

body[data-theme="obsidian"] .toastui-editor-contents tbody tr:nth-child(even),
body[data-theme="obsidian"] .toastui-editor-md-preview tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* Also style the selected/active cell in WYSIWYG */
.toastui-editor-contents td.toastui-editor-ww-table-selected-cell {
  background: var(--accent-soft) !important;
  outline: 2px solid var(--accent) !important;
  outline-offset: -2px;
}

/* ── Diagrams ─────────────────────────────────────────────── */

.mermaid-diagram {
  text-align: center;
  margin: 1rem 0;
  overflow-x: auto;
}

.mermaid-diagram svg {
  max-width: 100%;
  height: auto;
}

.diagram-plantuml {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1rem auto;
}

.ww-diagram-out {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--line);
  overflow-x: auto;
  cursor: pointer;
}

.ww-diagram-out:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 10px;
}

.toastui-editor-ww-code-block.is-diagram-rendered .toastui-editor-ww-code-block-language,
.toastui-editor-ww-code-block.is-diagram-rendered pre {
  display: none;
}

.toastui-editor-ww-code-block.is-diagram-rendered .ww-diagram-out {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.toastui-editor-ww-code-block.is-diagram-rendered.is-source-visible .toastui-editor-ww-code-block-language,
.toastui-editor-ww-code-block.is-diagram-rendered.is-source-visible pre {
  display: block;
}

.toastui-editor-ww-code-block.is-diagram-rendered.is-source-visible .ww-diagram-out {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--line);
}

.noteeli-diagram-toolbar-group {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding-left: 0.35rem;
  /* No zoom here — zoom creates a stacking context that breaks
     position:fixed on the dropdown menu. Size button manually instead. */
}

.noteeli-toolbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Match the visual size of zoomed toolbar buttons (28px × 0.78 ≈ 22px) */
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.noteeli-toolbar-button:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.noteeli-toolbar-menu {
  position: fixed;
  /* top/left are set dynamically by JS via inline style */
  min-width: 10rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  z-index: 150;
}

/* Reset all ToastUI toolbar-group button styles that bleed into our menu */
.noteeli-toolbar-menu .noteeli-toolbar-menu-item {
  all: unset;
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 0.32rem 0.55rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.5;
  cursor: pointer;
  white-space: nowrap;
}

.noteeli-toolbar-menu .noteeli-toolbar-menu-item:hover {
  background: var(--accent-soft);
}

body[data-theme="dark"] .toastui-editor-defaultUI,
body[data-theme="dark"] .toastui-editor-main,
body[data-theme="dark"] .toastui-editor-md-container,
body[data-theme="dark"] .toastui-editor-ww-container,
body[data-theme="dark"] .toastui-editor-toolbar,
body[data-theme="dark"] .toastui-editor-defaultUI-toolbar,
body[data-theme="dark"] .toastui-editor-mode-switch,
body[data-theme="dark"] .toastui-editor-popup {
  background: #0f1c34 !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}

body[data-theme="dark"] .toastui-editor-toolbar,
body[data-theme="dark"] .toastui-editor-defaultUI-toolbar,
body[data-theme="dark"] .toastui-editor-mode-switch {
  background:
    linear-gradient(180deg, rgba(11, 18, 32, 0.96), rgba(15, 28, 52, 0.96)) !important;
  box-shadow:
    inset 0 -1px 0 rgba(148, 163, 184, 0.12),
    inset 0 1px 0 rgba(191, 219, 254, 0.04);
}

body[data-theme="dark"] .toastui-editor-mode-switch {
  flex: 0 0 auto;
  display: flex !important;
  height: auto !important;
  min-height: 3.5rem;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.7rem 0.8rem !important;
  border-top: 1px solid rgba(148, 163, 184, 0.14) !important;
  box-sizing: border-box;
}

body[data-theme="dark"] .toastui-editor-toolbar button,
body[data-theme="dark"] .toastui-editor-defaultUI-toolbar button,
body[data-theme="dark"] .toastui-editor-mode-switch .tab-item {
  color: #aebfd8 !important;
}

body[data-theme="dark"] .toastui-editor-mode-switch .tab-item {
  min-width: 7.5rem;
  border: 1px solid rgba(148, 163, 184, 0.18) !important;
  border-radius: 999px !important;
  background: rgba(17, 24, 39, 0.68) !important;
  box-shadow: inset 0 1px 0 rgba(191, 219, 254, 0.03);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease;
}

body[data-theme="dark"] .toastui-editor-toolbar-icons {
  filter: invert(0.96) hue-rotate(180deg) saturate(0.9);
}

body[data-theme="dark"] .toastui-editor-contents,
body[data-theme="dark"] .toastui-editor-contents p,
body[data-theme="dark"] .toastui-editor-md-preview,
body[data-theme="dark"] .ProseMirror {
  color: #c6d1df !important;
}

body[data-theme="dark"] .toastui-editor-contents li,
body[data-theme="dark"] .toastui-editor-md-preview li,
body[data-theme="dark"] .toastui-editor-contents td,
body[data-theme="dark"] .toastui-editor-md-preview td {
  color: #c1ccdb !important;
}

body[data-theme="dark"] .toastui-editor-contents strong,
body[data-theme="dark"] .toastui-editor-md-preview strong {
  color: #d2dbe8 !important;
}

body[data-theme="dark"] .toastui-editor-md-preview {
  background: #111c2f !important;
}

body[data-theme="dark"] .toastui-editor-contents blockquote,
body[data-theme="dark"] .toastui-editor-md-preview blockquote,
body[data-theme="dark"] .toastui-editor-contents blockquote p,
body[data-theme="dark"] .toastui-editor-md-preview blockquote p {
  color: #93a4bb !important;
  border-left-color: rgba(148, 163, 184, 0.24) !important;
}

body[data-theme="dark"] .toastui-editor-contents code,
body[data-theme="dark"] .toastui-editor-md-preview code {
  background: rgba(148, 163, 184, 0.1) !important;
  color: #c7b7ca !important;
}

body[data-theme="dark"] .toastui-editor-contents pre,
body[data-theme="dark"] .toastui-editor-md-preview pre {
  background: rgba(11, 18, 32, 0.6) !important;
  color: #b9c8da !important;
}

body[data-theme="dark"] .toastui-editor-contents a,
body[data-theme="dark"] .toastui-editor-md-preview a {
  color: #9dbbe2 !important;
}

body[data-theme="dark"] .toastui-editor-toolbar-group {
  border-color: rgba(148, 163, 184, 0.18) !important;
}

body[data-theme="dark"] .toastui-editor-toolbar button,
body[data-theme="dark"] .toastui-editor-defaultUI-toolbar button {
  border-radius: 10px !important;
}

body[data-theme="dark"] .toastui-editor-toolbar button:hover,
body[data-theme="dark"] .toastui-editor-defaultUI-toolbar button:hover,
body[data-theme="dark"] .toastui-editor-mode-switch .tab-item:hover,
body[data-theme="dark"] .toastui-editor-mode-switch .tab-item.active {
  background: rgba(59, 130, 246, 0.16) !important;
}

body[data-theme="dark"] .toastui-editor-toolbar button:hover,
body[data-theme="dark"] .toastui-editor-defaultUI-toolbar button:hover,
body[data-theme="dark"] .toastui-editor-mode-switch .tab-item:hover {
  color: #d6e1f0 !important;
}

body[data-theme="dark"] .toastui-editor-mode-switch .tab-item.active {
  color: #dde8f6 !important;
  border-color: rgba(191, 219, 254, 0.34) !important;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.28), rgba(29, 78, 216, 0.24)) !important;
  box-shadow:
    inset 0 0 0 1px rgba(191, 219, 254, 0.18),
    0 8px 18px rgba(37, 99, 235, 0.18);
}

body[data-theme="dark"] .toastui-editor-popup-body input,
body[data-theme="dark"] .toastui-editor-popup-body label,
body[data-theme="dark"] .toastui-editor-popup-body select {
  color: var(--text) !important;
}

body[data-theme="dark"] .toastui-editor-contents h1,
body[data-theme="dark"] .toastui-editor-contents h2,
body[data-theme="dark"] .toastui-editor-contents h3,
body[data-theme="dark"] .toastui-editor-contents h4,
body[data-theme="dark"] .toastui-editor-md-preview h1,
body[data-theme="dark"] .toastui-editor-md-preview h2,
body[data-theme="dark"] .toastui-editor-md-preview h3,
body[data-theme="dark"] .toastui-editor-md-preview h4 {
  color: #b7c7da !important;
}

body[data-theme="dark"] .toastui-editor-contents h1,
body[data-theme="dark"] .toastui-editor-md-preview h1 {
  border-bottom-color: rgba(148, 163, 184, 0.32) !important;
}

body[data-theme="dark"] .toastui-editor-contents h2,
body[data-theme="dark"] .toastui-editor-md-preview h2 {
  border-bottom-color: rgba(148, 163, 184, 0.2) !important;
}

.ProseMirror,
.toastui-editor-md-preview,
.toastui-editor-contents,
.toastui-editor-contents p,
.toastui-editor-contents li,
.toastui-editor-md-preview p,
.toastui-editor-md-preview li {
  font-size: var(--editor-font-size) !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 20, 27, 0.46);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  overflow-y: auto;
  z-index: 30;
}

body[data-theme="dark"] .modal-backdrop {
  background: rgba(3, 8, 20, 0.72);
}

.modal-card {
  width: min(100%, 520px);
  max-height: calc(100vh - 3rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-card-wide {
  width: min(100%, 760px);
}

body[data-theme="dark"] .modal-card {
  background:
    linear-gradient(180deg, rgba(17, 28, 47, 0.98), rgba(15, 28, 52, 0.96));
  border-color: var(--line-strong);
}

body[data-theme="dark"] .settings-profile-panel {
  background: rgba(17, 24, 39, 0.68);
  border-color: rgba(148, 163, 184, 0.18);
}

body[data-theme="dark"] .settings-profile-item {
  background: rgba(17, 24, 39, 0.78);
  border-color: rgba(148, 163, 184, 0.22);
}

body[data-theme="dark"] .directory-browser-path,
body[data-theme="dark"] .directory-browser-create {
  background: rgba(17, 24, 39, 0.78);
  border-color: rgba(148, 163, 184, 0.22);
}

body[data-theme="dark"] .directory-browser-list {
  background: rgba(17, 24, 39, 0.78);
  border-color: rgba(148, 163, 184, 0.22);
}

body[data-theme="dark"] .directory-browser-item {
  border-color: rgba(148, 163, 184, 0.1);
}

body[data-theme="dark"] .directory-browser-item:hover {
  background: rgba(59, 130, 246, 0.14);
}

.modal-header,
.modal-content,
.modal-actions {
  padding: 1.2rem 1.3rem;
}

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

.modal-header h3 {
  margin: 0.3rem 0 0;
}

.modal-content {
  display: grid;
  gap: 0.7rem;
  overflow-y: auto;
  min-height: 0;
}

.settings-profile-panel {
  display: grid;
  gap: 0.7rem;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line);
}

.settings-profile-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.settings-profile-list {
  display: grid;
  gap: 0.55rem;
}

.settings-profile-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.75rem 0.85rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.settings-profile-item.is-editing {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-profile-item-info {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.settings-profile-item-info span {
  font-size: 0.82rem;
  color: var(--muted);
  word-break: break-word;
}

.settings-profile-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.settings-profile-action {
  min-width: 6rem;
}

.settings-profile-empty {
  padding: 0.75rem 0.2rem 0.1rem;
  font-size: 0.86rem;
}

.directory-browser-current {
  display: grid;
  gap: 0.35rem;
}

.directory-browser-path {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0.8rem 0.95rem;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  word-break: break-word;
}

.directory-browser-crumb {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0.15rem 0.2rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

.directory-browser-crumb:hover {
  background: var(--accent-soft);
}

.directory-browser-crumb.is-current {
  color: var(--text);
  cursor: default;
  font-weight: 600;
}

.directory-browser-separator {
  color: var(--muted);
  font-size: 0.86rem;
}

.directory-browser-actions {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.directory-browser-create {
  display: grid;
  gap: 0.7rem;
  padding: 0.8rem 0.9rem;
  border-radius: 16px;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.4);
}

.directory-browser-create-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.directory-browser-list {
  display: flex;
  flex-direction: column;
  max-height: min(50vh, 420px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.directory-browser-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
  padding: 0.38rem 0.6rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  transition: background-color 0.12s ease;
}

.directory-browser-item:last-child {
  border-bottom: 0;
}

.directory-browser-item:hover {
  background: var(--accent-soft);
}

.directory-browser-item-icon {
  flex-shrink: 0;
  color: #c8974a;
  opacity: 0.9;
}

body[data-theme="obsidian"] .directory-browser-item-icon {
  color: #d4a73a;
}

.directory-browser-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.directory-browser-item-chevron {
  flex-shrink: 0;
  color: var(--muted);
  opacity: 0.6;
}

.directory-browser-empty {
  padding: 0.65rem 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

@media (max-width: 720px), (max-height: 860px) {
  .modal-backdrop {
    padding: 0.75rem;
    place-items: start center;
  }

  .modal-card {
    max-height: calc(100vh - 1.5rem);
    border-radius: 20px;
  }

  .modal-header,
  .modal-content,
  .modal-actions {
    padding: 1rem;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 320px minmax(0, 1fr);
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .workspace-topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .sidebar-toolbar .button {
    flex-basis: calc(50% - 0.3rem);
  }
}

/* ── Tree icons ──────────────────────────────────────────── */

.tree-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-right: 0.3rem;
}

.tree-icon svg {
  width: 14px;
  height: 14px;
}

.tree-link-dir {
  display: inline-flex;
  align-items: center;
}

.tree-toggle-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tree-icon-folder { color: #c8974a; }
.tree-icon-md     { color: #6b9fd4; }
.tree-icon-image  { color: #6aaf76; }
.tree-icon-pdf    { color: #c96b6b; }
.tree-icon-generic { color: var(--muted); }

/* ── Obsidian theme ──────────────────────────────────────── */

body[data-theme="obsidian"] {
  --bg: #1e1e1e;
  --panel: #252526;
  --panel-strong: #1e1e1e;
  --surface: #2d2d30;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #cccccc;
  --muted: #808080;
  --accent: #7c6fcd;
  --accent-strong: #6a5db8;
  --accent-soft: rgba(124, 111, 205, 0.15);
  --warning: #f28779;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  --glow: transparent;
  --radius: 4px;

  background: #1e1e1e;
}

body[data-theme="obsidian"] .app-shell {
  gap: 0;
  padding: 0;
  height: 100vh;
}

body[data-theme="obsidian"] .sidebar,
body[data-theme="obsidian"] .workspace-panel {
  border-radius: 0;
  backdrop-filter: none;
  box-shadow: none;
  background: var(--panel);
  border: none;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

body[data-theme="obsidian"] .workspace-panel {
  border-right: none;
}

body[data-theme="obsidian"] .brand-block h1,
body[data-theme="obsidian"] .workspace-topbar h2,
body[data-theme="obsidian"] .modal-header h3 {
  color: #d4d4d4;
}

body[data-theme="obsidian"] .button {
  border-radius: 4px;
  transform: none !important;
}

body[data-theme="obsidian"] .button-primary {
  background: var(--accent);
  border-color: transparent;
  box-shadow: none;
  color: #fff;
}

body[data-theme="obsidian"] .button-primary:hover {
  background: var(--accent-strong);
  box-shadow: none;
}

body[data-theme="obsidian"] .button-secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}

body[data-theme="obsidian"] .button-secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

body[data-theme="obsidian"] .icon-button {
  border-radius: 4px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

body[data-theme="obsidian"] .icon-button:hover {
  background: var(--accent-soft);
  border-color: transparent;
}

body[data-theme="obsidian"] .user-chip {
  border-radius: 4px;
  background: var(--surface);
  border-color: var(--line-strong);
}

body[data-theme="obsidian"] .profiles-dropdown {
  border-radius: 6px;
  background: #252526;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
  backdrop-filter: none;
}

body[data-theme="obsidian"] .profiles-dropdown-header {
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="obsidian"] .profiles-dropdown-item {
  border-radius: 4px;
}

body[data-theme="obsidian"] .profiles-dropdown-item:hover {
  background: var(--accent-soft);
}

body[data-theme="obsidian"] .settings-profile-panel {
  border-radius: 6px;
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="obsidian"] .settings-profile-item {
  border-radius: 4px;
  background: #252526;
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="obsidian"] .directory-browser-create {
  border-radius: 4px;
  background: #252526;
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="obsidian"] .tree-toggle,
body[data-theme="obsidian"] .tree-link {
  border-radius: 3px;
}

body[data-theme="obsidian"] .tree-link:hover,
body[data-theme="obsidian"] .tree-toggle:hover {
  background: var(--accent-soft);
}

body[data-theme="obsidian"] .tree-link.is-active {
  background: var(--accent-soft);
  color: #a89de8;
  box-shadow: none;
}

body[data-theme="obsidian"] .sidebar-tree-icon {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

body[data-theme="obsidian"] .sidebar-tree-icon:hover {
  background: var(--accent-soft);
  border-color: transparent;
}

body[data-theme="obsidian"] .sidebar-tree-icon.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

body[data-theme="obsidian"] .workspace-topbar,
body[data-theme="obsidian"] .statusbar,
body[data-theme="obsidian"] .modal-header,
body[data-theme="obsidian"] .modal-actions {
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="obsidian"] .editor-stage {
  background: #1e1e1e;
}

body[data-theme="obsidian"] .toastui-editor-defaultUI,
body[data-theme="obsidian"] .toastui-editor-main,
body[data-theme="obsidian"] .toastui-editor-md-container,
body[data-theme="obsidian"] .toastui-editor-ww-container,
body[data-theme="obsidian"] .toastui-editor-popup {
  background: #1e1e1e !important;
  color: #cccccc !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

body[data-theme="obsidian"] .toastui-editor-toolbar,
body[data-theme="obsidian"] .toastui-editor-defaultUI-toolbar,
body[data-theme="obsidian"] .toastui-editor-mode-switch {
  background: #252526 !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  box-shadow: none !important;
}

body[data-theme="obsidian"] .toastui-editor-toolbar-icons {
  filter: invert(0.82) hue-rotate(180deg) saturate(0.7);
}

body[data-theme="obsidian"] .toastui-editor-toolbar button,
body[data-theme="obsidian"] .toastui-editor-defaultUI-toolbar button {
  border-radius: 3px !important;
  color: #808080 !important;
}

body[data-theme="obsidian"] .toastui-editor-toolbar button:hover,
body[data-theme="obsidian"] .toastui-editor-defaultUI-toolbar button:hover {
  background: var(--accent-soft) !important;
  color: #cccccc !important;
}

body[data-theme="obsidian"] .toastui-editor-toolbar-group {
  border-color: rgba(255, 255, 255, 0.08) !important;
}

body[data-theme="obsidian"] .toastui-editor-mode-switch {
  min-height: 2.8rem;
  padding: 0.5rem 0.6rem !important;
  border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
}

body[data-theme="obsidian"] .toastui-editor-mode-switch .tab-item {
  border-radius: 3px !important;
  background: var(--surface) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #808080 !important;
  box-shadow: none !important;
}

body[data-theme="obsidian"] .toastui-editor-mode-switch .tab-item.active {
  background: var(--accent-soft) !important;
  border-color: var(--accent) !important;
  color: #a89de8 !important;
  box-shadow: none !important;
}

body[data-theme="obsidian"] .toastui-editor-contents,
body[data-theme="obsidian"] .toastui-editor-contents p,
body[data-theme="obsidian"] .ProseMirror,
body[data-theme="obsidian"] .toastui-editor-md-preview {
  background: #1e1e1e !important;
  color: #cccccc !important;
}

body[data-theme="obsidian"] .toastui-editor-contents h1,
body[data-theme="obsidian"] .toastui-editor-contents h2,
body[data-theme="obsidian"] .toastui-editor-contents h3,
body[data-theme="obsidian"] .toastui-editor-contents h4,
body[data-theme="obsidian"] .toastui-editor-md-preview h1,
body[data-theme="obsidian"] .toastui-editor-md-preview h2,
body[data-theme="obsidian"] .toastui-editor-md-preview h3,
body[data-theme="obsidian"] .toastui-editor-md-preview h4 {
  color: #e8e8e8 !important;
}

body[data-theme="obsidian"] .toastui-editor-contents h1,
body[data-theme="obsidian"] .toastui-editor-md-preview h1 {
  border-bottom-color: rgba(255, 255, 255, 0.12) !important;
}

body[data-theme="obsidian"] .toastui-editor-contents h2,
body[data-theme="obsidian"] .toastui-editor-md-preview h2 {
  border-bottom-color: rgba(255, 255, 255, 0.07) !important;
}

body[data-theme="obsidian"] .toastui-editor-contents code,
body[data-theme="obsidian"] .toastui-editor-md-preview code {
  background: rgba(255, 255, 255, 0.07) !important;
  color: #ce9178 !important;
}

body[data-theme="obsidian"] .toastui-editor-contents pre,
body[data-theme="obsidian"] .toastui-editor-md-preview pre {
  background: #1a1a1a !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: #d4d4d4 !important;
}

body[data-theme="obsidian"] .toastui-editor-contents a,
body[data-theme="obsidian"] .toastui-editor-md-preview a {
  color: #569cd6 !important;
}

body[data-theme="obsidian"] .toastui-editor-contents blockquote,
body[data-theme="obsidian"] .toastui-editor-md-preview blockquote,
body[data-theme="obsidian"] .toastui-editor-contents blockquote p,
body[data-theme="obsidian"] .toastui-editor-md-preview blockquote p {
  border-left-color: var(--accent) !important;
  color: #808080 !important;
}

body[data-theme="obsidian"] .toastui-editor-contents li,
body[data-theme="obsidian"] .toastui-editor-md-preview li {
  color: #cccccc !important;
}

body[data-theme="obsidian"] .toastui-editor-contents strong,
body[data-theme="obsidian"] .toastui-editor-md-preview strong {
  color: #e8e8e8 !important;
}

body[data-theme="obsidian"] .toastui-editor-popup-body input,
body[data-theme="obsidian"] .toastui-editor-popup-body label,
body[data-theme="obsidian"] .toastui-editor-popup-body select {
  color: var(--text) !important;
}

body[data-theme="obsidian"] .context-menu {
  border-radius: 6px;
  background: #2d2d30;
  border-color: rgba(255, 255, 255, 0.13);
  backdrop-filter: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

body[data-theme="obsidian"] .context-menu-item {
  border-radius: 3px;
  color: #cccccc;
}

body[data-theme="obsidian"] .context-menu-item:hover {
  background: var(--accent-soft);
}

body[data-theme="obsidian"] .context-menu-item-muted {
  color: #808080;
}

body[data-theme="obsidian"] .context-menu-header {
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="obsidian"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.65);
}

body[data-theme="obsidian"] .modal-card {
  border-radius: 6px;
  background: #252526;
  border-color: rgba(255, 255, 255, 0.13);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

body[data-theme="obsidian"] .settings-input {
  border-radius: 3px;
  background: #2d2d30;
  border-color: rgba(255, 255, 255, 0.13);
  color: #cccccc;
}

body[data-theme="obsidian"] .settings-input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

body[data-theme="obsidian"] .directory-browser-path {
  border-radius: 4px;
  background: #2d2d30;
  border-color: rgba(255, 255, 255, 0.1);
  color: #cccccc;
}

body[data-theme="obsidian"] .directory-browser-list {
  background: #2d2d30;
  border-color: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

body[data-theme="obsidian"] .directory-browser-item {
  color: #cccccc;
  border-color: rgba(255, 255, 255, 0.06);
}

body[data-theme="obsidian"] .directory-browser-item:hover {
  background: var(--accent-soft);
}


body[data-theme="obsidian"] .upload-dropzone {
  border-radius: 4px;
  background: #2d2d30;
  border-color: rgba(255, 255, 255, 0.13);
}

body[data-theme="obsidian"] .upload-dropzone:hover,
body[data-theme="obsidian"] .upload-dropzone.is-dragover,
body[data-theme="obsidian"] .upload-dropzone:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: none;
}

body[data-theme="obsidian"] .upload-file-list {
  border-radius: 4px;
  background: #2d2d30;
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="obsidian"] .overlay-card {
  border-radius: 4px;
  background: rgba(37, 37, 38, 0.95);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

body[data-theme="obsidian"] .tree-scope-up {
  border-radius: 3px;
  background: #2d2d30;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cccccc;
}

body[data-theme="obsidian"] .tree-scope-up:hover {
  background: var(--accent-soft);
}

body[data-theme="obsidian"] .alert-error {
  background: rgba(80, 20, 20, 0.6);
  border-color: rgba(242, 135, 121, 0.3);
}

body[data-theme="obsidian"] .tree-icon-folder { color: #d4a73a; }
body[data-theme="obsidian"] .tree-icon-md     { color: #6b9fd4; }
body[data-theme="obsidian"] .tree-icon-image  { color: #6aaf76; }
body[data-theme="obsidian"] .tree-icon-pdf    { color: #c96b6b; }
body[data-theme="obsidian"] .tree-icon-generic { color: #808080; }
