:root {
  --color-background: #f8fafc;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-secondary: #7c3aed;
  --color-accent: #f59e0b;
  --color-text-primary: #0f172a;
  --color-text-secondary: #475569;
  --color-divider: #e2e8f0;
  --color-success: #0f9d58;
  --color-danger: #d93025;
  --color-highlight: #0f172a;
  --color-muted-background: #e2e8f0;

  --font-sans: "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
}

.theme-light {
  --color-background: #f8fafc;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-secondary: #7c3aed;
  --color-accent: #f59e0b;
  --color-text-primary: #0f172a;
  --color-text-secondary: #475569;
  --color-divider: #e2e8f0;
  --color-success: #0f9d58;
  --color-danger: #d93025;
  --color-highlight: #0f172a;
  --color-muted-background: #e2e8f0;
}

.theme-dark {
  --color-background: #0f172a;
  --color-surface: #111827;
  --color-primary: #38bdf8;
  --color-secondary: #a855f7;
  --color-accent: #f59e0b;
  --color-text-primary: #e2e8f0;
  --color-text-secondary: #94a3b8;
  --color-divider: #1e293b;
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-highlight: #f8fafc;
  --color-muted-background: #1e293b;
}

html,
body {
  background-color: var(--color-background);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  margin: 0;
  padding: 0;
  min-height: 100%;
}

.hidden {
  display: none !important;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: underline;
}

.agora-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.08), transparent 60%),
              var(--color-background);
}

.agora-nav {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1.25rem;
  padding: 1.5rem 2rem;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.16), transparent), var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
}

.theme-toggle {
  position: relative;
  width: 48px;
  height: 26px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  margin-left: auto;
}

.theme-toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  transition: background 0.3s ease;
}

.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-surface);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.3);
  transition: transform 0.3s ease, background 0.3s ease;
}

.theme-toggle[data-theme="dark"] .theme-toggle-track {
  background: rgba(56, 189, 248, 0.35);
}

.theme-toggle[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(20px);
  background: var(--color-primary);
}

.viewer-theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 1000;
}

.agora-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.agora-logo-mark {
  height: 2.25rem;
  width: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: var(--color-highlight);
  font-weight: 700;
}

.agora-nav-links {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  font-size: 0.95rem;
}

.agora-nav-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--color-divider);
  background: rgba(148, 163, 184, 0.08);
  color: var(--color-text-primary);
  font-weight: 500;
  transition: all 0.2s ease;
}

.agora-nav-action:hover {
  border-color: var(--color-primary);
  color: var(--color-highlight);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
}

 .agora-main {
  display: flex;
  flex-direction: column;
  gap: clamp(2rem, 4vw, 3rem);
  padding: clamp(1.5rem, 4vw, 3rem);
}

.agora-content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: clamp(1.5rem, 3vw, 2.5rem);
}

.agora-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 1.25rem;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: clamp(1.25rem, 2vw, 1.75rem);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.agora-panel:hover {
  box-shadow: 0 22px 45px rgba(15, 23, 42, 0.12);
  border-color: rgba(37, 99, 235, 0.22);
}

.account-dashboard {
  display: flex;
  flex-direction: column;
  gap: clamp(1.5rem, 3vw, 2.5rem);
}

.account-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: clamp(1.25rem, 3vw, 2rem);
  align-items: center;
  padding: clamp(1.35rem, 3vw, 1.9rem);
  border-radius: 1.25rem;
  background: linear-gradient(130deg, rgba(37, 99, 235, 0.1), rgba(124, 58, 237, 0.12));
  border: 1px solid rgba(37, 99, 235, 0.22);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
  position: relative;
  overflow: hidden;
}

.account-header::after {
  content: "";
  position: absolute;
  inset: auto -20% -60% auto;
  width: clamp(200px, 38vw, 320px);
  height: clamp(200px, 38vw, 360px);
  background: radial-gradient(circle, rgba(37, 99, 235, 0.2), transparent 70%);
  filter: blur(60px);
  opacity: 0.6;
  pointer-events: none;
}

.account-header-info {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2vw, 1.6rem);
  min-width: 0;
}

.account-header-info h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.6rem);
}

.account-header-info p {
  margin: 0.3rem 0 0;
  font-size: 0.95rem;
}

.account-avatar {
  width: clamp(3.1rem, 3vw + 2rem, 3.75rem);
  height: clamp(3.1rem, 3vw + 2rem, 3.75rem);
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 1.25rem;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: var(--color-highlight);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.36);
}

.account-header-meta {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.account-header-meta .label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.account-header-meta .value {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.account-header-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.account-papers {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.account-papers-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  align-items: center;
  text-align: center;
}

.account-papers-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: min(100%, 480px);
  position: relative;
}

.account-papers-controls::before {
  content: "\1F50D";
  position: absolute;
  left: 1rem;
  font-size: 0.95rem;
  opacity: 0.55;
  pointer-events: none;
}

.account-papers-controls input[type="search"] {
  width: 100%;
  border-radius: 0.85rem;
  border: 1px solid var(--color-divider);
  background: var(--color-surface);
  padding: 0.65rem 0.85rem 0.65rem 2.4rem;
  font-size: 0.95rem;
  color: var(--color-text-primary);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.account-papers-controls input[type="search"]:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.4);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.account-papers-list {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.account-paper-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 1rem;
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.account-paper-card.is-active {
  border-color: rgba(37, 99, 235, 0.4);
  box-shadow: 0 18px 40px rgba(37, 99, 235, 0.18);
}

.account-paper-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.account-paper-card__meta .meta-item + .meta-item::before {
  content: "•";
  margin: 0 0.35rem;
  opacity: 0.5;
}

.account-paper-card__actions {
  display: flex;
  justify-content: flex-end;
}

.account-paper-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.12);
}

.account-editor-info {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.account-editor-info__card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 1.1rem;
  padding: clamp(1.25rem, 2.5vw, 1.75rem);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.1);
  color: var(--color-text-secondary);
  line-height: 1.6;
}

@media (max-width: 992px) {
  .account-header {
    grid-template-columns: minmax(0, 1fr);
    text-align: left;
  }

  .account-header-actions,
  .account-header-meta {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .account-papers-list {
    grid-template-columns: 1fr;
  }

  .account-papers-controls::before {
    left: 0.85rem;
  }
}

.agora-panel-title {
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.auth-panel {
  max-width: 420px;
  margin: 0 auto;
  text-align: left;
}

.auth-panel .form-status {
  text-align: center;
  min-height: 1.2rem;
}

.auth-panel .hub-muted {
  text-align: center;
  color: var(--color-text-secondary);
}

.agora-panel-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.agora-highlight-card {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 1rem;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  color: var(--color-highlight);
}

.agora-highlight-title {
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 600;
}

.agora-highlight-subtitle {
  max-width: 38rem;
  color: var(--color-text-secondary);
  font-size: 1rem;
}

.agora-grid {
  display: grid;
  gap: 1.5rem;
}

.agora-grid.two-column {
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
}

.agora-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 1rem;
  padding: 1.35rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
}

.agora-card:hover {
  transform: translateY(-4px);
  border-color: rgba(37, 99, 235, 0.24);
  box-shadow: 0 20px 36px rgba(15, 23, 42, 0.12);
}

.agora-card-badge {
  align-self: flex-start;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--color-text-secondary);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.agora-card-title {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--color-highlight);
}

.agora-card-text {
  color: var(--color-text-secondary);
  line-height: 1.6;
  font-size: 0.95rem;
}

