/* GlowAuth v24 — shared responsive and interaction refinement layer.
   Loaded last intentionally so all existing workspace screens share one final set of guardrails. */
:root {
  --ga-page-gutter: clamp(12px, 3.1vw, 44px);
  --ga-content-limit: 1600px;
  --ga-radius-card: clamp(17px, 1.7vw, 25px);
  --ga-control-height: 44px;
  --ga-focus-ring: 0 0 0 3px rgba(173, 150, 255, .19);
  --ga-ease-out: cubic-bezier(.2, .75, .25, 1);
}

html {
  min-width: 320px;
  overflow-x: hidden;
  overflow-x: clip;
  scroll-padding-top: 18px;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}

*, *::before, *::after { box-sizing: border-box; }
img, video, canvas, iframe { max-width: 100%; }
svg { flex-shrink: 0; }
button, input, select, textarea { max-width: 100%; }
button, a, input, select, textarea, summary { touch-action: manipulation; }
button, input, select, textarea { font-family: inherit; }

.ga-icon-svg {
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
  max-width: 100%;
  overflow: visible;
  vertical-align: -0.16em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab-icon .ga-icon-svg { width: 18px; height: 18px; vertical-align: middle; }
.execution-stat-card > i .ga-icon-svg { width: 22px; height: 22px; }
.drop-icon .ga-icon-svg { width: 24px; height: 24px; }
.quick-icon .ga-icon-svg, .script-controls-empty-icon .ga-icon-svg,
.script-item-glyph .ga-icon-svg, .recent-execution-icon .ga-icon-svg,
.execution-asset-icon .ga-icon-svg, .api-token-symbol .ga-icon-svg,
.api-project-icon .ga-icon-svg, .api-list-empty .ga-icon-svg,
.key-generator-empty-icon .ga-icon-svg, .empty-orb .ga-icon-svg { width: 1.25em; height: 1.25em; }

/* Wider content on large displays without letting text lines become uncomfortably long. */
.dashboard-shell {
  width: min(var(--ga-content-limit), calc(100% - clamp(22px, 4.2vw, 88px))) !important;
  min-width: 0 !important;
  margin-inline: auto !important;
}
.dashboard-section, .dashboard-header, .dashboard-nav,
.dashboard-overview-hero, .dashboard-overview-copy,
.execution-content-grid, .workspace-grid, .panel-builder-grid,
.panel-editor-card, .panel-preview-column, .panel-preview-card,
.api-layout-grid, .api-heading, .api-hero, .docs-hero,
.controls-hero, .controls-settings-card, .shop-dialog,
.shop-dialog-content, .premium-bg-preview-dialog, .panel-source-dialog {
  min-width: 0;
  max-width: 100%;
}
.dashboard-overview-copy p,
.dashboard-home-card-heading p,
.panel-card-heading p,
.panel-form-section-title small,
.api-heading p,
.docs-hero p,
.controls-hero-copy p { overflow-wrap: anywhere; }

/* Eight dashboard destinations align evenly at desktop and tablet widths. */
@media (min-width: 1101px) {
  .dashboard-nav {
    width: 100% !important;
    max-width: none !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    align-items: stretch;
  }
  .dashboard-nav .dashboard-tab {
    width: 100%;
    min-width: 0;
    min-height: 58px;
  }
  .dashboard-nav .dashboard-tab > span:last-child { min-width: 0; }
  .dashboard-nav .dashboard-tab strong,
  .dashboard-nav .dashboard-tab small {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (min-width: 701px) and (max-width: 1100px) {
  .dashboard-shell {
    width: min(calc(100% - 30px), 1120px) !important;
  }
  .dashboard-nav {
    width: 100% !important;
    max-width: none !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .dashboard-nav .dashboard-tab { min-width: 0; }
  .dashboard-header { flex-wrap: wrap; row-gap: 12px; }
  .dashboard-header .top-actions { flex: 1 1 100%; justify-content: flex-end; min-width: 0; }
  .dashboard-overview-hero { grid-template-columns: minmax(0, 1fr) minmax(170px, .48fr); }
  .execution-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .api-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Cards and form rows are allowed to shrink; controls never push their grid wider. */
.workspace-grid > *, .panel-builder-grid > *, .api-layout-grid > *,
.panel-fields > *, .panel-feature-fields > *, .key-generator-grid > *,
.execution-stat-grid > *, .execution-content-grid > *,
.api-stats-grid > *, .api-pricing-grid > *, .shop-plan-grid > *,
.shop-style-grid > *, .panel-preview-column > * { min-width: 0; }
.panel-field, .panel-field > *, .panel-source-launch-copy,
.file-info, .api-token-row-info, .api-project-info,
.script-item-main, .script-control-title, .recent-execution-detail,
.execution-asset-detail { min-width: 0; }
.panel-field input, .panel-field textarea, .panel-field select,
.source-code-input, .api-copy-row input, .api-endpoint-line code,
.file-id code, .script-item-endpoint code { max-width: 100%; }

/* Stable, readable controls. Avoid global cursor-only button effects for disabled controls. */
button, [role="button"], input, select, textarea {
  accent-color: #a894ff;
}
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid #b8a7ff;
  outline-offset: 3px;
  box-shadow: var(--ga-focus-ring);
}
button:disabled, [aria-disabled="true"] { cursor: not-allowed; }
.primary-btn, .secondary-btn, .logout-btn, .shop-header-button,
.mobile-tabs-toggle, .builder-heading-actions button,
.panel-appearance-actions button, .panel-source-open-btn,
.panel-source-apply, .api-buy-button, .shop-plan-actions button,
.shop-style-action, .shop-style-preview, .shop-close-button,
.premium-bg-preview-footer button, .panel-preview-device-switch button {
  min-height: var(--ga-control-height);
}
.primary-btn, .secondary-btn, .logout-btn, .shop-header-button,
.mobile-tabs-toggle, .dashboard-tab, .panel-appearance-actions button,
.panel-source-open-btn, .api-buy-button, .shop-plan-actions button,
.shop-style-action, .shop-style-preview, .panel-source-apply {
  transition: transform .17s var(--ga-ease-out), border-color .17s ease,
    background-color .17s ease, box-shadow .17s ease, color .17s ease;
}
@media (hover: hover) and (pointer: fine) {
  .primary-btn:hover:not(:disabled), .builder-publish:hover:not(:disabled),
  .api-buy-button:hover:not(:disabled), .shop-style-action:hover:not(:disabled) {
    transform: translateY(-1px);
  }
  .primary-btn:active:not(:disabled), .secondary-btn:active:not(:disabled),
  .logout-btn:active:not(:disabled), .shop-header-button:active:not(:disabled),
  .mobile-tabs-toggle:active:not(:disabled) { transform: translateY(0) scale(.985); }
}

/* Modals use the visual viewport, safe areas, and their own scroll region on all devices. */
.shop-modal, .premium-bg-preview-modal, .panel-source-modal {
  padding-top: max(8px, env(safe-area-inset-top, 0px));
  padding-right: max(8px, env(safe-area-inset-right, 0px));
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  padding-left: max(8px, env(safe-area-inset-left, 0px));
  overscroll-behavior: contain;
}
.shop-dialog, .premium-bg-preview-dialog, .panel-source-dialog {
  max-height: min(94vh, 940px);
  max-height: min(94dvh, 940px);
  overscroll-behavior: contain;
}
.shop-dialog-content, .premium-bg-preview-mount, .panel-source-dialog-body { overscroll-behavior: contain; }
body.shop-open, body.modal-open { overflow: hidden; }

/* Correct line breaking for IDs, URLs, code examples, and long generated loadstrings. */
.api-token-prefix, .api-project-info code, .script-item-endpoint code,
.published-link-row input, .panel-loader-box input,
.panel-loader-box textarea, .api-endpoint-line code,
.api-code, .source-code-input { overflow-wrap: anywhere; }
.api-code, .source-code-input { overscroll-behavior-x: contain; }
.file-row, .saved-panel-row, .panel-key-row, .generated-key-item,
.api-token-row, .api-project-row, .script-control-item,
.recent-execution-item, .execution-asset-row { min-width: 0; max-width: 100%; }

/* Mobile is a deliberately re-composed interface, not a shrunken desktop page. */
@media (max-width: 700px) {
  .dashboard-shell {
    width: calc(100% - 20px) !important;
    padding-top: max(10px, env(safe-area-inset-top, 0px)) !important;
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px)) !important;
  }
  .dashboard-header { min-width: 0; }
  .dashboard-header .brand-link { max-width: 100%; }
  .dashboard-header .brand-copy { min-width: 0; }
  .dashboard-header .top-actions { flex-wrap: wrap; min-width: 0; }
  .dashboard-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: auto !important;
    max-width: none !important;
    gap: 7px !important;
  }
  .dashboard-nav .dashboard-tab {
    min-width: 0;
    min-height: 56px !important;
    padding: 9px !important;
  }
  .dashboard-nav .dashboard-tab > span:last-child { min-width: 0; }
  .dashboard-nav .dashboard-tab strong,
  .dashboard-nav .dashboard-tab small {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  /* The open mobile navigation is a single-column drawer, not a content grid. */
  body.mobile-tabs-open #dashboardNav {
    grid-template-columns: minmax(0, 1fr) !important;
    width: auto !important;
  }
  body.mobile-tabs-open #dashboardNav > .dashboard-tab {
    grid-column: auto !important;
    width: 100% !important;
  }
  .dashboard-overview-hero { grid-template-columns: minmax(0, 1fr) !important; }
  .dashboard-overview-actions { align-items: flex-start; flex-wrap: wrap; }
  .execution-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .execution-stat-card { min-width: 0; padding: clamp(13px, 4vw, 17px) !important; }
  .execution-stat-card strong { overflow-wrap: anywhere; }
  .execution-content-grid, .workspace-grid, .panel-builder-grid,
  .api-layout-grid, .api-project-form, .api-token-form,
  .controls-settings-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .panel-preview-column { position: static !important; max-height: none !important; overflow: visible !important; }
  .panel-preview-column .key-manager-card,
  .panel-preview-column .saved-panels-card { grid-column: auto !important; }
  .panel-fields.two-col, .panel-feature-fields,
  .api-scope-grid, .api-doc-endpoints { grid-template-columns: minmax(0, 1fr) !important; }
  .section-top, .result-head, .files-head, .panel-card-heading,
  .api-heading, .api-pricing-heading, .controls-settings-heading {
    min-width: 0;
    flex-wrap: wrap;
  }
  .section-top > *, .result-head > *, .files-head > *, .panel-card-heading > * { min-width: 0; }
  .files-head { align-items: stretch; }
  .library-tools { grid-template-columns: minmax(0, 1fr) auto; }
  .library-tools input { min-width: 0; width: 100%; }
  .file-row-actions { min-width: 0; }
  .api-copy-row { align-items: stretch; }
  .api-copy-row input { min-width: 0; font-size: 16px; }
  .api-token-row, .api-project-row { flex-wrap: wrap; }
  .api-token-row-info, .api-project-info { flex: 1 1 calc(100% - 52px); }
  .api-token-state { margin-left: 0; }
  .api-token-actions { display: flex; flex: 1 1 100%; gap: 8px; }
  .api-token-actions button { min-height: 42px; flex: 1 1 0; }
  .api-project-archive { min-height: 42px; }
  .api-code { font-size: .68rem; }
  .shop-dialog { width: 100%; max-height: 96vh; max-height: 96dvh; border-radius: 19px; }
  .shop-dialog-header { grid-template-columns: minmax(0, 1fr) 40px; }
  .shop-dialog-content { min-width: 0; }
  .shop-plan-grid, .shop-style-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .shop-plan-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .premium-bg-preview-dialog, .panel-source-dialog { width: 100%; max-width: 100%; }
  .panel-source-dialog-body textarea, .source-code-input { font-size: 16px; }
  .floating-shop-banner { max-width: calc(100vw - 20px); }
}

