/* ==========================================================================
   ao-writer.css — Around OECTA Writer Studio Stylesheet
   Phase 3 Writer Programme — Google Sites model (Basic / Advanced canvas).
   M1 2026-09-27: rebuilt to the Figma design of record (page 353:2, polish
   frames 389:2 / 391:2, design-lead pass): navy header, tonal surfaces in
   place of sectioning 1px borders (No-Line rule), floating white pill
   toolbars, amber selection ring, 2-col tonal tray, 420px assistant sheet,
   440px Details dialog, phone bottom sheets, tablet icon rail, IBM Plex Mono
   for times / URLs / counts. Two deliberate deviations from the frames, both
   platform rulings: the Publish CTA keeps dark ink on amber (the frames'
   white fails AA at ~2.2:1) and every control keeps a ≥44px hit area.
   The --aow-* aliases fall back to literals so the vendored member copy (M3)
   renders without console.css.
   ========================================================================== */

/* Declared on #ao-writer (not :root) so the .oecta-console class the Writer puts on its own root
   actually remaps the console tokens, and the M3 member copy resolves the literal fallbacks
   (review, 2026-09-28). Every Writer surface lives inside #ao-writer, so the vars inherit. */
#ao-writer {
  --aow-z: var(--oecta-z-overlay, 9000);
  --aow-head-h: 56px;
  --aow-tray-w: 260px;
  --aow-side-w: 320px;
  --aow-assistant-w: 420px;
  /* Console-layer tokens with member-safe fallbacks */
  --aow-navy: var(--con-heat-peak, var(--oecta-primary-container, #204164));
  --aow-accent: var(--accent, var(--oecta-accent, #f39c12));
  --aow-surface: var(--surface, #f8fafc);
  --aow-card: var(--surface-card, #ffffff);
  --aow-line: var(--surface-line, #e2e8f0);
  --aow-tonal: var(--con-heat-base, #f1f5f9);
  --aow-ink: var(--ink, #0f172a);
  --aow-ink-2: var(--ink-2, #475569);
  --aow-muted: var(--ink-mute, #64748b);
  --aow-on-brand: var(--con-on-brand, #ffffff);
  --aow-ok: var(--con-dot-ok, #16a34a);
  --aow-error: var(--oecta-error, #ba1a1a);
  --aow-error-soft: var(--oecta-error-soft, #fee2e2);
  --aow-mono: var(--con-mono, 'IBM Plex Mono', ui-monospace, Menlo, monospace);
  --aow-shadow-pill: 0 4px 8px rgba(32, 65, 100, 0.06);
  --aow-shadow-card: 0 10px 15px rgba(32, 65, 100, 0.08);
  --aow-shadow-sheet: 0 16px 24px rgba(32, 65, 100, 0.12);
  /* legacy aliases still referenced by inline styles in older shell markup */
  --aow-primary: var(--aow-navy);
  --aow-bg: var(--aow-surface);
  --aow-border: var(--aow-line);
  --aow-border-strong: var(--aow-line);
}

#ao-writer {
  position: fixed;
  inset: 0;
  z-index: var(--aow-z);
  display: flex;
  flex-direction: column;
  background: var(--aow-surface);
  color: var(--aow-ink);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

#ao-writer[hidden] {
  display: none !important;
}

/* ==========================================================================
   WRITER HEADER — navy bar, on-brand controls (frame 383/398)
   ========================================================================== */

.aow-head {
  height: var(--aow-head-h);
  background: var(--aow-navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  gap: 12px;
}

.aow-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.aow-back-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}

.aow-back-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--aow-on-brand);
}

.aow-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.aow-doc-title {
  font-family: Inter, sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--aow-on-brand);
  max-width: 420px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.aow-doc-status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.75);
}

/* Status pill: tonal pill + state dot; time reads in mono */
.aow-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--aow-on-brand);
}

.aow-status-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: #cbd5e1;
}

.aow-status-chip[data-status="published"]::before { background: var(--aow-ok); }
.aow-status-chip[data-status="scheduled"]::before { background: var(--aow-accent); }
.aow-status-chip[data-status="review"]::before { background: #38bdf8; }

.aow-version-chip {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--aow-on-brand);
}

.aow-autosave-indicator {
  font-family: var(--aow-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s ease;
}

.aow-autosave-indicator.is-dirty { color: #fcd34d; }
.aow-autosave-indicator.is-saving { color: #7dd3fc; }

/* Live co-editing peers (M1): overlapping initial circles + a quiet note */
.aow-peer-pills {
  display: inline-flex;
  align-items: center;
  padding-left: 4px;
}

.aow-peer-pills[hidden] { display: none !important; }

.aow-peer-pill {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--aow-card);
  border: 2px solid var(--aow-navy);
  color: #204164;
  font-family: Manrope, Inter, sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: -8px;
  box-shadow: 0 1px 3px rgba(16, 42, 67, 0.25);
}

.aow-peer-pill:first-child { margin-left: 0; }

.aow-peer-note {
  margin-left: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
}

.aow-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* On-brand secondary buttons: transparent + light border on the navy bar */
.aow-head-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: var(--aow-on-brand);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.aow-head-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.45);
}

.aow-head-btn.is-active {
  background: var(--aow-card);
  color: var(--aow-navy);
  border-color: var(--aow-card);
}

.aow-head-btn.aow-share-btn { font-weight: 700; }

/* Save = quiet on-brand secondary, shown only once something changed (Batch 2.1) */
.aow-cta-btn {
  background: transparent;
  color: var(--aow-on-brand);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.aow-cta-btn:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.45); }
.aow-cta-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.aow-cta-btn[hidden] { display: none !important; }

/* The ONE primary: amber gradient, dark ink (frames' white-on-amber fails AA — ruling) */
.aow-publish-btn {
  background: linear-gradient(162deg, #f39c12, #fea520);
  color: #3a2600;
  border: none;
  border-radius: 8px;
  padding: 9px 20px;
  min-height: 38px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(243, 156, 18, 0.35);
  transition: filter 0.15s ease, transform 0.15s ease;
}

.aow-publish-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.aow-publish-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; filter: none; }
.aow-publish-btn[hidden] { display: none !important; }

/* ==========================================================================
   WRITER BODY LAYOUT (Tray + Canvas + Sidebar) — tonal separation, no lines
   ========================================================================== */

.aow-body {
  flex: 1 1 auto;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Left tray: tonal rail, 2-col grid of white tiles (frame 383) */
.aow-tray {
  width: var(--aow-tray-w);
  background: var(--aow-tonal);
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: min-content;
  align-content: start;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 16px;
  gap: 8px;
}

.aow-tray-group-title {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--aow-muted);
  margin: 10px 2px 0 2px;
}

.aow-tray-group-title:first-child { margin-top: 0; }

.aow-tile {
  background: var(--aow-card);
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 68px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  cursor: grab;
  user-select: none;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--aow-ink-2);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.aow-tile:hover {
  border-color: var(--aow-navy);
  box-shadow: var(--aow-shadow-pill);
  transform: translateY(-1px);
}

.aow-tile:active { cursor: grabbing; }

.aow-tile-ico {
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
}

/* A section members cannot see yet (video / embed, until the as-built reader — M0): shown, not insertable. */
.aow-tile.is-disabled,
.aow-tile.is-disabled:hover {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

/* Import / paste entry lives in the tray flow on phones via the sheet; nothing extra here. */

/* Details: plain hints, and the "reaches no one" warning under the audience (M0). */
.aow-prop-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--aow-muted);
}

.aow-reach-warning {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--aow-error-soft);
  color: var(--aow-error);
}

/* Inline control errors (embed / video URL refusals) — same recipe */
.aow-prop-error {
  margin: 6px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--aow-error-soft);
  color: var(--aow-error);
}

.aow-prop-error[hidden] { display: none !important; }

/* Center canvas */
.aow-canvas-wrap {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px;
}

.aow-canvas-card {
  width: 100%;
  max-width: 800px;
  background: var(--aow-card);
  border-radius: 12px;
  box-shadow: var(--aow-shadow-card);
  min-height: 480px;
  padding: 32px 48px 48px;
  display: flex;
  flex-direction: column;
  position: relative;
  flex-shrink: 0;
  height: auto;
}

.aow-title-input {
  font-family: Manrope, Inter, sans-serif;
  font-weight: 800;
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--aow-navy);
  border: none;
  outline: none;
  width: 100%;
  padding: 0;
  margin: 0 0 10px 0;
  background: transparent;
  resize: none;
  overflow: hidden;
  box-sizing: border-box;
  display: block;
}

.aow-title-input::placeholder { color: #94a3b8; }

.aow-subtitle-input {
  font-family: var(--oecta-font-body, Inter, system-ui, sans-serif);
  font-size: 1.15rem;
  line-height: 1.45;
  color: var(--aow-muted);
  border: none;
  outline: none;
  width: 100%;
  padding: 0;
  margin: 0 0 24px 0;
  background: transparent;
  resize: none;
  overflow: hidden;
  box-sizing: border-box;
  display: block;
}

.aow-subtitle-input::placeholder { color: #94a3b8; }

.aow-sections-mount {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#aow-gjs-canvas,
.gjs-editor,
.gjs-editor-cont,
.aow-canvas-card .gjs-cv-canvas,
.aow-canvas-card .gjs-frame-wrapper,
.aow-canvas-card .gjs-frame {
  background: transparent !important;
  background-color: transparent !important;
}

#aow-gjs-canvas {
  width: 100%;
  min-height: 480px;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

.aow-canvas-card .gjs-cv-canvas {
  position: relative !important;
  background-color: transparent !important;
  width: 100% !important;
  height: auto !important;
  min-height: 480px !important;
  top: 0 !important;
  bottom: auto !important;
  left: 0 !important;
  overflow: visible !important;
}

.aow-canvas-card .gjs-frame-wrapper {
  background: transparent !important;
  position: relative !important;
  width: 100% !important;
  height: auto !important;
  overflow: visible !important;
}

.aow-canvas-card .gjs-frame {
  position: relative !important;
  width: 100% !important;
  display: block !important;
  border: none !important;
  overflow: hidden !important;
}

.aow-section-item {
  border-radius: 8px;
  transition: box-shadow 0.15s ease, background 0.15s ease;
  cursor: pointer;
}

.aow-section-item:hover {
  outline: 2px dashed rgba(243, 156, 18, 0.4);
}

.aow-section-item.is-selected {
  outline: 2px solid var(--aow-accent);
  box-shadow: 0 0 0 4px rgba(243, 156, 18, 0.1);
}

.aow-drop-target {
  min-height: 44px;
  background: #f4f3f6;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--aow-muted);
  transition: all 0.2s ease;
}

.aow-drop-target.is-active,
.aow-dragging-tile .aow-drop-target {
  background: rgba(243, 156, 18, 0.1);
  color: #b45309;
}

/* Right side card: white full-height panel, tonal separation (frame 388/384) */
.aow-side {
  width: var(--aow-side-w);
  background: var(--aow-card);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 24px;
}

.aow-side-header { margin-bottom: 16px; }

.aow-side-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--aow-tonal);
  color: var(--aow-ink-2);
  display: inline-block;
  margin-bottom: 4px;
}

.aow-side-title {
  font-family: Manrope, Inter, sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  color: var(--aow-navy);
  margin: 0 0 12px 0;
}

.aow-prop-empty {
  font-size: 0.86rem;
  color: var(--aow-muted);
  line-height: 1.5;
}

.aow-prop-empty p { margin: 6px 0 0 0; }

.aow-prop-field { margin-bottom: 16px; }

.aow-prop-field label {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--aow-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.aow-prop-input,
.aow-prop-select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--aow-line);
  border-radius: 6px;
  padding: 8px 11px;
  min-height: 38px;
  font-size: 16px;   /* never smaller — iOS zoom rule */
  font-family: inherit;
  color: var(--aow-ink);
  background: var(--aow-card);
  transition: border-color 0.15s ease;
}

.aow-prop-input:focus,
.aow-prop-select:focus {
  border-color: var(--aow-navy);
  outline: none;
}

/* Two short inputs side by side (event month / day) */
.aow-prop-row2 {
  display: flex;
  gap: 8px;
}

.aow-prop-row2 .aow-prop-input { width: 50%; }

/* Segmented choice groups: tonal track, white active segment (frame 391) */
.aow-prop-btn-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  background: var(--aow-tonal);
  padding: 2px;
  border-radius: 6px;
}

