:root {
  color-scheme: light;
  --bg: #edf0f7;
  --panel: #ffffff;
  --panel-alt: #f8f9fd;
  --surface: #f6f7fc;
  --surface-hover: #eff1f6;
  --text: #3d4356;
  --text-strong: #23283a;
  --muted: #8a91a8;
  --line: #dfe3ef;
  --line-soft: #eaedf6;
  --primary: #5566d8;
  --primary-strong: #4353c4;
  --primary-soft: #edeffb;
  --primary-tint: #f6f7fc;
  --danger: #f0454f;
  --danger-soft: #fdeced;
  --success: #17a34a;
  --radius: 20px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(90, 105, 170, 0.08);
  --shadow: 0 20px 44px -14px rgba(90, 105, 170, 0.18), 0 2px 10px rgba(90, 105, 170, 0.07);
  --shadow-lg: 0 30px 70px -18px rgba(90, 105, 170, 0.24), 0 4px 14px rgba(90, 105, 170, 0.08);
}

* {
  box-sizing: border-box;
}

/* Thin, quiet scrollbars everywhere. */
* {
  scrollbar-width: thin;
  scrollbar-color: #cfd4e3 transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: #cfd4e3;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: #b4bad0;
  background-clip: padding-box;
}

html:has(.wide-shell) {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--app-font-family, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  font-size: var(--app-font-size, 14px);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body:has(.wide-shell) {
  height: 100%;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

body,
button,
input,
select,
textarea,
table {
  font-size: var(--app-font-size, 14px);
}

button,
.upload-button {
  border: 0;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  min-height: 40px;
  padding: 0 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: var(--app-font-size, 14px);
  font-weight: 650;
  box-shadow: 0 1px 2px rgba(23, 30, 60, 0.06);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover,
.upload-button:hover {
  background: var(--primary-strong);
  box-shadow: 0 10px 22px -8px rgba(85, 102, 216, 0.45);
  transform: translateY(-1px);
}

button:active,
.upload-button:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(23, 30, 60, 0.06);
}

button:disabled {
  background: #c4cad8;
  color: #f7f9fb;
  box-shadow: none;
  cursor: not-allowed;
}

button:disabled:hover {
  background: #c4cad8;
  box-shadow: none;
  transform: none;
}

button.secondary {
  background: var(--primary-soft);
  color: var(--primary-strong);
  box-shadow: none;
}

button.secondary:hover {
  background: #dfe3fa;
  box-shadow: none;
}

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

button.danger:hover {
  background: #c43038;
  box-shadow: 0 10px 22px -8px rgba(240, 69, 79, 0.55);
}

input {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  min-height: 42px;
  padding: 0 12px;
  width: 100%;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus {
  outline: none;
  border-color: #b9c1f0;
  box-shadow: 0 0 0 3px rgba(85, 102, 216, 0.15);
}

select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 28px 0 10px;
  background: #fff;
  color: var(--muted);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select:focus {
  outline: none;
  border-color: #b9c1f0;
  box-shadow: 0 0 0 3px rgba(85, 102, 216, 0.15);
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(1704px, calc(100% - 96px));
  margin: 0 auto;
  min-height: 100vh;
  padding: 24px 0 48px;
}

.wide-shell {
  width: 100%;
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  padding: 0;
  background: var(--bg);
}

.auth-panel {
  width: min(560px, 100%);
  margin: 12vh auto 0;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 35px;
  height: 35px;
  border-radius: 14px;
  background: linear-gradient(135deg, #4aa8ff, var(--primary));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: calc(var(--font-scale, 1) * 24px);
  box-shadow: 0 6px 16px rgba(85, 102, 216, 0.35);
}

h1 {
  margin: 0;
  font-size: calc(var(--font-scale, 1) * 24px);
  line-height: 1.2;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.message {
  min-height: 24px;
  margin-top: 16px;
  color: var(--muted);
}

.message.error {
  color: var(--danger);
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(30, 36, 51, 0.36);
}

.dialog-overlay.nested-dialog {
  z-index: 1100;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: end start;
  padding: 24px 24px 24px 96px;
  background: rgba(30, 36, 51, 0.18);
}

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 1200;
  display: grid;
  justify-items: center;
  width: min(520px, calc(100% - 32px));
  pointer-events: none;
  transform: translateX(-50%);
}

.toast {
  max-width: 100%;
  padding: 12px 18px;
  border-radius: 12px;
  color: #fff;
  background: rgba(24, 24, 27, 0.96);
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.28);
  font-weight: 650;
  line-height: 1.45;
  overflow-wrap: anywhere;
  animation: toast-in 0.18s ease-out both;
}

.toast.error {
  background: rgba(180, 35, 24, 0.96);
}

.toast.leaving {
  animation: toast-out 0.65s ease-in forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

.dialog-card {
  width: min(420px, 100%);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

.settings-card {
  width: min(520px, 100%);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
  padding: 22px;
}

#codeSettingsForm {
  max-height: 100%;
  overflow: auto;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.dialog-field-wide {
  grid-column: 1 / -1;
}

.dialog-title {
  margin: 0;
  color: var(--text);
  font-size: calc(var(--font-scale, 1) * 18px);
  line-height: 1.35;
}

.dialog-message {
  margin: 10px 0 0;
  color: var(--text);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.dialog-input {
  margin-top: 18px;
}

.dialog-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.dialog-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 13px);
  font-weight: 650;
}

.dialog-field input,
.dialog-field select {
  width: 100%;
  min-height: 44px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: calc(var(--font-scale, 1) * 15px);
  font-weight: 500;
}

.color-picker {
  position: relative;
  width: 36px;
  height: 34px;
}

.color-picker > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  list-style: none;
  cursor: pointer;
}

.color-picker > summary::-webkit-details-marker {
  display: none;
}

.color-picker > summary::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--swatch-color, conic-gradient(#e53935, #fb8c00, #fdd835, #43a047, #1e88e5, #8e24aa, #e53935));
  box-shadow: inset 0 0 0 3px #fff;
}

.color-picker-panel {
  position: absolute;
  z-index: 20;
  top: 38px;
  left: 0;
  box-sizing: border-box;
  width: 214px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 24px rgb(15 23 42 / 18%);
}

.color-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.color-picker-head input[type="color"] {
  width: 28px;
  min-height: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
}

.color-swatch {
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(90, 105, 170, 0.24);
  border-radius: 3px;
  background: var(--swatch-color);
  cursor: pointer;
  transform: none;
}

.color-swatch.selected {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.color-swatch-default {
  background: linear-gradient(to bottom right, #fff 47%, var(--primary) 48%, var(--primary) 52%, #fff 53%);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.dialog-actions button {
  min-width: 80px;
}

.file-view {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  gap: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

.file-view.notes-view {
  grid-template-rows: minmax(0, 1fr);
}

.file-view.files-view {
  grid-template-rows: 40px minmax(0, 1fr);
}

.file-view.notes-view .workspace-bar,
.file-view.bare-view .workspace-bar {
  display: none;
}

.file-view.bare-view {
  grid-template-rows: minmax(0, 1fr);
}

.file-view.bare-view .view-panel {
  grid-row: 1;
}

.file-view.notes-view .notes-panel {
  grid-row: 1;
}

/* The rail floats over the page instead of claiming a grid column. */
.topbar {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  width: 64px;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 0;
  padding: 8px 6px;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  /* Layered: a hairline ring plus a close ambient shadow so the floating rail reads on
     all sides, not just below — the single -12px spread cast almost nothing sideways. */
  box-shadow:
    0 0 0 1px rgba(90, 105, 170, 0.07),
    0 2px 12px rgba(90, 105, 170, 0.14),
    0 14px 34px -10px rgba(90, 105, 170, 0.34);
}

.rail-toggle {
  width: 100%;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  font-size: calc(var(--font-scale, 1) * 18px);
  line-height: 1;
}

.rail-toggle:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
}

.file-view.rail-collapsed .topbar {
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.file-view.rail-collapsed .top-actions {
  display: none;
}

.file-view.rail-collapsed .rail-toggle {
  width: 44px;
  height: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
}

.top-actions,
.upload-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.upload-bar {
  height: 61px;
  flex-wrap: nowrap;
}

.top-actions {
  width: 100%;
  gap: 6px;
  align-items: stretch;
  flex-direction: column;
}

#settingsBtn {
  margin-top: 0;
  min-height: 44px;
}

.top-actions > .workspace-status {
  width: 100%;
  min-height: 44px;
  justify-content: center;
}

.top-actions button {
  min-height: 38px;
  padding: 0 4px;
}

.top-actions button.secondary {
  width: 100%;
  min-width: 0;
  padding: 0 4px;
  flex: 0 0 auto;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  justify-content: center;
  flex-direction: column;
  gap: 3px;
  min-height: 52px;
  border-radius: 10px;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 10.5px);
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}

.workspace-bar {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.workspace-context {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.workspace-home-button {
  display: none;
}

.workspace-context h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: calc(var(--font-scale, 1) * 15px);
  font-weight: 750;
  white-space: nowrap;
}

.workspace-context .crumbs {
  min-width: 0;
  margin: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

.file-view.files-view .workspace-context {
  gap: 20px;
}

.file-view.files-view .workspace-home-button {
  display: grid;
  flex: 0 0 30px;
  width: 30px;
  min-height: 30px;
  padding: 0;
  place-items: center;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  color: #6a7391;
  transform: none;
}

.file-view.files-view .workspace-home-button:hover {
  background: var(--surface-hover);
}

.file-view.files-view .workspace-home-icon {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.file-view.files-view .workspace-context h2 {
  display: none;
}

.file-view.files-view .workspace-context .crumbs {
  display: flex;
  align-items: center;
  gap: 20px;
  color: #6a7391;
  font-size: calc(var(--font-scale, 1) * 16px);
  font-weight: 500;
}

.file-view.files-view .workspace-context .crumbs button {
  color: #6a7391;
  font-size: inherit;
  font-weight: 500;
}

.file-view.files-view .workspace-context .crumbs button:last-child {
  color: var(--text-strong);
  font-weight: 650;
}

.file-view.files-view .workspace-search {
  display: none;
}

.workspace-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(360px, 34vw);
  margin-left: auto;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-alt);
  color: var(--muted);
}

.workspace-search:focus-within {
  border-color: #b9c1f0;
  box-shadow: 0 0 0 3px rgba(85, 102, 216, 0.13);
}

.workspace-search input {
  min-height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.workspace-status {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--success);
  box-shadow: none;
}

.workspace-status:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--success);
  box-shadow: none;
  transform: none;
}

.workspace-status:active,
.workspace-status:disabled {
  background: transparent;
  box-shadow: none;
  transform: none;
}

.workspace-status:disabled {
  cursor: wait;
}

.workspace-status-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace-status.syncing {
  color: var(--primary);
}

.workspace-status.syncing .workspace-status-icon {
  animation: workspace-spin 0.8s linear infinite;
}

.workspace-status.syncing .workspace-status-icon circle {
  stroke-dasharray: 34 16;
}

.workspace-status-error-mark,
.workspace-status.syncing .workspace-status-check,
.workspace-status.syncing .workspace-status-error-mark {
  display: none;
}

.workspace-status.error {
  color: var(--danger);
}

.workspace-status.error .workspace-status-check {
  display: none;
}

.workspace-status.error .workspace-status-error-mark {
  display: inline;
}

@keyframes workspace-spin {
  to { transform: rotate(360deg); }
}

.top-actions button.secondary:not(.settings-button)::before {
  width: 20px;
  height: 20px;
  background: currentColor;
  content: "";
  -webkit-mask: center / contain no-repeat var(--nav-icon);
  mask: center / contain no-repeat var(--nav-icon);
}

#notesBtn::before {
  --nav-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 3h9l3 3v15H6zM9 10h6M9 14h6M9 18h4M15 3v4h4' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

#filesBtn::before {
  --nav-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 7h7l2 2h9v11H3zM3 7V5h7l2 2' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'/%3E%3C/svg%3E");
}

#rssBtn::before {
  --nav-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 4.5a15.5 15.5 0 0 1 15.5 15.5M4 11a9 9 0 0 1 9 9' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3Ccircle cx='5.5' cy='18.5' r='1.9' fill='black'/%3E%3C/svg%3E");
}

#logsBtn::before {
  --nav-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 3h12v18H6zM9 8h6M9 12h6M9 16h3M3 7h3M3 12h3M3 17h3' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}

#codeBtn::before {
  --nav-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m9 7-5 5 5 5M15 7l5 5-5 5' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.top-actions button.icon-button,
button.icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  flex: 0 0 38px;
  font-size: calc(var(--font-scale, 1) * 18px);
}

