/* ==========================================================================
   Dimo Softwares — Shared Design System (tokens + primitives)

   Calm, neutral, precise. The UI is almost entirely greyscale; each service's
   accent (--primary-rgb) is reserved for the primary action, focus rings,
   selection and small active indicators. No glows, no ambient gradients, no
   glass: depth comes from three surface steps and hairline borders.

   Layers (both themes):
     page      --color-bg-dark        the canvas
     surface   --color-surface        cards, panels, sidebars
     raised    --color-raised         popovers, menus, sheets
     well      --sunken               inputs, code, recessed plates
   ========================================================================== */

:root {
    color-scheme: dark;
    --color-bg-rgb: 14 15 18;
    --color-surface-rgb: 22 23 27;
    --color-raised-rgb: 29 31 36;
    --color-text-main-rgb: 236 237 240;
    --color-text-muted-rgb: 145 150 161;
    --color-text-on-primary-rgb: 10 11 13;
    --color-bg-dark: #0E0F12;
    --color-surface: #16171B;
    --color-raised: #1D1F24;
    --color-text-main: #ECEDF0;
    --color-text-muted: #9196A1;
    --color-text-subtle: #6B707B;
    --color-text-on-primary: #0A0B0D;
    --color-surface-translucent: rgb(22 23 27 / 0.72);
    --color-raised-translucent: rgb(29 31 36 / 0.9);
    --color-hover-subtle: rgb(255 255 255 / 0.045);
    --color-hover-strong: rgb(255 255 255 / 0.075);
    --header-bg: rgb(14 15 18 / 0.82);
    --shadow-color: rgb(0 0 0 / 0.55);

    /* Overridden per service by the [data-service] blocks below */
    --primary-rgb: 163 230 53;
    /* --primary-ink-rgb is the accent when it is used as TEXT or as an icon
       stroke rather than as a fill. On the dark theme they are the same value;
       the light theme overrides it per service with a darkened variant.
       Rule of thumb: fills/borders use --primary-rgb, `color:` uses
       --primary-ink-rgb. */
    --primary-ink-rgb: var(--primary-rgb);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --border-subtle: rgb(255 255 255 / 0.075);
    --border-strong: rgb(255 255 255 / 0.13);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

    --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3), 0 1px 3px rgb(0 0 0 / 0.2);
    --shadow-md: 0 8px 20px -6px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 24px 48px -16px rgb(0 0 0 / 0.65), 0 4px 10px -4px rgb(0 0 0 / 0.3);
}

/* ── Light theme ─────────────────────────────────────────────────────────────
   A soft neutral page with white cards. Text is near-black ink (18:1 on
   cards); muted copy is #5B6271 (6.4:1 on white, 6:1 on the page) so the
   small meta labels used across the dashboards stay legible. */
:root[data-theme="light"] {
    color-scheme: light;
    --color-bg-rgb: 246 247 249;
    --color-surface-rgb: 255 255 255;
    --color-raised-rgb: 255 255 255;
    --color-text-main-rgb: 14 17 22;
    --color-text-muted-rgb: 91 98 113;
    --color-text-on-primary-rgb: 255 255 255;
    --color-bg-dark: #F6F7F9;
    --color-surface: #FFFFFF;
    --color-raised: #FFFFFF;
    --color-text-main: #0E1116;
    --color-text-muted: #5B6271;
    --color-text-subtle: #858B98;
    --color-text-on-primary: #FFFFFF;
    --color-surface-translucent: rgb(255 255 255 / 0.92);
    --color-raised-translucent: rgb(255 255 255 / 0.96);
    --color-hover-subtle: rgb(14 17 22 / 0.04);
    --color-hover-strong: rgb(14 17 22 / 0.065);
    --header-bg: rgb(246 247 249 / 0.85);
    --shadow-color: rgb(14 17 22 / 0.12);
    --border-subtle: rgb(14 17 22 / 0.08);
    --border-strong: rgb(14 17 22 / 0.14);

    --shadow-xs: 0 1px 2px rgb(14 17 22 / 0.05);
    --shadow-sm: 0 1px 2px rgb(14 17 22 / 0.05), 0 1px 3px rgb(14 17 22 / 0.04);
    --shadow-md: 0 6px 16px -4px rgb(14 17 22 / 0.08), 0 2px 4px -2px rgb(14 17 22 / 0.04);
    --shadow-lg: 0 20px 40px -14px rgb(14 17 22 / 0.16), 0 4px 10px -4px rgb(14 17 22 / 0.05);

    /* Default accent (hub green) — deepened, see the per-service block below. */
    --primary-rgb: 58 118 16;
    --primary-ink-rgb: 58 118 16;
}

/* Service accents. The brand hues, pulled back a step from neon so a filled
   button reads as confident rather than loud. */