.aow-prop-btn {
  flex: 1 1 auto;
  padding: 7px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--aow-ink-2);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.aow-prop-btn:hover { background: rgba(255, 255, 255, 0.7); }

.aow-prop-btn.is-active {
  background: var(--aow-card);
  color: var(--aow-navy);
  border-color: var(--aow-line);
}

/* Action buttons that live OUTSIDE a segmented track (upload, add link, use-first-photo) —
   never the buttons inside a .aow-prop-btn-group, whose track styling must win */
.aow-prop-field > .aow-prop-btn,
.aow-prop-field > div:not(.aow-prop-btn-group) > .aow-prop-btn {
  background: var(--aow-card);
  border: 1px solid var(--aow-line);
  color: var(--aow-navy);
}

.aow-prop-field > .aow-prop-btn:hover,
.aow-prop-field > div:not(.aow-prop-btn-group) > .aow-prop-btn:hover {
  background: var(--aow-tonal);
}

.aow-prop-btn--upload {
  width: 100%;
  min-height: 38px;
}

/* Move up / down — first row of every section card (phones rely on it) */
.aow-move-row { margin-bottom: 16px; }

/* Event picker: search + white results dropdown (design-lead treatment) */
.aow-event-search {
  background: var(--aow-tonal) !important;
}