.top-actions button.settings-button {
  width: 100%;
  min-width: 0;
  flex: 0 0 auto;
  gap: 5px;
  font-size: var(--app-font-size, 14px);
}

.settings-button span[aria-hidden="true"] {
  --settings-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.38a2 2 0 0 0-.73-2.73l-.15-.09a2 2 0 0 1-1-1.74v-.51a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
  display: block;
  width: 18px;
  height: 18px;
  background: currentColor;
  font-size: 0;
  -webkit-mask: center / contain no-repeat var(--settings-icon);
  mask: center / contain no-repeat var(--settings-icon);
}

.top-actions button.secondary:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
  transform: none;
}

.top-actions button:disabled,
.top-actions button:disabled:hover {
  background: var(--primary-soft);
  color: var(--primary-strong);
  box-shadow: none;
  cursor: default;
  transform: none;
}

.crumbs {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 14px);
}

.crumbs button {
  background: transparent;
  box-shadow: none;
  color: var(--primary);
  padding: 0;
  min-height: 0;
}

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

.upload-bar,
.log-toolbar {
  background: var(--panel);
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  box-shadow: none;
  padding: 0 16px;
}

.upload-bar > button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}

.upload-bar > button:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
  transform: none;
}

.file-stats {
  margin-left: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 13px);
  white-space: nowrap;
}

.file-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.file-search:focus-within {
  border-color: #b9c1f0;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(85, 102, 216, 0.15);
}

.file-search input {
  width: 180px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  outline: none;
  font-size: calc(var(--font-scale, 1) * 14px);
}

.upload-button input {
  display: none;
}

.upload-state {
  color: var(--muted);
  min-height: 22px;
}

.table-wrap {
  background: var(--panel);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: auto;
  padding: 0;
}

table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: calc(var(--font-scale, 1) * 14px);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 11.5px);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--panel);
  user-select: none;
}

tr:hover td {
  background: var(--primary-tint);
}

.file-row {
  cursor: pointer;
}

.file-row.selected td {
  background: var(--primary-soft);
}

.file-row:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.file-row.dragging td,
.notes-tree-row.dragging {
  opacity: 0.55;
}

.file-row.drop-target td,
#crumbs button.drop-target,
.notes-tree-row.drop-target {
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.file-row.drop-target td:first-child {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}

.file-row.drop-target td:last-child {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

.file-table td:nth-child(2),
.file-table td:nth-child(3),
.file-table td:nth-child(4),
.log-table td {
  color: var(--muted);
}

.file-table td:nth-child(2) {
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: normal;
}

.file-table td:nth-child(3) {
  white-space: nowrap;
}

.file-table td:nth-child(4) {
  line-height: 1.35;
}

.file-table td:nth-child(5) {
  text-align: left;
}

td.name-cell {
  font-weight: 650;
}

.file-entry {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.file-icon {
  --file-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5zM14 2v6h6M8 13h8M8 17h8M8 9h2'/%3E%3C/svg%3E");
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  background: var(--muted);
  -webkit-mask: center / contain no-repeat var(--file-icon);
  mask: center / contain no-repeat var(--file-icon);
}

.file-icon-folder {
  --file-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 7v11a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-7l-2-3H5a2 2 0 0 0-2 2z'/%3E%3C/svg%3E");
}

.name-button {
  padding: 0;
  min-height: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-weight: 700;
}

.name-button:hover {
  background: transparent;
  color: var(--text-strong);
}

.file-name,
.name-button {
  display: block;
  min-width: 0;
  max-width: 100%;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  padding: 42px;
  text-align: center;
  color: var(--muted);
}

.action-buttons {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
  justify-content: flex-start;
  opacity: 1;
}

.action-buttons button {
  min-height: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  color: var(--primary);
  font-weight: 650;
}

.action-buttons button:hover {
  background: transparent;
  color: var(--primary-strong);
  text-decoration: underline;
}

.file-download-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: pdf-spin 0.8s linear infinite;
}

.file-table .sort-header {
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  display: inline;
  justify-content: flex-start;
}

.file-table .sort-header:hover {
  background: transparent !important;
  color: var(--primary-strong);
}

.file-table .sort-header::after {
  content: "↕";
  display: inline;
  margin-left: 8px;
  vertical-align: middle;
  opacity: 0.35;
}

.file-table .sort-header.active::after {
  opacity: 0.9;
}

.file-table .sort-header.active[data-direction="asc"]::after {
  content: "↑";
}

.file-table .sort-header.active[data-direction="desc"]::after {
  content: "↓";
}

.view-panel {
  display: grid;
  grid-column: 1;
  grid-row: 2;
  min-height: 0;
  padding: 0;
  background: #fff;
}

#filePanel {
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  row-gap: 0;
  overflow: hidden;
}

#filePanel:has(.file-details.hidden) {
  grid-template-columns: minmax(0, 1fr);
}

#filePanel .upload-bar,
#filePanel .table-wrap,
#filePanel .file-pagination {
  grid-column: 1;
}

#filePanel .table-wrap {
  min-height: 0;
}

#filePanel .file-table {
  min-width: 740px;
}

#filePanel .file-table th:nth-child(1),
#filePanel .file-table td:nth-child(1) {
  width: 34%;
}

#filePanel .file-table th:nth-child(2),
#filePanel .file-table td:nth-child(2) {
  width: 20%;
}

