@font-face {
  font-family: "Space Grotesk";
  src: url("/static/vendor/fonts/SpaceGrotesk-Latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/vendor/fonts/IBMPlexMono-Regular-Latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/vendor/fonts/IBMPlexMono-Medium-Latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

:root {
  --bg-top: #0f2027;
  --bg-mid: #203a43;
  --bg-bottom: #2c5364;
  --surface: rgba(10, 18, 24, 0.78);
  --surface-alt: rgba(16, 28, 36, 0.9);
  --stroke: rgba(154, 187, 201, 0.3);
  --text: #edf7fa;
  --muted: #b7ced8;
  --accent: #ff9f1c;
  --accent-strong: #ffbf69;
  --success: #50e3a4;
  --danger: #ff6b6b;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
  --console-bg: rgba(10, 18, 24, 0.65);
  --console-text: #d8edf6;
  --console-error: #ffd2d2;
  --console-success: #b0ffd9;
  --console-hover-bg: rgba(183, 206, 216, 0.16);
  --divider-size: var(--panel-gap);
  --divider-line: rgba(154, 187, 201, 0.45);
  --divider-line-active: rgba(255, 191, 105, 0.95);
  --panel-gap: 0.45rem;
  --panel-gap-fullscreen: 0.3rem;
  --editor-font-base: 0.9rem;
  --editor-font-scale: 0.85;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  background: linear-gradient(140deg, var(--bg-top), var(--bg-mid) 55%, var(--bg-bottom));
  color: var(--text);
}

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

body.theme-light {
  --bg-top: #edf3f8;
  --bg-mid: #e3ebf3;
  --bg-bottom: #d9e5ef;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-alt: rgba(249, 252, 255, 0.95);
  --stroke: rgba(60, 92, 116, 0.28);
  --text: #173041;
  --muted: #4d6a7d;
  --shadow: 0 14px 34px rgba(34, 58, 76, 0.16);
  --console-bg: rgba(255, 255, 255, 0.88);
  --console-text: #264257;
  --console-error: #ab2f2f;
  --console-success: #1d7d54;
  --console-hover-bg: rgba(24, 55, 78, 0.12);
  --divider-line: rgba(60, 92, 116, 0.34);
  --divider-line-active: rgba(255, 159, 28, 0.88);
}

body.theme-light .topbar {
  background: linear-gradient(180deg, rgba(251, 253, 255, 0.96), rgba(239, 246, 252, 0.9));
}

body.theme-light .btn.ghost,
body.theme-light .btn.primary {
  background: rgba(24, 55, 78, 0.08);
  border-color: rgba(41, 73, 96, 0.26);
}

body.theme-light #pdfFrame {
  background: #ffffff;
}

body.theme-light .CodeMirror {
  background: #ffffff;
  color: #1f3345;
}

body.theme-light .CodeMirror-gutters {
  background: #f3f8fc;
  border-right: 1px solid rgba(60, 92, 116, 0.2);
}

.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--panel-gap);
  min-height: 100%;
  padding: 0.65rem;
  animation: rise-in 280ms ease-out;
}

body.is-fullscreen .app-shell {
  padding: 0.4rem;
  gap: var(--panel-gap-fullscreen);
  height: 100vh;
  min-height: 100vh;
}

body.is-fullscreen .workspace {
  min-height: 0;
}

body.is-fullscreen .workspace > .panel {
  height: 100%;
}

.topbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  background: linear-gradient(180deg, rgba(8, 15, 20, 0.9), rgba(13, 24, 31, 0.8));
  border: 1px solid var(--stroke);
  border-radius: 11px;
  box-shadow: var(--shadow);
  padding: 0.4rem 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.44rem;
}

.brand-logo {
  display: block;
  --brand-logo-height: clamp(19px, 2.85vw, 26px);
  height: var(--brand-logo-height);
  width: calc(var(--brand-logo-height) * 1.15);
  max-width: min(40vw, 220px);
}

.brand-wordmark {
  display: block;
  height: clamp(15px, 2.1vw, 20px);
  width: auto;
  max-width: min(36vw, 155px);
}

body.theme-dark .brand-logo {
  filter: brightness(0) invert(1);
}

body.theme-light .brand-logo {
  filter: none;
}

