/* RodmanSlides — visuals adapted from RodmanWord with PowerPoint-orange theme. */

:root {
  --primary: #b7472a;
  --primary-dark: #8b3520;
  --primary-light: #d05c3d;
  --tab-active: #ffffff;
  --tab-inactive: #f3f3f3;
  --ribbon-bg: #f3f3f3;
  --ribbon-border: #d6d6d6;
  --workspace-bg: #e6e6e6;
  --pane-bg: #f3f3f3;
  --pane-border: #d6d6d6;
  --text: #222;
  --muted: #666;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  --status-bg: #b7472a;
  --status-fg: #fff;
  --hover: rgba(183, 71, 42, 0.1);
  --active: rgba(183, 71, 42, 0.2);
  --selection: #ffd1c2;
  --slide-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);

  /* Slide-stage theme tokens (set by themes.applyToStage) */
  --slide-bg: #ffffff;
  --slide-primary: var(--primary);
  --slide-accent: #1f6fb2;
  --slide-title: #1a1a1a;
  --slide-body: #333333;
  --slide-font-heading: "Calibri Light", "Segoe UI", -apple-system, sans-serif;
  --slide-font-body: Calibri, "Segoe UI", -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--workspace-bg);
  overflow: hidden;
}

body {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  height: 100vh;
}

/* Title bar ----------------------------------------------------------------- */
.title-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 36px;
  padding: 5px 12px;
  background: var(--primary);
  color: #fff;
  flex-shrink: 0;
  user-select: none;
}

.rodmanoffice-back {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  color: inherit; text-decoration: none;
  font-size: 12px; font-weight: 500;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
}
.rodmanoffice-back:hover { background: rgba(255, 255, 255, 0.25); }
.rodmanoffice-back svg { display: block; }