#filePanel .file-table th:nth-child(3),
#filePanel .file-table td:nth-child(3) {
  width: 86px;
}

#filePanel .file-table th:nth-child(4),
#filePanel .file-table td:nth-child(4) {
  width: 176px;
}

#filePanel .file-table th:nth-child(5),
#filePanel .file-table td:nth-child(5) {
  width: 132px;
}

#logPanel {
  grid-template-rows: minmax(280px, 42%) minmax(0, 1fr);
  overflow: hidden;
}

.log-dashboard {
  min-height: 0;
  overflow: auto;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.log-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.log-metric,
.log-dashboard-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.log-metric {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
}

.log-metric strong {
  color: var(--text-strong);
  font-size: calc(var(--font-scale, 1) * 20px);
}

.log-metric span,
.log-chart-label,
.log-chart-empty,
.log-stat-empty {
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 12px);
}

.log-dashboard-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(360px, 1.2fr);
  gap: 10px;
}

.log-dashboard-card {
  min-width: 0;
  padding: 12px 14px;
}

.log-dashboard-card h2 {
  margin: 0 0 8px;
  color: var(--text-strong);
  font-size: calc(var(--font-scale, 1) * 13px);
}

.log-endpoints {
  display: grid;
  gap: 5px;
}

.log-dashboard-card-wide {
  grid-column: 1 / -1;
}

.log-ip-list {
  /* Every distinct address is listed; scroll instead of stretching the card off-screen. */
  max-height: 220px;
  overflow: auto;
}

.log-endpoint-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  font-size: calc(var(--font-scale, 1) * 12px);
}

.log-endpoint-row span:first-child {
  overflow: hidden;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-endpoint-row span:last-child {
  color: var(--muted);
  white-space: nowrap;
}

.log-response-chart {
  display: block;
  width: 100%;
  height: 150px;
}

.log-chart-grid {
  stroke: var(--line-soft);
  stroke-width: 1;
}

.log-chart-line {
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.log-stat-empty {
  padding: 22px 0;
  text-align: center;
}

.log-dashboard .upload-state:empty {
  display: none;
}

.code-panel {
  grid-template-columns: 260px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  background: var(--surface);
}

.code-toolbar {
  grid-column: 1 / -1;
}

.code-toolbar,
.code-form {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.code-messages {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 20px 0 20px 20px;
}

.code-message {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.code-message.user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
}

.code-message.error {
  color: var(--danger);
  border: 1px solid #f0b8b8;
}

.code-message.thinking {
  color: var(--muted);
}

.code-message.thinking::after {
  content: "";
  animation: code-thinking-dots 1.2s steps(1, end) infinite;
}

@keyframes code-thinking-dots {
  25% { content: "."; }
  50% { content: ".."; }
  75%, 100% { content: "..."; }
}

.code-message.markdown-body {
  max-width: none;
  white-space: normal;
  font-family: var(--note-editor-font-family, var(--app-font-family));
  font-size: var(--note-editor-font-size, var(--app-font-size));
}

.code-message.markdown-body .vditor-reset {
  font-family: inherit;
  font-size: inherit;
}

.code-message.markdown-body > :first-child {
  margin-top: 0;
}

.code-message.markdown-body > :last-child {
  margin-bottom: 0;
}

.code-message-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.code-message-action {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

.code-message-action::before {
  width: 18px;
  height: 18px;
  content: "";
  background: currentColor;
  -webkit-mask: center / contain no-repeat var(--action-icon);
  mask: center / contain no-repeat var(--action-icon);
}

.code-copy-button::before {
  --action-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='8' y='8' width='12' height='12' rx='2' fill='none' stroke='black' stroke-width='1.8'/%3E%3Cpath d='M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2' fill='none' stroke='black' stroke-width='1.8'/%3E%3C/svg%3E");
}

.code-notes-button::before {
  --action-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 3h9l3 3v15H6zM15 3v4h4M9 12h6M12 9v6' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.code-message-action:hover {
  background: var(--primary-soft);
  color: var(--text);
  transform: none;
}

.code-form {
  grid-column: 2;
  grid-row: 3;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.code-composer {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.code-composer:focus-within {
  border-color: #b9c1f0;
  box-shadow: 0 0 0 3px rgba(85, 102, 216, 0.15);
}

.code-form textarea {
  width: 100%;
  min-height: 52px;
  max-height: 180px;
  resize: vertical;
  padding: 12px;
  border: 0;
  border-radius: inherit;
  outline: none;
  box-shadow: none;
  background: #fff;
  color: var(--text);
}

.code-form textarea:focus {
  outline: none;
  box-shadow: none;
}

.code-composer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 8px 8px;
}

.code-composer-select {
  width: auto;
  min-height: 28px;
  padding: 2px 24px 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background-color: var(--panel-alt);
  box-shadow: none;
  color: var(--text);
  font-size: calc(var(--font-scale, 1) * 12.5px);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.code-composer-select:hover {
  border-color: #b9c1f0;
  background-color: var(--primary-soft);
  color: var(--primary-strong);
}

.code-composer-select:focus,
.code-composer-select:focus-visible {
  outline: 2px solid #b9c1f0;
  outline-offset: -2px;
  box-shadow: none;
}

/* Sits in the selector row, so it matches the chips instead of the 36px toolbar buttons. */
.code-attach-button {
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 50%;
  font-size: calc(var(--font-scale, 1) * 18px);
  line-height: 1;
}

/* Hairline keeps the attach action visually separate from the model/settings chips. */
.code-composer-bar .code-attach-wrap {
  display: flex;
  margin-right: 2px;
  padding-right: 8px;
  border-right: 1px solid var(--line);
}

.code-attach-wrap {
  position: relative;
}

.code-attach-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 20;
  display: grid;
  gap: 4px;
  width: 170px;
  padding: 6px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.code-attach-menu button {
  justify-content: flex-start;
  min-height: 36px;
}

.code-files-card {
  width: min(620px, 100%);
  max-height: min(680px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
  padding: 22px;
}

.code-files-crumbs {
  display: flex;
  gap: 4px;
  margin: 16px 0 10px;
  overflow-x: auto;
}

.code-files-crumbs button {
  min-height: 32px;
  padding: 0 10px;
}

.code-files-list {
  min-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.code-files-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}

.code-files-row:last-child {
  border-bottom: 0;
}

.code-files-row label {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-wrap: anywhere;
}

.code-files-row input {
  width: 18px;
  min-height: 18px;
  flex: 0 0 auto;
}

.code-files-row > span {
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 12px);
}

.code-files-folder {
  width: 100%;
  min-height: 32px;
  justify-content: flex-start;
  padding: 0 8px;
}

.code-files-card > .upload-state {
  min-height: 20px;
  margin-top: 8px;
}

.code-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 8px 0;
}

.code-attachments:empty {
  display: none;
}

.code-attachment,
.code-message-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 240px;
  margin: 0 6px 6px 0;
  padding: 4px 8px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--text);
  font-size: calc(var(--font-scale, 1) * 12px);
}

.code-attachment button {
  min-width: 20px;
  min-height: 20px;
  padding: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 18px);
}

.code-message-file {
  display: flex;
  width: fit-content;
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
}

.code-history {
  grid-column: 1;
  grid-row: 2 / 4;
  min-width: 0;
  padding: 16px 12px;
  overflow: auto;
  border-right: 1px solid var(--line-soft);
  background: #fff;
}

.code-history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.code-history-list button {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  justify-content: flex-start;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  text-overflow: ellipsis;
  box-shadow: none;
}

.code-history-list button:hover,
.code-history-list button.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.file-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  min-height: 44px;
  padding: 0 14px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 13px);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--muted);
  box-shadow: none;
}

.pagination-button:hover {
  border-color: #b9c1f0;
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: none;
  transform: none;
}

.pagination-button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.pagination-button:disabled,
.pagination-button:disabled:hover {
  border-color: var(--line-soft);
  background: var(--panel);
  color: #c2c8d6;
  box-shadow: none;
}

.pagination-size {
  display: inline-flex;
  align-items: center;
}

.file-details {
  grid-column: 2;
  grid-row: 1 / -1;
  min-width: 0;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.file-details-head {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 61px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.96);
}

.file-details-head h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: calc(var(--font-scale, 1) * 15px);
}

.file-details-head .icon-button {
  min-height: 32px;
  flex-basis: 32px;
  width: 32px;
  min-width: 32px;
  padding: 0;
}

.file-details-empty {
  display: grid;
  min-height: 360px;
  padding: 32px;
  color: var(--muted);
  text-align: center;
  place-content: center;
  justify-items: center;
}

.file-details-empty-icon,
.file-details-icon {
  --details-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5zM14 2v6h6M8 13h8M8 17h8M8 9h2'/%3E%3C/svg%3E");
  display: block;
  width: 34px;
  height: 34px;
  background: var(--muted);
  -webkit-mask: center / contain no-repeat var(--details-icon);
  mask: center / contain no-repeat var(--details-icon);
}

.file-details-empty-icon {
  opacity: 0.55;
}