.agora-footer {
  padding: 1.5rem 3rem;
  border-top: 1px solid var(--color-divider);
  color: var(--color-text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.agora-footer-links {
  display: flex;
  gap: 1.5rem;
}

.agora-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-highlight);
  font-size: 0.8rem;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.agora-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.agora-status.success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--color-success);
}

.agora-status.danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--color-danger);
}

.agora-muted {
  color: var(--color-text-secondary);
}

.agora-divider {
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(148, 163, 184, 0.25),
    transparent
  );
  margin: 1.5rem 0;
}

.agora-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.agora-pill {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(148, 163, 184, 0.08);
  color: var(--color-highlight);
  font-size: 0.85rem;
}

.agora-glow {
  position: absolute;
  inset: -30% 10% auto auto;
  height: 200px;
  width: 200px;
  filter: blur(90px);
  background: radial-gradient(circle, rgba(56, 189, 248, 0.35), transparent 70%);
  pointer-events: none;
}

@media (max-width: 1080px) {
  .agora-main {
    grid-template-columns: 1fr;
    padding: 2rem 1.5rem;
  }

  .agora-nav {
    flex-direction: column;
    gap: 1rem;
  }
}

/* Editor Layout */
.agora-editor {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.agora-editor-shell {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.agora-editor-meta,
.agora-editor-sidebar,
.agora-editor-sources {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 1rem;
  padding: clamp(1.25rem, 2vw, 1.75rem);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
}

.meta-field,
.meta-grid > div {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.meta-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.meta-authors {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.meta-author {
  display: flex;
  gap: 0.75rem;
}

.meta-author input,
.meta-field input,
.meta-field textarea,
.meta-grid textarea {
  background: var(--color-muted-background);
  border: 1px solid var(--color-divider);
  border-radius: 0.75rem;
  padding: 0.75rem;
  color: var(--color-text-primary);
  font-family: var(--font-sans);
}

.agora-editor-body {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(18rem, 20rem) minmax(0, 1fr) minmax(18rem, 20rem);
}

.editor-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(37, 99, 235, 0.2);
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-primary);
  font-size: 0.94rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
  text-decoration: none;
}

.editor-button:hover {
  background: rgba(37, 99, 235, 0.18);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.18);
  transform: translateY(-1px);
}

.editor-button:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
}

.editor-button.is-active {
  background: rgba(37, 99, 235, 0.22);
  border-color: rgba(37, 99, 235, 0.45);
  color: var(--color-highlight);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.editor-button--ghost {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.3);
  color: var(--color-text-primary);
}

.editor-button--ghost:hover {
  background: rgba(148, 163, 184, 0.2);
  color: var(--color-highlight);
  box-shadow: 0 10px 20px rgba(148, 163, 184, 0.18);
}

.editor-button--primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-color: transparent;
  color: var(--color-highlight);
  box-shadow: 0 16px 32px rgba(37, 99, 235, 0.28);
}

.editor-button--primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 20px 36px rgba(37, 99, 235, 0.32);
}

.editor-button--danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.45);
  color: var(--color-danger);
}

.editor-button--danger:hover {
  background: rgba(239, 68, 68, 0.16);
  box-shadow: 0 12px 24px rgba(239, 68, 68, 0.25);
  color: var(--color-highlight);
}

.editor-icon-button {
  width: 36px;
  height: 36px;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: rgba(148, 163, 184, 0.16);
  color: var(--color-text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.editor-icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.5);
  color: var(--color-highlight);
  box-shadow: 0 12px 22px rgba(37, 99, 235, 0.2);
}

.editor-icon-button.is-danger {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.16);
  color: var(--color-danger);
}

.editor-icon-button.is-danger:hover {
  color: var(--color-highlight);
  box-shadow: 0 14px 26px rgba(239, 68, 68, 0.26);
}

.editor-block input,
.editor-block select {
  background: var(--color-muted-background);
  border: 1px solid var(--color-divider);
  border-radius: 0.8rem;
  padding: 0.65rem 0.9rem;
  color: var(--color-text-primary);
  font-family: var(--font-sans);
}

.editor-block input:focus,
.editor-block select:focus,
.editor-block textarea:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.agora-editor-meta [data-action="add-author"] {
  align-self: flex-start;
}

.agora-editor-main {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 1rem;
  padding: clamp(1.25rem, 2vw, 1.75rem);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
}

.editor-section-toolbar {
  display: flex;
  justify-content: flex-end;
}

.editor-sections {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.editor-section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 1rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
}

.editor-section-card .section-header {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  align-items: end;
}

.section-header label {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.section-header input,
.section-header select {
  width: 100%;
  background: var(--color-muted-background);
  border: 1px solid var(--color-divider);
  border-radius: 0.75rem;
  padding: 0.6rem 0.75rem;
  color: var(--color-text-primary);
}

.section-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.editor-block {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.editor-block textarea,
.editor-block input,
.editor-block select {
  background: var(--color-muted-background);
  border: 1px solid var(--color-divider);
  border-radius: 0.75rem;
  padding: 0.65rem 0.75rem;
  color: var(--color-text-primary);
  font-family: var(--font-sans);
}

.editor-block textarea.has-error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.3);
}

.editor-block-chart-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.editor-chart-preview {
  min-height: 240px;
  background: var(--color-muted-background);
  border: 1px dashed rgba(37, 99, 235, 0.25);
  border-radius: 0.9rem;
  padding: 1rem;
}

.editor-chart-tabular {
  margin-top: 0.5rem;
  padding: 1rem;
  border: 1px solid var(--color-divider);
  border-radius: 0.75rem;
  background: var(--color-muted-background);
}

.editor-chart-tabular.hidden {
  display: none;
}