.aow-event-results {
  margin-top: 4px;
  background: var(--aow-card);
  border-radius: 8px;
  box-shadow: var(--aow-shadow-pill);
  overflow: hidden;
  max-height: 260px;
  overflow-y: auto;
}

.aow-event-results[hidden] { display: none !important; }

.aow-event-result {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease;
}

.aow-event-result:hover { background: var(--aow-tonal); }

.aow-event-result-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--aow-ink);
}

.aow-event-result-meta {
  font-family: var(--aow-mono);
  font-size: 0.72rem;
  color: var(--aow-muted);
}

.aow-event-result-empty {
  padding: 12px;
  font-size: 0.82rem;
  color: var(--aow-muted);
}

/* Advanced Designer Pane */
#aow-adv { display: none; }
.aow--advanced #aow-side-props { display: none; }
.aow--advanced #aow-adv { display: block; }

.aow-adv-head {
  font-family: Manrope, Inter, sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--aow-navy);
  margin-bottom: 12px;
}

/* ==========================================================================
   GrapesJS UI overrides — amber ring + floating white pill toolbars (391)
   ========================================================================== */

.gjs-badge { display: none !important; }

.gjs-highlighter {
  border: 1px dashed rgba(243, 156, 18, 0.5) !important;
  outline: none !important;
  box-shadow: none !important;
}

.gjs-selection {
  border: 2px solid var(--aow-accent) !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.1) !important;
  border-radius: 8px !important;
}

.gjs-editing .gjs-selection,
.gjs-editing .gjs-highlighter { opacity: 0 !important; }

/* The engine hides both floating toolbars with an INLINE display — the forced flex below must
   never override that, or a closed toolbar floats forever ([hidden]-loses-to-display lesson). */