.app-brand {
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.app-logo {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  background: #fff;
  color: var(--primary);
  border-radius: 4px;
  font-weight: 800; font-size: 13px;
  flex-shrink: 0;
}
.app-title { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.doc-title {
  background: transparent; border: 1px solid transparent;
  color: inherit; font-size: 13px; font-weight: 600;
  padding: 2px 6px; border-radius: 3px;
  width: 280px; max-width: 44vw;
}
.doc-title:hover { border-color: rgba(255, 255, 255, 0.3); }
.doc-title:focus { outline: none; border-color: rgba(255, 255, 255, 0.7); background: rgba(255,255,255,0.08); }
.app-subtitle {
  font-size: 11px; opacity: 0.85; padding-left: 6px;
}

.title-actions {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
  flex-shrink: 0;
}

/* Document tabs — between the presentation name and the title actions.
   Sized so the header height never grows past the app logo. */
.doc-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.doc-tabs::-webkit-scrollbar { height: 0; width: 0; }
.doc-tab {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  height: 24px;
  max-width: 160px;
  padding: 0 2px 0 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid transparent;
  border-radius: 4px 4px 0 0;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.doc-tab:hover { background: rgba(255, 255, 255, 0.2); }
.doc-tab.active { background: rgba(255, 255, 255, 0.28); font-weight: 600; }
.doc-tab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-tab-close {
  flex-shrink: 0;
  width: 16px; height: 16px; line-height: 14px;
  padding: 0;
  border: 0; border-radius: 2px;
  background: transparent; color: inherit;
  font-size: 11px; cursor: pointer; opacity: 0.6;
}
.doc-tab-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.3); }
.doc-tab-new {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  padding: 0;
  border: 0; border-radius: 3px;
  background: rgba(255, 255, 255, 0.15); color: #fff;
  font-size: 15px; line-height: 1; cursor: pointer;
}
.doc-tab-new:hover { background: rgba(255, 255, 255, 0.28); }

/* New-presentation template gallery. */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.template-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px;
  border: 1px solid var(--border, #cbd2d8);
  border-radius: 6px;
  background: var(--panel, #fff);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.template-card:hover { border-color: var(--primary, #b7472a); }
.template-card .tpl-name { font-weight: 600; font-size: 13px; }
.template-card .tpl-summary { font-size: 12px; opacity: 0.7; }
.title-bar .ask-claude {
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border-radius: 3px;
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
}
.title-bar .ask-claude:hover,
.title-bar .ask-claude[aria-expanded="true"] { background: rgba(255, 255, 255, 0.28); }
.claude-panel {
  position: fixed;
  top: 44px;
  right: 12px;
  bottom: 16px;
  width: min(360px, calc(100vw - 24px));
  z-index: 1200;
  display: flex;
  flex-direction: column;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--ribbon-border);
  border-radius: 6px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
.claude-panel[hidden] { display: none !important; }
.claude-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.claude-panel-header button {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}
.claude-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.claude-panel-notice {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.4;
}
.claude-api-key-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.claude-api-key-row span {
  font-weight: 600;
}
.claude-api-key-row input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #fed7aa;
  border-radius: 4px;
  padding: 7px 8px;
  font: inherit;
  color: var(--text);
  background: #fff;
}
.claude-panel-intro {
  background: #fff1ec;
  border: 1px solid #f2c8ba;
  border-radius: 6px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.claude-panel-intro h3 {
  margin: 0;
  font-size: 14px;
  color: var(--primary-dark);
}
.claude-panel-intro p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
}
.claude-panel-label {
  margin-top: 4px !important;
  font-size: 11px !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.claude-panel-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.claude-panel-chips button {
  text-align: left;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--ribbon-border);
  border-radius: 14px;
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
}
.claude-panel-chips button:hover {
  background: var(--hover);
  border-color: var(--primary-light);
}
.claude-panel-output {
  margin: 0 12px 12px;
  padding: 10px 12px;
  border: 1px solid var(--ribbon-border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.claude-panel-output.status {
  color: var(--muted);
}
.claude-panel-output.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}
.claude-panel-input {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid var(--ribbon-border);
  background: var(--ribbon-bg);
}
.claude-panel-input textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  border: 1px solid var(--ribbon-border);
  border-radius: 4px;
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}
.claude-panel-input button {
  border: 0;
  border-radius: 4px;
  padding: 6px 14px;
  background: var(--primary);
  color: #fff;
}
.claude-panel-input button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.save-indicator {
  font-size: 12px; opacity: 0.85;
  padding: 0 8px;
}
.icon-btn {
  background: transparent; border: none; color: inherit;
  width: 30px; height: 28px; border-radius: 3px;
  cursor: pointer; display: grid; place-items: center;
  font-size: 14px; font-family: inherit;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.15); }

/* Tabs --------------------------------------------------------------------- */
.tabs {
  background: var(--primary);
  display: flex; padding: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-family: inherit; font-size: 13px;
  padding: 8px 18px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.tab.active {
  background: var(--tab-active);
  color: var(--text);
  border-bottom-color: var(--tab-active);
}

/* Ribbon ------------------------------------------------------------------- */
.ribbon {
  background: var(--ribbon-bg);
  border-bottom: 1px solid var(--ribbon-border);
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: visible;
}
.ribbon::-webkit-scrollbar { height: 6px; }
.ribbon::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
.ribbon > .group { display: none !important; }
.ribbon.collapsed { display: none; }

.ribbon-panel {
  display: none;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  row-gap: 4px;
  width: 100%;
  min-height: 88px;
  max-height: 280px;
  padding: 6px 8px;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
}
.ribbon-panel.active { display: flex; animation: panelIn 0.15s ease; }

@keyframes panelIn {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: translateY(0); }
}

.group {
  display: flex; flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--ribbon-border);
  padding: 4px 10px;
  min-width: 0;
  min-height: 76px;
  flex-shrink: 0;
}
.group-row {
  display: flex; align-items: center; gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.group-label {
  font-size: 11px; color: var(--muted);
  text-align: center; margin-top: 2px;
}

.ribbon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-family: inherit; font-size: 13px;
  padding: 4px 8px;
  min-width: 30px; height: 30px;
  border-radius: 3px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 4px;
  white-space: nowrap;
}
.ribbon-btn:hover { background: var(--hover); border-color: var(--ribbon-border); }
.ribbon-btn.active, .ribbon-btn:active {
  background: var(--active);
  border-color: var(--ribbon-border);
}
.ribbon-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ribbon-btn.wide { min-width: 90px; padding: 4px 10px; }

.select {
  font-family: inherit; font-size: 13px;
  height: 28px; padding: 2px 6px;
  min-width: 110px;
  border: 1px solid var(--ribbon-border);
  background: #fff; border-radius: 3px;
  color: var(--text);
}
.select.sm { width: auto; min-width: 56px; }

.color-input {
  width: 30px; height: 30px;
  border: 1px solid var(--ribbon-border);
  border-radius: 3px;
  padding: 0; background: #fff;
  cursor: pointer;
}