[data-service="hub"]      { --primary-rgb: 163 230 53; }   /* lime  #A3E635 */
[data-service="main"]     { --primary-rgb: 163 230 53; }
[data-service="dashboard"]{ --primary-rgb: 163 230 53; }
[data-service="agents"]   { --primary-rgb: 34 211 238; }   /* cyan  #22D3EE */
[data-service="imagine"]  { --primary-rgb: 214 120 255; }  /* pink  #D678FF */
[data-service="storage"]  { --primary-rgb: 250 204 21; }   /* amber #FACC15 */
[data-service="edits"]    { --primary-rgb: 255 138 76; }   /* orange #FF8A4C */
/* Support keeps a calm teal so a help page never looks like an alert. */
[data-service="support"]  { --primary-rgb: 45 212 191; }   /* teal  #2DD4BF */

/* ── Light-theme accents ────────────────────────────────────────────────────
   Neon hues fail on white both as text (1.2:1) and as fills (glare), so each
   service swaps to a deep, same-hue accent that carries white text at >= 5:1
   and clears 4.5:1 as text. Storage keeps a golden fill with dark text and a
   separate darker ink.

   IMPORTANT: --primary-ink-rgb must be re-declared alongside every
   --primary-rgb override. A `--x: var(--y)` alias is resolved where it is
   declared, so a descendant changing --primary-rgb does NOT change it. */