.file-details-content {
  padding: 34px 22px 24px;
  text-align: center;
}

.file-details-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  color: var(--primary);
  background: currentColor;
}

.file-details-icon.folder {
  --details-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 7v11a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-7l-2-3H5a2 2 0 0 0-2 2z'/%3E%3C/svg%3E");
}

.file-details-content h3 {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text-strong);
  font-size: calc(var(--font-scale, 1) * 16px);
}

.file-details-summary {
  margin: 7px 0 26px;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 12px);
}

.file-details-list {
  display: grid;
  gap: 0;
  margin: 0;
  text-align: left;
}

.file-details-list > div {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
}

.file-details-list dt {
  color: var(--muted);
}

.file-details-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

.file-details-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 24px;
}

.file-details-actions button {
  min-width: 0;
  padding: 0 10px;
}

.file-details-actions #fileDetailsOpenBtn {
  grid-column: 1 / -1;
}

.notes-panel {
  display: grid;
  grid-column: 1;
  grid-row: 2;
  grid-template-columns: var(--notes-sidebar-width, 318px) 1px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  padding-bottom: 0;
  background: var(--bg);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

.notes-sidebar {
  min-width: 0;
  background: transparent;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  border: 0;
  border-radius: 0;
  box-shadow: none !important;
  overflow: hidden;
}

.notes-resize-handle {
  position: relative;
  z-index: 2;
  width: 21px;
  margin: 0 -10px;
  cursor: col-resize;
  touch-action: none;
}

.notes-resize-handle::before {
  position: absolute;
  inset: 0 auto 0 10px;
  width: 1px;
  background: transparent;
  content: "";
}

.notes-resize-grip {
  position: absolute;
  top: 50%;
  /* ponytail: integer left (handle 21px - grip 18px)/2 rounded down; left:50% lands on a half pixel and the antialiasing changes as the sidebar resizes */
  left: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 36px;
  border: 1px solid #dfe3ef;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 2px 7px rgba(90, 105, 170, 0.12);
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.notes-resize-handle:hover .notes-resize-grip {
  opacity: 1;
}

.notes-resize-grip::before {
  width: 2px;
  height: 12px;
  border-radius: 2px;
  background: #708196;
  content: "";
}

body.is-resizing-notes {
  cursor: col-resize;
  user-select: none;
}

.notes-sidebar-head,
.notes-reader-head {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 8px 14px;
}

.notes-sidebar-head {
  justify-content: space-between;
  gap: 10px;
  padding: 22px 18px 10px;
  background: transparent;
}

.notes-reader-head {
  padding: 24px 44px 6px;
}

.notes-sidebar-toggle {
  display: none;
}

.notes-sidebar-actions,
.notes-reader-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.notes-sidebar-head button {
  min-height: 44px;
  padding: 0 12px;
  white-space: nowrap;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-weight: 600;
}

#notesCreateBtn {
  background: var(--surface);
}

.notes-sidebar-head button:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
  transform: none;
}

#notesCreateBtn::before {
  margin-right: 5px;
  content: "+";
  font-size: calc(var(--font-scale, 1) * 18px);
  font-weight: 400;
}

.notes-brand-mark {
  display: none;
}

.notes-sidebar-actions {
  width: 100%;
}

.notes-sidebar-head #notesCreateBtn,
.notes-sidebar-head #notesImportBtn {
  flex: 1 1 0;
}

.notes-sidebar-head #notesCreateBtn {
  background: linear-gradient(180deg, #6274e3, #4c5cd0);
  color: #fff;
  box-shadow: 0 6px 16px rgba(85, 102, 216, 0.3);
}

.notes-sidebar-head #notesCreateBtn:hover {
  background: var(--primary-strong);
  color: #fff;
}

.notes-sidebar-head #notesImportBtn {
  background: transparent;
  color: var(--muted);
}

.notes-sidebar-head #notesImportBtn:hover {
  background: var(--surface-hover);
}

#notesSaveBtn {
  min-width: 72px;
}

#notesMindmapBtn {
  height: 30px;
  min-height: 30px;
}

#notesSaveBtn.save-ok {
  background: #1f883d;
  color: #fff;
  font-size: calc(var(--font-scale, 1) * 20px);
  font-weight: 800;
}

#notesSaveBtn.save-ok:hover {
  background: #1a7f37;
}

.notes-search-input {
  /* The global input rule is width:100%, which in this grid row means 100% *plus* the side
     margins — the right edge lands outside the sidebar and gets clipped. */
  width: auto;
  margin: 8px 18px 0;
  min-height: 40px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #fff url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%238a91a8' stroke-width='2' stroke-linecap='round' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 12px center / 16px 16px no-repeat;
  font-size: calc(var(--font-scale, 1) * 14px);
}

.notes-sync-loading {
  display: grid;
  min-height: 32px;
  margin: 8px 18px 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--surface);
  place-items: center;
}

.notes-sync-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: pdf-spin 0.8s linear infinite;
}

.notes-tree-pin {
  margin-left: 6px;
  font-size: calc(var(--font-scale, 1) * 11px);
}

.notes-tree-placeholder {
  padding: 12px 6px;
  color: var(--muted);
}

.note-history-card {
  display: grid;
  gap: 12px;
  width: min(680px, 100%);
  max-height: min(80vh, 640px);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.note-history-list {
  display: grid;
  gap: 4px;
  max-height: 160px;
  overflow: auto;
}

.note-history-row {
  justify-content: flex-start;
  min-height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-weight: 500;
}

.note-history-row.active {
  background: var(--primary-soft);
  color: var(--text-strong);
}

.note-history-preview {
  min-height: 120px;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: calc(var(--font-scale, 1) * 13px);
}

.notes-context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 128px;
  padding: 6px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.notes-context-menu button {
  width: 100%;
  justify-content: flex-start;
  min-height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.notes-context-menu button:not(.danger) {
  background: transparent;
  color: var(--text);
}

.notes-context-menu button:not(.danger):hover {
  background: var(--surface-hover);
  color: var(--text-strong);
}

.notes-sidebar .upload-state {
  padding: 8px 14px 0;
  min-height: 28px;
}

.notes-sidebar .upload-state:empty {
  display: none;
}

.notes-tree-heading {
  margin: 24px 24px 8px;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 11px);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  line-height: 20px;
}

.notes-tree {
  min-height: 0;
  overflow: auto;
  padding: 6px 14px 24px;
  font-size: calc(var(--font-scale, 1) * 14px);
  line-height: 1.35;
}

.notes-tree-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  height: 35px;
  /* No chevron column, so depth alone carries the nesting — step it wider to stay readable. */
  padding-left: calc(var(--depth, 0) * 14px);
  padding-right: 10px;
  border-radius: 8px;
  margin-bottom: 1px;
  transition: background 0.12s ease;
}

/* Neutral gray, not the accent: the accent is reserved for actions (Evernote-style). */
.notes-tree-row.active {
  background: #e8eaf1;
}

.notes-tree-row.active::before {
  display: none;
}

.notes-tree-name {
  min-height: 40px;
  padding: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
}

.notes-tree-name:hover {
  background: transparent;
  color: var(--text-strong);
  box-shadow: none;
  transform: none;
}

.notes-tree-row:hover:not(.active) {
  background: var(--surface-hover);
}

.notes-tree-name {
  position: relative;
  min-width: 0;
  justify-content: flex-start;
  text-align: left;
  gap: 10px;
  color: var(--text);
  font-weight: 400;
}

.notes-tree-row.active .notes-tree-name {
  color: var(--text-strong);
  font-weight: 650;
}

.notes-tree-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-tree-count {
  flex: 0 0 auto;
  min-width: 20px;
  min-height: 20px;
  margin-left: auto;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: #a3a9bd;
  font-size: calc(var(--font-scale, 1) * 12px);
  font-weight: 400;
  text-align: right;
}

.notes-tree-name::before {
  content: "";
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
}

.notes-tree-row.folder .notes-tree-name::before {
  width: 16px;
  height: 16px;
  margin-right: 0;
  background: center / 16px 16px no-repeat url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%239aa0b5' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 7v11a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-7l-2-3H5a2 2 0 0 0-2 2z'/%3E%3C/svg%3E");
  box-shadow: none;
}

/* The open folder replaces the chevron as the only expanded/collapsed cue. */
.notes-tree-row.folder.expanded .notes-tree-name::before {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%235566d8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2'/%3E%3C/svg%3E");
}

.notes-tree-row.folder .notes-tree-name::after {
  display: none;
}

.notes-tree-row.file .notes-tree-name::before {
  width: 16px;
  height: 16px;
  background: center / 16px 16px no-repeat url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%239aa0b5' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5z'/%3E%3Cpath d='M14 2v6h6M8 13h8M8 17h8M8 9h2'/%3E%3C/svg%3E");
}

.notes-tree-row.file .notes-tree-name::after {
  display: none;
}

