:root {
  --nav: #11161d;
  --nav-ink: #f2f5f7;
  --accent: #f2a65a;
  --accent-ink: #17130f;
  --line: #2d3743;
  --paper: #171d25;
  --ink: #d9e0e7;
  --muted: #8793a0;
  --pane: #121820;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
  --font: "DM Sans", "Segoe UI", sans-serif;
  --display-font: "Space Grotesk", "DM Sans", sans-serif;
  --mono: "IBM Plex Mono", "Cascadia Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image: linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 34px 34px;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: linear-gradient(115deg, #11161d 0%, #17212b 72%, #1e2a33 100%);
  color: var(--nav-ink);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 3.1rem;
  height: 2.6rem;
  border: 1px solid rgba(242, 166, 90, 0.48);
  border-radius: 8px;
  background: rgba(242, 166, 90, 0.1);
  color: var(--accent);
  font-family: var(--display-font);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 5px 14px rgba(0,0,0,0.18);
}

.brand-copy { display: flex; flex-direction: column; gap: 0.16rem; }
.brand-sub {
  color: #f2f5f7;
  font-family: var(--display-font);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}
.brand-accent { color: var(--accent); }
.brand-caption {
  color: #93a1af;
  font-size: 15px;
  font-weight: 500;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.guide-link {
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.guide-link:hover { background: #202a35; color: #ffc37f; }
.guide-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mode-tabs {
  display: flex;
  gap: 0.3rem;
  padding: 0.3rem;
  background: #101720;
  border: 1px solid #364351;
  border-radius: 10px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.25), 0 3px 9px rgba(0,0,0,0.18);
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-width: 7.8rem;
  min-height: 2.65rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #aebbc8;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.45rem 0.85rem;
  transition: 180ms ease;
}

.mode-tab svg { width: 1.1rem; height: 1.1rem; }
.mode-tab:hover:not(.is-active) { background: #202a35; color: #f2f5f7; }
.mode-tab:active { transform: translateY(1px); }
.mode-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode-tab.is-active {
  border-color: #ffc37f;
  background: var(--accent);
  color: #20170f;
  box-shadow: 0 3px 10px rgba(242, 166, 90, 0.28), inset 0 1px 0 rgba(255,255,255,0.45);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.8rem 1rem;
  padding: 0.8rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: #1a222c;
  position: relative;
  z-index: 1;
}

.toolbar-group { display: flex; flex-direction: column; gap: 0.42rem; }
.toolbar-label { color: #94a2b0; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.action-row { display: flex; gap: 0.45rem; }
.toolbar-export { margin-left: auto; flex-direction: row; align-items: end; gap: 0.55rem; }

.file-pick,
.theme-pick,
.export-scope {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.file-pick input,
.theme-pick select,
.export-scope select {
  font: inherit;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  background: #111820;
  border: 1px solid var(--line);
  padding: 0.48rem 0.65rem;
  min-height: 2.55rem;
  border-radius: 7px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.16);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.file-pick input:hover, .theme-pick select:hover, .export-scope select:hover { border-color: #526274; background-color: #151e28; }
.file-pick input:focus-visible, .theme-pick select:focus-visible, .export-scope select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.file-pick input::file-selector-button {
  margin: -0.3rem 0.55rem -0.3rem -0.35rem;
  padding: 0.36rem 0.65rem;
  border: 1px solid #4a5a6b;
  border-radius: 5px;
  background: #273441;
  color: #f2f5f7;
  font: 600 0.75rem var(--font);
  cursor: pointer;
  transition: 160ms ease;
}
.file-pick input::file-selector-button:hover { background: #334352; border-color: #718092; }

.file-pick input {
  max-width: 16rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid #465565;
  background: #25313d;
  color: var(--ink);
  padding: 0.5rem 0.9rem;
  min-height: 2.55rem;
  cursor: pointer;
  border-radius: 7px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.06);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease, filter 160ms ease;
}

.btn svg { width: 1.05rem; height: 1.05rem; flex: 0 0 auto; }
.btn:hover { border-color: #8293a5; background: #334251; transform: translateY(-1px); box-shadow: 0 5px 12px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.08); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-accent {
  background: linear-gradient(180deg, #ffc17c 0%, #f2a65a 100%);
  border-color: #ffc17c;
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(242,166,90,0.24), inset 0 1px 0 rgba(255,255,255,0.42);
}

.btn-accent:hover { background: linear-gradient(180deg, #ffd09a 0%, #f5ad65 100%); border-color: #ffd09a; box-shadow: 0 6px 14px rgba(242,166,90,0.3), inset 0 1px 0 rgba(255,255,255,0.5); }

.btn-tiny {
  min-height: 2.25rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.74rem;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem 1.5rem 1.4rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  min-height: 1.8rem;
  padding: 0.15rem 1.5rem;
  border-top: 1px solid rgba(45, 55, 67, 0.7);
  color: var(--muted);
  font-size: 0.67rem;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.site-footer a:hover { color: #ffc37f; text-decoration: underline; text-underline-offset: 2px; }
.site-footer a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

.pane-editor {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
  min-height: 1.5rem;
}

.pane-head h2 {
  margin: 0;
  font-family: var(--display-font);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #b8c3cd;
}

.editor-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  min-width: 0;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.dialog-eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font: 500 0.65rem var(--mono);
}

.dialog-head h2 {
  margin: 0;
  font: 600 1.25rem var(--display-font);
}

.icon-btn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border: 1px solid #465565;
  border-radius: 6px;
  background: #202a35;
  color: var(--ink);
  font: 1.3rem/1 var(--font);
  cursor: pointer;
}

.icon-btn:hover { border-color: #8293a5; background: #334251; }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#enrich-prompt {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 3.1rem;
  max-height: 8rem;
  resize: vertical;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: #10161d;
  color: var(--ink);
  font: 0.78rem/1.5 var(--font);
}

#enrich-prompt:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(242, 166, 90, 0.11); }
#enrich-prompt:disabled { opacity: 0.65; }

.dialog-note {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.enrich-error {
  margin: 0.8rem 0 0;
  padding: 0.6rem 0.7rem;
  border: 1px solid rgba(239, 115, 105, 0.45);
  border-radius: 5px;
  background: rgba(132, 43, 39, 0.18);
  color: #ffaaa2;
  font-size: 0.75rem;
  line-height: 1.45;
}

.ai-assist {
  flex: 0 0 auto;
  margin-bottom: 0.65rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: linear-gradient(135deg, rgba(242, 166, 90, 0.07), rgba(18, 24, 32, 0.72));
}

.ai-prompt-form { display: flex; align-items: stretch; gap: 0.5rem; }
.ai-run-btn { flex: 0 0 auto; align-self: stretch; min-height: 3.1rem; }

.ai-review {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  left: 0.75rem;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid #465565;
  border-radius: 7px;
  background: rgba(23, 31, 40, 0.96);
  color: #c5d0d9;
  font-size: 0.72rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(8px);
}

.ai-review-actions { display: flex; flex: 0 0 auto; gap: 0.45rem; }
.ai-review button:disabled { cursor: wait; opacity: 0.6; transform: none; }
.ai-assist-error { margin-top: 0.55rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.image-download-dialog {
  width: min(94vw, 1120px);
  max-height: 94vh;
  max-height: 94dvh;
  padding: 1.15rem;
  border: 1px solid #465565;
  border-radius: 10px;
  background: #171f28;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.image-download-dialog::backdrop { background: rgba(5, 9, 13, 0.72); backdrop-filter: blur(3px); }
.image-download-dialog .dialog-head { flex: 0 0 auto; margin-bottom: 0.55rem; }
.image-download-dialog h2 { margin: 0; font: 600 1.25rem var(--display-font); }
.image-download-dialog .dialog-note { margin: 0 0 0.75rem; }
.image-preview {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 8rem;
  max-height: calc(94vh - 11rem);
  max-height: calc(94dvh - 11rem);
  overflow: hidden;
  border: 1px solid #364351;
  border-radius: 8px;
  background: #0c1117;
}
.image-preview img { display: block; max-width: 100%; max-height: calc(94vh - 11rem); max-height: calc(94dvh - 11rem); object-fit: contain; }
.image-nav {
  position: absolute;
  top: 50%;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  transform: translateY(-50%);
  border: 1px solid #607080;
  border-radius: 50%;
  background: rgba(17, 24, 32, 0.88);
  color: #f2f5f7;
  cursor: pointer;
}
.image-nav svg { width: 1.5rem; height: 1.5rem; }
.image-nav:hover:not(:disabled), .image-nav:focus-visible { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.image-nav:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.image-nav:disabled { cursor: default; opacity: 0.45; }
.image-nav-prev { left: 0.75rem; }
.image-nav-next { right: 0.75rem; }
.image-download-controls { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.75rem; }
.image-download-controls > span { min-width: 0; overflow: hidden; color: var(--muted); font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 560px) {
  .image-download-dialog { width: calc(100vw - 1.5rem); padding: 0.85rem; }
  .image-preview { max-height: calc(94vh - 13rem); max-height: calc(94dvh - 13rem); }
  .image-preview img { max-height: calc(94vh - 13rem); max-height: calc(94dvh - 13rem); }
  .image-nav { width: 2.35rem; height: 2.35rem; }
  .image-nav-prev { left: 0.45rem; }
  .image-nav-next { right: 0.45rem; }
}

.status {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
}

.status-dot { display: inline-block; width: 0.42rem; height: 0.42rem; margin-right: 0.35rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(242,166,90,0.12); }

@media (max-width: 560px) {
  .editor-head-actions { gap: 0.35rem; }
  .editor-head-actions .status { max-width: 38%; font-size: 0.68rem; }
  .ai-assist { padding: 0.6rem; }
  .ai-prompt-form { flex-direction: column; }
  .ai-run-btn { align-self: flex-end; min-height: 2.35rem; }
  .ai-review { gap: 0.4rem; }
  .ai-review > span { display: none; }
}

.md-editor-wrap {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  margin-bottom: 0.65rem;
}

#md-input {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow: auto;
  resize: none;
  border: 1px solid var(--line);
  background: #10161d;
  color: var(--ink);
  padding: 0.9rem 1rem;
  font: 0.84rem/1.75 var(--mono);
  box-shadow: var(--shadow);
  border-radius: 4px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

#md-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(242,166,90,0.11), var(--shadow);
}

#md-input:disabled { cursor: wait; opacity: 0.82; }
#md-input.has-ai-review { padding-bottom: 4.4rem; }

.preview-stage {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: 2.4rem 1fr 2.4rem;
  align-items: stretch;
  gap: 0.35rem;
  min-height: 0;
  overflow: hidden;
}

.preview-frame {
  grid-column: 2;
  min-height: 0;
  height: 100%;
  border: 1px solid var(--line);
  background: var(--pane);
  margin: 0;
  padding: 1rem 1.1rem;
  overflow: auto;
  box-shadow: var(--shadow);
  border-radius: 4px;
}

.preview-frame:has(#preview.ppt-mode) {
  padding-inline: 3.75rem;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 3.1rem;
  height: 3.1rem;
  border: 1px solid #738295;
  border-radius: 12px;
  background: rgba(17, 24, 32, 0.96);
  color: #f2f5f7;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transform: translateY(-50%);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-arrow svg { width: 1.5rem; height: 1.5rem; }

.nav-arrow-left {
  left: 3.25rem;
}

.nav-arrow-right {
  right: 3.25rem;
}

.nav-arrow:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  transform: translateY(-50%) scale(1.06);
}

.nav-arrow:focus-visible {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

select:focus, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.nav-arrow:disabled {
  opacity: 0.72;
  cursor: default;
}

.present-exit,
.present-pos {
  grid-column: 2;
}

.present-exit {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  border-color: rgba(255,255,255,0.35);
  background: rgba(17, 24, 32, 0.96);
  color: #f2f5f7;
  box-shadow: 0 5px 16px rgba(0,0,0,0.3);
}
.present-exit svg { width: 1rem; height: 1rem; }

.present-pos {
  justify-self: center;
  align-self: end;
  font-size: 0.78rem;
  color: var(--muted);
  pointer-events: none;
  margin-bottom: 0.4rem;
}

.preview-body {
  min-height: 100%;
}

.preview-body.ppt-mode {
  min-height: 100%;
  display: flex;
}

.slide {
  display: none;
  width: 100%;
  min-height: 18rem;
  padding: 0.35rem 0.2rem 1rem;
  background: var(--theme-surface);
}

.slide.is-active {
  display: block;
}

.preview-frame.layout-landscape:has(#preview.ppt-mode) .slide {
  aspect-ratio: 16 / 9;
  min-height: 0;
}

.preview-frame.layout-portrait:has(#preview.ppt-mode) .slide {
  width: min(100%, 22rem);
  aspect-ratio: 9 / 16;
  min-height: 0;
  margin-inline: auto;
}

.image-export-frame .slide {
  padding: 18mm 16mm;
}

.ppt-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--muted);
}

body.is-presenting {
  overflow: hidden;
}

body.is-presenting .navbar,
body.is-presenting .toolbar,
body.is-presenting .site-footer,
body.is-presenting .pane-editor,
body.is-presenting .pane-head {
  display: none !important;
}

body.is-presenting .workspace {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: block;
  padding: 0;
  background: transparent;
}

body.is-presenting .pane-preview,
body.is-presenting .preview-stage {
  height: 100%;
  min-height: 100%;
}

@media (max-width: 760px) {
  body {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .navbar { align-items: center; flex-direction: row; padding: 0.7rem 1rem; }
  .brand-caption { display: none; }
  .mode-tab { min-width: auto; padding-inline: 0.65rem; }
  .toolbar { padding: 0.8rem 1rem; }
  .toolbar-file { width: 100%; }
  .toolbar-export { margin-left: 0; }
  .workspace {
    width: 100%;
    flex: 0 0 auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 1rem;
    padding: 0.9rem 1rem 1rem;
    overflow: visible;
  }

  .pane-editor {
    min-height: 27rem;
    grid-template-rows: auto minmax(14rem, 1fr) auto;
  }

  .pane-preview { min-height: 25rem; }

  .preview-stage {
    min-height: 22rem;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .preview-frame {
    grid-column: 1;
    width: 100%;
    padding: 0.85rem;
  }

  .preview-frame:has(#preview.ppt-mode) { padding-inline: 0.85rem; }

  .nav-arrow { width: 2.5rem; height: 2.5rem; }
  .nav-arrow-left { left: 0.4rem; }
  .nav-arrow-right { right: 0.4rem; }
}

body.is-presenting .preview-stage {
  grid-template-columns: 4.5rem 1fr 4.5rem;
  gap: 0;
}

body.is-presenting .preview-frame {
  min-height: 100%;
  border: 0;
  box-shadow: none;
  padding: 7vh 4vw 8vh;
}

body.is-presenting .preview-frame:has(#preview.ppt-mode) {
  padding: 7vh 4vw 8vh;
}

body.is-presenting .nav-arrow {
  width: 3.1rem;
  height: 3.1rem;
  font-size: 1.9rem;
  z-index: 45;
}

body.is-presenting .present-exit {
  position: fixed;
  top: 1rem;
  right: 1.1rem;
  z-index: 50;
  display: inline-flex !important;
}

body.is-presenting .present-pos {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: block !important;
  color: inherit;
  opacity: 0.7;
}

body.is-presenting .slide.is-active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
  padding: 0;
}

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

@media (max-width: 900px) {
  body {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .workspace {
    width: 100%;
    flex: 0 0 auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    overflow: visible;
  }
}

@media (max-width: 520px) {
  .navbar { align-items: stretch; flex-direction: column; gap: 0.65rem; padding: 0.65rem 0.8rem; }
  .navbar-actions { width: 100%; flex-direction: column; align-items: stretch; gap: 0.3rem; }
  .guide-link { display: none; }
  .navbar-actions .mode-tabs { width: 100%; }
  .mode-tab { flex: 1 1 0; gap: 0.35rem; padding-inline: 0.35rem; font-size: 0.7rem; }
  .mode-tab svg { width: 0.95rem; height: 0.95rem; }
  .toolbar { gap: 0.75rem; padding: 0.75rem 0.8rem; }
  .toolbar-file input { width: 100%; max-width: 100%; }
  .toolbar-actions { width: 100%; }
  .action-row { flex-wrap: wrap; }
  .toolbar-actions .action-row .btn { flex: 1 1 auto; }
  .toolbar-theme, .toolbar-font { flex: 1 1 calc(50% - 0.5rem); min-width: 0; }
  .toolbar-theme select, .toolbar-font select { width: 100%; }
  .toolbar-export { width: 100%; justify-content: flex-end; }
  .workspace { padding-inline: 0.8rem; }
  .pane-head { gap: 0.4rem; }
  .editor-head-actions { max-width: 58%; }
  .editor-head-actions .status { max-width: 100%; }
  .ai-prompt-form { flex-direction: row; align-items: stretch; }
  #enrich-prompt { min-height: 3.1rem; }
  .ai-run-btn { align-self: stretch; min-height: 3.1rem; }
}

@media (max-width: 380px) {
  .ai-prompt-form { flex-direction: column; }
  .ai-run-btn { align-self: flex-end; min-height: 2.35rem; }
  .action-row .btn { padding-inline: 0.55rem; font-size: 0.75rem; }
}