:root[data-theme="light"][data-service="hub"],
:root[data-theme="light"][data-service="main"],
:root[data-theme="light"][data-service="dashboard"] { --primary-rgb: 58 118 16;  --primary-ink-rgb: 58 118 16; }   /* #3A7610 */
:root[data-theme="light"][data-service="agents"]    { --primary-rgb: 8 112 140;  --primary-ink-rgb: 8 112 140; }   /* #08708C */
:root[data-theme="light"][data-service="imagine"]   { --primary-rgb: 134 46 190; --primary-ink-rgb: 134 46 190; }  /* #862EBE */
:root[data-theme="light"][data-service="storage"]   { --primary-rgb: 234 179 8;  --primary-ink-rgb: 133 90 0;
                                                      --color-text-on-primary-rgb: 31 24 0; --color-text-on-primary: #1F1800; }
:root[data-theme="light"][data-service="edits"]     { --primary-rgb: 194 65 12;  --primary-ink-rgb: 194 65 12; }   /* #C2410C */
:root[data-theme="light"][data-service="support"]   { --primary-rgb: 13 110 100; --primary-ink-rgb: 13 110 100; }  /* #0D6E64 */

/* --------------------------------------------------------- base ---------- */

* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
    background-color: var(--color-bg-dark);
    color: var(--color-text-main);
    font-family: 'Vazirmatn', ui-sans-serif, system-ui, sans-serif;
    font-feature-settings: 'ss02';
    font-size: 15px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

:root.nav-open { overflow: hidden; }

::selection {
    background: rgb(var(--primary-rgb) / 0.3);
    color: var(--color-text-main);
}

.font-mono, code, pre, kbd, .tabular {
    font-family: 'Roboto Mono', ui-monospace, 'SFMono-Regular', monospace;
    font-feature-settings: normal;
}

/* Latin numerals stay readable inside RTL text */
[dir="rtl"] .ltr { direction: ltr; unicode-bidi: embed; }

/* ------------------------------------------------------ scrollbar -------- */

* { scrollbar-width: thin; scrollbar-color: rgb(var(--color-text-muted-rgb) / 0.28) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgb(var(--color-text-muted-rgb) / 0.22);
    border: 3px solid transparent;
    background-clip: padding-box;
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: rgb(var(--color-text-muted-rgb) / 0.4); background-clip: padding-box; }

/* ------------------------------------------------------ ambience --------- */

/* The canvas is deliberately plain: no grid, no bloom. */
.dimo-canvas::before,
.dimo-canvas::after { content: none; }

/* ------------------------------------------------------ surfaces --------- */

.surface {
    background-color: var(--color-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.surface-flat {
    background-color: var(--color-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.surface-sunken {
    background-color: var(--sunken, rgb(0 0 0 / 0.2));
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
}

/* Interactive card: the border firms up on hover. No glow, no jump. */
.card-hover {
    transition: border-color 0.2s var(--ease-out),
                box-shadow 0.2s var(--ease-out),
                background-color 0.2s var(--ease-out);
}
.card-hover:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

/* Retired decoration: a hairline accent across the card top. */
.card-edge { position: relative; overflow: hidden; }
.card-edge::before { content: none; }

/* Focused state for keyboard navigation */
.card-hover.focused {
    outline: 2px solid rgb(var(--primary-rgb) / 0.8);
    outline-offset: 2px;
}

/* Component display beats a bare Tailwind `hidden`; JS-toggled buttons
   need an explicit pair so details/preview actions can actually hide. */
.btn.hidden,
.opt-btn.hidden {
    display: none;
}

/* --------------------------------------------------- file explorer -------- */

.fx-shell {
    display: grid;
    grid-template-columns: 1fr;
    min-height: min(70vh, 820px);
    background: var(--color-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    overflow: visible;
}
@media (min-width: 768px) {
    .fx-shell { grid-template-columns: 220px minmax(0, 1fr); }
}
@media (min-width: 1280px) {
    .fx-shell { grid-template-columns: 220px minmax(0, 1fr) 280px; }
}
.fx-nav,
.fx-details {
    background: var(--color-bg-dark);
    overflow-y: auto;
    min-width: 0;
    position: relative;
    z-index: 1;
}
.fx-nav { border-bottom: 1px solid var(--border-subtle); }
.fx-details { border-top: 1px solid var(--border-subtle); }
@media (min-width: 768px) {
    .fx-nav { border-bottom: 0; border-inline-end: 1px solid var(--border-subtle); }
}
@media (min-width: 1280px) {
    .fx-details { border-top: 0; border-inline-start: 1px solid var(--border-subtle); }
}
.fx-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    position: relative;
    z-index: 2;
    overflow: visible;
}
.fx-pane {
    flex: 1 1 auto;
    overflow: visible;
    padding: 0.75rem;
}
.fx-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
    gap: 0.35rem;
    align-items: stretch;
}
.fx-item {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border: 1px solid transparent;
    border-radius: 0.4rem;
    background: transparent;
    cursor: default;
    position: relative;
    z-index: 0;
    transition: background-color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}
.fx-item:hover,
.fx-item:focus-within { z-index: 5; }
.fx-item:hover { background: var(--color-hover-subtle); }
.fx-item.is-on,
.fx-item:has([data-sel]:checked) {
    background: rgb(var(--primary-rgb) / 0.12);
    border-color: rgb(var(--primary-rgb) / 0.35);
}
.fx-thumb {
    aspect-ratio: 1 / 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: transparent;
    position: relative;
    cursor: pointer;
    border: 0;
    padding: 0;
}
.fx-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    pointer-events: none;
}
.fx-caption {
    height: 2.7rem;
    padding: 0.2rem 0.35rem 0.4rem;
    text-align: center;
    font-size: 0.75rem;
    line-height: 1.25;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: var(--color-text-main);
    word-break: break-word;
}
.fx-menu {
    position: fixed;
    z-index: 80;
    width: 7.5rem;
    min-width: 7.5rem;
    max-width: 7.5rem;
    padding: 0.2rem;
}
.fx-menu.hidden { display: none; }
.fx-menu button {
    padding: 0.35rem 0.5rem;
    font-size: 0.6875rem;
    line-height: 1.2;
    white-space: nowrap;
}
.fx-dots {
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.3rem;
    color: #fff;
    background-color: rgb(0 0 0 / 0.45);
    border-color: rgb(255 255 255 / 0.2);
}
.fx-dots:hover {
    color: #fff;
    background-color: rgb(0 0 0 / 0.65);
    border-color: rgb(255 255 255 / 0.35);
}
.fx-dots svg {
    width: 0.9rem;
    height: 0.9rem;
    display: block;
    fill: currentColor;
}
.fx-filter {
    width: auto;
    min-width: 0;
    max-width: 7.5rem;
    padding: 0.28rem 1.6rem 0.28rem 0.45rem;
    font-size: 0.6875rem;
    line-height: 1.2;
    background-size: 0.75rem;
    background-position: left 0.35rem center;
    padding-left: 1.35rem;
}
.fx-search {
    width: 100%;
    max-width: 16rem;
    padding: 0.28rem 0.6rem 0.28rem 1.7rem;
    font-size: 0.75rem;
}
.fx-row {
    display: grid;
    grid-template-columns: 1.75rem minmax(0, 2.4fr) minmax(0, 1.1fr) 5.5rem 4.5rem 6.5rem 2.5rem;
    gap: 0.75rem;
    align-items: center;
    min-height: 2.5rem;
    padding: 0.2rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}
.fx-row-head {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--color-surface);
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    min-height: 2rem;
}
.fx-ico {
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.fx-ico img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}
@media (max-width: 767px) {
    .fx-row { grid-template-columns: 1.75rem minmax(0, 1fr) 2.5rem; }
    .fx-hide-sm { display: none; }
}


/* ── Searchable Select & Filter inputs ────────────────────────────────────── */
.model-search-input {
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm, 0.375rem);
    border: 1px solid var(--border-subtle);
    background-color: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.model-search-input:focus {
    border-color: rgb(var(--primary-rgb) / 0.75);
    outline: none;
    box-shadow: 0 0 0 3px rgb(var(--primary-rgb) / 0.16);
}
.model-search-input::placeholder {
    color: rgba(156, 163, 175, 0.6);
}
/* Agent-volume file list: no checkbox column, extra room for the two actions. */
.agent-fx-head,
.agent-file-row {
    grid-template-columns: 1.75rem minmax(0, 2fr) minmax(0, 1.4fr) 5.5rem 6.5rem 8.5rem;
}
@media (max-width: 767px) {
    .agent-fx-head,
    .agent-file-row { grid-template-columns: 1.75rem minmax(0, 1fr) auto; }
}

/* ------------------------------------------------------- buttons --------- */

/* .btn and its variants live in shell.css (loaded after this file), which is
   the single source for button styling. Only the small square icon control
   is defined here. */

.icon-btn {
    display: inline-flex;
    width: 2.25rem;
    height: 2.25rem;
    flex: 0 0 2.25rem;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--color-text-muted);
    background-color: transparent;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
.icon-btn:hover {
    color: var(--color-text-main);
    background-color: var(--color-hover-strong);
}
.icon-btn.is-on,
.icon-btn[aria-pressed="true"] {
    color: rgb(var(--primary-ink-rgb));
    background-color: rgb(var(--primary-rgb) / 0.1);
}
.icon-btn:focus-visible {
    outline: 2px solid rgb(var(--primary-rgb) / 0.7);
    outline-offset: 2px;
}

/* -------------------------------------------------------- inputs --------- */

.field-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-main);
    margin-bottom: 0.45rem;
}