.agora-chart-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.agora-chart-form-header {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.agora-chart-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.agora-chart-input {
  background: var(--color-muted-background);
  border: 1px solid var(--color-divider);
  border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
  color: var(--color-text-primary);
}

.agora-chart-form-table {
  width: 100%;
  border-collapse: collapse;
}

.agora-chart-form-table th,
.agora-chart-form-table td {
  border: 1px solid rgba(148, 163, 184, 0.24);
  padding: 0.5rem;
  text-align: left;
}

.editor-source-row {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 0.9rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.editor-source-row textarea {
  resize: vertical;
}

@media (max-width: 1080px) {
  .agora-editor-body {
    grid-template-columns: 1fr;
  }

  .agora-editor-sidebar,
  .agora-editor-sources {
    order: 2;
  }
}

/* Viewer Layout */
.agora-viewer-shell {
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(16rem, 18rem) minmax(0, 1fr) minmax(16rem, 18rem);
}

.viewer-toc,
.viewer-sidepanel {
  background: rgba(17, 24, 39, 0.82);
  border: 1px solid var(--color-divider);
  border-radius: 1rem;
  padding: 1.5rem;
  backdrop-filter: blur(12px);
}

.viewer-toc ol {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.viewer-toc li button {
  background: none;
  border: none;
  color: var(--color-highlight);
  text-align: left;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.5rem;
  transition: background 0.2s ease;
}

.viewer-toc li button:hover {
  background: rgba(56, 189, 248, 0.15);
}

.viewer-toc .toc-level-3 button {
  padding-left: 1.25rem;
  font-size: 0.9rem;
}

.viewer-article {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.viewer-article-header h1 {
  font-size: 2.25rem;
  margin-bottom: 0.25rem;
}

.viewer-article-header h2 {
  font-size: 1.2rem;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.viewer-authors {
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
}


.viewer-toc-block {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 0.9rem;
  padding: 1.25rem 1.35rem;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.viewer-toc-block__list {
  margin: 0;
  padding-left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.viewer-toc-block__list li {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
}

.viewer-toc-block__list li[data-level="3"] {
  padding-left: 0.75rem;
}

.viewer-abstract {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 0.9rem;
  padding: 1.1rem 1.25rem;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
}

.viewer-section h2,
.viewer-section h3,
.viewer-section h4 {
  margin-bottom: 0.75rem;
}

.viewer-paragraph p {
  line-height: 1.8;
  color: var(--color-text-secondary);
}

.viewer-chart {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 1rem;
  padding: 1.1rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
}

.viewer-chart-canvas {
  min-height: 260px;
}

.viewer-chart figcaption {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

.viewer-footnote {
  cursor: pointer;
  color: var(--color-primary);
}

.viewer-sources ol {
  list-style: decimal;
  padding-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.viewer-sources li {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 0.9rem;
  padding: 0.9rem 1.2rem;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  cursor: pointer;
}

.viewer-sources li:hover {
  border-color: rgba(37, 99, 235, 0.28);
}

.viewer-sidepanel h4 {
  margin-top: 0;
}

.agora-chart-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
}

.agora-chart-table th,
.agora-chart-table td {
  border: 1px solid rgba(148, 163, 184, 0.24);
  padding: 0.5rem;
}

.agora-chart-caption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.agora-chart-warning {
  padding: 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 0.75rem;
  color: var(--color-danger);
}

.agora-chart {
  width: 100%;
}

.agora-chart canvas {
  width: 100% !important;
  height: auto !important;
}

/* Hub Styles */
.hub-auth {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hub-auth > div {
  background: var(--color-muted-background);
  border: 1px solid var(--color-divider);
  border-radius: 1rem;
  padding: 1.25rem 1.35rem;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.hub-form,
.hub-form-inline {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.hub-form-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
}

.hub-form-inline input[type="search"] {
  flex: 1;
  min-width: 0;
}

.hub-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.hub-form input,
.hub-form-inline input {
  background: var(--color-muted-background);
  border: 1px solid var(--color-divider);
  border-radius: 0.75rem;
  padding: 0.6rem 0.75rem;
  color: var(--color-text-primary);
}

.auth-panel .hub-form {
  gap: 1rem;
}

.auth-panel .hub-button {
  width: 100%;
  justify-content: center;
}

.hub-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.15rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(37, 99, 235, 0.26);
  background: rgba(37, 99, 235, 0.12);
  color: var(--color-primary);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.hub-button:hover {
  background: rgba(37, 99, 235, 0.2);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.18);
  transform: translateY(-1px);
}

.hub-tabs {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.hub-tab {
  padding: 0.45rem 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid var(--color-divider);
  background: var(--color-muted-background);
  color: var(--color-text-secondary);
  cursor: pointer;
}

.hub-tab.is-active {
  border-color: rgba(37, 99, 235, 0.28);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(124, 58, 237, 0.18));
  color: var(--color-highlight);
}

.hub-panel {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.hub-panel.is-active {
  display: flex;
}

.hub-results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hub-box {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 0.9rem;
  padding: 1rem 1.25rem;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.hub-box.hub-muted {
  color: var(--color-text-secondary);
}

.hub-box.hub-error {
  border-color: rgba(217, 48, 37, 0.22);
  background: rgba(217, 48, 37, 0.08);
  color: var(--color-danger);
}

.hub-results-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.hub-results-group h4 {
  margin: 0;
  color: var(--color-text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.85rem;
}

.hub-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 0.9rem;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.hub-card h5 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--color-text-primary);
}

.hub-card-actions {
  display: flex;
  gap: 0.75rem;
}

.hub-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(148, 163, 184, 0.12);
  color: var(--color-highlight);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.form-status {
  font-size: 0.85rem;
  margin: 0;
  color: var(--color-text-secondary);
}

.form-status[data-tone="error"] {
  color: var(--color-danger);
}

.form-status[data-tone="success"] {
  color: var(--color-success);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(6px);
  z-index: 2000;
  transition: opacity 0.2s ease;
}

.loading-overlay.hidden {
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.loading-bar {
  width: min(420px, 80vw);
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
  position: relative;
}

body[data-page="editor"] .editor-page-shell {
  padding: clamp(1.5rem, 3vw, 2.5rem);
  background: linear-gradient(120deg, rgba(37, 99, 235, 0.08), rgba(15, 23, 42, 0.05));
  min-height: calc(100vh - 80px);
}

.notebook-editor-wrapper {
  width: 100%;
}

.notebook-editor {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.notebook-controls {
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 1.2rem;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(12px);
}

.notebook-controls .controls-scroll {
  overflow-y: auto;
  max-height: inherit;
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.control-group h3 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.control-group label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.control-group input,
.control-group select,
.control-group textarea {
  background: var(--color-muted-background);
  border: 1px solid var(--color-divider);
  border-radius: 0.85rem;
  padding: 0.65rem 0.85rem;
  font: inherit;
  color: var(--color-text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.control-group input:focus,
.control-group select:focus,
.control-group textarea:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.control-chip {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.control-chip input {
  flex: 1;
}

.control-chip button {
  border: none;
  background: rgba(239, 68, 68, 0.14);
  color: var(--color-danger);
  border-radius: 0.6rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}

.control-source-row {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.control-source-row textarea {
  grid-column: 1 / -1;
  resize: vertical;
}

.control-config-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.control-config-header h3 {
  margin: 0;
  font-size: 1rem;
}

.notebook-main {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 2rem);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 1.2rem;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(12px);
}

.notebook-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-divider);
}

.notebook-stage {
  flex: 1;
  overflow: auto;
  padding: 1.75rem;
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.18), transparent 18%);
}

.editor-page-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
}

.editor-page {
  --page-width: 794px;
  --page-height: 1123px;
  width: var(--page-width);
  min-height: var(--page-height);
  background: #ffffff;
  border-radius: 1.1rem;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.16);
  border: 1px solid rgba(148, 163, 184, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-page-header,
.editor-page-footer {
  padding: 1.15rem 1.65rem;
}

.editor-page-header {
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}

.editor-page-header div {
  line-height: 1.4;
}

.page-header-title {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--color-text-primary);
}

.page-header-subtitle,
.page-header-authors {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

.editor-page-content {
  flex: 1;
  padding: 2.2rem 2.4rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.editor-page-footer {
  border-top: 1px solid rgba(148, 163, 184, 0.3);
  text-align: right;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.editor-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 2rem;
  z-index: 3000;
}

.editor-preview {
  width: min(1200px, 100%);
  max-height: min(90vh, 100%);
  background: var(--color-surface);
  border-radius: 1.25rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: 0 40px 80px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
}

.editor-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-divider);
}

.editor-preview-header button {
  border: none;
  background: rgba(239, 68, 68, 0.16);
  color: var(--color-danger);
  border-radius: 0.75rem;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}

.editor-preview-body {
  padding: 1.5rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.16), transparent 20%);
}

.editor-cell {
  position: relative;
  background: rgba(148, 163, 184, 0.08);
  border: 1px dashed transparent;
  border-radius: 0.8rem;
  padding: 1rem 1.1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.editor-cell:hover,
.editor-cell.is-active {
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.12);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.14);
}

.editor-cell-toolbar {
  position: absolute;
  top: -1.9rem;
  right: 0.4rem;
  display: flex;
  gap: 0.4rem;
}

.editor-cell-toolbar button {
  border: none;
  background: rgba(148, 163, 184, 0.24);
  color: var(--color-text-primary);
  border-radius: 0.5rem;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  font-size: 0.8rem;
}

.editor-cell-toolbar button.is-danger {
  background: rgba(239, 68, 68, 0.2);
  color: var(--color-danger);
}

.cell-editor {
  min-height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 0.75rem;
  padding: 0.7rem 0.85rem;
  font: inherit;
  color: var(--color-text-primary);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.12);
  outline: none;
  word-break: break-word;
}

.cell-editor[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: rgba(107, 114, 128, 0.7);
  pointer-events: none;
}

.cell-editor--heading {
  font-weight: 600;
}

.cell-editor--h1 {
  font-size: 1.8rem;
}

.cell-editor--h2 {
  font-size: 1.45rem;
}

.cell-editor--h3 {
  font-size: 1.2rem;
}

.cell-editor--caption {
  font-style: italic;
}

.editor-chart-block {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.editor-chart-preview {
  min-height: 220px;
  border: 1px dashed rgba(37, 99, 235, 0.3);
  border-radius: 0.85rem;
  padding: 0.75rem;
  background: rgba(37, 99, 235, 0.06);
}

.editor-toc-block {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.editor-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--color-text-secondary);
}

.editor-toc-list li[data-level="2"] {
  padding-left: 1rem;
}

.editor-toc-list li[data-level="3"] {
  padding-left: 2rem;
}

.config-hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}


/* -------------------------------------------------------------------------- */
/* Editor 3.0 Layout                                                          */
/* -------------------------------------------------------------------------- */

body[data-page="editor"] {
  overflow: hidden;
}

body[data-page="editor"] .agora-shell {
  height: 100vh;
}

body[data-page="editor"] .editor-page-shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 0;
}

body[data-page="editor"] #editor-root {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.editor-app-root {
  --sidebar-width: 300px;
  --sidebar-min-width: 260px;
  --sidebar-max-width: 520px;
  --page-width: 840px;
  --page-height: 1188px;
  --page-margin-top: 112px;
  --page-margin-bottom: 112px;
  --page-gap: 56px;
  --page-padding-horizontal: 104px;
  --page-content-height: calc(var(--page-height) - var(--page-margin-top) - var(--page-margin-bottom));
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.16), transparent 22%);
}

.editor-app-root *,
.editor-app-root *::before,
.editor-app-root *::after {
  box-sizing: border-box;
}

.editor-app {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.editor-app-toolbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 0.9rem 1.6rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
  transition: box-shadow 0.2s ease;
}

.editor-app-toolbar.has-shadow {
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
}

.toolbar-start,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toolbar-start {
  flex: 1 1 auto;
  min-width: 0;
}

.toolbar-title {
  position: relative;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  min-width: 0;
  max-width: 28rem;
  padding: 0.25rem 0.4rem;
  border-radius: 0.6rem;
  line-height: 1.35;
  outline: none;
  border: 1px solid transparent;
  background: transparent;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.toolbar-title:focus {
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.1);
}

.toolbar-title.is-placeholder::after {
  content: attr(data-placeholder);
  position: absolute;
  inset: 0.1rem 0.4rem;
  display: flex;
  align-items: center;
  color: var(--color-text-secondary);
  opacity: 0.6;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar-title.is-placeholder:focus::after {
  opacity: 0.4;
}

.toolbar-status {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(148, 163, 184, 0.18);
  color: var(--color-text-secondary);
}

.toolbar-status[data-status="draft"] {
  background: rgba(37, 99, 235, 0.12);
  color: var(--color-primary);
}

.toolbar-status[data-status="review"] {
  background: rgba(245, 158, 11, 0.16);
  color: var(--color-accent);
}

.toolbar-status[data-status="published"] {
  background: rgba(16, 185, 129, 0.16);
  color: var(--color-success);
}

.toolbar-save-indicator {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.toolbar-save-indicator::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.45);
  box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.toolbar-save-indicator[data-status="saving"] {
  color: var(--color-primary);
}

.toolbar-save-indicator[data-status="error"] {
  color: var(--color-danger);
}

.toolbar-save-indicator[data-status="saved"] {
  color: var(--color-success);
}

.toolbar-save-indicator[data-status="saved"]::before {
  background: #22c55e;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.35);
  opacity: 1;
}

.toolbar-save-indicator[data-status="dirty"]::before {
  background: #facc15;
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.4);
  opacity: 1;
}

.toolbar-button,
.toolbar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(148, 163, 184, 0.14);
  color: var(--color-text-primary);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.55rem 1.05rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.toolbar-button:hover,
.toolbar-icon:hover {
  background: rgba(148, 163, 184, 0.22);
  border-color: rgba(37, 99, 235, 0.45);
  color: var(--color-primary);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.toolbar-button:focus-visible,
.toolbar-icon:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.55);
  outline-offset: 2px;
}

.toolbar-button--primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-color: transparent;
  color: var(--color-highlight);
  box-shadow: 0 16px 36px rgba(37, 99, 235, 0.32);
}