body.theme-dark .brand-wordmark {
  filter: brightness(0) invert(1);
}

body.theme-light .brand-wordmark {
  filter: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.mode-selector {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.mode-selector > span {
  font-size: 0.78rem;
  color: var(--muted);
}

.mode-selector .settings-select {
  min-width: 8.9rem;
  padding: 0.36rem 0.44rem;
  font-size: 0.82rem;
}

.template-menu,
.download-menu {
  position: relative;
}

.template-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.46rem 0.68rem;
  font-size: 0.84rem;
}

.template-menu-caret {
  font-size: 0.75rem;
  opacity: 0.86;
}

.template-dropdown,
.download-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.32rem);
  min-width: 14rem;
  border: 1px solid var(--stroke);
  border-radius: 7px;
  background: rgba(10, 18, 24, 0.96);
  box-shadow: var(--shadow);
  padding: 0.38rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  z-index: 30;
}

body.theme-light .template-dropdown,
body.theme-light .download-dropdown {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(41, 73, 96, 0.28);
}

.template-dropdown[hidden],
.download-dropdown[hidden] {
  display: none;
}

.template-dropdown-title,
.download-dropdown-title {
  margin: 0.1rem 0.1rem 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: normal;
}

.template-option,
.download-option {
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(183, 206, 216, 0.07);
  color: var(--text);
  text-align: left;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.42rem 0.54rem;
  cursor: pointer;
}

.template-option:hover:not(:disabled),
.download-option:hover:not(:disabled) {
  border-color: rgba(255, 191, 105, 0.32);
  background: rgba(255, 191, 105, 0.14);
}

.download-option:disabled {
  opacity: 0.5;
  cursor: default;
}

.template-option.active {
  border-color: rgba(255, 191, 105, 0.55);
  background: rgba(255, 191, 105, 0.2);
}

body.theme-light .template-option {
  background: rgba(24, 55, 78, 0.06);
  color: #173041;
}

body.theme-light .template-option:hover {
  border-color: rgba(255, 159, 28, 0.42);
  background: rgba(255, 159, 28, 0.18);
}