.field {
    width: 100%;
    background-color: var(--field-bg, rgb(0 0 0 / 0.22));
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 0.625rem 0.85rem;
    color: var(--color-text-main);
    font-size: 0.9375rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.field::placeholder { color: rgb(var(--color-text-muted-rgb) / 0.7); }
.field:focus {
    outline: none;
    border-color: rgb(var(--primary-rgb) / 0.75);
    box-shadow: 0 0 0 3px rgb(var(--primary-rgb) / 0.16);
}
.field:hover:not(:focus) { border-color: rgb(var(--color-text-muted-rgb) / 0.35); }
.field:disabled,
.field[readonly] {
    opacity: 0.7;
    cursor: not-allowed;
    color: var(--color-text-muted);
}
.field:disabled:hover,
.field[readonly]:hover { border-color: var(--border-strong); }

select.field {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239196A1' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.8rem center;
    background-size: 1rem;
    padding-left: 2.4rem;
}
select.field option { background-color: var(--color-raised); }

textarea.field { resize: vertical; min-height: 6rem; line-height: 1.75; }

/* --------------------------------------------------------- chips ---------- */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.125rem 0.5rem;
    border-radius: 6px;
    font-size: 0.6875rem;
    font-weight: 500;
    line-height: 1.6;
    border: 1px solid var(--border-subtle);
    color: var(--color-text-muted);
    background-color: var(--color-hover-subtle);
}
.chip-primary {
    border-color: rgb(var(--primary-rgb) / 0.25);
    color: rgb(var(--primary-ink-rgb));
    background-color: rgb(var(--primary-rgb) / 0.08);
}

.dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 99px;
    background-color: rgb(var(--primary-rgb));
    flex-shrink: 0;
}

/* ---------------------------------------------------------- nav ----------- */

.nav-link {
    position: relative;
    padding: 0.4rem 0.15rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    transition: color 0.2s var(--ease-out);
}
.nav-link:hover { color: var(--color-text-main); }
.nav-link::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    bottom: -0.35rem;
    height: 2px;
    border-radius: 2px;
    background-color: rgb(var(--primary-rgb));
    transform: scaleX(0);
    transition: transform 0.25s var(--ease-out);
}
.nav-link:hover::after { transform: scaleX(0); }
.nav-link.is-active {
    color: rgb(var(--primary-ink-rgb));
}
.nav-link.is-active::after { transform: scaleX(1); }