.notes-reader {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: var(--panel);
  border: 0;
  border-radius: 20px;
  margin: 20px 24px 24px 6px;
  box-shadow: 0 1px 3px rgba(90, 105, 170, 0.1), 0 16px 44px -18px rgba(90, 105, 170, 0.22) !important;
}

/* The sidebar toggle sits before this block in the DOM, so it can only be matched by class:
   a :first-child selector here never applies and the title stacks over its meta line. */
.notes-reader-title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.notes-reader-state {
  flex: 0 0 auto;
  margin-left: auto;
  min-height: 0;
  padding: 0;
  text-align: right;
  white-space: nowrap;
}

.notes-reader-state:empty {
  display: none;
}

.notes-path {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  font-weight: 750;
  /* Truncate rather than wrap: a long file name must not push the meta line out of the 40px head. */
  white-space: nowrap;
  text-overflow: ellipsis;
}

.notes-path .note-title-button {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.note-title-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.note-title-button {
  min-height: 0;
  justify-content: flex-start;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text-strong);
  font-size: calc(var(--font-scale, 1) * 20px);
  font-weight: 700;
  line-height: 28px;
  letter-spacing: -0.01em;
  text-align: left;
  white-space: normal;
}

.note-title-button::before {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin-right: 8px;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%2374777c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 3h9l3 3v15H6zM15 3v4h4M9 11h6M9 15h6'/%3E%3C/svg%3E");
  content: "";
}

.note-title-button:hover {
  background: transparent;
  color: var(--primary);
  transform: none;
}

.note-title-input {
  width: min(520px, 100%);
  min-height: 34px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: calc(var(--font-scale, 1) * 20px);
  font-weight: 700;
}

.notes-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 12px);
  white-space: nowrap;
  align-items: baseline;
}

.notes-download {
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.notes-download:hover {
  background: var(--surface-hover);
}

.notes-content {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 40px clamp(40px, 8vw, 110px);
  background: var(--panel);
}

.notes-content.editor-wrap {
  padding: 0;
  overflow: visible;
}

.note-editor {
  display: block;
  width: 100%;
  height: 100%;
  min-height: min(72vh, 820px);
  border: 0;
  border-radius: 0;
  padding: 22px 28px;
  resize: none;
  outline: none;
  color: var(--note-editor-color, #6a737d);
  background: #fff;
  font-family: var(--note-editor-font-family, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: var(--note-editor-font-size, 16px);
  line-height: 1.7;
}

.vditor-editor-wrap {
  background: #fff;
}

.vditor-note-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.vditor-note-editor.vditor {
  --panel-background-color: #fff;
  --textarea-background-color: #fff;
  --textarea-text-color: #24292e;
  border: 0;
  border-radius: 0;
  height: 100% !important;
  min-height: 0;
  font-family: var(--note-editor-font-family, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif);
}

.vditor-note-editor .vditor-toolbar {
  position: relative;
  z-index: 2;
  overflow: visible;
  border-bottom: 0;
  display: flex !important;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-start !important;
  height: 40px;
  padding: 2px 40px !important;
  background-color: white;
}

.vditor-note-editor .vditor-toolbar::after {
  display: none;
}

.vditor-note-editor .vditor-toolbar svg {
  color: #8a91a8;
}

.note-style-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  margin-right: 10px;
}

/* ponytail: font/size pickers hidden for a quieter Evernote-style bar; the stored
   font settings still apply via CSS vars. Unhide here to bring the pickers back. */
.note-style-controls .note-style-select {
  display: none;
}

.note-style-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  overflow: visible;
}

.note-style-select {
  height: 34px;
  max-width: 150px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: 13px/1.2 var(--app-font-family);
}

.note-style-size-select {
  width: 58px;
}

.note-color-control {
  position: relative;
  width: 36px;
  height: 34px;
  flex: 0 0 36px;
}

.note-color-control > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 34px;
  list-style: none;
  cursor: pointer;
}

.note-color-control > summary::-webkit-details-marker {
  display: none;
}

.note-color-control > summary::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 1px solid #d8dee7;
  border-radius: 50%;
  background: conic-gradient(#e53935, #fb8c00, #fdd835, #43a047, #1e88e5, #8e24aa, #e53935);
  box-shadow: inset 0 0 0 3px #fff;
}

.note-color-control > summary::after {
  content: "";
  width: 0;
  height: 0;
  margin-left: 4px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #5f6b7a;
}

.note-color-panel {
  position: absolute;
  z-index: 20;
  top: 34px;
  left: 0;
  box-sizing: border-box;
  width: min(230px, calc(100vw - 16px));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 24px rgb(15 23 42 / 18%);
}

.note-color-custom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--text);
  font: 13px/1.2 var(--app-font-family);
  cursor: pointer;
}

.note-color-input {
  width: 28px;
  height: 28px;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0;
  background: #fff;
  cursor: pointer;
}

.note-color-presets {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 4px;
}

.note-color-preset {
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgb(15 23 42 / 10%);
  border-radius: 3px;
  cursor: pointer;
  transform: none;
}

.note-color-preset.is-default {
  background: linear-gradient(to bottom right, #fff 47%, #3b82f6 48%, #3b82f6 52%, #fff 53%);
}

.note-color-preset:hover,
.note-color-preset:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  transform: none;
}

.vditor-note-editor .vditor-toolbar__item {
  position: relative;
  overflow: visible;
  display: flex !important;
  align-items: center;
  flex: 0 0 auto;
  float: none !important;
  margin: 0 !important;
}

.vditor-note-editor .vditor-toolbar__item .vditor-tooltipped {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  margin: 0 !important;
  width: 32px;
  height: 30px;
  min-height: 0;
  padding: 0 8px;
  color: var(--muted);
  transform: none;
}

.vditor-note-editor .vditor-toolbar__item .vditor-tooltipped:hover,
.vditor-note-editor .vditor-toolbar__item .vditor-tooltipped:focus-visible {
  border-radius: 6px;
  background: #edeffb;
  color: var(--text-strong);
  box-shadow: none;
  transform: none;
}

.vditor-note-editor .vditor-toolbar__item svg {
  width: 16px;
  height: 16px;
}

.vditor-note-editor .vditor-toolbar__item .vditor-tooltipped:has(.mindmap-toolbar-label) {
  width: auto;
  padding: 0 10px;
  box-shadow: none;
}

.vditor-note-editor .vditor-toolbar__item .vditor-tooltipped:has(.mindmap-toolbar-label)::before,
.vditor-note-editor .vditor-toolbar__item .vditor-tooltipped:has(.mindmap-toolbar-label)::after {
  display: none !important;
}

.mindmap-toolbar-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font: 500 calc(var(--font-scale, 1) * 14px) / 1 var(--app-font-family);
  white-space: nowrap;
}

.vditor-note-editor .vditor-toolbar__divider {
  flex: 0 0 auto;
  float: none !important;
  height: 22px;
  margin: 0 3px;
  border-left-color: var(--line);
}

.vditor-note-editor .vditor-toolbar__br {
  display: none !important;
}

.vditor-note-editor .vditor-content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