.toolbar-button--primary:hover {
  box-shadow: 0 20px 40px rgba(37, 99, 235, 0.38);
  color: var(--color-highlight);
}

.toolbar-icon {
  width: 38px;
  height: 38px;
  padding: 0;
}

.toolbar-theme-toggle {
  position: relative;
}

.toolbar-theme-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 1.2rem;
  line-height: 1;
}

.toolbar-theme-icon::before {
  content: "☀";
}

.toolbar-theme-toggle[data-theme="dark"] .toolbar-theme-icon::before {
  content: "🌙";
}

.toolbar-separator {
  width: 1px;
  height: 28px;
  background: rgba(148, 163, 184, 0.35);
}

.editor-app-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(var(--sidebar-min-width), var(--sidebar-width), var(--sidebar-max-width)) 10px minmax(0, 1fr);
  align-items: stretch;
  background: transparent;
}

.editor-sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--color-divider);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(9px);
  box-shadow: inset -1px 0 0 rgba(148, 163, 184, 0.24);
}

.sidebar-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-divider);
  background: rgba(148, 163, 184, 0.14);
}

.sidebar-tab-button {
  flex: 1 1 0;
  padding: 0.65rem 0.75rem;
  border: none;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-tab-button:hover {
  background: rgba(37, 99, 235, 0.14);
  color: var(--color-primary);
}

.sidebar-tab-button.is-active {
  background: rgba(37, 99, 235, 0.18);
  color: var(--color-primary);
}

.sidebar-tab-button.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sidebar-content {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.sidebar-view {
  position: absolute;
  inset: 0;
  padding: 1.25rem 1.5rem 1.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  background: transparent;
}

.sidebar-view.hidden {
  display: none;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.sidebar-label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.sidebar-label input,
.sidebar-label textarea,
.sidebar-label select {
  width: 100%;
  font: inherit;
  color: var(--color-text-primary);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 0.75rem;
  padding: 0.6rem 0.85rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-label textarea {
  resize: vertical;
  min-height: 5.5rem;
}

.sidebar-label input:focus,
.sidebar-label textarea:focus,
.sidebar-label select:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.sidebar-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.sidebar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.38);
  background: rgba(148, 163, 184, 0.16);
  color: var(--color-text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.sidebar-button:hover {
  background: rgba(37, 99, 235, 0.18);
  border-color: rgba(37, 99, 235, 0.45);
  color: var(--color-primary);
  transform: translateY(-1px);
}

.sidebar-button--ghost {
  background: transparent;
}

.sidebar-button--danger {
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--color-danger);
}

.sidebar-button--danger:hover {
  background: rgba(239, 68, 68, 0.14);
  color: var(--color-highlight);
  border-color: rgba(239, 68, 68, 0.45);
}

.sidebar-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.75rem;
  border: 1px solid var(--color-divider);
  background: rgba(148, 163, 184, 0.14);
}

.sidebar-chip input {
  flex: 1 1 auto;
  border: none;
  background: transparent;
  font: inherit;
  color: var(--color-text-primary);
  padding: 0.35rem 0.4rem;
}

.sidebar-chip input:focus {
  outline: none;
}

.sidebar-chip-remove {
  border: none;
  background: rgba(239, 68, 68, 0.14);
  color: var(--color-danger);
  border-radius: 0.6rem;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.sidebar-chip-remove:hover {
  background: rgba(239, 68, 68, 0.24);
  color: var(--color-highlight);
}

.sources-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.source-item {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: 1rem;
  border-radius: 0.85rem;
  border: 1px solid var(--color-divider);
  background: rgba(148, 163, 184, 0.12);
}

.source-item label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.source-item input,
.source-item select,
.source-item textarea {
  font: inherit;
  color: var(--color-text-primary);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 0.65rem;
  padding: 0.55rem 0.7rem;
}

.source-item textarea {
  resize: vertical;
  min-height: 4.5rem;
}

.sidebar-hint {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  background: rgba(148, 163, 184, 0.14);
  border-radius: 0.75rem;
  padding: 0.75rem 0.9rem;
  line-height: 1.5;
}

.sidebar-hint kbd {
  padding: 0.15rem 0.4rem;
  border-radius: 0.4rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(148, 163, 184, 0.16);
  font-size: 0.75rem;
}

.sidebar-actions {
  display: flex;
  justify-content: flex-end;
}

.sidebar-empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  background: rgba(148, 163, 184, 0.12);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
}

.editor-resizer {
  position: relative;
  cursor: col-resize;
}

.editor-resizer::after {
  content: "";
  position: absolute;
  inset: 18% auto;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: rgba(148, 163, 184, 0.32);
  border-radius: 999px;
}

.editor-resizer:hover::after {
  background: rgba(37, 99, 235, 0.52);
}

.editor-stage {
  position: relative;
  display: flex;
  background: transparent;
  min-width: 0;
  overflow: hidden;
}

.editor-stage-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2rem 0 2.5rem;
  display: flex;
  justify-content: center;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.06), transparent 18%);
  scroll-behavior: smooth;
}