.app-navigation {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.app-navigation-head { display: none; }
.nav-backdrop { display: none; }

/* --------------------------------------------------------- footer -------- */

.app-footer {
    border-top: 1px solid var(--border-subtle);
    background-color: var(--color-bg-dark);
}
.footer-heading {
    margin-bottom: 0.9rem;
    color: var(--color-text-main);
    font-size: 0.8125rem;
    font-weight: 700;
}
.footer-links {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
    color: var(--color-text-muted);
    font-size: 0.8125rem;
}
.footer-links a { transition: color 0.18s var(--ease-out); }
.footer-links a:hover { color: rgb(var(--primary-ink-rgb)); }
.footer-bottom { border-top: 1px solid var(--border-subtle); }

/* ── Brand lockups on the light theme ───────────────────────────────────────
   Every logo PNG is authored for a dark UI: near-white wordmarks with neon
   glyphs. On the light theme they wash out (the plain Dimo mark measures
   1.12:1 on white — effectively invisible).

   `filter: invert(1)` was the previous fix and only ever worked for the
   greyscale mark: inverting a coloured lockup rotates its hue 180°, so the cyan
   Agents logo came out orange and Storage's yellow came out blue.

   Instead each lockup keeps its hue and is darkened (with a touch of extra
   saturation for the already-dark magenta) until the wordmark clears 4.5:1 on
   white. Values were measured against each PNG's median visible pixel, not
   guessed — re-measure if the artwork is replaced. */
:root[data-theme="light"] .brand-logo,
:root[data-theme="light"] .shell-brand img,
:root[data-theme="light"] .eco-logo,
:root[data-theme="light"] .svc-logo,
:root[data-theme="light"] .f-brand img {
    /* Neutral default, correct for the greyscale Dimo mark. */
    filter: brightness(0.48);
}
:root[data-theme="light"] img[src*="agents_logo"]  { filter: brightness(0.54); }
:root[data-theme="light"] img[src*="imagine_logo"] { filter: saturate(1.6) brightness(0.8); }
:root[data-theme="light"] img[src*="storage_logo"] { filter: brightness(0.48); }
:root[data-theme="light"] img[src*="edits_logo"]   { filter: brightness(0.66); }

/* --------------------------------------------------- section titles ------- */

/* Small label above a heading. Persian copy, set quietly — never an
   uppercase Latin micro-label. */
.eyebrow {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.page-title {
    font-size: clamp(1.4rem, 2.4vw, 1.75rem);
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.01em;
    color: var(--color-text-main);
}

.text-primary-c { color: rgb(var(--primary-ink-rgb)); }
.bg-primary-c   { background-color: rgb(var(--primary-rgb)); }
.border-primary-c { border-color: rgb(var(--primary-rgb)); }
.glow-primary   { box-shadow: none; }

/* --------------------------------------------------- side nav links ------- */

/* Vertical navigation used in app sidebars. */
.side-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    transition: background-color 0.18s var(--ease-out), color 0.18s var(--ease-out);
}
.side-link:hover {
    background-color: var(--color-hover-subtle);
    color: var(--color-text-main);
}
.side-link.is-on {
    background-color: var(--color-hover-strong);
    color: var(--color-text-main);
    font-weight: 600;
}
.side-link.is-on svg { color: rgb(var(--primary-ink-rgb)); }

/* --------------------------------------------------- option pills --------- */

/* Small segmented selector used in the generation studios. */
.opt-btn {
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-muted);
    background-color: transparent;
    border: 1px solid var(--border-strong);
    cursor: pointer;
    transition: background-color 0.18s var(--ease-out),
                color 0.18s var(--ease-out),
                border-color 0.18s var(--ease-out);
}
.opt-btn:hover {
    border-color: rgb(var(--color-text-muted-rgb) / 0.4);
    color: var(--color-text-main);
}
.opt-btn.is-on {
    background-color: rgb(var(--primary-rgb));
    border-color: rgb(var(--primary-rgb));
    color: var(--color-text-on-primary);
}

/* After .opt-btn so the kebab stays white on photos. Hidden until hover. */
.opt-btn.fx-dots {
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    color: #fff;
    background-color: rgb(0 0 0 / 0.55);
    border-color: rgb(255 255 255 / 0.28);
    opacity: 0;
}
.fx-item:hover .opt-btn.fx-dots,
.fx-row:hover .opt-btn.fx-dots,
.opt-btn.fx-dots:focus,
.opt-btn.fx-dots:focus-visible {
    opacity: 1;
}
.opt-btn.fx-dots:hover {
    color: #fff;
    background-color: rgb(0 0 0 / 0.75);
    border-color: rgb(255 255 255 / 0.45);
    opacity: 1;
}
.opt-btn.fx-dots svg {
    width: 0.9rem;
    height: 0.9rem;
    fill: #fff;
    color: #fff;
}

/* --------------------------------------------------------- meter ---------- */

.meter {
    width: 100%;
    height: 0.375rem;
    border-radius: 99px;
    background-color: var(--color-hover-strong);
    border: 0;
    overflow: hidden;
}
.meter > span {
    display: block;
    height: 100%;
    border-radius: 99px;
    background: rgb(var(--primary-rgb));
    /* Instant during an upload so every XHR tick is visible; quota meters
       still look fine because they jump once, not 60 times a second. */
    transition: width 0.12s linear;
}
.meter.is-critical > span {
    background: #EF4444;
}

/* ------------------------------------------------------- utilities -------- */

.divider {
    height: 1px;
    background: var(--border-subtle);
}

.skeleton {
    background: linear-gradient(90deg, var(--color-hover-subtle), var(--color-hover-strong), var(--color-hover-subtle));
    background-size: 200% 100%;
    animation: skeleton 1.4s infinite;
    border-radius: 0.5rem;
}
@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Placeholder notice for screens whose backend is not wired up yet. */
.stub-note {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    font-size: 0.8125rem;
    line-height: 1.7;
    color: var(--color-text-muted);
    background-color: var(--color-hover-subtle);
    border: 1px solid var(--border-subtle);
}

/* ───────────────────────────────────────────────────────────────────────────
   Ecosystem switcher rows — each service is identified by its own lockup
   instead of an abstract colour dot, so the menu matches the navbar brand.
   ─────────────────────────────────────────────────────────────────────────── */
