/* R14.1.F — Mobile 3x3 action grid (per aicademi_PhoneLayout_3.jpg). */

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

.mobile-action-grid {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  display: grid;
  /* R14.5.A — 2 rows × 3 cols (Add/Play/Send · Explorer/Auto/Search)
     R14.12.C — sleek mode default reduces row height ~50% via body class. */
  grid-template-columns: 1fr 1fr 1fr;
  grid-auto-rows: 56px;
  gap: 0;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.08);
}
/* R14.12.C — sleek mode (DEFAULT). Halves the touch-target heights so
   the 3 carousels get more vertical real estate. body.fat-mode opts back
   into the original taller buttons for accessibility. */
body:not(.fat-mode) .mobile-action-grid { grid-auto-rows: 36px; }
body:not(.fat-mode) .mag-cell { min-height: 36px; padding: 2px 4px; font-size: 0.62rem; }
body:not(.fat-mode) .mag-cell-ic { font-size: 1.0rem; }
body:not(.fat-mode) .mag-cell-ic svg { width: 18px; height: 18px; }
body:not(.fat-mode) .mag-cell-lbl { font-size: 0.58rem; }
body:not(.fat-mode) .mag-it-support { padding: 6px 12px; font-size: 0.78rem; }

/* Desktop never shows this grid. */
@media (min-width: 821px) {
  .mobile-action-grid { display: none; }
}