.editor-stage-scroll::-webkit-scrollbar {
  width: 10px;
}

.editor-stage-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 999px;
}

.editor-stage-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(37, 99, 235, 0.45);
}

.editor-sheet-frame {
  flex: 0 1 auto;
  width: 100%;
  max-width: calc(var(--page-width) + 6rem);
  padding: 0 2.5rem;
  display: flex;
  justify-content: center;
}

.editor-sheet {
  position: relative;
  width: var(--page-width);
  min-height: var(--page-height);
}

.editor-sheet-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.editor-page-background {
  display: none;
}

.editor-sheet-content {
  position: absolute;
  inset: 0;
  padding: 0;
  pointer-events: auto;
  display: flex;
  justify-content: center;
}

.editor-pages {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--page-gap);
  padding: 0;
  margin: 0;
}

.editor-page {
  width: var(--page-width);
  height: var(--page-height);
  border-radius: 1.4rem;
  background: var(--color-surface);
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
  display: flex;
  flex-direction: column;
}

.editor-page-surface {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--page-margin-top) var(--page-padding-horizontal) var(--page-margin-bottom);
}

.editor-page-body {
  flex: 1;
  min-height: var(--page-content-height);
  max-height: var(--page-content-height);
  overflow: hidden;
  color: var(--color-text-primary);
  font-size: 1.02rem;
  line-height: 1.66;
  pointer-events: auto;
  overflow-wrap: break-word;
}

.editor-page-body:focus {
  outline: none;
}

.editor-page-body p,
.editor-page-body blockquote,
.editor-page-body ul,
.editor-page-body ol,
.editor-page-body figure,
.editor-page-body aside,
.editor-page-body table {
  margin: 0 0 1.25rem;
}

.editor-page-body h1,
.editor-page-body h2,
.editor-page-body h3 {
  margin: 1.8rem 0 0.9rem;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
}

.editor-page-body h1 {
  font-size: 2.1rem;
  line-height: 1.2;
}

.editor-page-body h2 {
  font-size: 1.6rem;
  line-height: 1.25;
}

.editor-page-body h3 {
  font-size: 1.3rem;
  line-height: 1.3;
}

.editor-page-body ul,
.editor-page-body ol {
  padding-left: 1.75rem;
}

.editor-page-body li + li {
  margin-top: 0.35rem;
}

.editor-page-body blockquote {
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--color-primary);
  background: rgba(37, 99, 235, 0.08);
  border-radius: 0.75rem;
  color: var(--color-text-secondary);
}

.editor-page-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  line-height: 1.5;
}

.editor-page-body table th,
.editor-page-body table td {
  border: 1px solid rgba(148, 163, 184, 0.3);
  padding: 0.6rem 0.75rem;
  text-align: left;
}

.editor-page-body table th {
  background: rgba(148, 163, 184, 0.14);
  font-weight: 600;
}

.editor-page-body img,
.editor-page-body canvas,
.editor-page-body video {
  max-width: 100%;
  border-radius: 0.85rem;
  display: block;
  margin: 0 auto;
}

.doc-module {
  margin: 1.75rem 0;
  border-radius: 1.1rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.1);
  overflow: hidden;
}

.doc-module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.2rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.26);
  background: rgba(148, 163, 184, 0.12);
}

.doc-module-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.14);
  color: var(--color-primary);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.doc-module-handle {
  border: none;
  border-radius: 0.65rem;
  background: rgba(148, 163, 184, 0.22);
  color: var(--color-text-secondary);
  padding: 0.35rem 0.5rem;
  cursor: grab;
}

.doc-module-body {
  padding: 1.2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.doc-module-footer {
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  padding: 0.75rem 1.2rem;
  background: rgba(148, 163, 184, 0.08);
}

.doc-module-caption {
  min-height: 1.2rem;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

.doc-module-caption:focus {
  outline: none;
}

.doc-chart-preview {
  min-height: 260px;
  border-radius: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: rgba(15, 23, 42, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.doc-chart-preview > div:first-child {
  width: 100% !important;
  max-width: 100% !important;
  height: 100%;
}

.doc-module--toc ol {
  margin: 0;
  padding-left: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.doc-module--toc li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
}

.doc-module--toc li[data-level="3"] {
  padding-left: 1rem;
}

.doc-module--toc .toc-label {
  flex: 1;
}

.doc-module--toc .toc-page {
  margin-left: 1.5rem;
  min-width: 3ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.doc-module--callout {
  border-left: 4px solid var(--callout-accent, var(--color-primary));
  background: rgba(37, 99, 235, 0.06);
}

.doc-callout-title {
  margin: 0;
  font-size: 1.1rem;
  color: var(--color-text-primary);
}

.doc-callout-content {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  color: var(--color-text-secondary);
}

.doc-module--divider hr {
  border: none;
  border-top: 1px dashed rgba(148, 163, 184, 0.6);
}

.doc-module--page-break {
  border: none;
  background: transparent;
  margin: 0.75rem 0 0;
  padding: 0;
}

.doc-page-break-label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.doc-page-break-label::before,
.doc-page-break-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(148, 163, 184, 0.35);
  margin: 0 0.75rem;
}

.editor-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 2000;
}

.editor-preview {
  width: min(960px, 90vw);
  max-height: calc(100vh - 4rem);
  background: var(--color-surface);
  border-radius: 1.25rem;
  border: 1px solid var(--color-divider);
  box-shadow: 0 28px 64px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--color-divider);
  font-weight: 600;
  font-size: 1.05rem;
}

.editor-preview-header button {
  border: none;
  border-radius: 0.75rem;
  padding: 0.45rem 0.85rem;
  background: rgba(239, 68, 68, 0.12);
  color: var(--color-danger);
  cursor: pointer;
}

.editor-preview-header button:hover {
  background: rgba(239, 68, 68, 0.2);
  color: var(--color-highlight);
}

.editor-preview-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.5rem;
  background: rgba(148, 163, 184, 0.12);
}

.viewer-preview-page {
  width: var(--page-width);
  margin: 0 auto 1.5rem;
  background: var(--color-surface);
  border-radius: 1.2rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}

.viewer-preview-header {
  padding: 1.75rem 2.25rem 1.2rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.26);
}

