/* ==========================================================================
   MS Office Shapes Gallery & Editing System Styles
   ========================================================================== */
@import url('gradient.css');

/* Shapes Picker Modal */
.office-shapes-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.office-shapes-dialog {
  background: var(--bg-surface, #ffffff);
  border-radius: 10px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  width: 760px;
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-color, #cbd5e1);
  animation: shapesModalPop 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes shapesModalPop {
  0% { transform: scale(0.96); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.office-shapes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-toolbar, #f8fafc);
}

.office-shapes-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main, #0f172a);
}

.office-shapes-btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  border-radius: 4px;
  padding: 0 4px;
}

.office-shapes-btn-close:hover {
  color: #ef4444;
}

/* Preset Style Quick Selector Bar */
.office-shapes-styles-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--bg-surface, #ffffff);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.office-shapes-bar-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted, #64748b);
}

.office-shapes-style-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.shape-style-chip {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.shape-style-chip:hover {
  transform: scale(1.12);
}

.shape-style-chip.active {
  box-shadow: 0 0 0 2px #0f172a, 0 2px 6px rgba(0,0,0,0.25);
  transform: scale(1.1);
}

/* Gallery Content */
.office-shapes-gallery-content {
  padding: 14px 18px;
  overflow-y: auto;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-surface, #ffffff);
}

.office-shapes-section-title {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #64748b);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color, #f1f5f9);
  padding-bottom: 4px;
}

.office-shapes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 6px;
}

.office-shape-item-btn {
  background: var(--bg-surface, #ffffff);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s ease;
}

.office-shape-item-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  transform: translateY(-1px);
}