.gjs-toolbar[style*="none"],
.gjs-rte-toolbar[style*="none"] {
  display: none !important;
}

/* Section-actions toolbar: floating white pill of round icon buttons */
.gjs-toolbar {
  background: var(--aow-card, #fff) !important;
  border-radius: 999px !important;
  padding: 4px !important;
  box-shadow: var(--aow-shadow-pill), 0 1px 3px rgba(16, 42, 67, 0.12) !important;
  display: flex !important;
  align-items: center !important;
  gap: 2px !important;
  z-index: 100 !important;
  transform: translateY(-8px) !important;
}

.aow-tlb-act {
  color: var(--aow-ink-2, #475569) !important;
  padding: 0 !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 34px !important;
  height: 34px !important;
  border-radius: 999px !important;
  transition: background 0.12s ease, color 0.12s ease !important;
}

.aow-tlb-act:hover {
  background: var(--aow-tonal, #f1f5f9) !important;
  color: var(--aow-navy, #204164) !important;
}

.aow-tlb-act.aow-tlb-del:hover {
  background: var(--aow-error-soft, #fee2e2) !important;
  color: var(--aow-error, #ba1a1a) !important;
}

/* Inline RTE toolbar: the same white pill language (replaces the dark bar) */
.gjs-rte-toolbar {
  background: var(--aow-card, #fff) !important;
  border: none !important;
  border-radius: 999px !important;
  box-shadow: var(--aow-shadow-pill), 0 2px 6px rgba(16, 42, 67, 0.14) !important;
  padding: 4px !important;
  display: flex !important;
  align-items: center !important;
  gap: 2px !important;
  z-index: 1000 !important;
  transform: translateY(-12px) !important;
  pointer-events: auto !important;
}

.gjs-rte-action {
  color: var(--aow-ink-2, #475569) !important;
  fill: var(--aow-ink-2, #475569) !important;
  border-radius: 999px !important;
  padding: 0 6px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  font-family: Inter, system-ui, sans-serif !important;
  min-width: 34px !important;
  height: 34px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  transition: all 0.12s ease !important;
}

.gjs-rte-action:hover {
  background: var(--aow-tonal, #f1f5f9) !important;
  color: var(--aow-navy, #204164) !important;
}

.gjs-rte-action:active,
.gjs-rte-action.gjs-rte-active {
  background: var(--aow-tonal, #f1f5f9) !important;
  color: var(--aow-navy, #204164) !important;
  box-shadow: inset 0 0 0 2px var(--aow-accent, #f39c12) !important;
}

/* ==========================================================================
   AI ASSISTANT SIDE SHEET (#aow-assistant) — 420px, tonal head, ghost actions
   (frames 388:2 / 390:2); Vertex Montréal northamerica-northeast1.
   ========================================================================== */

#aow-assistant {
  width: var(--aow-assistant-w);
  max-width: 100vw;
  background: var(--aow-card);
  display: flex;
  flex-direction: column;
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: calc(var(--aow-z) + 10);
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: var(--aow-shadow-sheet);
}

#aow-assistant.is-open { transform: translateX(0); }

.aow-asst-head {
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--aow-surface);
}

.aow-asst-title {
  font-family: Manrope, Inter, sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--aow-navy);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.aow-asst-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: #15803d;
  background: #dcfce7;
  padding: 2px 6px;
  border-radius: 4px;
}

.aow-asst-close {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--aow-muted);
  border-radius: 6px;
  padding: 4px;
}

.aow-asst-close:hover {
  background: var(--aow-tonal);
  color: var(--aow-navy);
}

.aow-asst-chat {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.aow-asst-msg {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--aow-ink);
}

.aow-asst-msg.user {
  background: var(--aow-tonal);
  align-self: flex-end;
  max-width: 85%;
  border-bottom-right-radius: 4px;
}

.aow-asst-msg.assistant {
  background: transparent;
  align-self: flex-start;
  max-width: 100%;
  padding: 0;
}

.aow-asst-msg.assistant.is-thinking { color: var(--aow-muted); font-style: italic; }
.aow-asst-msg.assistant.is-error { color: var(--aow-error); font-weight: 600; }

.aow-asst-sent-note {
  margin-top: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--aow-muted);
}

/* A drafted answer: white card preview + ghost action row */
.aow-asst-draft-preview {
  margin-top: 8px;
  background: var(--aow-card);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 2px 4px rgba(32, 65, 100, 0.04), 0 0 0 1px var(--aow-line);
  max-height: 260px;
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.6;
}

.aow-asst-draft-preview h2,
.aow-asst-draft-preview h3 {
  font-family: Manrope, Inter, sans-serif;
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--aow-navy);
  margin: 0 0 6px;
}

.aow-asst-draft-preview p { margin: 0 0 8px; }

.aow-asst-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.aow-asst-act-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #204164;
  cursor: pointer;
  transition: background 0.15s ease;
}

.aow-asst-act-btn:hover { background: var(--aow-tonal); }

/* Quick-action chips: borderless tonal pills in one scroll row */
.aow-asst-chips {
  padding: 8px 24px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  background: var(--aow-card);
  flex-shrink: 0;
}

.aow-chip-btn {
  background: var(--aow-tonal);
  border: none;
  border-radius: 999px;
  padding: 8px 11px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--aow-ink-2);
  cursor: pointer;
  white-space: nowrap;
}

.aow-chip-btn:hover { background: #e2e8f0; }
.aow-chip-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Attachment chips above the composer */
.aow-asst-attach-chips {
  padding: 6px 24px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--aow-card);
}

.aow-asst-attach-chips[hidden] { display: none !important; }

.aow-asst-img-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--aow-tonal);
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--aow-ink-2);
  max-width: 100%;
}

.aow-asst-img-chip img {
  width: 24px;
  height: 24px;
  object-fit: cover;
  border-radius: 4px;
}

.aow-asst-img-chip > span:not(.aow-asst-chip-ico) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.aow-asst-chip-x {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--aow-muted);
  font-size: 0.8rem;
  padding: 2px 4px;
  border-radius: 999px;
}

.aow-asst-chip-x:hover { color: var(--aow-error); }

/* Composer: tonal strip, no border-top */
.aow-asst-composer {
  padding: 12px 24px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--aow-surface);
  flex-shrink: 0;
}

.aow-asst-model {
  border: 1px solid var(--aow-line);
  border-radius: 6px;
  background: var(--aow-card);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--aow-ink-2);
  padding: 6px;
  max-width: 130px;
}