@media (max-width: 420px) {
  .dashboard-shell { width: calc(100% - 16px) !important; }
  .dashboard-header .brand-logo-frame { flex-basis: 35px; width: 35px; height: 35px; }
  .dashboard-header .brand-copy .brand-subtitle { display: none; }
  .dashboard-header .profile { min-width: 0; max-width: 100%; }
  .dashboard-header .profile > div { min-width: 0; }
  .dashboard-header .profile strong { max-width: min(30vw, 110px); }
  .dashboard-header .profile small { max-width: min(30vw, 110px); }
  .dashboard-overview-copy h1 { font-size: clamp(2rem, 10.2vw, 2.65rem) !important; }
  .builder-heading-actions { grid-template-columns: minmax(0, 1fr) !important; }
  .builder-heading-actions button { width: 100%; }
  .execution-stat-card > span { overflow-wrap: anywhere; }
  .shop-plan-actions { grid-template-columns: minmax(0, 1fr) !important; }
  .api-copy-row { display: grid; grid-template-columns: minmax(0, 1fr); }
  .api-copy-row button { min-height: 44px; }
  .floating-shop-banner { left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom, 0px)); width: auto; }
}

@media (max-width: 350px) {
  .execution-stat-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .dashboard-nav { grid-template-columns: minmax(0, 1fr) !important; }
  .dashboard-nav .dashboard-tab { min-height: 48px !important; }
  .dashboard-nav .dashboard-tab small { display: none; }
  .library-tools { grid-template-columns: minmax(0, 1fr); }
  .library-tools > * { width: 100%; }
  .profile { max-width: calc(100% - 78px); }
}