.viewer-preview-header h1 {
  margin: 0;
  font-size: 1.8rem;
  color: var(--color-text-primary);
}

.viewer-preview-header h2 {
  margin: 0.35rem 0 0;
  font-size: 1.2rem;
  color: var(--color-text-secondary);
}

.viewer-preview-authors {
  margin: 0.6rem 0 0;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
}

.viewer-preview-content {
  padding: 2.25rem 2.4rem;
  color: var(--color-text-primary);
  font-size: 1.02rem;
  line-height: 1.66;
}

.viewer-preview-abstract {
  margin-bottom: 1.75rem;
  padding: 1.25rem 1.4rem;
  border-radius: 0.95rem;
  background: rgba(148, 163, 184, 0.14);
}

.viewer-preview-paragraph p {
  margin: 0 0 1.1rem;
}

.viewer-preview-chart {
  margin: 1.5rem 0;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  overflow: hidden;
  background: rgba(15, 23, 42, 0.04);
}

.viewer-preview-chart-canvas {
  padding: 1rem;
  background: var(--color-surface);
}

.viewer-preview-chart figcaption {
  padding: 0.85rem 1.2rem;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  background: rgba(148, 163, 184, 0.12);
}

.viewer-preview-callout {
  border-left: 4px solid var(--callout-accent, var(--color-primary));
  padding: 1.1rem 1.4rem;
  border-radius: 0.85rem;
  background: rgba(37, 99, 235, 0.08);
  margin: 1.5rem 0;
}

.viewer-preview-callout strong {
  display: block;
  margin-bottom: 0.5rem;
}

.viewer-preview-callout-body p {
  margin: 0.35rem 0 0;
}

.viewer-preview-toc {
  margin: 1.5rem 0;
}

.viewer-preview-toc h3 {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
}

.viewer-preview-toc ol {
  margin: 0;
  padding-left: 1.4rem;
}

.viewer-preview-toc li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
  color: var(--color-text-secondary);
}

.viewer-preview-toc li[data-level="3"] {
  padding-left: 1rem;
}

.viewer-toc-label {
  flex: 1;
}

.viewer-toc-page {
  font-variant-numeric: tabular-nums;
}

.viewer-preview-toc ol.is-multicolumn {
  column-count: 2;
  column-gap: 2.5rem;
}

.viewer-footnote {
  font-size: 0.7rem;
  padding: 0.1rem 0.25rem;
  border-radius: 0.35rem;
  background: rgba(37, 99, 235, 0.16);
  color: var(--color-primary);
}

.viewer-divider {
  height: 1px;
  width: 100%;
  background: rgba(148, 163, 184, 0.35);
  margin: 1.75rem 0;
}

.viewer-page-break {
  height: 0;
  margin: 1.75rem 0;
  border-top: 1px dashed rgba(148, 163, 184, 0.4);
}

@media (max-width: 1440px) {
  .editor-app-toolbar {
    gap: 1rem;
    padding: 0.85rem 1.3rem;
  }

  .toolbar-title {
    max-width: 22rem;
  }

  .editor-sheet-frame {
    padding: 0 1.5rem;
  }
}

@media (max-width: 1200px) {
  .editor-app-body {
    grid-template-columns: clamp(var(--sidebar-min-width), 280px, var(--sidebar-max-width)) 8px minmax(0, 1fr);
  }
}

@media (max-width: 1024px) {
  .editor-app-body {
    grid-template-columns: clamp(var(--sidebar-min-width), 260px, var(--sidebar-max-width)) 6px minmax(0, 1fr);
  }

  .toolbar-start {
    flex-wrap: wrap;
  }

  .toolbar-title {
    max-width: 100%;
  }
}

@media (max-width: 860px) {
  .editor-app-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .editor-sidebar {
    display: none;
  }

  .editor-resizer {
    display: none;
  }
}

.theme-dark .editor-app-toolbar {
  background: rgba(17, 24, 39, 0.92);
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow: 0 8px 22px rgba(2, 6, 23, 0.55);
}

.theme-dark .editor-app-toolbar.has-shadow {
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.75);
}

.theme-dark .toolbar-title {
  color: var(--color-highlight);
}

.theme-dark .toolbar-button,
.theme-dark .toolbar-icon {
  background: rgba(51, 65, 85, 0.55);
  border-color: rgba(148, 163, 184, 0.32);
  color: var(--color-highlight);
}

.theme-dark .toolbar-button:hover,
.theme-dark .toolbar-icon:hover {
  border-color: rgba(56, 189, 248, 0.5);
  color: var(--color-highlight);
}

.theme-dark .toolbar-status {
  background: rgba(51, 65, 85, 0.65);
  color: var(--color-highlight);
}

.theme-dark .toolbar-status[data-status="draft"] {
  background: rgba(56, 189, 248, 0.22);
  color: var(--color-highlight);
}

.theme-dark .toolbar-status[data-status="review"] {
  background: rgba(245, 158, 11, 0.28);
  color: var(--color-highlight);
}

.theme-dark .toolbar-status[data-status="published"] {
  background: rgba(16, 185, 129, 0.28);
  color: var(--color-highlight);
}

.theme-dark .toolbar-save-indicator {
  color: rgba(226, 232, 240, 0.75);
}

.theme-dark .editor-app-body {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.3), transparent 18%);
}

.theme-dark .editor-sidebar {
  background: rgba(17, 24, 39, 0.9);
  border-color: rgba(148, 163, 184, 0.28);
  box-shadow: inset -1px 0 0 rgba(148, 163, 184, 0.22);
}

.theme-dark .sidebar-tabs {
  background: rgba(51, 65, 85, 0.45);
  border-color: rgba(148, 163, 184, 0.28);
}

.theme-dark .sidebar-tab-button {
  color: rgba(226, 232, 240, 0.75);
}

.theme-dark .sidebar-tab-button.is-active {
  background: rgba(56, 189, 248, 0.22);
  color: var(--color-highlight);
}

.theme-dark .sidebar-label input,
.theme-dark .sidebar-label textarea,
.theme-dark .sidebar-label select {
  background: rgba(15, 23, 42, 0.85);
  border-color: rgba(148, 163, 184, 0.32);
  color: var(--color-highlight);
}

.theme-dark .sidebar-button {
  background: rgba(51, 65, 85, 0.55);
  border-color: rgba(148, 163, 184, 0.32);
  color: var(--color-highlight);
}

.theme-dark .sidebar-button:hover {
  background: rgba(56, 189, 248, 0.28);
  border-color: rgba(56, 189, 248, 0.5);
  color: var(--color-highlight);
}

.theme-dark .sidebar-button--danger {
  border-color: rgba(239, 68, 68, 0.5);
  color: rgba(248, 113, 113, 0.9);
}

.theme-dark .sidebar-button--danger:hover {
  background: rgba(239, 68, 68, 0.32);
  color: var(--color-highlight);
}

.theme-dark .sidebar-chip {
  background: rgba(51, 65, 85, 0.6);
  border-color: rgba(148, 163, 184, 0.28);
}