.aow-asst-model[hidden] { display: none !important; }

.aow-asst-attach {
  background: transparent;
  border: none;
  font-size: 1.05rem;
  cursor: pointer;
  color: var(--aow-ink-2);
  border-radius: 6px;
  padding: 8px;
}

.aow-asst-attach:hover { background: var(--aow-tonal); color: var(--aow-navy); }
.aow-asst-attach:disabled { opacity: 0.5; cursor: not-allowed; }

.aow-asst-input {
  flex: 1 1 auto;
  border: 1px solid var(--aow-line);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  background: var(--aow-card);
}

.aow-asst-input:focus { border-color: var(--aow-navy); outline: none; }

.aow-asst-send {
  background: var(--aow-navy);
  color: var(--aow-on-brand);
  border: none;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
}

.aow-asst-send:disabled { opacity: 0.55; cursor: not-allowed; }

/* ==========================================================================
   DETAILS SLIDE-OUT SHEET (#aow-details) — 440px full-height dialog, flat
   sections, tonal link rows, "Publisher only" chip (frame 389:2)
   ========================================================================== */

#aow-details {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 100vw;
  background: var(--aow-card);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--aow-shadow-sheet);
}

#aow-details.is-open { transform: translateX(0); }

.aow-details-head {
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--aow-surface);
  flex-shrink: 0;
}

.aow-details-title {
  margin: 0;
  font-family: Manrope, Inter, sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--aow-navy);
  letter-spacing: -0.01em;
}

.aow-details-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--aow-muted);
  padding: 4px;
  border-radius: 6px;
  line-height: 1;
}

.aow-details-close:hover { color: var(--aow-navy); background: var(--aow-tonal); }

.aow-details-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.aow-cover-preview-box {
  margin-top: 8px;
  border-radius: 8px;
  overflow: hidden;
  max-height: 140px;
  background: var(--aow-tonal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.aow-cover-preview-box[hidden] { display: none !important; }

.aow-cover-preview-img {
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
}

/* Zones flatten to sections: heading row + content, tonal shift only where locked */
.aow-details-pub-zone,
.aow-details-collab-zone {
  background: transparent;
  border-radius: 0;
  padding: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.aow-pub-zone-header,
.aow-collab-zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: Manrope, Inter, sans-serif;
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--aow-navy);
  margin-bottom: 2px;
}

.aow-badge-locked {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--aow-tonal);
  color: var(--aow-ink-2);
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0;
}

.aow-badge-locked::before { content: "🔒"; font-size: 0.75rem; }

/* Locked rows stay VISIBLE, quiet and inert (Paul: visible, not hidden) */
.aow-details-pub-zone.is-locked > .aow-prop-field { opacity: 0.55; }
.aow-details-pub-zone.is-locked input { cursor: not-allowed; }

.aow-badge-collab {
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--aow-tonal);
  color: var(--aow-ink-2);
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0;
}

.aow-collab-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.aow-collab-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--aow-tonal);
  color: var(--aow-ink);
  font-size: 0.78rem;
  font-weight: 600;
}

.aow-collab-pill small { opacity: 0.75; font-weight: normal; }

.aow-collab-pill--owner { background: #e0f2fe; color: #0369a1; }
.aow-collab-pill--private { background: var(--aow-tonal); color: var(--aow-muted); }

.aow-btn-share-trigger {
  width: 100%;
  background: var(--aow-navy);
  color: var(--aow-on-brand);
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  font-family: inherit;
}

.aow-btn-share-trigger:hover { background: #17324d; }

/* Resource-links editor (M1): tonal rows that expand into stacked inputs */
.aow-links-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0;
}

.aow-link-row {
  display: grid;
  grid-template-columns: 1fr 40px;
  grid-template-areas: "label remove" "url remove" "note remove";
  gap: 6px 8px;
  align-items: center;
  background: var(--aow-tonal);
  border-radius: 6px;
  padding: 10px 12px;
}

.aow-link-row .aow-link-label { grid-area: label; }
.aow-link-row .aow-link-url { grid-area: url; font-family: var(--aow-mono); font-size: 0.82rem; }
.aow-link-row .aow-link-note { grid-area: note; }

.aow-link-row .aow-link-remove {
  grid-area: remove;
  flex: 0 0 auto;
  width: 40px;
  min-height: 40px;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--aow-muted);
  font-size: 0.9rem;
  cursor: pointer;
  align-self: center;
}

