: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: "Space Grotesk", "Segoe UI", 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: var(--nav);
  color: var(--nav-ink);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 1;
}

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

.brand-mark {
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.brand-sub {
  border-left: 1px solid var(--line);
  color: #aeb9c4;
  font-size: 0.77rem;
  padding-left: 0.65rem;
  letter-spacing: 0.06em;
}

.mode-tabs {
  display: flex;
  gap: 0.15rem;
  padding: 0.2rem;
  background: #19212b;
  border: 1px solid var(--line);
}

.mode-tab {
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  padding: 0.45rem 0.9rem;
  transition: 160ms ease;
}

.mode-tab.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.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: #1b232d;
  position: relative;
  z-index: 1;
}

.toolbar-group { display: flex; flex-direction: column; gap: 0.35rem; }
.toolbar-label { color: #7f8d9b; font-size: 0.63rem; font-weight: 700; letter-spacing: 0.12em; 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.43rem 0.55rem;
  min-height: 2.1rem;
  border-radius: 3px;
}

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

.btn {
  font: inherit;
  font-size: 0.86rem;
  border: 1px solid #3b4856;
  background: #202a35;
  color: var(--ink);
  padding: 0.42rem 0.8rem;
  min-height: 2.1rem;
  cursor: pointer;
  border-radius: 3px;
  transition: 160ms ease;
}

.btn:hover {
  border-color: #718092;
  background: #293542;
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.btn-accent:hover {
  filter: brightness(1.05);
}

.btn-tiny {
  min-height: 1.7rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
}

.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;
}

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

.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-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b8c3cd;
}

.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); }

#md-input {
  flex: 1;
  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.9rem/1.6 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);
}

.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;
}

.nav-arrow {
  align-self: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid #3b4856;
  border-radius: 999px;
  background: #202a35;
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.nav-arrow:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

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

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

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

.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;
}

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

.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 .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) {
  .navbar { align-items: flex-start; flex-direction: column; padding: 0.85rem 1rem; }
  .toolbar { padding: 0.8rem 1rem; }
  .toolbar-file { width: 100%; }
  .toolbar-export { margin-left: 0; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); padding: 0.9rem 1rem 1rem; }
}

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 .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) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }

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

  .mode-tabs {
    justify-content: flex-end;
  }
}