.theme-dark .sidebar-chip input {
  color: var(--color-highlight);
}

.theme-dark .sidebar-chip-remove {
  background: rgba(239, 68, 68, 0.28);
  color: var(--color-highlight);
}

.theme-dark .sources-list .source-item {
  background: rgba(17, 24, 39, 0.82);
  border-color: rgba(148, 163, 184, 0.28);
}

.theme-dark .sources-list label {
  color: rgba(226, 232, 240, 0.75);
}

.theme-dark .sources-list input,
.theme-dark .sources-list select,
.theme-dark .sources-list textarea {
  background: rgba(15, 23, 42, 0.88);
  border-color: rgba(148, 163, 184, 0.28);
  color: var(--color-highlight);
}

.theme-dark .sidebar-hint {
  background: rgba(51, 65, 85, 0.55);
  color: rgba(226, 232, 240, 0.75);
}

.theme-dark .sidebar-hint kbd {
  border-color: rgba(148, 163, 184, 0.38);
  background: rgba(51, 65, 85, 0.7);
  color: var(--color-highlight);
}

.theme-dark .sidebar-empty {
  background: rgba(51, 65, 85, 0.48);
  color: rgba(226, 232, 240, 0.75);
}

.theme-dark .editor-stage-scroll {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.4), transparent 18%);
}

.theme-dark .editor-page {
  background: rgba(17, 24, 39, 0.95);
  border-color: rgba(148, 163, 184, 0.28);
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.7);
}

.theme-dark .editor-page-body {
  color: var(--color-highlight);
}

.theme-dark .editor-page-body blockquote {
  background: rgba(37, 99, 235, 0.22);
  border-left-color: rgba(56, 189, 248, 0.65);
  color: rgba(226, 232, 240, 0.8);
}

.theme-dark .editor-page-body table th,
.theme-dark .editor-page-body table td {
  border-color: rgba(51, 65, 85, 0.65);
}

.theme-dark .doc-module {
  background: rgba(17, 24, 39, 0.9);
  border-color: rgba(148, 163, 184, 0.28);
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.65);
}

.theme-dark .doc-module-header {
  background: rgba(51, 65, 85, 0.55);
  border-color: rgba(148, 163, 184, 0.22);
}

.theme-dark .doc-module-chip {
  background: rgba(56, 189, 248, 0.28);
  color: var(--color-highlight);
}

.theme-dark .doc-module-caption {
  color: rgba(226, 232, 240, 0.75);
}

.theme-dark .doc-chart-preview {
  background: rgba(2, 6, 23, 0.65);
  border-color: rgba(148, 163, 184, 0.28);
}

.theme-dark .doc-module--toc li {
  color: rgba(226, 232, 240, 0.75);
}

.theme-dark .doc-module--callout {
  background: rgba(37, 99, 235, 0.22);
}

.theme-dark .doc-callout-content {
  color: rgba(226, 232, 240, 0.75);
}

.theme-dark .doc-page-break-label {
  color: rgba(226, 232, 240, 0.65);
}

.theme-dark .doc-page-break-label::before,
.theme-dark .doc-page-break-label::after {
  background: rgba(148, 163, 184, 0.35);
}

.theme-dark .editor-preview {
  background: rgba(17, 24, 39, 0.95);
  border-color: rgba(148, 163, 184, 0.32);
}

.theme-dark .editor-preview-header {
  border-color: rgba(148, 163, 184, 0.24);
}

.theme-dark .editor-preview-header button {
  background: rgba(239, 68, 68, 0.28);
  color: var(--color-highlight);
}

.theme-dark .editor-preview-body {
  background: rgba(15, 23, 42, 0.65);
}

.theme-dark .viewer-preview-page {
  background: rgba(17, 24, 39, 0.92);
  border-color: rgba(148, 163, 184, 0.28);
}

.theme-dark .viewer-preview-header {
  border-color: rgba(148, 163, 184, 0.22);
}

.theme-dark .viewer-preview-header h1,
.theme-dark .viewer-preview-header h2,
.theme-dark .viewer-preview-content {
  color: var(--color-highlight);
}

.theme-dark .viewer-preview-abstract {
  background: rgba(51, 65, 85, 0.55);
}

.theme-dark .viewer-preview-chart {
  background: rgba(2, 6, 23, 0.6);
  border-color: rgba(148, 163, 184, 0.28);
}

.theme-dark .viewer-preview-chart figcaption {
  background: rgba(51, 65, 85, 0.55);
  color: rgba(226, 232, 240, 0.7);
}

.theme-dark .viewer-preview-callout {
  background: rgba(37, 99, 235, 0.24);
}

.theme-dark .viewer-preview-toc li {
  color: rgba(226, 232, 240, 0.7);
}

.theme-dark .viewer-footnote {
  background: rgba(56, 189, 248, 0.28);
  color: var(--color-highlight);
}

.theme-dark .viewer-divider,
.theme-dark .viewer-page-break {
  background: rgba(148, 163, 184, 0.35);
  border-color: rgba(148, 163, 184, 0.35);
}

.theme-dark .notebook-controls {
  background: rgba(17, 24, 39, 0.88);
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: none;
}

.theme-dark .notebook-main {
  background: rgba(17, 24, 39, 0.9);
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: none;
}

.theme-dark .editor-page {
  background: rgba(17, 24, 39, 0.96);
  border-color: rgba(37, 99, 235, 0.32);
}

.theme-dark .editor-page-header,
.theme-dark .editor-page-footer {
  border-color: rgba(37, 99, 235, 0.25);
}

.theme-dark .editor-cell {
  background: rgba(37, 99, 235, 0.18);
  border-color: transparent;
}

.theme-dark .editor-cell:hover,
.theme-dark .editor-cell.is-active {
  background: rgba(37, 99, 235, 0.28);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.32);
}

.theme-dark .control-group input,
.theme-dark .control-group select,
.theme-dark .control-group textarea {
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(148, 163, 184, 0.32);
  color: var(--color-highlight);
}

.theme-dark .control-chip button {
  background: rgba(239, 68, 68, 0.2);
  color: var(--color-highlight);
}

.theme-dark .cell-editor {
  background: rgba(15, 23, 42, 0.8);
  color: var(--color-highlight);
  box-shadow: inset 0 1px 2px rgba(37, 99, 235, 0.18);
}

.theme-dark .cell-editor[data-placeholder]:empty::before {
  color: rgba(226, 232, 240, 0.6);
}


@media (max-width: 1280px) {
  .notebook-editor {
    grid-template-columns: 1fr;
  }

  .notebook-controls {
    position: static;
    max-height: none;
  }
}


.theme-dark .agora-panel,
.theme-dark .hero-feature,
.theme-dark .hub-box,
.theme-dark .hub-card,
.theme-dark .editor-block,
.theme-dark .agora-editor-meta,
.theme-dark .agora-editor-sidebar,
.theme-dark .agora-editor-sources,
.theme-dark .agora-editor-main,
.theme-dark .viewer-abstract,
.theme-dark .viewer-chart,
.theme-dark .viewer-sources li,
.theme-dark .agora-chart {
  background: rgba(17, 24, 39, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: none;
}

.theme-dark .hub-button {
  background: rgba(37, 99, 235, 0.32);
  border-color: rgba(37, 99, 235, 0.48);
  color: var(--color-highlight);
}

.theme-dark .hub-button:hover {
  background: rgba(37, 99, 235, 0.48);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.32);
}

.theme-dark .hub-button--ghost {
  background: rgba(51, 65, 85, 0.52);
  border-color: rgba(148, 163, 184, 0.38);
  color: var(--color-highlight);
}