.aow-link-row .aow-link-remove:hover { color: var(--aow-error); background: rgba(255, 255, 255, 0.7); }

.aow-links-empty { margin: 4px 0; }

.aow-btn-add-link {
  width: 100%;
  min-height: 38px;
  background: var(--aow-card);
  border: 1px solid var(--aow-line);
  color: var(--aow-navy);
}

/* Knowledge flag + checkbox rows */
.aow-prop-checkbox-label {
  display: flex !important;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.84rem !important;
  font-weight: 600 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--aow-ink) !important;
  cursor: pointer;
}

.aow-prop-checkbox-label input {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  accent-color: var(--aow-navy);
  flex-shrink: 0;
}

/* ==========================================================================
   PHONE CHROME (M1): floating Add pill, tray bottom sheet + scrim,
   bottom-docked section card (frames 385/386)
   ========================================================================== */

.aow-tray-scrim {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(2, 43, 77, 0.42);
  z-index: 140;
}

.aow-phone-bar {
  display: none;
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 130;
}

.aow-phone-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  border-radius: 999px;
  padding: 0 16px 0 12px;
  background: var(--aow-navy);
  color: var(--aow-on-brand);
  border: none;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--aow-shadow-card);
}

/* ==========================================================================
   PREVIEW OVERLAY (#aow-preview)
   ========================================================================== */

#aow-preview {
  position: fixed;
  inset: 0;
  z-index: calc(var(--aow-z, 9000) + 20);
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
}

#aow-preview[hidden] { display: none !important; }

.aow-preview-bar {
  height: 56px;
  background: var(--aow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  gap: 12px;
}

.aow-preview-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.aow-preview-back-btn {
  background: none;
  border: none;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--aow-navy);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.aow-preview-back-btn:hover { background: var(--aow-tonal); }

.aow-preview-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--aow-ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aow-preview-tabs {
  display: flex;
  gap: 4px;
  background: var(--aow-tonal);
  padding: 3px;
  border-radius: 8px;
}

.aow-preview-tab {
  background: none;
  border: none;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--aow-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.aow-preview-tab.is-active {
  background: var(--aow-card);
  color: var(--aow-navy);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  font-weight: 700;
}

.aow-preview-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--aow-muted);
  cursor: pointer;
  padding: 6px;
  line-height: 1;
}

.aow-preview-close:hover { color: var(--aow-ink); }

/* The member story page (Figma 377:2, member ao-reader.css .aom-sp-*), in the Writer's own classes:
   a left-anchored column, never centred (the no-centre-squeeze rule); the reactions and resources
   column sits to the right when the page has the room and drops underneath when it has not. */
.aow-preview-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px 24px 48px;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  background: var(--aow-surface);
}

.aow-preview-story-wrap[hidden] { display: none !important; }

.aow-preview-story-wrap {
  width: 100%;
  container-type: inline-size;
}

.aow-pv-page {
  display: grid;
  grid-template-columns: minmax(0, 824px);
  column-gap: 32px;
  row-gap: 24px;
  align-items: start;
}

@container (min-width: 1060px) {
  .aow-pv-page { grid-template-columns: minmax(0, 824px) minmax(280px, 340px); }
}

.aow-pv-main { min-width: 0; }

.aow-pv-head { max-width: 760px; margin: 0 0 24px; }

.aow-pv-eyebrow {
  margin: 0 0 8px;
  font-family: var(--oecta-font-ui, Inter, system-ui, sans-serif);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--aow-muted);
}

.aow-pv-title {
  margin: 0 0 12px;
  font-family: var(--oecta-font-display, Manrope, Inter, sans-serif);
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--aow-ink);
}

.aow-pv-standfirst {
  margin: 0 0 16px;
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--aow-ink-2);
}

.aow-pv-byline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--aow-muted);
}

.aow-pv-avatar {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--aow-tonal);
  color: var(--aow-navy);
  font-size: 0.7rem;
  font-weight: 700;
}

.aow-pv-author { font-weight: 600; color: var(--aow-ink); }

.aow-pv-num { font-family: var(--aow-mono); font-variant-numeric: tabular-nums; }

.aow-pv-statutory {
  margin: 16px 0 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--aow-tonal);
  color: var(--aow-ink-2);
  font-size: 0.875rem;
}

.aow-pv-card {
  background: var(--aow-card);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--aow-shadow-card);
}

.aow-preview-frame {
  display: block;
  width: 100%;
  height: 480px;
  border: none;
  background: var(--aow-card);
}

.aow-pv-rail { min-width: 0; }

@container (min-width: 1060px) {
  .aow-pv-rail { padding-top: 56px; }
}