body.theme-light .template-option.active {
  border-color: rgba(255, 159, 28, 0.6);
  background: rgba(255, 159, 28, 0.26);
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn.primary {
  background: rgba(183, 206, 216, 0.12);
  color: var(--text);
  border-color: var(--stroke);
  font-weight: 600;
}

.btn.ghost {
  background: rgba(183, 206, 216, 0.12);
  color: var(--text);
  border-color: var(--stroke);
}

.preview-toggle-icon-btn i {
  font-size: 1.14rem;
  color: currentColor;
  transition: color 120ms ease, opacity 120ms ease;
}

.preview-toggle-icon-btn.is-collapsed {
  background: rgba(183, 206, 216, 0.08);
  border-color: rgba(154, 187, 201, 0.24);
}

.preview-toggle-icon-btn.is-collapsed i {
  color: currentColor;
  opacity: 0.92;
}

.project-panel-toggle-btn i {
  font-size: 1.08rem;
  transition: color 120ms ease, opacity 120ms ease;
}

.project-panel-toggle-btn.is-collapsed {
  background: rgba(183, 206, 216, 0.08);
  border-color: rgba(154, 187, 201, 0.24);
}

.project-panel-toggle-btn.is-collapsed i {
  color: currentColor;
  opacity: 0.92;
}

.icon-btn {
  width: 2.45rem;
  height: 2.45rem;
  padding: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  width: 1.16rem;
  height: 1.16rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn i {
  font-size: 1.1rem;
  line-height: 1;
}

.compile-icon-btn i {
  margin-left: 0.08rem;
  transition: color 120ms ease;
}

.compile-icon-btn:hover:not(:disabled) i {
  color: #ff7a00;
}

.symbol-toggle-btn span {
  font-family: "Times New Roman", Times, serif;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1;
}

.symbol-toggle-btn[aria-pressed="true"] {
  border-color: var(--stroke);
  background: rgba(183, 206, 216, 0.18);
}

#creditsBtn i {
  font-size: 1.3rem;
}

.symbol-bar {
  position: absolute;
  top: 4.3rem;
  right: 0.8rem;
  z-index: 90;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  max-width: min(92vw, 36rem);
  border: 1px solid var(--stroke);
  border-radius: 8px;
  padding: 0.42rem;
  background: var(--surface-alt);
  box-shadow: var(--shadow);
}

.symbol-bar[hidden] {
  display: none;
}

.symbol-chip {
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: rgba(183, 206, 216, 0.1);
  color: var(--text);
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 0.82rem;
  line-height: 1;
  min-width: 2rem;
  padding: 0.38rem 0.45rem;
  cursor: pointer;
}

.symbol-chip:hover {
  border-color: rgba(255, 191, 105, 0.55);
  background: rgba(255, 191, 105, 0.22);
}

body.theme-light .symbol-chip {
  background: rgba(24, 55, 78, 0.06);
}

.project-workspace-panel {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  padding: 0.45rem 0.55rem 0.4rem;
  border-bottom: 1px solid var(--stroke);
  background: rgba(183, 206, 216, 0.06);
}

.project-workspace-panel[hidden] {
  display: none;
}

.icon-btn[hidden] {
  display: none;
}

body.theme-light .project-workspace-panel {
  background: rgba(24, 55, 78, 0.05);
}

.project-workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.project-workspace-title-row {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.project-mode-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  font-size: 0.7rem;
  color: var(--muted);
}

.project-workspace-name {
  font-size: 0.82rem;
  color: var(--text);
  max-width: 12rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-workspace-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.project-action-btn {
  padding: 0.3rem 0.45rem;
  border-radius: 8px;
  font-size: 0.74rem;
}

.project-action-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  min-width: 2.15rem;
}

.project-action-prefix {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
}

.project-action-btn-icon i {
  font-size: 0.82rem;
  line-height: 1;
}

.project-file-list-wrap {
  min-height: 5.6rem;
}

.project-file-list {
  width: 100%;
  min-height: 5.6rem;
  max-height: 11rem;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: rgba(10, 18, 24, 0.75);
  color: var(--text);
  font: inherit;
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 0.78rem;
  line-height: 1.4;
  padding: 0.24rem;
}

body.theme-light .project-file-list {
  background: rgba(255, 255, 255, 0.95);
}

.editor-file-header {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.38rem 0.55rem;
  min-height: 2.05rem;
  border-bottom: 1px solid var(--stroke);
  background: rgba(183, 206, 216, 0.04);
}

body.theme-light .editor-file-header {
  background: rgba(24, 55, 78, 0.04);
}

.editor-file-label {
  font-size: 0.69rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.editor-file-name {
  min-width: 0;
  flex: 1;
  font-size: 0.81rem;
  color: var(--text);
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 1.3fr) var(--divider-size) minmax(300px, 1fr);
  column-gap: 0;
  row-gap: var(--panel-gap);
  flex: 1;
  min-height: 0;
  transition: grid-template-columns 220ms ease;
}

.workspace.is-resizing {
  transition: none;
}

.workspace.preview-collapsed {
  grid-template-columns: minmax(330px, 1fr);
}

.panel {
  border-radius: 9px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  background: var(--surface);
  overflow: hidden;
}

.editor-panel {
  grid-column: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.panel-divider {
  grid-column: 2;
  position: relative;
  min-width: var(--divider-size);
  cursor: col-resize;
  touch-action: none;
}

.panel-divider::before {
  display: none;
}

.preview-panel {
  grid-column: 3;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface-alt);
  transition: opacity 180ms ease, transform 180ms ease;
}

.workspace.preview-collapsed .preview-panel,
.workspace.preview-collapsed .panel-divider {
  display: none;
}

.preview-header {
  display: flex;
  align-items: center;
  padding: 0.38rem 0.55rem;
  min-height: 2.05rem;
  border-bottom: 1px solid var(--stroke);
  color: var(--muted);
  font-size: 0.81rem;
}

.preview-panel.pdf-loaded .preview-header {
  display: none;
}

#pdfFrame {
  border: 0;
  width: 100%;
  flex: 1;
  height: 100%;
  min-height: 0;
  background: #151515;
}

.CodeMirror {
  height: 100%;
  min-height: 0;
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: calc(var(--editor-font-base) * var(--editor-font-scale));
  line-height: 1.55;
}