.ribbon-empty { color: var(--muted); font-size: 12px; padding: 6px 4px; }

.zoom-display { min-width: 48px; text-align: center; font-size: 12px; color: var(--muted); }

/* Theme strip (Design tab) */
.themes-group {
  flex: 1 1 620px;
  max-width: 100%;
}
.ribbon-panel[data-panel="transitions"] .group:first-child {
  flex: 1 1 420px;
  max-width: 100%;
}
#themeStrip,
#transitionStrip {
  max-width: 100%;
}
.theme-card {
  width: 88px; height: 54px;
  border: 1px solid var(--ribbon-border);
  border-radius: 4px;
  margin: 0;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.theme-card:hover { border-color: var(--primary); }
.theme-card.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(183,71,42,0.24); }
.theme-card .tc-bar {
  position: absolute; top: 6px; left: 6px; right: 6px; height: 4px;
  border-radius: 2px;
}
.theme-card .tc-block {
  position: absolute; left: 6px; right: 6px; height: 8px;
  border-radius: 2px;
}
.theme-card .tc-name {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.92);
  font-size: 10px; padding: 2px 4px;
  border-top: 1px solid var(--ribbon-border);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Transition strip */
.transition-card {
  width: 78px; height: 52px;
  border: 1px solid var(--ribbon-border);
  border-radius: 4px;
  margin: 0;
  cursor: pointer;
  background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}
.transition-card:hover { border-color: var(--primary); }
.transition-card.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(183,71,42,0.24); }
.transition-card .tc-icon { font-size: 18px; margin-bottom: 2px; }

/* Workspace = three-pane: slide list | editor | (notes or sorter overlay) */
.workspace {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 0;
  background: var(--workspace-bg);
  position: relative;
}
.workspace.with-notes {
  grid-template-columns: 200px 1fr 280px;
}

/* Slide list pane */
.slide-list-pane {
  background: var(--pane-bg);
  border-right: 1px solid var(--pane-border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.slide-list {
  flex: 1; overflow-y: auto;
  padding: 10px 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.slide-list-item {
  position: relative;
  background: #fff;
  border: 1px solid var(--pane-border);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
  flex-shrink: 0;
}
.slide-list-item:hover { border-color: var(--primary-light); }
.slide-list-item.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(183, 71, 42, 0.18);
}
.slide-list-item .sli-num {
  position: absolute; left: -22px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--muted);
  width: 18px; text-align: right;
}
.slide-list-item .sli-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--slide-bg);
}
.slide-list-item .sli-thumb .thumb-stage {
  pointer-events: none;
}
.slide-list-item.hidden-slide .sli-thumb {
  opacity: 0.52;
}
.slide-list-item.hidden-slide .sli-num::after {
  content: " hidden";
  display: block;
  font-size: 9px;
  color: var(--primary);
}

.add-slide-btn {
  margin: 8px; padding: 8px;
  background: #fff;
  border: 1px dashed var(--pane-border);
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit; font-size: 12px; color: var(--muted);
}
.add-slide-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Editor area */
.editor-area {
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column;
  min-width: 0;
}
.editor-scroll {
  flex: 1;
  overflow: auto;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.stage-shadow {
  box-shadow: var(--slide-shadow);
  background: #fff;
  border-radius: 2px;
  /* Width/height set by JS based on zoom */
}
.stage {
  width: 1280px; height: 720px;
  position: relative;
  overflow: hidden;
  transform-origin: top left;
  background: var(--slide-bg);
}
.stage-shadow.view-grayscale .stage {
  filter: grayscale(1);
}
.stage-shadow.view-bw .stage {
  filter: grayscale(1) contrast(1.8);
}
.view-overlay-layer {
  position: absolute;
  inset: 0;
  z-index: 900;
  pointer-events: none;
}
.view-gridlines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(183, 71, 42, 0.18) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(183, 71, 42, 0.18) 1px, transparent 1px);
  background-size: 80px 80px;
}
.view-guide {
  position: absolute;
  background: rgba(59, 130, 246, 0.75);
}
.view-guide.v-50 { left: 50%; top: 0; width: 1px; height: 100%; }
.view-guide.h-50 { left: 0; top: 50%; width: 100%; height: 1px; }
.view-guide.v-33 { left: 33.333%; top: 0; width: 1px; height: 100%; opacity: 0.45; }
.view-guide.v-67 { left: 66.667%; top: 0; width: 1px; height: 100%; opacity: 0.45; }
.view-guide.h-33 { left: 0; top: 33.333%; width: 100%; height: 1px; opacity: 0.45; }
.view-guide.h-67 { left: 0; top: 66.667%; width: 100%; height: 1px; opacity: 0.45; }
.view-ruler {
  position: absolute;
  background-color: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.65);
}
.view-ruler.top {
  left: 0;
  top: 0;
  width: 100%;
  height: 22px;
  background-image: linear-gradient(to right, rgba(15, 23, 42, 0.55) 1px, transparent 1px);
  background-size: 80px 100%;
}
.view-ruler.left {
  left: 0;
  top: 0;
  width: 22px;
  height: 100%;
  background-image: linear-gradient(to bottom, rgba(15, 23, 42, 0.55) 1px, transparent 1px);
  background-size: 100% 80px;
}