.eco-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.625rem;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    transition: background-color 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
}
.eco-item:hover {
    background-color: var(--color-hover-subtle);
}
.eco-logo {
    height: 1.35rem;
    width: auto;
    max-width: 7.5rem;
    object-fit: contain;
    flex-shrink: 0;
    /* Logos are authored for dark UI; dim them until the row is hovered so the
       active service colour stays the loudest thing in the menu. */
    opacity: 0.75;
    transition: opacity 0.2s var(--ease-out);
}
.eco-item:hover .eco-logo { opacity: 1; }

@media (max-width: 767px) {
    /* Legacy .app-navigation rules removed to avoid conflicting with .shell-nav */
}

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

/* ── Responsive-visibility guard ────────────────────────────────────────────
   This file is loaded AFTER tailwind.css, so any component class that declares
   its own `display` (.btn, .icon-btn, .chip, .side-link, .footer-links …) beats
   a Tailwind `hidden` utility at equal specificity — last one wins.

   That silently broke every responsive hide: `class="icon-btn md:hidden"` still
   computed `display: flex` at 1440px, so the mobile hamburger rendered on
   desktop next to the full nav, and `hidden lg:inline-flex chip` header chips
   stayed visible on mobile and pushed the header 8px past the viewport.

   Re-asserting the responsive `hidden` variants here — at the end of the
   cascade, each inside its own breakpoint — hands visibility back to the
   utilities while components keep owning their layout. Scoped deliberately to
   the `min-width` variants: a bare `.hidden` is NOT re-declared, because
   `class="hidden md:flex"` legitimately relies on the later `md:flex` winning.
   Breakpoints mirror Tailwind's defaults. */
@media (min-width: 640px)  { .sm\:hidden  { display: none; } }
@media (min-width: 768px)  { .md\:hidden  { display: none; } }
@media (min-width: 1024px) { .lg\:hidden  { display: none; } }
@media (min-width: 1280px) { .xl\:hidden  { display: none; } }
@media (min-width: 1536px) { .\32xl\:hidden { display: none; } }

/* ---------------------------------------- avatar change button (agent detail) */
/* A primary-styled pill next to the status chips: the old plain "chip" label
   read as a passive tag, not the upload control it actually is. */
.avatar-change-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.7rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid rgb(var(--primary-rgb) / 0.3);
    color: rgb(var(--primary-ink-rgb));
    background-color: rgb(var(--primary-rgb) / 0.08);
    transition: background-color .25s, border-color .25s;
}
.avatar-change-btn:hover {
    background-color: rgb(var(--primary-rgb) / 0.18);
    border-color: rgb(var(--primary-rgb) / 0.6);
}


/* ── Model picker (static/js/model_picker.js) ───────────────────────────────
   Replaces the visible face of a native <select data-model-picker>: creator
   icons, creator sections, approximate token-usage chips, search, and a
   bottom sheet on phones. The select itself is kept in the DOM but hidden. */
.mp {
    position: relative;
}
.mp-source {
    display: none !important;
}

/* Control: the closed picker face. */
.mp-control {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--field-bg, rgb(0 0 0 / 0.22));
    color: var(--color-text-main);
    cursor: pointer;
    text-align: start;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.mp-control:hover { border-color: var(--border-strong); }
.mp-control:focus-visible {
    border-color: rgb(var(--primary-ink-rgb));
    outline: none;
    box-shadow: 0 0 0 2px rgb(var(--primary-rgb) / 0.25);
}

.mp-ico,
.mp-avatar {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 0.35rem;
    flex-shrink: 0;
}
.mp-ico {
    object-fit: contain;
    background: rgb(255 255 255 / 0.92);   /* brand logos sit on a light plate */
    padding: 2px;
    border: 1px solid var(--border-subtle);
}
.mp-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgb(255 255 255 / 0.92);
    font-size: 0.72rem;
    font-weight: 800;
}

.mp-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
    text-align: start;
    font-size: 0.82rem;
    font-weight: 600;
}
.mp-control .mp-label { font-size: 0.875rem; }

.mp-control-chip { flex-shrink: 0; }

.mp-chevron {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    color: var(--color-text-muted);
    transition: transform 0.2s var(--ease-out);
}
.mp-chevron svg { width: 100%; height: 100%; display: block; }
.mp-control[aria-expanded="true"] .mp-chevron { transform: rotate(180deg); }

/* Usage chip: approximate token consumption, low → high. */
.mp-chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 0.14rem 0.5rem;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 700;
    white-space: nowrap;
    direction: rtl;
}
.mp-u-low    { background: rgb(34 197 94 / 0.14);  color: rgb(74 222 128); }
.mp-u-medium { background: rgb(245 158 11 / 0.14); color: rgb(251 191 36); }
.mp-u-high   { background: rgb(239 68 68 / 0.14);  color: rgb(248 113 113); }
:root[data-theme="light"] .mp-u-low    { color: rgb(22 138 80); }
:root[data-theme="light"] .mp-u-medium { color: rgb(180 83 9); }
:root[data-theme="light"] .mp-u-high   { color: rgb(185 28 28); }