.theme-dark .hub-button--ghost:hover {
  background: rgba(37, 99, 235, 0.32);
  border-color: rgba(37, 99, 235, 0.52);
  color: var(--color-highlight);
}

.theme-dark .editor-button {
  background: rgba(37, 99, 235, 0.28);
  border-color: rgba(37, 99, 235, 0.48);
  color: var(--color-highlight);
}

.theme-dark .editor-button:hover {
  background: rgba(37, 99, 235, 0.36);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.32);
}

.theme-dark .editor-button--ghost {
  background: rgba(51, 65, 85, 0.5);
  border-color: rgba(148, 163, 184, 0.35);
  color: var(--color-highlight);
}

.theme-dark .editor-button--danger {
  background: rgba(239, 68, 68, 0.24);
  border-color: rgba(239, 68, 68, 0.55);
  color: var(--color-highlight);
}

.theme-dark .editor-icon-button {
  background: rgba(51, 65, 85, 0.45);
  border-color: rgba(148, 163, 184, 0.35);
  color: var(--color-highlight);
}

.theme-dark .editor-icon-button.is-danger {
  background: rgba(239, 68, 68, 0.3);
  border-color: rgba(239, 68, 68, 0.55);
}

.theme-dark .editor-block input,
.theme-dark .editor-block select,
.theme-dark .editor-block textarea {
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(148, 163, 184, 0.32);
  color: var(--color-highlight);
}

.theme-dark .account-header {
  background: linear-gradient(130deg, rgba(37, 99, 235, 0.26), rgba(168, 85, 247, 0.24));
  border-color: rgba(37, 99, 235, 0.32);
}

.theme-dark .account-paper-card {
  background: rgba(17, 24, 39, 0.8);
  border-color: rgba(148, 163, 184, 0.28);
}

.theme-dark .account-papers-controls input[type="search"] {
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(148, 163, 184, 0.32);
  color: var(--color-highlight);
}

.theme-dark .account-papers-controls::before {
  color: rgba(226, 232, 240, 0.7);
}

.theme-dark .hub-tab {
  background: rgba(17, 24, 39, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: var(--color-highlight);
}

.theme-dark .hub-tab.is-active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(168, 85, 247, 0.18));
  border-color: rgba(56, 189, 248, 0.35);
}

.theme-dark .hero-search input[type="search"] {
  background: rgba(17, 24, 39, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: var(--color-highlight);
}

.theme-dark .hub-form input,
.theme-dark .hub-form-inline input,
.theme-dark .meta-author input,
.theme-dark .meta-field input,
.theme-dark .meta-field textarea,
.theme-dark .meta-grid textarea,
.theme-dark .agora-chart-input {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: var(--color-highlight);
}

.theme-dark .hub-auth > div {
  background: rgba(17, 24, 39, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.26);
  box-shadow: none;
}

.theme-dark .editor-chart-preview,
.theme-dark .editor-chart-tabular {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(148, 163, 184, 0.24);
}

.theme-dark .editor-source-row {
  background: rgba(17, 24, 39, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: none;
}

.theme-dark .agora-hero {
  background: linear-gradient(145deg, rgba(56, 189, 248, 0.15), rgba(168, 85, 247, 0.12)), rgba(17, 24, 39, 0.9);
  border-color: rgba(56, 189, 248, 0.24);
  box-shadow: none;
}

.theme-dark .agora-nav {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), transparent);
  box-shadow: none;
}

@media (max-width: 1024px) {
  .agora-hero__features {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .agora-panel--hub .hub-layout {
    grid-template-columns: 1fr;
  }

  .hub-auth {
    order: 2;
  }

  .hub-main {
    order: 1;
  }
}

@media (max-width: 720px) {
  .agora-nav {
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
  }

  .agora-nav-links {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .theme-toggle {
    order: 3;
  }

  .agora-hero {
    padding: clamp(1.75rem, 6vw, 3rem);
  }

  .agora-hero__cta {
    flex-direction: column;
    align-items: stretch;
  }

  .agora-panel--editor #agora-editor {
    min-height: 280px;
  }
}

.loading-bar-progress {
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  border-radius: inherit;
  animation: loading-bar-slide 1.2s ease-in-out infinite;
}

.loading-overlay p {
  margin: 0;
  color: var(--color-highlight);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.9rem;
}

@keyframes loading-bar-slide {
  0% {
    transform: translateX(-100%);
  }
  50% {
    transform: translateX(15%);
  }
  100% {
    transform: translateX(120%);
  }
}
.agora-hero {
  position: relative;
  overflow: hidden;
  border-radius: 1.5rem;
  padding: clamp(2.5rem, 6vw, 4rem);
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.18), rgba(124, 58, 237, 0.18)), var(--color-surface);
  border: 1px solid rgba(37, 99, 235, 0.25);
  box-shadow: 0 28px 60px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  gap: clamp(1.25rem, 2.5vw, 1.75rem);
}

.agora-hero::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: clamp(180px, 28vw, 320px);
  height: clamp(220px, 34vw, 360px);
  background: radial-gradient(circle, rgba(37, 99, 235, 0.25), transparent 65%);
  filter: blur(40px);
  opacity: 0.8;
}

.agora-hero__badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.agora-hero__tagline {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.28);
  font-weight: 600;
  color: var(--color-primary);
}

.agora-hero__title {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.15;
  color: var(--color-text-primary);
  margin: 0;
}

.agora-hero__subtitle {
  max-width: 42rem;
  font-size: 1.05rem;
  color: var(--color-text-secondary);
}

.agora-hero__cta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.hero-search {
  margin: 1.5rem auto 1rem;
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  max-width: 560px;
  width: min(100%, 560px);
  justify-content: center;
}

.hero-search input[type="search"] {
  flex: 1 1 320px;
  min-width: 240px;
  background: var(--color-muted-background);
  border: 1px solid var(--color-divider);
  border-radius: 0.85rem;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  color: var(--color-text-primary);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.hero-search button {
  flex: 0 0 auto;
  min-width: 140px;
}

.hero-search input[type="search"]:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.18);
}

.hub-button--ghost {
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.28);
  color: var(--color-text-primary);
}

.hub-button--ghost:hover {
  border-color: var(--color-primary);
  color: var(--color-highlight);
  background: rgba(37, 99, 235, 0.15);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.16);
}

.agora-hero__features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.hero-feature {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 1rem;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.hero-feature h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--color-text-primary);
}

.hero-feature p {
  margin: 0;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.agora-panel--hub .hub-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(320px, 1fr);
  gap: clamp(1.5rem, 3vw, 2.5rem);
  align-items: start;
}

.hub-main {
  display: flex;
  flex-direction: column;
  gap: clamp(1.25rem, 2vw, 1.75rem);
}

.hub-box,
.hub-card,
.editor-block,
.viewer-chart,
.agora-chart {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: 1rem;
  padding: 1.15rem 1.35rem;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.hub-box.hub-muted,
.hub-card .hub-muted,
.viewer-paragraph p {
  color: var(--color-text-secondary);
}

.hub-box.hub-error {
  background: rgba(217, 48, 37, 0.08);
  border-color: rgba(217, 48, 37, 0.22);
  color: var(--color-danger);
}
.agora-panel--editor #agora-editor {
  min-height: clamp(320px, 50vh, 520px);
  border: 1px dashed var(--color-divider);
  border-radius: 1rem;
  padding: clamp(1rem, 2vw, 1.5rem);
  background: var(--color-muted-background);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  text-align: center;
}

.agora-panel--editor #agora-editor .editor-placeholder {
  max-width: 34rem;
  margin: 0;
  line-height: 1.6;
}