.slide-element {
  user-select: none;
  touch-action: none;
  cursor: move;
}
.slide-element.is-selected {
  outline: 1.5px dashed var(--primary);
  outline-offset: 1px;
}
/* Multi-select: secondary (non-primary) members get a thinner, dimmer
   outline so the primary stays distinguishable. */
.slide-element.is-selected:not(.is-primary) {
  outline-style: solid;
  outline-width: 1px;
  outline-color: rgba(183, 71, 42, 0.55);
}

/* Slide-thumb drag-to-reorder: source thumb fades, drop targets get
   a colored bar on the side the drop will land on. */
.slide-list-item { transition: opacity 80ms ease; }
.slide-list-item.is-dragging { opacity: 0.4; }
.slide-list-item.is-drop-before { box-shadow: inset 0 3px 0 0 var(--primary); }
.slide-list-item.is-drop-after  { box-shadow: inset 0 -3px 0 0 var(--primary); }

/* Image-format sliders in the Home ribbon. Compact two-up layout. */
.image-adjust-row { gap: 10px; }
label.adjust {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 10px; color: var(--muted);
  font-family: inherit;
}
label.adjust input[type=range] {
  width: 92px; height: 16px; accent-color: var(--primary);
}
label.adjust select {
  height: 28px;
  min-width: 110px;
  padding: 2px 6px;
  border: 1px solid var(--ribbon-border);
  border-radius: 3px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

/* Theme palette swatches next to the shape fill picker. */
.theme-swatches {
  display: grid;
  grid-template-columns: repeat(4, 14px);
  grid-auto-rows: 14px;
  gap: 3px;
}
.theme-swatch {
  width: 14px; height: 14px;
  border: 1px solid rgba(0,0,0,0.4);
  border-radius: 2px;
  cursor: pointer;
  padding: 0;
}
.theme-swatch:hover { transform: scale(1.15); }

/* Per-element animations played by present.js. Keep these as global
   keyframes so any rendering surface (editor preview, present mode,
   thumbs) can use them. */
@keyframes fadeIn       { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut      { from { opacity: 1; } to { opacity: 0; } }
@keyframes slideInLeft  { from { opacity: 0; transform: translateX(-60px); } to { opacity: 1; transform: translateX(0); } }
@keyframes zoomIn       { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse        { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.slide-element[data-kind="text"] .slide-text { cursor: text; }
.slide-element[data-kind="text"][contenteditable="true"] { cursor: text; }

.slide-text[contenteditable="true"] {
  outline: none;
  background: rgba(255, 255, 255, 0.05);
  cursor: text;
  user-select: text;
}

.resize-handle { z-index: 10; }

/* Notes pane */
.notes-pane {
  background: var(--pane-bg);
  border-left: 1px solid var(--pane-border);
  display: flex; flex-direction: column;
  padding: 10px;
}
.notes-label {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.notes-pane textarea {
  flex: 1;
  font-family: inherit; font-size: 13px;
  border: 1px solid var(--pane-border);
  border-radius: 3px;
  padding: 8px;
  resize: none;
  min-height: 120px;
}
.notes-pane textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

/* Slide sorter (overlays the editor area) */
.sorter-area {
  position: absolute; inset: 0;
  background: var(--workspace-bg);
  overflow: auto;
  padding: 24px;
  z-index: 5;
}
.sorter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.sorter-grid .slide-list-item {
  background: #fff;
}

/* Status bar */
.status-bar {
  background: var(--status-bg);
  color: var(--status-fg);
  display: flex; align-items: center;
  padding: 4px 12px;
  gap: 16px;
  font-size: 12px;
}
.status-bar .status-spacer { flex: 1; }

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  background: rgba(20, 20, 20, 0.38);
  padding: 20px;
}

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

.help-modal-card {
  width: min(560px, 92vw);
  max-height: min(520px, 86vh);
  display: flex;
  flex-direction: column;
  background: var(--pane-bg);
  color: var(--text);
  border: 1px solid var(--pane-border);
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.help-modal-card header,
.help-modal-card footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--pane-border);
}

.help-modal-card footer {
  justify-content: flex-end;
  border-top: 1px solid var(--pane-border);
  border-bottom: 0;
}

.help-modal-card h3 {
  margin: 0;
  font-size: 15px;
}

.help-modal-card header .icon-btn {
  margin-left: auto;
}

.help-modal-body {
  overflow: auto;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
}

.help-modal-body ul {
  margin: 0;
  padding-left: 18px;
}

.help-modal-body li + li {
  margin-top: 8px;
}

/* Present mode ------------------------------------------------------------- */
.present-overlay {
  position: fixed; inset: 0;
  background: var(--slide-bg, #000);
  display: grid; place-items: center;
  z-index: 1000;
  outline: none;
}
.present-stage-wrap {
  position: relative;
  width: 100vw; height: 100vh;
  overflow: hidden;
}
.present-stage {
  position: absolute; inset: 0;
  display: grid; place-items: center;
}
.present-stage > * {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  position: relative;
}
.present-stage[data-transition="fade"].entering   { animation: ptFade 0.4s ease forwards; }
.present-stage[data-transition="fade"].leave      { animation: ptFadeOut 0.4s ease forwards; }
.present-stage[data-transition="push"].entering   { animation: ptPushIn 0.4s ease forwards; }
.present-stage[data-transition="push"].leave      { animation: ptPushOut 0.4s ease forwards; }
.present-stage[data-transition="wipe"].entering   { animation: ptWipeIn 0.4s ease forwards; }
.present-stage[data-transition="wipe"].leave      { animation: ptFadeOut 0.4s ease forwards; }
.present-stage[data-transition="zoom"].entering   { animation: ptZoomIn 0.4s ease forwards; }
.present-stage[data-transition="zoom"].leave      { animation: ptZoomOut 0.4s ease forwards; }

@keyframes ptFade   { from { opacity: 0; } to { opacity: 1; } }
@keyframes ptFadeOut{ from { opacity: 1; } to { opacity: 0; } }
@keyframes ptPushIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes ptPushOut{ from { transform: translateX(0); } to { transform: translateX(-100%); } }
@keyframes ptWipeIn { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes ptZoomIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
@keyframes ptZoomOut{ from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(1.06); } }

.present-controls {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(20,20,20,0.78); color: #fff;
  border-radius: 999px; padding: 6px 12px;
  display: flex; align-items: center; gap: 12px;
  font-size: 13px;
  opacity: 0; transition: opacity 0.2s;
  z-index: 1001;
}
.present-overlay:hover .present-controls,
.present-overlay:focus .present-controls { opacity: 1; }
.present-controls .pc-btn {
  background: transparent; border: none; color: inherit;
  font-size: 18px; line-height: 1;
  cursor: pointer; padding: 4px 8px; border-radius: 4px;
}
.present-controls .pc-btn:hover { background: rgba(255,255,255,0.18); }

/* Print-to-PDF -------------------------------------------------------------- */
@media print {
  @page { size: 11in 6.1875in landscape; margin: 0; }
  body * { visibility: hidden; }
  .print-deck, .print-deck * { visibility: visible; }
  .print-deck {
    position: absolute; left: 0; top: 0; width: 100%;
  }
  .print-deck .print-slide {
    page-break-after: always;
    width: 1280px; height: 720px;
    transform-origin: top left;
    position: relative;
    overflow: hidden;
    background: var(--slide-bg);
  }
  .print-deck .print-slide:last-child { page-break-after: auto; }
}

/* Mobile / small screens --------------------------------------------------- */
@media (max-width: 720px) {
  body { font-size: 14px; }
  .title-bar {
    gap: 8px;
    padding: 5px 8px;
  }
  .app-subtitle,
  .save-indicator {
    display: none;
  }
  /* The present (▶) and help (?) icon buttons aren't useful on
     mobile (F5 / ? are keyboard-only shortcuts) and the cluster
     otherwise overflows the right edge of the title bar — hiding
     them makes room for the Ask Claude pill. Mirrors the Word
     title bar's iPhone treatment. */
  .title-bar .title-actions .icon-btn { display: none; }
  .doc-title {
    width: min(120px, 32vw);
    max-width: 32vw;
    font-size: 13px;
  }
  .tabs { touch-action: pan-x; }
  .title-actions { gap: 4px; }
  .title-bar .ask-claude { padding: 4px 8px; }
  .tab { padding: 8px 14px; font-size: 12px; }
  .ribbon { overflow: visible; }
  .ribbon-panel {
    flex-wrap: nowrap !important;
    align-items: center;
    align-content: center;
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: 52px;
    min-height: 0;
    padding: 2px 4px;
    gap: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    touch-action: pan-x;
  }
  .group {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    flex-shrink: 0;
    border-right: 1px solid var(--ribbon-border);
    padding: 2px 6px;
    gap: 2px;
    min-height: 0;
  }
  .group-row { display: contents; }
  .group-label { display: none; }
  .ribbon-btn {
    height: 32px; min-width: 32px;
    padding: 2px 6px;
    font-size: 12px;
    flex-shrink: 0;
  }
  .ribbon-btn.wide { min-width: 60px; padding: 2px 8px; }
  .select {
    height: 28px;
    font-size: 12px;
    min-width: 64px;
    max-width: 126px;
    padding: 1px 6px;
    flex-shrink: 0;
  }
  .select.sm { min-width: 50px; }
  .color-input {
    width: 32px; height: 32px;
    flex-shrink: 0;
  }
  label.adjust {
    font-size: 11px;
    flex-shrink: 0;
  }
  label.adjust input[type=range] { width: 72px; }
  label.adjust select {
    min-width: 90px;
    max-width: 118px;
    font-size: 12px;
  }
  .theme-card {
    width: 76px; height: 46px;
    flex-shrink: 0;
  }
  .transition-card {
    width: 72px; height: 46px;
    flex-shrink: 0;
  }
  .themes-group,
  .ribbon-panel[data-panel="transitions"] .group:first-child {
    flex: 0 0 auto;
    max-width: none;
  }
  .workspace { grid-template-columns: 1fr; }
  .workspace.with-notes {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 180px;
  }
  .slide-list-pane { display: none; }
  .editor-scroll { padding: 12px; }
  .notes-pane {
    border-left: 0;
    border-top: 1px solid var(--pane-border);
  }
  .claude-panel {
    top: 42px;
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
  }
}

/* Window-level drag-and-drop highlight. pointer-events:none is essential —
   the overlay must not become a drag target, or it would generate its own
   dragenter/dragleave storm. */
.drop-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(183, 71, 42, 0.12);
  z-index: 9000;
  pointer-events: none;
}
.drop-overlay.is-active { display: flex; }
.drop-overlay-card {
  border: 3px dashed var(--primary);
  border-radius: 14px;
  padding: 28px 44px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  text-align: center;
  min-width: 260px;
}
.drop-overlay-icon {
  font-size: 38px;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 8px;
}
.drop-overlay-title { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.drop-overlay-sub { font-size: 12px; opacity: 0.7; }

/* Clipart picker */
.clipart-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border, #cbd2d8);
}
.clipart-tab {
  background: transparent;
  border: none;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
  border-bottom: 2px solid transparent;
  color: var(--muted, #666);
}
.clipart-tab.active {
  color: inherit;
  border-bottom-color: var(--primary);
}
.clipart-status {
  font-size: 12px;
  margin: 8px 0;
  opacity: 0.75;
}
.clipart-status.error {
  color: #b91c1c;
  opacity: 1;
}
.clipart-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  min-height: 200px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
  background: #fafafa;
  border: 1px solid var(--border, #cbd2d8);
  border-radius: 4px;
}
.clipart-grid.icons-mode {
  grid-template-columns: repeat(8, 1fr);
}
.clipart-tile {
  aspect-ratio: 1;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border, #cbd2d8);
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.clipart-tile:hover {
  border-color: var(--primary);
}
.clipart-tile.selected {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.clipart-tile.broken {
  opacity: 0.3;
}
.clipart-tile img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.clipart-attribution {
  font-size: 12px;
  margin-top: 8px;
  padding: 6px 8px;
  background: #fafafa;
  border-radius: 3px;
}