/* Panel: desktop dropdown (positioned by JS), phone bottom sheet. */
.mp-panel {
    position: fixed;
    z-index: 90;
    display: none;
    flex-direction: column;
    background: var(--color-raised);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.mp-panel.mp-visible { display: flex; animation: mp-in 0.16s var(--ease-out); }
@keyframes mp-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .mp-panel.mp-visible { animation: none; }
}

.mp-search {
    margin: 0.6rem 0.7rem 0.35rem;
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--field-bg, rgb(0 0 0 / 0.22));
    color: var(--color-text-main);
    direction: rtl;
}
.mp-search:focus {
    border-color: rgb(var(--primary-ink-rgb));
    outline: none;
    box-shadow: 0 0 0 2px rgb(var(--primary-rgb) / 0.2);
}

.mp-list {
    overflow-y: auto;
    max-height: min(380px, 58vh);
    overscroll-behavior: contain;
    padding: 0.25rem 0.35rem 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.mp-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.55rem 0.3rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--color-text-muted);
    position: sticky;
    top: 0;
    background: var(--color-raised);
    z-index: 1;
}
.mp-group .mp-ico,
.mp-group .mp-avatar { width: 1.1rem; height: 1.1rem; border-radius: 0.28rem; }
.mp-group-title { direction: ltr; }

.mp-opt {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.55rem;
    border-radius: 0.5rem;
    cursor: pointer;
    border-inline-start: 2px solid transparent;
}
.mp-opt:hover,
.mp-opt.mp-active { background: var(--color-hover-subtle); }
.mp-opt[aria-selected="true"] {
    border-inline-start-color: rgb(var(--primary-ink-rgb));
    background: var(--color-hover-strong);
}
.mp-opt .mp-label { font-weight: 500; }

.mp-empty {
    padding: 1.1rem 0.9rem;
    text-align: center;
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

/* The hidden attribute must win over the flex display of rows/sections,
   otherwise filtered-out options stay rendered. The panel mounts directly
   under <body> while open, so scope to the panel itself. */
.mp-panel [hidden] { display: none !important; }

/* Backdrop + scroll lock while the panel is open. */
.mp-backdrop {
    position: fixed;
    inset: 0;
    z-index: 85;
    background: var(--scrim, rgb(0 0 0 / 0.5));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}
.mp-backdrop.mp-show { opacity: 1; pointer-events: auto; }
body.mp-locked { overflow: hidden; }

/* Phones: the panel becomes a bottom sheet with large touch targets. */
@media (max-width: 767px) {
    .mp-panel {
        inset: auto 0 0 0 !important;
        width: auto !important;
        max-width: none !important;
        border-radius: 1rem 1rem 0 0;
        max-height: 84vh;
        padding-bottom: env(safe-area-inset-bottom);
        animation: mp-sheet 0.22s var(--ease-out);
    }
    @keyframes mp-sheet {
        from { transform: translateY(60px); opacity: 0; }
        to   { transform: translateY(0); opacity: 1; }
    }
    .mp-panel::before {
        content: "";
        align-self: center;
        width: 2.6rem;
        height: 0.28rem;
        margin: 0.5rem 0 0.15rem;
        border-radius: 999px;
        background: var(--border-strong);
    }
    .mp-list { max-height: none; flex: 1 1 auto; }
    .mp-opt { padding: 0.8rem 0.6rem; }
    .mp-opt .mp-label { font-size: 0.9rem; }
    .mp-ico, .mp-avatar { width: 1.7rem; height: 1.7rem; }
}

/* ── Browser-notification offer (static/js/push.js) ─────────────────────── */
.push-offer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 0.75rem;
    margin: 0.75rem 0;
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius);
    background: var(--color-surface);
    border: 1px solid var(--border-subtle);
    color: var(--color-text-main);
}
.push-offer.is-on { background: rgb(74 222 128 / 0.08); border-color: rgb(74 222 128 / 0.3); }
.push-offer-icon { flex: none; width: 1.25rem; height: 1.25rem; color: rgb(var(--primary-ink-rgb)); }
.push-offer.is-on .push-offer-icon { color: rgb(74 222 128); }
.push-offer-icon svg { width: 100%; height: 100%; }
.push-offer-text { flex: 1 1 14rem; min-width: 0; margin: 0; font-size: 0.8rem; line-height: 1.8; }
.push-offer-actions { display: flex; gap: 0.4rem; margin-inline-start: auto; }
.push-offer.is-compact { margin: 0.5rem 0; padding: 0.6rem 0.7rem; }
.push-offer.is-compact .push-offer-text { flex-basis: 100%; font-size: 0.72rem; }

/* ── Out-of-credit card (static/js/credit_notice.js) ────────────────────────
   One look for "your credit ran out" on every AI surface. Amber, not red: it
   is an account state with a fix one click away, not a failure. */