.editor-panel .CodeMirror {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

body.is-fullscreen #pdfFrame,
body.is-fullscreen .CodeMirror {
  height: 100%;
  min-height: 0;
}

.log-panel {
  flex: 0 0 auto;
  padding: 0.62rem 0.75rem;
  background: var(--console-bg);
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.log-panel h2 {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 500;
}

.console-toggle {
  width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.console-toggle:hover {
  color: var(--text);
  background: var(--console-hover-bg);
}

#statusLog {
  margin: 0.35rem 0 0;
  max-height: 21vh;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--console-text);
  font-family: inherit;
  font-size: 0.8rem;
}

body.is-fullscreen .log-panel:not(.collapsed) #statusLog {
  min-height: 4.8em;
}

#statusLog.error {
  color: var(--console-error);
}

#statusLog.success {
  color: var(--console-success);
}

.log-panel.collapsed {
  padding: 0.46rem 0.72rem;
}

.log-panel.collapsed #statusLog {
  display: none;
}

.log-panel.collapsed .log-header {
  min-height: 1.35rem;
}

.log-panel.collapsed h2 {
  font-size: 0.9rem;
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(6, 14, 20, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.settings-modal[hidden] {
  display: none;
}

.settings-dialog {
  width: min(430px, 100%);
  border: 1px solid var(--stroke);
  border-radius: 9px;
  background: var(--surface-alt);
  box-shadow: var(--shadow);
  padding: 0.8rem;
}

.credits-dialog {
  width: min(500px, 100%);
  padding: 0;
  overflow: hidden;
}

.credits-header {
  margin: 0;
  padding: 0.68rem 0.82rem;
  background: linear-gradient(180deg, rgba(8, 15, 20, 0.9), rgba(13, 24, 31, 0.8));
  border-bottom: 1px solid var(--stroke);
}

body.theme-light .credits-header {
  background: linear-gradient(180deg, rgba(251, 253, 255, 0.96), rgba(239, 246, 252, 0.9));
}

.credits-header h2 {
  color: var(--text);
}

.credits-dialog .settings-close {
  border: 1px solid var(--stroke);
  border-radius: 8px;
}

.credits-dialog .credits-content {
  padding: 0.82rem;
}

.credits-content {
  display: flex;
  flex-direction: column;
  gap: 0.52rem;
}

.credits-identity {
  display: flex;
  align-items: center;
  gap: 0.62rem;
}

.credits-logo {
  display: block;
  --credits-logo-height: 31px;
  height: var(--credits-logo-height);
  width: calc(var(--credits-logo-height) * 1.15);
}

body.theme-dark .credits-logo {
  filter: brightness(0) invert(1);
}

body.theme-light .credits-logo {
  filter: none;
}

.credits-identity-text {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.credits-content p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.credits-copy {
  color: var(--text);
  font-weight: 600;
}

.credits-owner {
  color: var(--muted);
  font-size: 0.84rem;
}

.credits-identity + .credits-note {
  margin-top: 0.34rem;
}

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

.credits-divider {
  width: 100%;
  margin: 0.22rem 0 0.14rem;
  border: 0;
  border-top: 1px solid var(--stroke);
  opacity: 0.8;
}

#visitCounterText {
  font-size: 0.79rem;
}

.cloud-dialog {
  width: min(560px, 100%);
}

.cloud-form {
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
}

.cloud-connection-status {
  margin: 0;
  padding: 0.42rem 0.52rem;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: rgba(183, 206, 216, 0.08);
  color: var(--muted);
  font-size: 0.82rem;
}

.cloud-connection-status.success {
  color: var(--console-success);
}

.cloud-connection-status.error {
  color: var(--console-error);
}

.cloud-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.cloud-project-list {
  min-height: 11rem;
  font-size: 0.82rem;
}

.workspace-hint {
  margin: 0.08rem 0 0;
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.35;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.settings-header h2 {
  margin: 0;
  font-size: 1rem;
}

.settings-close {
  width: 1.35rem;
  height: 1.35rem;
  font-size: 1.1rem;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

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

.settings-select {
  border: 1px solid var(--stroke);
  border-radius: 8px;
  padding: 0.44rem 0.52rem;
  background: rgba(10, 18, 24, 0.75);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

body.theme-light .settings-select {
  background: rgba(255, 255, 255, 0.95);
}

.settings-select option {
  color: #e9f0f4;
  background: #15222b;
}

body.theme-light .settings-select option {
  color: #0f1f2a;
  background: #ffffff;
}

.font-size-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.6rem;
}

#fontScaleInput {
  width: 100%;
}

#fontScaleValue {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  min-width: 3.8rem;
  text-align: right;
  color: var(--muted);
}

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

.settings-field.compact {
  gap: 0.25rem;
}

.table-assistant-dialog {
  width: min(940px, 100%);
}

.table-assistant-form {
  display: flex;
  flex-direction: column;
  gap: 0.62rem;
}

.table-assistant-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr)) repeat(5, auto);
  gap: 0.42rem;
  align-items: end;
}