.aow-pv-rx {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.aow-pv-rx-q {
  flex-basis: 100%;
  font-weight: 700;
  color: var(--aow-ink);
}

.aow-pv-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--aow-card);
  color: var(--aow-ink-2);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--aow-shadow-pill);
}

.aow-pv-save { color: var(--aow-navy); }

.aow-pv-section-title {
  margin: 0 0 12px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--aow-muted);
}

.aow-pv-res { display: grid; gap: 8px; }

.aow-pv-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 64px;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--aow-card);
  color: var(--aow-ink);
  text-decoration: none;
  box-shadow: var(--aow-shadow-pill);
}

.aow-pv-tile-label { font-weight: 600; }
.aow-pv-tile-meta { font-size: 0.8rem; color: var(--aow-muted); }

/* Who the preview reads as, and what that member gets. */
.aow-pv-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 20px;
  background: var(--aow-card);
  flex-shrink: 0;
}

.aow-pv-who { display: flex; align-items: center; gap: 8px; }
.aow-pv-who[hidden] { display: none !important; }

.aow-pv-who-label { font-size: 0.84rem; font-weight: 600; color: var(--aow-ink-2); }

.aow-pv-combo { position: relative; }

.aow-pv-search {
  width: min(320px, 70vw);
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--aow-line);
  border-radius: 8px;
  background: var(--aow-surface);
  color: var(--aow-ink);
  font-size: 1rem;
}

.aow-pv-search:focus-visible { outline: 2px solid var(--aow-navy); outline-offset: 1px; }

.aow-pv-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 2;
  width: max(100%, 320px);
  max-height: 320px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--aow-card);
  border-radius: 12px;
  box-shadow: var(--aow-shadow-sheet);
}

.aow-pv-results[hidden] { display: none !important; }

.aow-pv-opt {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.aow-pv-opt:hover,
.aow-pv-opt[aria-selected="true"] { background: var(--aow-tonal); }

.aow-pv-opt-name { font-weight: 600; color: var(--aow-ink); }
.aow-pv-opt-meta { font-size: 0.8rem; color: var(--aow-muted); }

.aow-pv-empty { padding: 10px; font-size: 0.875rem; color: var(--aow-muted); }

.aow-pv-clear {
  min-height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: var(--aow-tonal);
  color: var(--aow-navy);
  font-weight: 600;
  cursor: pointer;
}

.aow-pv-clear[hidden] { display: none !important; }

.aow-pv-note {
  flex: 1 1 280px;
  margin: 0;
  font-size: 0.875rem;
  color: var(--aow-ink-2);
}

@media (max-width: 768px) {
  .aow-preview-body { padding: 16px 16px 32px; }
  .aow-pv-card { padding: 16px; border-radius: 12px; }
  .aow-pv-title { font-size: 1.75rem; }
  .aow-pv-strip { padding: 10px 16px; }
  .aow-pv-who { flex-wrap: wrap; }
}

.aow-preview-card-wrap {
  width: 100%;
  max-width: 440px;
  display: flex;
  justify-content: flex-start;
}

.aow-preview-card-wrap[hidden] { display: none !important; }

.aow-preview-card-col { width: 100%; }

.aow-preview-card-mount {
  background: var(--aow-card);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

/* ==========================================================================
   DOCUMENT IMPORT & PASTE MODAL (#aow-import-modal)
   ========================================================================== */

#aow-import-modal {
  position: fixed;
  inset: 0;
  z-index: calc(var(--aow-z, 9000) + 30);
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#aow-import-modal[hidden] { display: none !important; }

.aow-modal-card {
  background: var(--aow-card);
  border-radius: 16px;
  box-shadow: 0 20px 48px rgba(16, 42, 67, 0.22);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: aowModalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes aowModalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.aow-modal-head {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--aow-surface);
}

.aow-modal-title {
  margin: 0;
  font-family: Manrope, Inter, sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--aow-navy);
}

.aow-modal-close {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  color: var(--aow-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.aow-modal-close:hover { background: var(--aow-tonal); color: var(--aow-navy); }

.aow-modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.aow-modal-lead {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--aow-muted);
}

.aow-import-box-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.aow-import-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--aow-muted);
}

.aow-import-paste-area {
  min-height: 130px;
  max-height: 220px;
  overflow-y: auto;
  padding: 12px 14px;
  background: var(--aow-tonal);
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  font-family: Inter, sans-serif;
  font-size: 16px;
  color: var(--aow-ink);
  outline: none;
  transition: all 0.15s ease;
}

.aow-import-paste-area:focus {
  border-color: var(--aow-navy);
  background: var(--aow-card);
  box-shadow: 0 0 0 3px rgba(32, 65, 100, 0.1);
}

.aow-import-paste-area:empty:before {
  content: attr(data-placeholder);
  color: #94a3b8;
  pointer-events: none;
}

.aow-import-mode-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.aow-import-radios {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.aow-import-radio {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: var(--aow-tonal);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.aow-import-radio:hover { background: #e8edf3; }

.aow-import-radio input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--aow-navy);
}

.aow-import-radio-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.aow-import-radio-text strong { font-size: 0.88rem; color: var(--aow-ink); }
.aow-import-radio-text small { font-size: 0.78rem; color: var(--aow-muted); }

.aow-import-status[hidden] { display: none !important; }

.aow-import-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #eff6ff;
  border-radius: 8px;
  font-size: 0.84rem;
  color: #1e40af;
}