.credit-notice {
    --cn-tone: 251 191 36;
    --cn-ink: rgb(252 211 77);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem 0.8rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    border: 1px solid rgb(var(--cn-tone) / 0.32);
    background: rgb(var(--cn-tone) / 0.08);
    color: var(--color-text-main);
    text-align: start;
}
:root[data-theme="light"] .credit-notice { --cn-tone: 217 119 6; --cn-ink: rgb(180 83 9); }
.credit-notice-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 999px;
    background: rgb(var(--cn-tone) / 0.14);
    color: var(--cn-ink);
}
.credit-notice-icon svg { width: 1.1rem; height: 1.1rem; }
.credit-notice-body { flex: 1 1 14rem; min-width: 0; }
.credit-notice-title { font-weight: 700; font-size: 0.875rem; color: var(--cn-ink); }
.credit-notice-text { margin: 0.15rem 0 0; font-size: 0.8rem; line-height: 1.8; color: var(--color-text-muted); }
.credit-notice-cta {
    flex: none;
    margin-inline-start: auto;
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    background: rgb(var(--primary-rgb));
    color: var(--color-text-on-primary);
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: filter 0.15s var(--ease-out);
}
.credit-notice-cta:hover { filter: brightness(1.08); }
.credit-notice-cta:focus-visible { outline: 2px solid rgb(var(--primary-rgb) / 0.6); outline-offset: 2px; }
.credit-notice.is-compact { padding: 0.6rem 0.75rem; gap: 0.5rem 0.6rem; }
.credit-notice.is-compact .credit-notice-icon { width: 1.75rem; height: 1.75rem; }
.credit-notice.is-compact .credit-notice-text { font-size: 0.74rem; }
@media (max-width: 480px) {
    .credit-notice-cta { flex-basis: 100%; justify-content: center; margin-inline-start: 0; }
}
.credit-toast-host {
    position: fixed;
    inset-block-end: 1.25rem;
    inset-inline-start: 1.25rem;
    z-index: 70;
    width: min(26rem, calc(100vw - 2rem));
}
.credit-notice.is-floating {
    position: relative;
    padding-inline-end: 2.4rem;
    background: linear-gradient(rgb(var(--cn-tone) / 0.1), rgb(var(--cn-tone) / 0.1)), var(--color-surface);
    box-shadow: var(--shadow-lg);
    animation: credit-notice-in 0.3s var(--ease-out);
}
.credit-notice-close {
    position: absolute;
    inset-block-start: 0.45rem;
    inset-inline-end: 0.45rem;
    display: grid;
    place-items: center;
    width: 1.6rem;
    height: 1.6rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
}
.credit-notice-close:hover { background: var(--color-hover-strong); color: var(--color-text-main); }
.credit-notice-close svg { width: 0.8rem; height: 0.8rem; }
@keyframes credit-notice-in { from { opacity: 0; transform: translateY(0.5rem); } }
@media (prefers-reduced-motion: reduce) { .credit-notice.is-floating { animation: none; } }
@media (max-width: 480px) {
    .credit-toast-host { inset-inline: 1rem; inset-block-end: 1rem; width: auto; }
}

/* Model picker, 2026-10-06 readability pass: names sit beside their icon in
   RTL, the chosen model carries a check, and phones get a titled sheet. */
[dir="rtl"] .mp-label { text-align: right; }
.mp-check { display: none; width: 1rem; height: 1rem; flex-shrink: 0; color: rgb(var(--primary-ink-rgb)); }
.mp-check svg { width: 100%; height: 100%; display: block; }
.mp-opt[aria-selected="true"] .mp-check { display: block; }
.mp-head { display: none; }
@media (max-width: 767px) {
    .mp-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        padding: 0.2rem 0.5rem 0.1rem;
        padding-inline-start: 0.8rem;
    }
    .mp-head-title { font-size: 0.9rem; font-weight: 700; color: var(--color-text-main); }
    .mp-close {
        display: grid;
        place-items: center;
        width: 2.4rem;
        height: 2.4rem;
        border-radius: 0.7rem;
        color: var(--color-text-muted);
    }
    .mp-close:active { background: var(--color-hover-strong); }
    .mp-close svg { width: 1.15rem; height: 1.15rem; }
    .mp-search { font-size: 16px; padding: 0.65rem 0.9rem; }
    .mp-list { padding-top: 0; }
    .mp-group {
        padding: 0.8rem 0.6rem 0.4rem;
        font-size: 0.75rem;
        font-weight: 700;
        color: var(--color-text-main);
        border-bottom: 1px solid var(--border-subtle);
        margin-bottom: 0.2rem;
    }
    .mp-opt { gap: 0.75rem; min-height: 3.25rem; }
    .mp-opt .mp-label { font-size: 0.95rem; }
    .mp-opt[aria-selected="true"] { border-inline-start-color: transparent; }
}