@media (max-height: 560px) and (orientation: landscape) {
  .shop-dialog, .premium-bg-preview-dialog, .panel-source-dialog {
    max-height: calc(100vh - 12px);
    max-height: calc(100dvh - 12px);
  }
  .shop-modal, .premium-bg-preview-modal, .panel-source-modal { align-items: start; }
  .dashboard-nav { scroll-margin-top: 8px; }
}

/* Limit expensive decorative rendering on coarse pointers and low-power devices. */
@media (pointer: coarse), (max-width: 760px) {
  .ambient { filter: none !important; opacity: .1 !important; }
  .shop-modal-backdrop { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
  .dashboard-overview-hero::before, .dashboard-overview-hero::after,
  .login-showcase::before, .login-showcase::after { animation: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}


/* Tiny animated indicators use compositor-friendly properties only. */
.ga-loading-spinner{display:inline-block;width:1.15em;height:1.15em;border:2px solid rgba(173,150,255,.22);border-top-color:#b8a7ff;border-radius:50%;animation:ga-spinner-rotate .75s linear infinite;vertical-align:-.2em}
@keyframes ga-spinner-rotate{to{transform:rotate(360deg)}}
@media(prefers-reduced-motion:reduce){.ga-loading-spinner{animation:none;border-top-color:rgba(173,150,255,.65)}}

/* Comfortable targets for the most frequently used navigation and modal actions. */
@media (pointer: coarse) {
  .dashboard-tab, .docs-toc a, .mobile-tabs-toggle, .logout-btn, .shop-header-button,
  .file-row-actions button, .saved-panel-actions button, .api-token-actions button,
  .api-project-archive, .panel-source-open-btn, .panel-source-apply,
  .shop-plan-actions button, .shop-style-action, .shop-style-preview,
  .key-submit, .key-status-button, .check-script-trigger { min-height: 44px !important; }
}