.table-merge-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.42rem;
}

.table-selection-hint {
  margin-right: auto;
  color: var(--muted);
  font-size: 0.8rem;
}

.table-color-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto auto;
  gap: 0.42rem;
  align-items: end;
}

.table-color-input {
  width: 4rem;
  height: 2.2rem;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: rgba(10, 18, 24, 0.75);
  cursor: pointer;
  padding: 0.12rem;
}

body.theme-light .table-color-input {
  background: rgba(255, 255, 255, 0.95);
}

.table-options-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 0.32rem 0.6rem;
}

.table-option {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.table-option code {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 0.76rem;
  color: var(--text);
}

.table-alignments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.table-align-col {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.79rem;
}

.table-align-select {
  min-width: 5.6rem;
  padding: 0.35rem 0.42rem;
  font-size: 0.82rem;
}

.table-matrix-wrap {
  max-height: min(38vh, 360px);
  overflow: auto;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: rgba(10, 18, 24, 0.5);
  padding: 0.35rem;
}

body.theme-light .table-matrix-wrap {
  background: rgba(255, 255, 255, 0.78);
}

.table-matrix {
  width: 100%;
  border-collapse: collapse;
  min-width: 460px;
}

.table-matrix th,
.table-matrix td {
  border: 1px solid var(--stroke);
  padding: 0.2rem 0.24rem;
  text-align: center;
}

.table-matrix td.table-cell-merged {
  background: rgba(255, 191, 105, 0.08);
}

.table-matrix thead th,
.table-matrix tbody th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  background: rgba(183, 206, 216, 0.08);
}

body.theme-light .table-matrix thead th,
body.theme-light .table-matrix tbody th {
  background: rgba(24, 55, 78, 0.06);
}

body.theme-light .table-matrix td.table-cell-merged {
  background: rgba(255, 159, 28, 0.08);
}

.table-cell-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  background: rgba(183, 206, 216, 0.09);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  line-height: 1.2;
  padding: 0.3rem 0.36rem;
}

.table-cell-input:focus {
  outline: none;
  border-color: rgba(255, 191, 105, 0.64);
  background: rgba(255, 191, 105, 0.12);
}

body.theme-light .table-cell-input {
  background: rgba(24, 55, 78, 0.06);
}

.table-matrix td.table-cell-selected {
  outline: 2px solid rgba(255, 191, 105, 0.78);
  outline-offset: -2px;
}

.table-matrix td.table-cell-selected .table-cell-input {
  border-color: rgba(255, 191, 105, 0.9);
}

.table-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.42rem;
}

.table-output-panel {
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: rgba(10, 18, 24, 0.45);
  padding: 0.35rem;
}

body.theme-light .table-output-panel {
  background: rgba(255, 255, 255, 0.72);
}

.table-output-toggle {
  font-size: 0.82rem;
  padding: 0.34rem 0.52rem;
}

.table-output-body {
  margin-top: 0.36rem;
}

.table-output-panel.collapsed .table-output-body {
  display: none;
}

.table-assistant-output-panel > .table-assistant-output-toggle::-webkit-details-marker {
  display: none;
}

.table-assistant-output-panel > .table-assistant-output-toggle::marker {
  content: "";
}

.table-assistant-output-panel > .table-assistant-output-toggle {
  display: inline-flex;
  align-items: center;
  list-style: none;
  cursor: pointer;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.2;
}

.table-assistant-output-panel .table-output-body {
  margin-top: 0.24rem;
}

.table-assistant-output-panel .table-latex-output {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 0;
  resize: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0.2rem 0.12rem 0.05rem;
}