.vditor-note-editor .vditor-wysiwyg {
  box-sizing: border-box;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  max-width: none !important;
  margin: 0 !important;
  min-height: 0;
  overflow: auto;
  padding: 0;
  text-align: left;
  font-family: var(--note-editor-font-family, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  font-size: var(--note-editor-font-size, 16px);
  background: #fff !important;
  color: var(--textarea-text-color, #24292e);
}

/* Evernote-style measure: cap the writing column and center it (Vditor writes inline
   padding and this rule already fought it with !important, so the measure lives here). */
.vditor-note-editor .vditor-wysiwyg pre.vditor-reset {
  width: 100%;
  margin: 0 !important;
  min-height: 100%;
  padding: 24px 40px 96px !important;
  text-align: left;
  line-height: 1.85;
  font-family: var(--note-editor-font-family, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  font-size: var(--note-editor-font-size, 16px);
  background: #fff !important;
  color: var(--textarea-text-color, #24292e) !important;
}

.vditor-note-editor .vditor-wysiwyg .vditor-reset,
.vditor-note-editor .vditor-wysiwyg p,
.vditor-note-editor .vditor-wysiwyg li,
.vditor-note-editor .vditor-wysiwyg h1,
.vditor-note-editor .vditor-wysiwyg h2,
.vditor-note-editor .vditor-wysiwyg h3,
.vditor-note-editor .vditor-wysiwyg h4,
.vditor-note-editor .vditor-wysiwyg h5,
.vditor-note-editor .vditor-wysiwyg h6 {
  font-family: inherit;
  color: var(--textarea-text-color, #24292e);
}

.vditor-note-editor .vditor-wysiwyg p {
  margin-top: 0;
  margin-bottom: 8px;
}

.vditor-note-editor .vditor-wysiwyg blockquote,
.vditor-note-editor .vditor-wysiwyg blockquote * {
  color: var(--note-editor-muted, #6a737d);
}

.vditor-note-editor .vditor-wysiwyg a,
.vditor-note-editor .vditor-wysiwyg span[data-type="a"],
.vditor-note-editor .vditor-wysiwyg span[data-type="link-ref"],
.vditor-note-editor .vditor-wysiwyg blockquote a,
.vditor-note-editor .vditor-wysiwyg blockquote span[data-type="a"],
.vditor-note-editor .vditor-wysiwyg blockquote span[data-type="link-ref"] {
  color: #5566d8;
  text-decoration: none;
}

.vditor-note-editor .vditor-wysiwyg ul,
.vditor-note-editor .vditor-wysiwyg ol {
  margin-top: 0;
  margin-bottom: 8px;
}

.vditor-note-editor .vditor-wysiwyg li + li {
  margin-top: 0.25em;
}

.vditor-note-editor .vditor-wysiwyg li p {
  margin-top: 6px;
  margin-bottom: 6px;
}

.vditor-note-editor .vditor-wysiwyg > .vditor-reset > h1::before,
.vditor-note-editor .vditor-wysiwyg > .vditor-reset > h2::before,
.vditor-note-editor .vditor-wysiwyg > .vditor-reset > h3::before,
.vditor-note-editor .vditor-wysiwyg > .vditor-reset > h4::before,
.vditor-note-editor .vditor-wysiwyg > .vditor-reset > h5::before,
.vditor-note-editor .vditor-wysiwyg > .vditor-reset > h6::before {
  content: none;
}

.vditor-note-editor .vditor-task {
  list-style: none !important;
}

.vditor-note-editor .vditor-task:has(input[type="checkbox"]:checked) {
  text-decoration: line-through;
}

.vditor-note-editor .vditor-task input[type="checkbox"] {
  display: inline-block;
  width: 14px;
  min-width: 14px;
  height: 14px;
  min-height: 14px;
  margin: 0 6px 2px -22px;
  padding: 0;
  vertical-align: middle;
}

.vditor-note-editor .vditor-task:has(> a[href^="#priority-"]) {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 4px 2px;
  border-bottom: 1px solid var(--line-soft);
}

.vditor-note-editor .vditor-task:has(> a[href^="#priority-"]) > input[type="checkbox"] {
  flex: 0 0 auto;
  margin: 0 2px 0 0;
}

.vditor-note-editor .vditor-task > a[href^="#priority-"],
.vditor-note-editor .vditor-task > a[href^="#due-"] {
  flex: 0 0 auto;
  border-radius: 5px;
  text-decoration: none;
}

.vditor-note-editor .vditor-task > a[href^="#priority-"] {
  min-width: 34px;
  margin-left: auto;
  padding: 2px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.vditor-note-editor .vditor-task > a[href="#priority-high"] {
  background: #fdecec;
  color: #ef4444;
}

.vditor-note-editor .vditor-task > a[href="#priority-medium"] {
  background: #fff1e6;
  color: #f97316;
}

.vditor-note-editor .vditor-task > a[href="#priority-low"] {
  background: #eaf8ee;
  color: #22a447;
}

.vditor-note-editor .vditor-task > a[href^="#due-"] {
  min-width: 76px;
  color: var(--muted);
  text-align: right;
  font-size: 13px;
}

.vditor-note-editor button:is([data-type="up"], [data-type="down"], [data-type="remove"]) {
  display: none;
}

.vditor-note-editor .vditor-wysiwyg div.vditor-wysiwyg__block::before,
.vditor-note-editor .vditor-wysiwyg div[data-type="link-ref-defs-block"]::before,
.vditor-note-editor .vditor-wysiwyg div[data-type="footnotes-block"]::before {
  display: none;
}

.vditor-note-editor .vditor-wysiwyg img {
  box-sizing: border-box;
  max-width: 100%;
  height: auto;
  border: 1px solid #111827;
  border-radius: 2px;
  cursor: default;
}

.vditor-note-editor .vditor-wysiwyg img.note-resizable-image {
  border-color: #5566d8;
}

.note-image-resize-handle {
  appearance: none;
  position: absolute;
  z-index: 20;
  display: block;
  width: 12px;
  min-width: 12px;
  height: 12px;
  min-height: 12px;
  padding: 0;
  border: 1px solid #fff;
  border-radius: 2px;
  background: #5566d8;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
  cursor: nwse-resize;
  line-height: 0;
}

.vditor-note-editor .vditor-panel:has(button[aria-label*="Remove"]) {
  display: none !important;
}

.notes-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  color: var(--muted);
  min-height: 360px;
  text-align: center;
  font-size: calc(var(--font-scale, 1) * 14px);
}

.notes-placeholder::before {
  content: "";
  width: 120px;
  height: 104px;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 104'%3E%3Ccircle cx='60' cy='52' r='48' fill='%23f3f4fb'/%3E%3Cg transform='rotate(-8 48 46)'%3E%3Crect x='26' y='24' width='44' height='44' rx='9' fill='%23cdd3f5'/%3E%3Crect x='34' y='36' width='24' height='3' rx='1.5' fill='%23fff'/%3E%3Crect x='34' y='44' width='18' height='3' rx='1.5' fill='%23fff'/%3E%3C/g%3E%3Cg transform='rotate(6 72 56)'%3E%3Crect x='48' y='30' width='48' height='48' rx='9' fill='%23fff' stroke='%233d4356' stroke-width='2.5'/%3E%3Crect x='57' y='42' width='28' height='3' rx='1.5' fill='%233d4356'/%3E%3Crect x='57' y='50' width='22' height='3' rx='1.5' fill='%233d4356'/%3E%3Crect x='57' y='58' width='16' height='3' rx='1.5' fill='%233d4356'/%3E%3C/g%3E%3Cg transform='rotate(14 88 76)'%3E%3Crect x='76' y='62' width='24' height='24' rx='6' fill='%23b7e3c8'/%3E%3Crect x='81' y='69' width='13' height='2.5' rx='1.25' fill='%23fff'/%3E%3Crect x='81' y='75' width='10' height='2.5' rx='1.25' fill='%23fff'/%3E%3C/g%3E%3C/svg%3E");
}

.notes-placeholder.error {
  color: var(--danger);
}

.notes-placeholder.error::before {
  display: none;
}

.note-image-wrap {
  min-height: 360px;
  display: grid;
  place-items: start center;
}

.note-image-wrap img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.notes-content.pdf-viewer-wrap {
  padding: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.pdf-viewer {
  position: relative;
  height: 100%;
  min-height: 0;
  background: #2f3339;
  display: flex;
  flex-direction: column;
}

.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  color: #fff;
  background: #3c3c3c;
  font-size: calc(var(--font-scale, 1) * 13px);
  flex: 0 0 auto;
}

.pdf-toolbar-button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 4px;
  color: #fff;
  background: transparent;
  font-size: calc(var(--font-scale, 1) * 18px);
  line-height: 1;
  cursor: pointer;
}

.pdf-toolbar-button:hover {
  background: rgb(255 255 255 / 12%);
}

.pdf-page-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 26px;
}

.pdf-page-display,
.pdf-page-input {
  width: 100%;
  height: 26px;
  border: 0;
  border-radius: 2px;
  color: #fff;
  background: #1f1f1f;
  text-align: center;
  font: inherit;
}

.pdf-page-display {
  cursor: pointer;
}

.pdf-page-input {
  padding: 0 4px;
  outline: 1px solid rgb(255 255 255 / 22%);
}

.pdf-page-total,
.pdf-zoom-label {
  color: #fff;
  white-space: nowrap;
}

.pdf-zoom-label {
  min-width: 44px;
  text-align: center;
}

.pdf-toolbar-separator {
  width: 1px;
  height: 24px;
  background: rgb(255 255 255 / 24%);
}

.pdf-toolbar-spacer {
  flex: 1;
}

.pdf-scroll {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 18px 0 28px;
}

.pdf-page {
  margin: 0 auto 14px;
  background: #fff;
  box-shadow: 0 2px 10px rgb(0 0 0 / 25%);
}

.pdf-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.pdf-loading {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--muted);
  background: var(--surface);
  font-size: calc(var(--font-scale, 1) * 14px);
}

.pdf-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: pdf-spin 0.8s linear infinite;
}

@keyframes pdf-spin {
  to {
    transform: rotate(360deg);
  }
}

.markdown-body {
  max-width: 900px;
  font-size: calc(var(--font-scale, 1) * 16px);
  line-height: 1.75;
  font-family: inherit;
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 28px 0 12px;
  line-height: 1.3;
}

.markdown-body h2 {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
  font-size: calc(var(--font-scale, 1) * 24px);
}

.markdown-body h3 {
  font-size: calc(var(--font-scale, 1) * 20px);
}

.markdown-body h4 {
  font-size: calc(var(--font-scale, 1) * 17px);
}

.markdown-body p,
.markdown-body ul,
.markdown-body pre {
  margin: 0 0 16px;
}

.markdown-body code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.markdown-body .note-pre {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.file-table th:nth-child(1),
.file-table td:nth-child(1) {
  width: 46%;
}

.file-table th:nth-child(2),
.file-table td:nth-child(2) {
  width: 24%;
}

.file-table th:nth-child(3),
.file-table td:nth-child(3) {
  width: 120px;
}

.file-table th:nth-child(4),
.file-table td:nth-child(4) {
  width: 180px;
}

.file-table th:nth-child(5),
.file-table td:nth-child(5) {
  width: 130px;
}

.log-table {
  min-width: 1120px;
}

.log-table th:nth-child(1),
.log-table td:nth-child(1) {
  width: 170px;
}

.log-table th:nth-child(2),
.log-table td:nth-child(2) {
  width: 160px;
}

.log-table th:nth-child(3),
.log-table td:nth-child(3) {
  width: 90px;
}

.log-table th:nth-child(4),
.log-table td:nth-child(4) {
  width: 210px;
}

.log-table th:nth-child(5),
.log-table td:nth-child(5) {
  width: 130px;
}

.log-detail {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: calc(var(--font-scale, 1) * 13px);
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: nowrap;
}

.status-ok {
  color: var(--primary-strong);
  font-weight: 700;
}

.status-fail {
  color: var(--danger);
  font-weight: 700;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding: 24px 0;
  }

  .wide-shell {
    width: 100%;
    height: 100dvh;
    padding: 0;
  }

  .auth-panel {
    margin-top: 6vh;
    padding: 20px;
  }

  .code-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
  }

  .code-messages,
  .code-form {
    grid-column: 1;
  }

  .file-view {
    grid-template-columns: 1fr;
    grid-template-rows: 48px 54px minmax(0, 1fr);
  }

  .file-view.files-view {
    grid-template-rows: 48px 40px minmax(0, 1fr);
  }

  .file-view.notes-view,
  .file-view.bare-view {
    grid-template-rows: 48px minmax(0, 1fr);
  }

  /* Narrow screens keep the rail as a normal top row, so no floating and no collapsing. */
  .topbar {
    position: static;
    transform: none;
    grid-column: 1;
    grid-row: 1;
    width: auto;
    flex-direction: row;
    min-height: 48px;
    padding: 0 4px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow-x: auto;
  }

  .rail-toggle,
  .file-view.rail-collapsed .rail-toggle {
    display: none;
  }

  .file-view.rail-collapsed .top-actions {
    display: flex;
  }

  .top-actions {
    flex-wrap: nowrap;
    flex-direction: row;
    gap: 0;
  }

  #settingsBtn {
    margin-top: 0;
  }

  .top-actions > .workspace-status {
    display: none;
  }

  .workspace-context .crumbs,
  .workspace-status {
    display: none;
  }

  .file-view.files-view .workspace-context .crumbs {
    display: none;
  }

  .workspace-search {
    width: auto;
    flex: 1 1 auto;
  }

  .view-panel,
  .notes-panel {
    grid-column: 1;
    grid-row: 3;
  }

  .file-view.notes-view .notes-panel,
  .file-view.bare-view .view-panel {
    grid-row: 2;
  }

  #logPanel {
    grid-template-rows: minmax(330px, 52%) minmax(0, 1fr);
  }

  .log-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .log-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .settings-overlay {
    place-items: end stretch;
    padding: 18px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button,
  .upload-button {
    flex: 1;
  }

  .top-actions button.secondary {
    flex: 1 1 0;
    min-height: 48px;
    font-size: 0;
  }

  .top-actions button.settings-button {
    flex: 1 1 0;
    min-height: 48px;
  }

  .top-actions button.secondary:not(.settings-button)::before {
    width: 22px;
    height: 22px;
  }

  .upload-bar {
    height: 52px;
    gap: 6px;
    padding: 6px 8px;
    overflow-x: auto;
  }

  .upload-bar > button {
    flex: 0 0 auto;
  }

  .file-search {
    display: none;
  }

  #filePanel .file-table {
    min-width: 0;
  }

  #filePanel .file-table th:nth-child(1),
  #filePanel .file-table td:nth-child(1) {
    width: auto;
  }

  #filePanel {
    grid-template-columns: 1fr;
  }

  .file-details {
    position: fixed;
    z-index: 30;
    top: 102px;
    right: 0;
    bottom: 0;
    width: min(360px, 100%);
    border-left: 1px solid var(--line);
    box-shadow: -18px 0 42px rgba(90, 105, 170, 0.18);
  }

  .file-details:has(.file-details-content.hidden) {
    display: none;
  }

  .file-pagination,
  .pagination-controls {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .file-stats {
    display: none;
  }

  .action-buttons {
    opacity: 1;
  }

  .file-table th:nth-child(3),
  .file-table th:nth-child(4),
  .file-table th:nth-child(2),
  .file-table td:nth-child(3),
  .file-table td:nth-child(4),
  .file-table td:nth-child(2),
  .log-table th:nth-child(4),
  .log-table td:nth-child(4),
  .log-table th:nth-child(5),
  .log-table td:nth-child(5) {
    display: none;
  }

  /* One pane at a time, like a phone notes app: full-screen list; opening a note
     adds sidebar-collapsed, which swaps in a full-screen reader (☰ goes back). */
  .notes-panel {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
  }

  .notes-panel:not(.sidebar-collapsed) .notes-reader {
    display: none;
  }

  /* Full-screen panes on phones: the floating-card chrome comes off. */
  .notes-reader {
    margin: 0;
    border-radius: 0;
    box-shadow: none !important;
  }

  .notes-reader-head {
    padding: 8px 14px;
  }

  .notes-sidebar-head {
    padding: 14px 14px 6px;
  }

  .notes-tree {
    font-size: calc(var(--font-scale, 1) * 15px);
  }

  .notes-tree-row {
    min-height: 44px;
  }

  .notes-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    margin-right: 10px;
    min-height: 0;
    height: 30px;
    padding: 0 10px;
  }

  .notes-panel.sidebar-collapsed .notes-sidebar {
    display: none;
  }

  .notes-resize-handle {
    display: none;
  }

  .notes-content {
    padding: 18px;
  }

  .notes-content.vditor-editor-wrap {
    padding: 0;
  }

  .notes-content.pdf-viewer-wrap {
    min-height: 0;
  }

  .pdf-viewer {
    min-height: 0;
  }

  .pdf-scroll {
    padding: 10px 0 18px;
  }

  .vditor-note-editor .vditor-wysiwyg {
    padding: 0;
  }

  .vditor-note-editor .vditor-wysiwyg pre.vditor-reset {
    padding: 18px !important;
  }

  .vditor-note-editor .vditor-toolbar {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 8px !important;
  }

  .vditor-note-editor .vditor-toolbar__item .vditor-tooltipped {
    height: 42px;
  }

  .code-history {
    grid-column: 1;
    grid-row: 4;
    display: flex;
    align-items: center;
    gap: 8px;
    max-height: none;
    padding: 6px 8px;
    overflow-x: auto;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .code-history-list {
    flex: 1 0 auto;
    flex-direction: row;
    margin-top: 0;
  }

  .code-history-list button {
    width: 140px;
    min-height: 36px;
  }

  .notes-reader-head {
    align-items: flex-start;
  }

  .notes-reader-title {
    flex-wrap: wrap;
    gap: 4px 10px;
  }
}