.mag-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  padding: 6px 4px;
  border: 0;
  border-right: 1px solid rgba(0, 0, 0, 0.05);
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  background: #ffffff;
  color: #374151;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 100ms ease;
}
.mag-cell:nth-child(3n) { border-right: 0; }
.mag-cell:nth-child(-n+3) { border-top: 0; }
.mag-cell:active { background: rgba(192, 132, 252, 0.12); }
.mag-cell:focus-visible { outline: 2px solid #f97316; outline-offset: -2px; }
.mag-cell-ic { font-size: 1.25rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.mag-cell-ic svg { display: block; }
.mag-cell-lbl { font-size: 0.64rem; letter-spacing: 0.01em; }

/* R14.2.A — align emphasized-cell palette with desktop siblings:
   Add + Send both use the purple gradient (matches desktop send pill).
   Auto uses the orange gradient (matches desktop Auto button).
   Msg stays subtle lavender. Preview pill purple to match Play gradient. */
/* R14.12.C — REVERSED rainbow: Support=red, going up through orange,
   yellow, green, blue, indigo, violet, magenta on the 5-button strip.
   Reading order in the grid (left→right, top→bottom):
     Add=violet, Play=indigo, Browse=blue,
     Files=green, Auto=yellow, Search=orange. */
.mag-add     { background: linear-gradient(180deg, #c084fc, #9333ea); color: #fff; }
.mag-add:active     { background: #7e22ce; }
.mag-preview { background: linear-gradient(180deg, #818cf8, #4f46e5); color: #fff; }
.mag-preview:active { background: #4338ca; }
.mag-shop    { background: linear-gradient(180deg, #60a5fa, #2563eb); color: #fff; }
.mag-shop:active    { background: #1d4ed8; }
/* R14.15 — Share takes the green slot in the rainbow; Experience keeps violet. */
.mag-share   { background: linear-gradient(180deg, #4ade80, #16a34a); color: #fff; }
.mag-share:active   { background: #15803d; }
.mag-experience { background: linear-gradient(180deg, #c084fc, #9333ea); color: #fff; }
.mag-experience:active { background: #7e22ce; }

/* R14.15 — Explorer sheet: Images tab grid + Download-all button. */
.mag-expl-dl {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid #ede9fe;
  background: linear-gradient(180deg, #faf8ff, #ede9fe);
  color: #5b21b6;
  border-radius: 12px;
  font: 600 0.9rem 'Inter', sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mag-expl-dl:active { background: #ddd6fe; }
.mag-expl-imgs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  padding: 4px;
}
.mag-expl-img-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  cursor: pointer;
}
.mag-expl-img-tile img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.mag-expl-img-label {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 4px 6px 3px;
  font: 500 0.64rem 'Inter', sans-serif;
  color: #fff;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.65));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* R14.14 — Play cell pulses gold when the preview finishes loading so
   the user knows the build is ready to check. */
@keyframes mag-ready-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.95); }
  70%  { box-shadow: 0 0 0 10px rgba(250, 204, 21, 0); }
  100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0); }
}
.mag-ready-flash {
  animation: mag-ready-pulse 1s ease-out infinite;
  position: relative;
  z-index: 2;
}
.mag-explorer{ background: linear-gradient(180deg, #4ade80, #16a34a); color: #fff; }
.mag-explorer:active{ background: #15803d; }
.mag-auto    { background: linear-gradient(180deg, #fde047, #eab308); color: #1f2937; }
.mag-auto:active    { background: #ca8a04; }
.mag-search  { background: linear-gradient(180deg, #fb923c, #ea580c); color: #fff; }
.mag-search:active  { background: #c2410c; }
.mag-send    { background: linear-gradient(180deg, #c084fc, #a855f7); color: #fff; }
.mag-send:active { background: #9333ea; }
/* R14.12 — image-stack popover (triggered by left-most strip button). */
.mag-img-stack-scrim {
  position: fixed;
  inset: 0;
  z-index: 1399;
  background: rgba(0, 0, 0, 0.18);
  -webkit-tap-highlight-color: transparent;
}
.mag-img-stack {
  position: fixed;
  left: 10px; right: 10px;
  bottom: calc(180px + env(safe-area-inset-bottom, 0px));
  z-index: 1400;
  background: #fff;
  border: 1px solid #ede9fe;
  border-radius: 14px;
  box-shadow: 0 10px 36px rgba(0,0,0,0.18);
  padding: 10px 12px;
  max-height: 50dvh;
  overflow: auto;
}
.mag-img-stack-h {
  display: flex; align-items: center; justify-content: space-between;
  font: 600 0.86rem 'Inter', sans-serif;
  color: #1f2937;
  margin-bottom: 8px;
}
.mag-img-stack-x {
  width: 28px; height: 28px;
  border: 0; background: transparent;
  font-size: 1.4rem; line-height: 1;
  color: #6b7280; cursor: pointer;
  border-radius: 6px;
}
.mag-img-stack-x:active { background: #f3f4f6; }
.mag-img-stack-empty {
  font: 500 0.84rem 'Inter', sans-serif;
  color: #6b7280;
  text-align: center;
  padding: 18px 8px;
}
.mag-img-stack-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
}
.mag-img-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
}
.mag-img-tile img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.mag-img-del {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border: 0;
  border-radius: 9999px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 1rem; line-height: 1;
  cursor: pointer;
  display: inline-grid; place-items: center;
}

/* R14.12 — preview keeps yellow background; ensure SVG icon contrasts. */
.mag-preview .mag-cell-ic svg { stroke: none; fill: currentColor; }
.mag-msg { background: #faf8ff; }

/* R14.12.C — REVERSED rainbow: Support is RED (the rainbow starts here). */
.mag-it-support {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  border: 0;
  background: linear-gradient(180deg, #fca5a5, #ef4444);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 120ms ease;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
}
.mag-it-support:active { background: #b91c1c; }
.mag-it-support[aria-pressed="true"] { background: linear-gradient(180deg, #16a34a, #15803d); }
.mag-it-support-ic { font-size: 1.05rem; line-height: 1; }
.mag-it-support-lbl { letter-spacing: 0.01em; }

/* Compact the body so grid + top-strip (R14.9.A) + IT-support fit.
   R14.5.A: grid 2 rows. R14.9.A: top-strip above the grid.
   R14.9.D fix: bumped to 310px so the view-canvas ports actually render
   above the composer + strip + grid + support stack. */
@media (max-width: 820px) {
  .workspace-body.page-workspace { padding-bottom: calc(310px + env(safe-area-inset-bottom, 0px)); }
  /* R14.9.D — ensure the view-canvas fills the available chat-panel height
     (the chat-input-area sibling on mobile is nearly empty after R14.3.C
     hid its buttons; without this rule, flex math sometimes gives ports
     almost 0 height). */
  .view-canvas { min-height: calc(100vh - 410px); }
  /* R14.2.A + R14.3.C + R14.3.E — every composer button now lives in the
     3x3 grid (or add-sheet). Hide the redundant in-composer toolbars on both
     the desktop-style chat-input-area AND the mobile .composer-r4 drawer
     (.cr4-tools). Only the textarea stays.
     FIX sighting 2026-04-14: the old .cr4-tools (mobile toolbar) was still
     showing on phone because the previous hide rule only covered the desktop
     row. The mobile teamBtn visual mirrored the new right-side toggle state,
     exposing the duplicate. */
  .chat-input-area #modelDropdown,
  .chat-input-area #callClaudeBtn,
  .chat-input-area #teamBtn,
  .chat-input-area #turboBtn,
  .chat-input-area #plusAddBtn,
  .chat-input-area #autoBtn,
  .chat-input-area #sendBtn { display: none !important; }
  .chat-input-area { gap: 0; padding: 8px 10px; }

  /* Mobile composer (composer-r4) — hide its tool row entirely. Keep the
     input row so the user can actually TYPE. The new grid owns every action
     the toolbar previously held (model picker → Settings cell → settings
     modal; team/turbo/delay → right-side vertical toggles; call → IT
     Support red button; plus → Add cell; auto → Auto cell; send → Send
     cell). */
  .composer-r4 .cr4-tools { display: none !important; }
  /* R14.11.B — Send moves BACK into the composer (its 2x3 cell becomes Shop). */
  .composer-r4 .cr4-send,
  .composer-r4 #cr4Send { display: inline-grid !important; }
  /* R14.3.G + R14.5.A + R14.9.A + R14.9.F — lift composer above everything.
     Strip shrank by 50% in R14.9.F so lift is ~230px now. */
  .composer-r4 {
    bottom: calc(230px + env(safe-area-inset-bottom, 0px)) !important;
    z-index: 1050 !important;
    padding-bottom: 10px !important;
  }
  .chat-drawer { bottom: calc(230px + env(safe-area-inset-bottom, 0px)) !important; }

  /* R14.6.D — hide the desktop-style preview toolbar on phone. The grid's
     Play cell + Share button on the preview panel already own these actions
     (refresh / open-new-tab / download / share). The preview panel on phone
     is just the iframe. Keep the header HIDDEN structurally but leave the
     buttons in the DOM so JS handlers (openNewTab/refreshPreview/etc) still
     work when triggered via the grid. */
  .panel-preview .preview-header { display: none !important; }
  .panel-preview .preview-iframe { border-top: 0 !important; }

  /* R14.7 — un-drawer the "curtain" over the canvas.
     Christoffer's ask: "there is a resizable window over the canvas...
     a curtain that can be dragged up on front with an x in right,
     that should be removed."
     The R5 .chat-drawer wrapped the chat + composer in a drag-to-resize
     sheet with snap states. The multi-panel canvas now owns visibility +
     (eventually) resizing, so the drawer chrome is redundant.
     Kill the drag handle, close X, card background, box-shadow, height
     snapping, and transforms. Force auto height + transparent container
     so children flow naturally. Disable touch-action interception so the
     user's swipes land on the actual message list, not the drawer. */
  .chat-drawer {
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    height: auto !important;
    transform: none !important;
    touch-action: auto !important;
    transition: none !important;
    pointer-events: auto !important;
  }
  .chat-drawer.is-collapsed,
  .chat-drawer.is-half,
  .chat-drawer.is-full,
  .chat-drawer.is-hidden {
    height: auto !important;
    transform: none !important;
    pointer-events: auto !important;
  }
  .chat-drawer-handle,
  .chat-drawer-close { display: none !important; }
  /* FAB (floating action button that reopened the drawer) — also redundant now. */
  #chatFab { display: none !important; }
}
/* Right-toggle strip also needs to lift less now. */
@media (max-width: 820px) {
  .mag-right-toggles { bottom: calc(205px + env(safe-area-inset-bottom, 0px)) !important; }
}

/* R14.3.D — right-edge vertical strip retired by R14.9.A. Kept the rule
   just in case anything still references it, but the element is mounted
   hidden from JS. */
.mag-right-toggles { display: none !important; }

/* R14.9.A + R14.9.F — horizontal 5-button strip directly above the grid.
   No background island. Buttons ~50% smaller. Sits right next to the grid. */
.mag-top-strip {
  position: fixed;
  bottom: calc(167px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
@media (min-width: 821px) { .mag-top-strip { display: none; } }
/* R14.15 — 7-button strip + triangle toggle retired. Their functions moved
   to the 2x3 grid, composer pills, ⋯ overlay, and Explorer sheet. Strip
   JS logic kept for learning / future re-use. */
.mag-top-strip { display: none !important; }
.wc-strip-toggle { display: none !important; }
/* R14.12.C — 5-button strip pills are MAGENTA (rainbow ends here). */
.mag-h {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: linear-gradient(180deg, #f0abfc, #c026d3);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 100ms ease;
  box-shadow: 0 2px 5px rgba(192, 38, 211, 0.30);
  padding: 0;
}
.mag-h:active { transform: scale(0.92); background: #a21caf; }
.mag-h:focus-visible { outline: 2px solid #f97316; outline-offset: 2px; }
.mag-h.mag-h-on {
  background: linear-gradient(180deg, #c026d3, #86198f);
  color: #fff;
  border-color: transparent;
}
.mag-h-ic { display: inline-flex; align-items: center; justify-content: center; }
.mag-h-ic svg { display: block; width: 14px; height: 14px; }
/* Share — middle, slightly bigger; brightest magenta. */
.mag-h-big {
  width: 34px;
  height: 34px;
  background: linear-gradient(180deg, #e879f9, #a21caf);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 3px 8px rgba(192, 38, 211, 0.45);
}
.mag-h-big:hover { box-shadow: 0 5px 12px rgba(192, 38, 211, 0.55); }
.mag-h-big .mag-h-ic svg { width: 18px; height: 18px; }
.mag-vt {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 100ms ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.mag-vt:active { transform: scale(0.94); }
.mag-vt.mag-vt-on {
  background: linear-gradient(180deg, #c084fc, #a855f7);
  color: #fff;
  border-color: transparent;
}
.mag-vt:focus-visible { outline: 2px solid #f97316; outline-offset: 2px; }
.mag-vt-ic svg { display: block; }

/* ---- Shared bottom-sheet chrome (add-sheet + sessions-sheet) ---- */
.mag-sheet {
  position: fixed;
  inset: 0;
  z-index: 1200;
}
.mag-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  animation: mag-fadeIn 180ms ease forwards;
}
@keyframes mag-fadeIn { to { opacity: 1; } }
.mag-sheet-card {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  padding: 10px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.14);
  transform: translateY(100%);
  transition: transform 240ms cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 72vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.mag-sheet-card.mag-sheet-in { transform: translateY(0); }

.mag-sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 9999px;
  background: #d1d5db;
  margin: 4px auto 10px;
}
.mag-sheet-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.02rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 10px;
  padding: 0 4px;
}

.mag-sheet-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mag-sheet-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-radius: 10px;
  border: 1px solid #f3f4f6;
  background: #fafafa;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: #111827;
  transition: background 100ms ease;
}
.mag-sheet-row:active { background: #f3f0ff; }
.mag-sheet-row-icon {
  font-size: 1.5rem;
  line-height: 1;
  text-align: center;
}
.mag-sheet-row-name { font-weight: 600; font-size: 0.92rem; }
.mag-sheet-row-sub { font-size: 0.76rem; color: #6b7280; margin-top: 2px; }

.mag-sheet-sessions { display: flex; flex-direction: column; gap: 4px; }
.mag-sess-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  text-decoration: none;
  color: #111827;
  background: #fafafa;
}
.mag-sess-row:active { background: #f3f0ff; }
.mag-sess-active { background: #ede9fe; box-shadow: inset 3px 0 0 #7c3aed; }
.mag-sess-ic { font-size: 1.1rem; line-height: 1; text-align: center; }
.mag-sess-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mag-sess-name { font-weight: 500; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mag-sess-when { font-size: 0.72rem; color: #9ca3af; }

.mag-sheet-new {
  margin-top: 12px;
  padding: 12px;
  border-radius: 9999px;
  border: 0;
  background: linear-gradient(180deg, #c084fc, #a855f7);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

/* R14.5.B — Explorer sheet (Files + Chats tabs) */
.mag-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f3f4f6;
  border-radius: 10px;
  margin-bottom: 10px;
}
.mag-tab {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: #6b7280;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.mag-tab.mag-tab-active { background: #fff; color: #111827; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.mag-expl-pane { display: flex; flex-direction: column; gap: 3px; }
.mag-expl-empty { padding: 18px; text-align: center; color: #9ca3af; font-size: 0.86rem; }
.mag-expl-file {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  color: #111827;
  background: #fafafa;
}
.mag-expl-ic { font-size: 1.05rem; text-align: center; line-height: 1; }
.mag-expl-name { font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, monospace; color: #374151; }

/* R14.5.D — Search sheet */
.mag-srch-input-wrap {
  display: flex;
  gap: 6px;
  padding: 8px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 12px;
  align-items: stretch;
  margin-bottom: 12px;
}
.mag-srch-input {
  flex: 1;
  padding: 8px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.88rem;
  resize: none;
  outline: none;
}
.mag-srch-submit {
  width: 44px;
  min-width: 44px;
  border: 0;
  border-radius: 9999px;
  background: linear-gradient(180deg, #c084fc, #a855f7);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}
.mag-srch-submit:active { background: #9333ea; }
.mag-srch-section { margin-bottom: 14px; }
.mag-srch-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #4b5563;
  margin-bottom: 8px;
  padding: 0 2px;
}
.mag-srch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.mag-srch-card {
  background: #fafafa;
  border: 1px solid #f3f4f6;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.mag-srch-card-emoji { font-size: 1.6rem; line-height: 1; margin-bottom: 4px; }
.mag-srch-card-name { font-size: 0.82rem; font-weight: 600; color: #111827; line-height: 1.2; }
.mag-srch-card-sub { font-size: 0.7rem; color: #9ca3af; margin-top: 3px; }
.mag-srch-note {
  font-size: 0.74rem;
  color: #9ca3af;
  text-align: center;
  padding: 8px 12px;
  font-style: italic;
}