body.theme-light .table-assistant-output-panel .table-latex-output {
  background: transparent;
}

.table-latex-output {
  min-height: 9rem;
  resize: vertical;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  padding: 0.5rem 0.56rem;
  background: rgba(10, 18, 24, 0.75);
  color: var(--text);
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 0.81rem;
  line-height: 1.35;
}

body.theme-light .table-latex-output {
  background: rgba(255, 255, 255, 0.95);
}

.image-assistant-dialog {
  width: min(900px, 100%);
}

.image-assistant-form {
  display: flex;
  flex-direction: column;
  gap: 0.62rem;
}

.image-assistant-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr)) minmax(180px, 1fr);
  gap: 0.42rem;
  align-items: center;
}

.image-subfigure-count-field {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.42rem;
  align-self: center;
}

.image-subfigure-count-field > span {
  white-space: nowrap;
}

.image-subfigure-count-field .settings-select {
  width: 4.25rem;
  flex: 0 0 4.25rem;
  text-align: center;
}

.image-size-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(3, minmax(140px, 1fr));
  gap: 0.42rem;
  align-items: end;
}

.image-assistant-items {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
}

.image-item-card {
  border: 1px solid var(--stroke);
  border-radius: 9px;
  background: rgba(10, 18, 24, 0.42);
  padding: 0.46rem;
  display: flex;
  flex-direction: column;
  gap: 0.34rem;
}

body.theme-light .image-item-card {
  background: rgba(255, 255, 255, 0.75);
}

.image-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.image-item-title {
  margin: 0;
  color: var(--text);
  font-size: 0.83rem;
  font-weight: 600;
}

.image-item-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto;
  gap: 0.38rem;
  align-items: end;
}

.image-selected-path {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  word-break: break-word;
}

.image-subcaption-field {
  margin-top: 0.12rem;
}

.image-assistant-form .table-latex-output {
  min-height: 8.5rem;
}

.image-output-panel > .image-output-toggle::-webkit-details-marker {
  display: none;
}

.image-output-panel > .image-output-toggle::marker {
  content: "";
}

.image-output-panel > .image-output-toggle {
  display: inline-flex;
  align-items: center;
  list-style: none;
  cursor: pointer;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.2;
}

.image-output-panel .table-output-body {
  margin-top: 0.24rem;
}

.image-output-panel .table-latex-output {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 0;
  resize: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0.2rem 0.12rem 0.05rem;
}

body.theme-light .image-output-panel .table-latex-output {
  background: transparent;
}

.is-hidden {
  display: none !important;
}

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

@media (max-width: 980px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.34rem 0.42rem;
  }

  .brand-wordmark {
    height: 17px;
  }

  .actions {
    justify-content: flex-start;
    gap: 0.35rem;
  }

  .mode-selector {
    width: 100%;
    justify-content: space-between;
  }

  .mode-selector .settings-select {
    min-width: 0;
    flex: 1;
  }

  .symbol-bar {
    left: 0.65rem;
    right: 0.65rem;
    max-width: none;
  }

  .template-dropdown,
  .download-dropdown {
    left: 0;
    right: auto;
    min-width: 12.2rem;
  }

  .table-assistant-dialog {
    width: min(880px, 100%);
  }

  .image-assistant-dialog {
    width: min(860px, 100%);
  }

  .table-assistant-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .image-assistant-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .image-subfigure-count-field {
    flex-direction: column;
    align-items: stretch;
  }

  .image-subfigure-count-field .settings-select {
    width: 100%;
    flex: 1 1 auto;
    text-align: left;
  }

  .image-size-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .image-item-grid {
    grid-template-columns: 1fr;
  }

  .table-merge-toolbar {
    gap: 0.32rem;
  }

  .table-selection-hint {
    width: 100%;
    margin-right: 0;
  }

  .table-color-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .table-meta-grid {
    grid-template-columns: 1fr;
  }

  .workspace,
  .workspace.preview-collapsed {
    grid-template-columns: 1fr;
  }

  .editor-panel,
  .preview-panel {
    grid-column: 1;
  }

  .panel-divider {
    display: none;
  }

  .workspace.preview-collapsed .preview-panel {
    display: none;
  }

  #pdfFrame,
  .CodeMirror {
    min-height: 0;
  }
}