.notes-content.mindmap-wrap {
  overflow: hidden;
}

.mindmap-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.mindmap-canvas {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--panel);
}

.mindmap-plane {
  position: relative;
  min-width: 100%;
  min-height: 100%;
}

.mindmap-links {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.mindmap-links path {
  fill: none;
  stroke: var(--line);
  stroke-width: 2;
}

.mindmap-node {
  position: absolute;
  width: max-content;
  max-width: 260px;
  min-width: 48px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-alt);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  outline: none;
  cursor: text;
}

.mindmap-node:empty::before {
  content: '\200b';
}

.mindmap-node:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.mindmap-node.mindmap-root {
  background: var(--primary);
  border-color: var(--primary-strong);
  color: #fff;
  font-weight: 600;
  cursor: default;
}

.mindmap-toggle {
  position: absolute;
  z-index: 1;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid var(--primary);
  border-radius: 50%;
  background: var(--panel);
  color: var(--primary);
  font-size: 10px;
  line-height: 13px;
  text-align: center;
  cursor: pointer;
}

.mindmap-toggle.collapsed {
  background: var(--primary);
  color: #fff;
}

.mindmap-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
}

.mindmap-hint .secondary {
  padding: 3px 10px;
  font-size: 12px;
}

.mindmap-node.mindmap-root.mindmap-root-editable {
  cursor: text;
}

/* Below the shared dialog overlay (1000) so the delete-node confirm stacks above the modal. */
.mindmap-modal {
  z-index: 990;
}

.mindmap-modal-card {
  display: flex;
  flex-direction: column;
  width: min(960px, 100%);
  height: min(680px, 100%);
  min-height: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
  padding: 16px 20px 20px;
}

.mindmap-modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.mindmap-modal-body .mindmap-editor {
  height: 100%;
}

.vditor-reset img[alt='mindmap'] {
  max-width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.vditor-reset img[alt='mindmap']:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

#rssPanel {
  position: relative;
  grid-template-columns: var(--rss-rail-width, 260px) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.rss-rail {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--panel-alt);
}