.aow-import-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(30, 64, 175, 0.3);
  border-top-color: #1e40af;
  border-radius: 50%;
  animation: aowSpin 0.7s linear infinite;
}

@keyframes aowSpin { to { transform: rotate(360deg); } }

.aow-modal-foot {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--aow-surface);
}

.aow-btn {
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
}

.aow-btn--secondary {
  background: var(--aow-card);
  border-color: var(--aow-line);
  color: var(--aow-navy);
}

.aow-btn--primary {
  background: var(--aow-navy);
  color: var(--aow-on-brand);
}

/* ==========================================================================
   TABLET ≤ 1100px: the tray collapses to an icon rail (frame 384:2)
   ========================================================================== */

@media (max-width: 1100px) and (min-width: 769px) {
  .aow-tray {
    width: 72px;
    grid-template-columns: 1fr;
    padding: 12px 8px;
    gap: 4px;
  }

  .aow-tray-group-title { display: none; }

  .aow-tile {
    min-height: 48px;
    padding: 6px 4px;
    gap: 0;
  }

  .aow-tile > span:not(.aow-tile-ico) { display: none; }

  .aow-side { width: 300px; padding: 16px; }

  .aow-doc-title { max-width: 260px; }

  .aow-head-btn { padding: 8px 10px; }
}

/* ==========================================================================
   PHONE LINEAR MODE (≤ 768px) — frames 385/386/387
   ========================================================================== */

@media (max-width: 768px) {
  #ao-writer {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .aow-head {
    height: auto;
    min-height: var(--aow-head-h);
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
  }

  .aow-head-left { min-width: 0; flex: 1 1 100%; }

  .aow-head-right {
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
  }

  .aow-head-btn { padding: 8px 10px; font-size: 0.76rem; }
  .aow-doc-title { max-width: none; }
  .aow-adv-toggle { display: none !important; }

  .aow-body {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* The tray becomes a bottom sheet behind the floating Add pill */
  .aow-tray {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    max-height: 70%;
    z-index: 150;
    background: var(--aow-card);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -16px 48px rgba(32, 65, 100, 0.18);
    padding: 20px 16px 16px;
    grid-template-columns: 1fr 1fr;
  }

  .aow-tray::before {
    /* grab handle */
    content: "";
    grid-column: 1 / -1;
    justify-self: center;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: #cbd5e1;
    margin-bottom: 4px;
  }

  .aow-tray-open .aow-tray { display: grid; }
  .aow-tray-open .aow-tray-scrim { display: block; }

  .aow-tray .aow-tile {
    background: var(--aow-tonal);
    min-height: 72px;
    font-size: 0.8rem;
  }

  /* Only the linear-mode sections on a phone (decision 7) */
  .aow-tile--desktop { display: none !important; }

  .aow-phone-bar { display: block; }

  .aow-canvas-wrap {
    padding: 16px 12px 96px;   /* room for the floating Add pill */
    width: 100%;
    box-sizing: border-box;
  }

  .aow-canvas-card {
    padding: 24px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(32, 65, 100, 0.04);
    width: 100%;
    box-sizing: border-box;
  }

  .aow-title-input { font-size: 1.5rem; width: 100%; box-sizing: border-box; }
  .aow-subtitle-input { font-size: 1rem; width: 100%; box-sizing: border-box; }

  /* The side card docks to the bottom while a section is selected */
  .aow-side {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    max-height: 55%;
    z-index: 120;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 24px rgba(32, 65, 100, 0.14);
    padding: 12px 16px 16px;
  }

  .aow-has-selection .aow-side { display: flex; }
  .aow-has-selection .aow-phone-bar { display: none; }   /* the Add pill never sits on the open card */

  .aow-prop-btn { min-height: 40px; }

  #aow-assistant { width: 100%; }
  #aow-details { width: 100%; }
}

/* ==========================================================================
   44 px TOUCH TARGETS (Batch 2.4 — Paul's ruling), extended to the M1 hooks.
   GrapesJS's floating pill toolbars keep 34px visuals; their hit area is
   grown with a pseudo-element instead.
   ========================================================================== */
.aow-head-btn, .aow-back-btn, .aow-cta-btn, .aow-publish-btn, .aow-tile, .aow-prop-btn,
.aow-btn-share-trigger, .aow-details-close, .aow-asst-close, .aow-asst-act-btn, .aow-chip-btn,
.aow-asst-send, .aow-preview-tab, .aow-preview-close, .aow-preview-back-btn, .aow-modal-close,
.aow-phone-add, .aow-asst-attach, .aow-btn-add-link, .aow-event-result, .aow-btn {
  min-height: 44px;
}

.aow-back-btn, .aow-details-close, .aow-asst-close, .aow-preview-close, .aow-modal-close,
.aow-asst-attach {
  min-width: 44px;
}

.aow-link-row .aow-link-remove { min-height: 44px; min-width: 40px; }

.aow-tlb-act, .gjs-rte-action { position: relative !important; }
.aow-tlb-act::after, .gjs-rte-action::after {
  content: "";
  position: absolute;
  inset: -5px;
}