.shape-item-svg-box {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shape-item-svg-box svg {
  max-width: 100%;
  max-height: 100%;
}

.shape-item-name {
  font-size: 0.65rem;
  color: var(--text-muted, #64748b);
  text-align: center;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.office-shape-item-btn:hover .shape-item-name {
  color: #1d4ed8;
  font-weight: 500;
}

/* Modal Footer */
.office-shapes-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--bg-toolbar, #f8fafc);
  border-top: 1px solid var(--border-color, #e2e8f0);
}

.office-shapes-footer-tip {
  font-size: 0.75rem;
  color: var(--text-muted, #64748b);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Inserted Shape Container & Controls
   ========================================================================== */
.office-shape-container {
  position: relative;
  display: inline-block;
  user-select: none;
  box-sizing: border-box;
}

.doc-inline-shape {
  margin: 12px 16px 12px 0;
  vertical-align: middle;
  float: none;
}

.sheets-floating-shape {
  position: absolute;
  z-index: 35;
  cursor: move;
}

.doc-floating-shape {
  position: absolute !important;
  margin: 0 !important;
  z-index: 35;
  cursor: move;
}

.office-shape-svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Shape Text Overlay (Centrally positioned text node inside shape) */
.shape-text-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 78%;
  max-height: 80%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.3;
  word-break: break-word;
  outline: none;
  cursor: text;
  pointer-events: auto;
  user-select: text;
  padding: 4px;
}

.shape-text-overlay:focus {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
}

/* Selection outline & handles (matching Slides orange theme) */
.shape-selection-outline {
  display: none;
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border: 1.5px dashed #ea580c;
  border-radius: 1px;
  pointer-events: none;
}

.office-shape-container.selected .shape-selection-outline {
  display: block;
}

.shape-handle {
  display: none;
  position: absolute;
  width: 9px;
  height: 9px;
  background: #ffffff;
  border: 1.5px solid #ea580c;
  border-radius: 1px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  z-index: 10;
  pointer-events: auto;
}

.office-shape-container.selected .shape-handle {
  display: block;
}

/* Handle positions (Square handles centered on borders) */
.handle-nw { top: -8px; left: -8px; cursor: nwse-resize; }
.handle-n  { top: -8px; left: calc(50% - 4.5px); cursor: ns-resize; }
.handle-ne { top: -8px; right: -8px; cursor: nesw-resize; }
.handle-e  { top: calc(50% - 4.5px); right: -8px; cursor: ew-resize; }
.handle-se { bottom: -8px; right: -8px; cursor: nwse-resize; }
.handle-s  { bottom: -8px; left: calc(50% - 4.5px); cursor: ns-resize; }
.handle-sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.handle-w  { top: calc(50% - 4.5px); left: -8px; cursor: ew-resize; }

/* Rotator Handle (Circular top handle with orange stem line matching Slides) */
.shape-rotator-stem {
  display: none;
  position: absolute;
  top: -26px;
  left: 50%;
  width: 1.5px;
  height: 26px;
  background-color: #ea580c;
  pointer-events: none;
  z-index: 20;
}

.office-shape-container.selected .shape-rotator-stem {
  display: block !important;
}

.shape-handle.handle-rotator {
  display: none;
  position: absolute;
  top: -34px;
  left: calc(50% - 7px);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #ea580c;
  cursor: grab;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s ease, background-color 0.1s ease;
  z-index: 25;
  pointer-events: auto;
}

.office-shape-container.selected .shape-handle.handle-rotator {
  display: block !important;
}

.shape-handle.handle-rotator:hover,
.shape-handle.handle-rotator.active {
  background-color: #ffffff;
  border-color: #ea580c;
  transform: scale(1.25);
}

.shape-handle.handle-rotator:active {
  cursor: grabbing;
}

[data-theme="dark"] .shape-selection-outline {
  border-color: #f97316;
}

[data-theme="dark"] .shape-handle {
  border-color: #f97316;
}

[data-theme="dark"] .shape-rotator-stem {
  background-color: #f97316;
}

[data-theme="dark"] .shape-handle.handle-rotator {
  border-color: #f97316;
}

[data-theme="dark"] .shape-handle.handle-rotator:hover,
[data-theme="dark"] .shape-handle.handle-rotator.active {
  border-color: #f97316;
}

/* Shape Live Rotation Degree Tooltip */
.shape-rotate-tooltip {
  position: absolute;
  top: -54px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  z-index: 25;
  display: none;
  animation: formatBarFade 0.1s ease-out;
}

.shape-rotate-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -4px;
  border-width: 4px;
  border-style: solid;
  border-color: #1e293b transparent transparent transparent;
}

.office-shape-container {
  cursor: grab;
}

.office-shape-container.moving {
  cursor: grabbing !important;
  opacity: 0.75;
}

.shape-fmt-angle-indicator {
  font-size: 0.72rem;
  font-weight: 600;
  color: #ea580c;
  background: #fff7ed;
  border: 1px solid #fdba74;
  padding: 2px 6px;
  border-radius: 4px;
  user-select: none;
}

[data-theme="dark"] .shape-fmt-angle-indicator {
  color: #fb923c;
  background: rgba(249, 115, 22, 0.15);
  border-color: #ea580c;
}

/* ==========================================================================
   Floating Formatting Toolbar for Selected Shape
   ========================================================================== */
.shape-floating-format-bar {
  position: fixed;
  z-index: 1020;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 6px;
  box-shadow: 0 10px 20px -3px rgba(0,0,0,0.18), 0 4px 6px -2px rgba(0,0,0,0.08);
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  animation: formatBarFade 0.14s ease-out;
}

@keyframes formatBarFade {
  0% { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

.shape-toolbar-handle {
  color: var(--text-muted, #94a3b8);
  font-size: 0.75rem;
  padding: 0 2px;
  cursor: grab;
}

.shape-fmt-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-main, #334155);
}

.shape-fmt-group label {
  font-size: 0.75rem;
  color: var(--text-muted, #64748b);
  cursor: pointer;
}

.shape-color-picker {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid var(--border-color, #cbd5e1);
  cursor: pointer;
  padding: 0;
  background: none;
}

.shape-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.shape-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

.shape-fmt-select {
  height: 24px;
  font-size: 0.75rem;
  border-radius: 4px;
  border: 1px solid var(--border-color, #cbd5e1);
  background: var(--bg-surface, #ffffff);
  color: var(--text-main, #0f172a);
  padding: 0 4px;
  cursor: pointer;
}

.shape-fmt-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.8rem;
  color: var(--text-main, #334155);
  cursor: pointer;
  transition: all 0.12s ease;
}

.shape-fmt-btn:hover {
  background: var(--bg-hover, #f1f5f9);
  border-color: var(--border-color, #cbd5e1);
}

.shape-fmt-btn.btn-danger {
  color: #ef4444;
}

.shape-fmt-btn.btn-danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.shape-fmt-divider {
  width: 1px;
  height: 18px;
  background-color: var(--border-color, #e2e8f0);
  margin: 0 2px;
}

/* Dark mode styling for shapes UI */
[data-theme="dark"] .office-shapes-dialog {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .office-shapes-header,
[data-theme="dark"] .office-shapes-footer {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .office-shapes-styles-bar,
[data-theme="dark"] .office-shapes-gallery-content {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .office-shapes-section-title {
  border-color: #334155;
  color: #94a3b8;
}

[data-theme="dark"] .office-shape-item-btn {
  background: #1e293b;
}

[data-theme="dark"] .office-shape-item-btn:hover {
  background: #0f172a;
  border-color: #3b82f6;
}

[data-theme="dark"] .shape-floating-format-bar {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .shape-fmt-select {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

/* ==========================================================================
   MS Office 7-Column Shape Styles Gallery (Theme Styles + Presets)
   ========================================================================== */
.office-shapes-styles-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-surface, #ffffff);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.office-shapes-styles-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.office-shapes-toggle-styles-btn {
  background: var(--bg-toolbar, #f1f5f9);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 5px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-main, #334155);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.14s ease;
}

.office-shapes-toggle-styles-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

#office-shapes-style-chips {
  max-height: 112px;
  overflow-y: auto;
  transition: max-height 0.22s ease;
  padding: 2px;
}

#office-shapes-style-chips.expanded {
  max-height: 360px;
}

#sidebar-shapes-style-chips {
  max-height: 290px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 6px;
  background: var(--bg-toolbar, #f8fafc);
}

.ms-shape-styles-gallery {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.ms-shape-styles-cat-header {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--text-muted, #475569);
  padding: 4px 4px 2px 4px;
  letter-spacing: 0.01em;
}

.ms-shape-styles-grid-7 {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  padding: 2px 4px 6px 4px;
}

.ms-shape-style-tile {
  position: relative;
  width: 100%;
  aspect-ratio: 1.15 / 1;
  min-width: 34px;
  min-height: 30px;
  padding: 3px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, border-color 0.1s ease, background-color 0.1s ease;
  box-sizing: border-box;
}

/* Checkerboard background for transparent & semi-transparent Presets */
.ms-shape-style-tile.ms-shape-tile-checker {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #d4d4d8 25%, transparent 25%),
    linear-gradient(-45deg, #d4d4d8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d4d4d8 75%),
    linear-gradient(-45deg, transparent 75%, #d4d4d8 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
  border: 1px solid #cbd5e1;
}

.ms-shape-style-tile:hover {
  transform: scale(1.08);
  border-color: #94a3b8;
  z-index: 2;
}

.ms-shape-style-tile.active {
  outline: 2px solid #ea580c;
  outline-offset: 1px;
  z-index: 3;
}

.ms-shape-style-tile-inner {
  width: 100%;
  height: 100%;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Calibri, 'Segoe UI', sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
  box-sizing: border-box;
  pointer-events: none;
  user-select: none;
}

/* Bottom "Other Theme Fills" menu item */
.ms-shape-styles-footer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  margin-top: 2px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-main, #1e293b);
  cursor: pointer;
  border-radius: 0 0 6px 6px;
  transition: background 0.12s ease;
}

.ms-shape-styles-footer-item:hover {
  background: var(--bg-hover, #f1f5f9);
}

.ms-shape-styles-footer-icon {
  color: #d97706;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
}

.ms-shape-styles-footer-text {
  flex: 1;
}

.ms-shape-styles-footer-caret {
  font-size: 0.72rem;
  color: var(--text-muted, #64748b);
}

/* Floating Format Bar: Shape Styles Trigger & Popover */
.shape-fmt-styles-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px !important;
  font-weight: 600;
  font-size: 0.76rem !important;
  background: var(--bg-toolbar, #f8fafc);
  border: 1px solid var(--border-color, #cbd5e1) !important;
}

.shape-fmt-styles-abc-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 4px;
  border-radius: 3px;
  background: #4472c4;
  border: 1px solid #2f5597;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.1;
}

.shape-fmt-styles-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 340px;
  max-height: 410px;
  overflow-y: auto;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #cbd5e1);
  border-radius: 8px;
  box-shadow: 0 14px 28px -4px rgba(0, 0, 0, 0.24), 0 6px 12px -2px rgba(0, 0, 0, 0.12);
  padding: 8px;
  z-index: 1080;
  animation: formatBarFade 0.14s ease-out;
}

[data-theme="dark"] .shape-fmt-styles-popover {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .shape-fmt-styles-trigger,
[data-theme="dark"] .office-shapes-toggle-styles-btn {
  background: #0f172a;
  border-color: #334155 !important;
  color: #f8fafc;
}

[data-theme="dark"] #sidebar-shapes-style-chips {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .ms-shape-styles-cat-header {
  color: #94a3b8;
}

[data-theme="dark"] .ms-shape-styles-footer-item {
  border-color: #334155;
  color: #f8fafc;
}

[data-theme="dark"] .ms-shape-styles-footer-item:hover {
  background: #334155;
}

/* Menu icon and shortcut styling matching other Infinity Office apps */
.menu-shortcut {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  opacity: 0.7;
}

button:hover .menu-shortcut {
  opacity: 1;
}

/* ==========================================================================
   Mobile-Optimized Responsive Experience for Infinity Photo Studio
   ========================================================================== */

/* Touch Action & Tap Target Optimization */
button, input, select, textarea, [role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Custom Scrollbars for Touch / Mobile */
.custom-scrollbar::-webkit-scrollbar,
.overflow-x-auto::-webkit-scrollbar,
.overflow-y-auto::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb,
.overflow-x-auto::-webkit-scrollbar-thumb,
.overflow-y-auto::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 4px;
}

/* Mobile Screens (<= 768px) */
@media screen and (max-width: 768px) {
  /* Hide the horizontal desktop main menu bar (File, Edit, Image, Select, Layer, Filter) on mobile */
  header .menu-bar,
  header .menubar,
  .menu-bar {
    display: none !important;
  }

  /* Header adjustments: clean, uncluttered, non-overflowing */
  header {
    height: 44px !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
    display: flex !important;
    align-items: center !important;
    overflow-x: hidden !important;
    white-space: nowrap !important;
  }

  /* Hide decorative / redundant header elements on mobile */
  header > div.h-5.w-px.bg-border {
    display: none !important;
  }

  /* Compact button paddings in header */
  header button {
    min-height: 32px !important;
  }

  /* Hide secondary text in header buttons on very small screens */
  header button.bg-primary {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  /* Clean up Quick Start / Quick PNG buttons on mobile to avoid overflow */
  header button:has(i.fa-wand-magic-sparkles) span,
  header button:has(i.fa-wand-magic-sparkles) font {
    display: none !important;
  }

  /* Mobile More / Tools Action Drawer */
  .photo-mobile-menu-drawer {
    display: none;
    position: fixed;
    top: 44px;
    left: 0;
    width: 250px;
    max-height: calc(100vh - 44px);
    background: #18142a;
    color: #f8fafc;
    border-right: 1px solid rgba(148, 163, 184, 0.25);
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    border-bottom-right-radius: 12px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    z-index: 99990;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
  }
  .photo-mobile-menu-drawer.open {
    display: block !important;
  }
  .photo-mobile-menu-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99980;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .photo-mobile-menu-backdrop.active {
    display: block !important;
  }

  .photo-mobile-menu-group {
    padding: 6px 14px 2px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
  }
  .photo-mobile-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 9px 16px;
    font-size: 13px;
    color: #f1f5f9;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
  }
  .photo-mobile-menu-item:hover, .photo-mobile-menu-item:active {
    background: rgba(148, 163, 184, 0.15);
    color: #ffffff;
  }

  /* Right Sidebar (Layers & Properties): Transform into Mobile Bottom Sheet Drawer */
  .photo-layers-sidebar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 52vh !important;
    max-height: 60vh !important;
    z-index: 9980 !important;
    border-top: 1px solid var(--border, #cbd5e1) !important;
    border-left: none !important;
    box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.35) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    transform: translateY(calc(100% - 42px)) !important;
  }

  .photo-layers-sidebar.mobile-expanded {
    transform: translateY(0) !important;
  }

  /* Mobile floating handle / tab header */
  .photo-layers-sidebar::before {
    content: "";
    display: block;
    width: 44px;
    height: 5px;
    margin: 8px auto 4px;
    background: #94a3b8;
    border-radius: 3px;
    opacity: 0.75;
    cursor: pointer;
  }

  /* Backdrop for bottom sheet when expanded */
  .photo-layers-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9975;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .photo-layers-backdrop.active {
    display: block;
  }

  /* Left Toolbar: Mobile floating bar */
  .photo-tools-sidebar {
    width: 44px !important;
    padding-top: 4px !important;
    padding-bottom: 50px !important; /* space so bottom tools are not covered by collapsed sheet */
    -webkit-overflow-scrolling: touch;
  }

  .photo-tools-sidebar button {
    width: 36px !important;
    height: 36px !important;
  }

  /* Tool Options Bar: Smooth Horizontal Scroll */
  header + div, div.flex.h-10.shrink-0.items-center.gap-3.overflow-x-auto {
    height: 40px !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch;
  }
  header + div::-webkit-scrollbar, div.flex.h-10.shrink-0.items-center.gap-3.overflow-x-auto::-webkit-scrollbar {
    display: none;
  }

  /* Multi-document Tabs Bar on Mobile */
  #photo-tabs-bar {
    height: 34px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  #photo-tabs-bar::-webkit-scrollbar {
    display: none;
  }
  .photo-doc-tab {
    padding: 3px 8px !important;
    font-size: 11px !important;
    gap: 4px !important;
  }

  /* Floating Info Pill on Mobile: Place on top or bottom right away from handle */
  main .pointer-events-none.absolute.bottom-3.left-3 {
    display: none !important;
  }

  /* Status Bar on Mobile: Floating Pill */
  .shadow-panel {
    max-width: 90vw !important;
    font-size: 10px !important;
    padding: 3px 8px !important;
  }

  /* Modal popups on mobile */
  #photo-shapes-submenu-panel {
    width: 94vw !important;
    left: 3vw !important;
    max-height: 65vh !important;
  }

  #canva-panel {
    width: 100vw !important;
    max-width: 100vw !important;
  }

  /* Full Responsive Overrides for New Project / Template & Export Dialogs */
  .fixed.inset-0.z-50 {
    padding: 8px !important;
  }

  .fixed.inset-0.z-50 > div.flex.h-\[min\(620px\,90vh\)\] {
    width: 100% !important;
    max-width: 100vw !important;
    height: 94vh !important;
    max-height: 94vh !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    border-radius: 12px !important;
  }

  /* Left sidebar in New Project modal */
  .fixed.inset-0.z-50 > div.flex.h-\[min\(620px\,90vh\)\] > div.w-48 {
    width: 100% !important;
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border, #334155) !important;
    padding: 8px 12px !important;
    gap: 8px !important;
  }

  .fixed.inset-0.z-50 > div.flex.h-\[min\(620px\,90vh\)\] > div.w-48 p.mt-auto {
    display: none !important;
  }

  .fixed.inset-0.z-50 > div.flex.h-\[min\(620px\,90vh\)\] > div.w-48 .text-xs {
    display: none !important;
  }

  /* Middle templates grid section */
  .fixed.inset-0.z-50 > div.flex.h-\[min\(620px\,90vh\)\] > div.min-w-0 {
    flex: 1 1 auto !important;
    min-height: 200px !important;
    max-height: 40vh !important;
    border-bottom: 1px solid var(--border, #334155) !important;
  }

  /* Right settings panel in New Project modal */
  .fixed.inset-0.z-50 > div.flex.h-\[min\(620px\,90vh\)\] > div.w-72 {
    width: 100% !important;
    border-left: none !important;
    padding: 12px !important;
    gap: 10px !important;
    flex-shrink: 0 !important;
  }

  /* Compact preset tabs */
  .fixed.inset-0.z-50 > div.flex.h-\[min\(620px\,90vh\)\] > div.min-w-0 > div:first-child {
    overflow-x: auto !important;
    white-space: nowrap !important;
    padding: 6px 8px !important;
  }

  .ms-action-search-wrapper {
    margin-left: 4px !important;
  }

  .ms-action-search-box {
    width: 160px !important;
  }
}


/* ==========================================================================
   Office Shapes Submenu Dropdown & Dialog Styles
   ========================================================================== */
#photo-shapes-submenu-container {
  position: relative;
  z-index: 99999;
}

#photo-shapes-submenu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99990;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(1px);
}

#photo-shapes-submenu-panel {
  position: fixed;
  z-index: 99995;
  width: 520px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface, #1e293b);
  color: var(--text-main, #f8fafc);
  border: 1px solid var(--border-color, #334155);
  border-radius: 10px;
  box-shadow: 0 20px 35px -5px rgba(0, 0, 0, 0.5), 0 10px 15px -5px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  box-sizing: border-box;
}

#photo-shapes-submenu-panel .photo-shapes-grid-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto !important;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}

#photo-shapes-submenu-panel .photo-shapes-grid-scroll::-webkit-scrollbar {
  width: 8px;
}

#photo-shapes-submenu-panel .photo-shapes-grid-scroll::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.4);
  border-radius: 4px;
}

#photo-shapes-submenu-panel .photo-shapes-grid-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.5);
  border-radius: 4px;
}

#photo-shapes-submenu-panel .photo-shapes-grid-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.8);
}

#photo-shapes-submenu-panel .photo-shapes-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

@media (min-width: 500px) {
  #photo-shapes-submenu-panel .photo-shapes-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.photo-shape-sub-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.3);
  color: var(--text-main, #f8fafc);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.photo-shape-sub-item:hover {
  background: rgba(148, 163, 184, 0.15);
  border-color: rgba(148, 163, 184, 0.4);
  transform: translateY(-1px);
}

.photo-shape-sub-item.active {
  background: rgba(59, 130, 246, 0.2);
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px #3b82f6;
}

.photo-shape-sub-item .shape-preview-wrap {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.photo-shape-sub-item .shape-name {
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ── Top bar: keep Language / Install App / Account pinned on the right, beside the menu ── */
header { min-width: 0; }
header > .menu-bar { flex: 0 1 auto; min-width: 0; overflow: visible; }
header > .ms-action-search-wrapper { flex: 0 1 245px; min-width: 40px; }
header > .ms-action-search-wrapper .ms-action-search-box { width: 100%; min-width: 0; }
header > .photo-header-right { flex: 0 0 auto !important; margin-left: auto !important; }
@media screen and (max-width: 1280px) {
  header > .ms-action-search-wrapper { flex-basis: 170px; }
  #photo-header-right .btn-pwa-install span { display: none; }
}
@media screen and (max-width: 1100px) {
  header > .ms-action-search-wrapper { display: none; }
  #photo-header-right .btn-lang-toggle span { display: none; }
  #photo-header-right .infinity-account-name { display: none; }
}