.rss-rail-resize {
  position: absolute;
  top: 0;
  right: -3px;
  bottom: 0;
  z-index: 8;
  width: 8px;
  cursor: col-resize;
}

.rss-rail-resize:hover,
.rss-rail-resize:focus-visible {
  background: var(--primary-soft);
}

#rssPanel.resizing {
  user-select: none;
}

.rss-rail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
}

.rss-rail-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  box-shadow: none;
  color: var(--text);
  text-align: left;
  transform: none;
}

.rss-rail-item:hover {
  background: var(--surface-hover);
  box-shadow: none;
  color: var(--text-strong);
}

.rss-rail-item.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 650;
}

.rss-rail-folder {
  font-weight: 650;
  color: var(--text-strong);
}

.rss-rail-item.dragging {
  opacity: 0.45;
}

.rss-rail-item.drop-target,
.rss-rail-section.drop-target {
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 2px var(--primary);
  color: var(--primary-strong);
}

.rss-rail-section.drop-target {
  border-radius: var(--radius-sm);
}

.rss-rail-sub {
  padding-left: 26px;
}

.rss-rail-icon {
  flex: 0 0 auto;
}

.rss-rail-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.rss-rail-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rss-rail-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 12px);
  font-weight: 550;
}

.rss-rail-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 10px 6px;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 11px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rss-rail-options {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  transform: none;
}

.rss-rail-options:hover {
  background: var(--surface-hover);
  box-shadow: none;
  color: var(--text-strong);
}

/* The section header is uppercase micro-type; the menu is normal UI text again. */
.rss-feeds-menu {
  width: 186px;
  font-size: calc(var(--font-scale, 1) * 13px);
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
}

.rss-rail-options .rss-svg-icon {
  width: 15px;
  height: 15px;
}

.rss-feeds-menu .rss-menu-title {
  padding: 4px 10px;
  font-size: calc(var(--font-scale, 1) * 12px);
}

.rss-feeds-menu .rss-menu-title ~ .rss-menu-title {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

.rss-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 10px 0;
}

.rss-add-form input {
  flex: 1 1 100%;
  min-width: 0;
}

.rss-add-form select {
  flex: 1;
  min-width: 0;
  min-height: 36px;
}

.rss-add-actions {
  display: flex;
  gap: 8px;
  margin: 10px;
}

.rss-add-folder,
.rss-add-content {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 650;
}

.rss-add-content {
  background: var(--primary);
  color: #fff;
}

.rss-add-content:hover {
  background: var(--primary-strong);
  color: #fff;
}

/* Outlined pill: the rail background is already tinted, so a filled grey button
   reads as plain text — the border is what makes it look pressable. */
.rss-add-folder {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.rss-add-folder:hover {
  border-color: #b9c1f0;
  background: var(--panel);
  color: var(--primary-strong);
  box-shadow: var(--shadow-sm);
}

.rss-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
}

.rss-list-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.rss-column {
  width: 100%;
  padding: 0 70px 0 40px;
}

.rss-main-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 26px 0 10px;
  border-bottom: 2px solid var(--line);
}

.rss-main-head h2 {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text-strong);
  font-size: calc(var(--font-scale, 1) * 22px);
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rss-unread-label {
  flex: 1;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 12.5px);
}

.rss-main-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rss-head-select {
  min-height: 34px;
  max-width: 150px;
  font-size: calc(var(--font-scale, 1) * 12.5px);
}

.rss-menu-wrap {
  position: relative;
  display: flex;
}

/* Shared stroke styling: glyphs like ✓ and ↻ vary by font and render inconsistently. */
.rss-svg-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rss-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 25;
  display: grid;
  gap: 2px;
  width: 210px;
  padding: 6px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
}

.rss-menu-title {
  padding: 6px 10px 8px;
  color: var(--text-strong);
  font-size: calc(var(--font-scale, 1) * 14px);
  font-weight: 700;
}

.rss-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  box-shadow: none;
  color: var(--text);
  justify-content: flex-start;
  transform: none;
}

.rss-menu-item:hover {
  background: var(--surface-hover);
  box-shadow: none;
  color: var(--text-strong);
}

.rss-menu-mark {
  flex: 0 0 17px;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 12px);
  font-weight: 650;
  text-align: center;
}

.rss-icon-btn {
  position: relative;
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: calc(var(--font-scale, 1) * 15px);
}

/* Instant hover hint; the native title tooltip waits ~1s and can't be styled.
   Right-aligned because these buttons sit against the panel edge. */
.rss-icon-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--text-strong);
  color: #fff;
  font-size: calc(var(--font-scale, 1) * 12px);
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.rss-icon-btn[data-tooltip]:hover::after,
.rss-icon-btn[data-tooltip]:focus-visible::after {
  opacity: 1;
}

.rss-magazine {
  display: flex;
  flex-direction: column;
  padding-bottom: 48px;
}

.rss-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 0;
  padding: 5px 2px;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
  transform: none;
}

.rss-card:hover {
  background: var(--surface-hover);
  box-shadow: none;
}

/* The row the reader popup is showing — the anchor ← / → move from. */
.rss-card.active {
  background: var(--primary-soft);
}

.rss-card-line {
  flex: 1;
  min-width: 0;
  /* Fixed line box so emoji or mixed-script glyphs can't stretch individual rows. */
  height: 24px;
  overflow: hidden;
  line-height: 24px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rss-card-title {
  margin-right: 10px;
  color: var(--text-strong);
  font-size: calc(var(--font-scale, 1) * 14px);
  font-weight: 700;
}

.rss-card.read .rss-card-title {
  color: var(--muted);
  font-weight: 500;
}

.rss-card-snippet {
  margin-right: 10px;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 13px);
  font-weight: 400;
}

.rss-card-source {
  flex: 0 0 140px;
  width: 140px;
  overflow: hidden;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 12.5px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rss-card-age {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 12px);
}

.rss-reader-backdrop {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: rgba(35, 40, 58, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.rss-load-more {
  align-self: center;
  margin: 16px 0;
  min-height: 34px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 12.5px);
  box-shadow: none;
}

.rss-load-more:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
  box-shadow: none;
}

.rss-reader-view {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  width: min(860px, 82%);
  min-height: 0;
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  transform: translateX(103%);
  transition: transform 0.25s ease;
}

/* The popup takes focus so ← / → reach it; the UA focus ring around the whole
   panel is just noise while paging, and the open row already shows the anchor. */
.rss-reader-view:focus,
.rss-reader-view:focus-visible {
  outline: none;
}

#rssPanel.reader-open .rss-reader-backdrop {
  opacity: 1;
  pointer-events: auto;
}

#rssPanel.reader-open .rss-reader-view {
  transform: none;
}

.rss-reader-resize {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -3px;
  z-index: 7;
  width: 8px;
  cursor: col-resize;
}

.rss-reader-resize:hover,
.rss-reader-resize:focus-visible {
  background: var(--primary-soft);
}

.rss-reader-view.resizing {
  transition: none;
}

/* The iframe swallows pointermove during a drag; disable it while resizing. */
.rss-reader-view.resizing .rss-reader-frame {
  pointer-events: none;
}

.rss-reader-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.rss-reader-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

#rssReaderFullBtn {
  min-height: 30px;
  padding: 0 12px;
  font-size: calc(var(--font-scale, 1) * 12.5px);
}

.rss-visit-btn {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: calc(var(--font-scale, 1) * 13px);
  font-weight: 650;
  text-decoration: none;
}

.rss-visit-btn:hover {
  background: var(--primary-strong);
}

.rss-reader-head {
  padding-top: 18px;
  padding-bottom: 10px;
}

.rss-reader-head h2 {
  margin: 0 0 6px;
  color: var(--text-strong);
  font-size: calc(var(--font-scale, 1) * 21px);
  line-height: 1.35;
}

.rss-reader-meta {
  margin: 0;
  color: var(--muted);
  font-size: calc(var(--font-scale, 1) * 12.5px);
}

.rss-reader-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: var(--panel);
}

/* PDF articles bypass the sandboxed iframe; pdf.js draws them here (shares .pdf-* styles). */
.rss-reader-pdf {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
}

@media (max-width: 900px) {
  #rssPanel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .rss-rail-resize {
    display: none;
  }

  .rss-rail {
    flex-direction: row;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .rss-rail-scroll {
    display: flex;
    gap: 4px;
    padding: 8px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .rss-rail-section {
    margin: 0 4px;
  }

  #rssFeedList {
    display: flex;
    gap: 4px;
  }

  .rss-rail-item {
    width: auto;
    white-space: nowrap;
  }

  .rss-rail-sub {
    padding-left: 10px;
  }

  .rss-add-form {
    padding: 8px;
  }

  .rss-add-actions {
    flex: 0 0 auto;
    margin: 8px;
  }

  .rss-add-folder,
  .rss-add-content {
    min-height: 34px;
    padding: 0 12px;
  }

  .rss-reader-view {
    width: 100%;
  }
}
