/*
 * Core Support interface.
 * Visual language follows Tabler (tabler.io, MIT), the same foundation as the Stackless theme:
 * neutral surfaces, hairline borders, soft card shadows, 36px controls, light "-lt" badges.
 * Branding (accent, neutral palette, radius, font, color mode) comes from Settings → Branding
 * through data attributes and custom properties on each root element.
 */

/* ------------------------------------------------------------------ Tokens */
/* Declared only on elements that carry branding attributes, so nested parts (like the standalone
   header and footer) inherit the site's brand instead of resetting it. */
:where([data-cs-base]) {
    --cs-accent: #066fd1;
    --cs-on-accent: #fff;
    --cs-accent-ink: #0559a8;
    --cs-accent-ink-dark: #6aa6e6;
    --cs-link: var(--cs-accent-ink);
    --cs-accent-lt: color-mix(in srgb, var(--cs-accent) 10%, var(--cs-surface));
    --cs-ring: color-mix(in srgb, var(--cs-accent) 28%, transparent);

    /* Neutral palette: Tabler's "neutral" base. */
    --cs-bg: #fafafa;
    --cs-surface: #fff;
    --cs-surface-2: #f6f6f6;
    --cs-ink: #171717;
    --cs-text: #262626;
    --cs-muted: #666;
    --cs-line: #e5e5e5;
    --cs-line-strong: #d4d4d4;

    /* Semantic colors are independent of the brand accent. */
    --cs-blue: #066fd1; --cs-blue-lt: #e8f1fb; --cs-blue-ink: #04437f;
    --cs-green: #2fb344; --cs-green-lt: #eaf7ec; --cs-green-ink: #1a6a28;
    --cs-yellow: #f59f00; --cs-yellow-lt: #fef5e6; --cs-yellow-ink: #7a4f00;
    --cs-orange: #f76707; --cs-orange-lt: #fef0e6; --cs-orange-ink: #8a3a03;
    --cs-red: #d63939; --cs-red-lt: #fbebeb; --cs-red-ink: #8f2020;
    --cs-purple: #ae3ec9; --cs-purple-lt: #f7ecfa; --cs-purple-ink: #6b2380;

    --cs-radius-sm: 4px;
    --cs-radius: 6px;
    --cs-radius-lg: 8px;
    --cs-font: system-ui, -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --cs-shadow-card: 0 2px 4px rgba(23, 23, 23, .04);
    --cs-shadow-input: 0 1px 1px rgba(23, 23, 23, .04);
    --cs-control-h: 2.25rem;
    color-scheme: light;
}

[data-cs-base="slate"] { --cs-bg: #f8fafc; --cs-surface-2: #f1f5f9; --cs-ink: #0f172a; --cs-text: #1e293b; --cs-muted: #64748b; --cs-line: #e2e8f0; --cs-line-strong: #cbd5e1; }
[data-cs-base="gray"] { --cs-bg: #f9fafb; --cs-surface-2: #f3f4f6; --cs-ink: #111827; --cs-text: #1f2937; --cs-muted: #6b7280; --cs-line: #e5e7eb; --cs-line-strong: #d1d5db; }
[data-cs-base="zinc"] { --cs-bg: #fafafa; --cs-surface-2: #f4f4f5; --cs-ink: #18181b; --cs-text: #27272a; --cs-muted: #71717a; --cs-line: #e4e4e7; --cs-line-strong: #d4d4d8; }
[data-cs-base="stone"] { --cs-bg: #fafaf9; --cs-surface-2: #f5f5f4; --cs-ink: #1c1917; --cs-text: #292524; --cs-muted: #78716c; --cs-line: #e7e5e4; --cs-line-strong: #d6d3d1; }

[data-cs-radius="square"] { --cs-radius-sm: 0; --cs-radius: 0; --cs-radius-lg: 0; }
[data-cs-radius="small"] { --cs-radius-sm: 2px; --cs-radius: 3px; --cs-radius-lg: 4px; }
[data-cs-radius="large"] { --cs-radius-sm: 6px; --cs-radius: 10px; --cs-radius-lg: 14px; }

[data-cs-font="theme"] { --cs-font: inherit; }
/* Standalone pages load no theme CSS, so "Theme font" falls back to the system sans-serif there. */
.csp-standalone-frame[data-cs-font="theme"] { --cs-font: system-ui, -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }
[data-cs-font="serif"] { --cs-font: ui-serif, Georgia, Cambria, "Times New Roman", serif; }
[data-cs-font="mono"] { --cs-font: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Dark tokens, shared by "dark" and by "automatic" on dark devices. */
[data-cs-mode="dark"] {
    --cs-bg: #171717; --cs-surface: #1f1f1f; --cs-surface-2: #262626; --cs-ink: #f5f5f5; --cs-text: #e5e5e5;
    --cs-muted: #a3a3a3; --cs-line: #333; --cs-line-strong: #4a4a4a;
    --cs-link: var(--cs-accent-ink-dark);
    --cs-accent-lt: color-mix(in srgb, var(--cs-accent) 22%, var(--cs-surface));
    --cs-blue-lt: #102a44; --cs-blue-ink: #9cc7f2; --cs-green-lt: #13321a; --cs-green-ink: #8fdb9c;
    --cs-yellow-lt: #3a2c08; --cs-yellow-ink: #f7cd6a; --cs-orange-lt: #3d2210; --cs-orange-ink: #f9ad7a;
    --cs-red-lt: #3d1717; --cs-red-ink: #f0a3a3; --cs-purple-lt: #331a3b; --cs-purple-ink: #dfa6ee;
    --cs-shadow-card: none; --cs-shadow-input: none;
    color-scheme: dark;
}
[data-cs-mode="dark"][data-cs-base="slate"] { --cs-bg: #0f172a; --cs-surface: #172033; --cs-surface-2: #1e293b; --cs-ink: #f1f5f9; --cs-text: #e2e8f0; --cs-muted: #94a3b8; --cs-line: #2b3a52; --cs-line-strong: #475569; }
[data-cs-mode="dark"][data-cs-base="gray"] { --cs-bg: #111827; --cs-surface: #1a2230; --cs-surface-2: #1f2937; --cs-ink: #f3f4f6; --cs-text: #e5e7eb; --cs-muted: #9ca3af; --cs-line: #313b4b; --cs-line-strong: #4b5563; }
[data-cs-mode="dark"][data-cs-base="zinc"] { --cs-bg: #18181b; --cs-surface: #1f1f23; --cs-surface-2: #27272a; --cs-ink: #f4f4f5; --cs-text: #e4e4e7; --cs-muted: #a1a1aa; --cs-line: #34343a; --cs-line-strong: #52525b; }
[data-cs-mode="dark"][data-cs-base="stone"] { --cs-bg: #1c1917; --cs-surface: #231f1d; --cs-surface-2: #292524; --cs-ink: #f5f5f4; --cs-text: #e7e5e4; --cs-muted: #a8a29e; --cs-line: #3a3431; --cs-line-strong: #57534e; }
@media (prefers-color-scheme: dark) {
    [data-cs-mode="auto"] {
        --cs-bg: #171717; --cs-surface: #1f1f1f; --cs-surface-2: #262626; --cs-ink: #f5f5f5; --cs-text: #e5e5e5;
        --cs-muted: #a3a3a3; --cs-line: #333; --cs-line-strong: #4a4a4a;
        --cs-link: var(--cs-accent-ink-dark);
        --cs-accent-lt: color-mix(in srgb, var(--cs-accent) 22%, var(--cs-surface));
        --cs-blue-lt: #102a44; --cs-blue-ink: #9cc7f2; --cs-green-lt: #13321a; --cs-green-ink: #8fdb9c;
        --cs-yellow-lt: #3a2c08; --cs-yellow-ink: #f7cd6a; --cs-orange-lt: #3d2210; --cs-orange-ink: #f9ad7a;
        --cs-red-lt: #3d1717; --cs-red-ink: #f0a3a3; --cs-purple-lt: #331a3b; --cs-purple-ink: #dfa6ee;
        --cs-shadow-card: none; --cs-shadow-input: none;
        color-scheme: dark;
    }
    [data-cs-mode="auto"][data-cs-base="slate"] { --cs-bg: #0f172a; --cs-surface: #172033; --cs-surface-2: #1e293b; --cs-ink: #f1f5f9; --cs-text: #e2e8f0; --cs-muted: #94a3b8; --cs-line: #2b3a52; --cs-line-strong: #475569; }
    [data-cs-mode="auto"][data-cs-base="gray"] { --cs-bg: #111827; --cs-surface: #1a2230; --cs-surface-2: #1f2937; --cs-ink: #f3f4f6; --cs-text: #e5e7eb; --cs-muted: #9ca3af; --cs-line: #313b4b; --cs-line-strong: #4b5563; }
    [data-cs-mode="auto"][data-cs-base="zinc"] { --cs-bg: #18181b; --cs-surface: #1f1f23; --cs-surface-2: #27272a; --cs-ink: #f4f4f5; --cs-text: #e4e4e7; --cs-muted: #a1a1aa; --cs-line: #34343a; --cs-line-strong: #52525b; }
    [data-cs-mode="auto"][data-cs-base="stone"] { --cs-bg: #1c1917; --cs-surface: #231f1d; --cs-surface-2: #292524; --cs-ink: #f5f5f4; --cs-text: #e7e5e4; --cs-muted: #a8a29e; --cs-line: #3a3431; --cs-line-strong: #57534e; }
}

/* ------------------------------------------------------------------ Standalone pages */
html.csp-standalone-document { margin-top: 0 !important; }
.csp-standalone { margin: 0; }
.csp-standalone-frame {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--cs-bg);
    color: var(--cs-text);
    font-family: var(--cs-font);
}
.csp-standalone .csp-standalone-header {
    width: 100%;
    max-width: none;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 max(24px, calc((100% - 1392px) / 2));
    background: var(--cs-surface);
    border-bottom: 1px solid var(--cs-line);
}
.csp-standalone-content {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 32px 24px;
    flex: 1;
    box-sizing: border-box;
}
.csp-standalone-content .csp-block { margin-block: 0; }
.csp-standalone .csp-standalone-footer {
    width: 100%;
    max-width: none;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 20px max(24px, calc((100% - 1392px) / 2));
    background: var(--cs-surface);
    border-top: 1px solid var(--cs-line);
    color: var(--cs-muted);
    font-size: 12px;
}
.csp-standalone-footer a { color: var(--cs-link); }

/* Header and footer parts set under Settings → Header and footer. */
.csp-frame-label {
    padding: 1px 8px;
    border: 1px solid var(--cs-line);
    border-radius: 999px;
    color: var(--cs-muted);
    font-size: 12px;
    font-weight: 500;
}
.csp-frame-nav { display: flex; align-items: center; gap: 16px; }
.csp-frame-link { font-size: 14px; text-decoration: none; }
.csp-frame-link:hover { text-decoration: underline; }
.csp-frame-menu { position: relative; display: none; }
.csp-frame-menu > summary { list-style: none; cursor: pointer; }
.csp-frame-menu > summary::-webkit-details-marker { display: none; }
.csp-frame-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    display: grid;
    min-width: 200px;
    padding: 6px;
    background: var(--cs-surface);
    border: 1px solid var(--cs-line);
    border-radius: var(--cs-radius);
    box-shadow: var(--cs-shadow-card);
}
.csp-frame-menu-panel a { padding: 8px 10px; border-radius: var(--cs-radius-sm); color: var(--cs-ink); text-decoration: none; }
.csp-frame-menu-panel a:hover, .csp-frame-menu-panel a:focus-visible { background: var(--cs-surface-2); }
.csp-frame-footer-start, .csp-frame-footer-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.csp-frame-footer-links { justify-content: flex-end; }
@media (max-width: 900px) {
    .csp-standalone-header .csp-frame-nav > .csp-frame-link { display: none; }
    .csp-frame-nav.has-menu .csp-frame-menu { display: block; }
    .csp-frame-menu-panel > :is(.is-button, .is-primary) { display: none; }
}
@media (max-width: 600px) {
    .csp-standalone-header .csp-frame-nav.has-menu > .csp-button.csp-button { display: none; }
    .csp-frame-menu-panel > :is(.is-button, .is-primary) { display: block; }
    .csp-frame-label { display: none; }
    .csp-standalone .csp-standalone-footer { flex-direction: column; }
    .csp-frame-footer-links { justify-content: flex-start; }
}

/* ------------------------------------------------------------------ App shell */
.csp-app {
    box-sizing: border-box;
    font-family: var(--cs-font);
    color: var(--cs-text);
    font-size: 14px;
    line-height: 1.4286;
    text-align: start;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 32px;
}
.csp-app *,
.csp-app *::before,
.csp-app *::after { box-sizing: border-box; }
.csp-app [hidden] { display: none !important; }
.csp-app :is(button, input, textarea, select) { font: inherit; }
.csp-app a { color: var(--cs-link); }
.csp-app :focus-visible {
    outline: 2px solid var(--cs-accent);
    outline-offset: 2px;
}
.csp-app h2 {
    font-size: 1.25rem;
    line-height: 1.4;
    font-weight: 600;
    color: var(--cs-ink);
}

/* Header: brand, beta chip, navigation */
.csp-header {
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--cs-line);
}
.csp-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--cs-ink);
    text-decoration: none;
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -.01em;
}
.csp-app .csp-brand { color: var(--cs-ink); }
.csp-mark {
    display: grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: var(--cs-radius);
    object-fit: cover;
}
.csp-mark-logo {
    width: auto;
    max-width: 160px;
    object-fit: contain;
    border-radius: 0;
}
.csp-alpha {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    padding: 2px 6px;
    border-radius: var(--cs-radius-sm);
    background: var(--cs-accent-lt);
    color: var(--cs-link);
}
.csp-header nav {
    margin-inline-start: auto;
    display: flex;
    gap: 20px;
}
.csp-header nav a {
    color: var(--cs-muted);
    font-size: 14px;
    text-decoration: none;
}
.csp-header nav a:hover { color: var(--cs-ink); }

/* Page header (Tabler .page-header) */
.csp-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 28px 0 20px;
}
.csp-eyebrow {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--cs-muted);
}
.csp-intro :is(h1, h2) {
    margin: 0;
    font-size: 1.5rem;
    line-height: 1.3333;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--cs-ink);
}
.csp-intro p:last-child {
    margin: 4px 0 0;
    color: var(--cs-muted);
}

/* Buttons (Tabler .btn). The root plus a repeated class gives (0,3,0), above theme rules for submit
   buttons such as :is(.button, button[type=submit]):not(.button-link) at (0,2,1), which set full width
   and their own colors. Contextual button rules elsewhere use (0,3,0) and load later, so they still win.
   The resets cover properties themes commonly set on submit buttons. */
:is(.csp-app, .csp-admin) .csp-button.csp-button {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    min-height: var(--cs-control-h);
    margin: 0;
    padding: 7px 14px;
    border: 1px solid var(--cs-line-strong);
    border-radius: var(--cs-radius);
    background: var(--cs-surface);
    color: var(--cs-text);
    box-shadow: var(--cs-shadow-input);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4286;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease-in-out, border-color .15s ease-in-out, color .15s ease-in-out;
}
:is(.csp-app, .csp-admin) .csp-button.csp-button:hover {
    background: var(--cs-surface-2);
    border-color: var(--cs-line-strong);
    color: var(--cs-text);
}
:is(.csp-app, .csp-admin) .csp-button.csp-button:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px var(--cs-ring);
}
:is(.csp-app, .csp-admin) .csp-button.csp-button.csp-primary {
    background: var(--cs-accent);
    border-color: var(--cs-accent);
    color: var(--cs-on-accent);
}
:is(.csp-app, .csp-admin) .csp-button.csp-button.csp-primary:hover {
    background: color-mix(in srgb, var(--cs-accent) 88%, #000);
    border-color: color-mix(in srgb, var(--cs-accent) 88%, #000);
    color: var(--cs-on-accent);
}
:is(.csp-app, .csp-admin) .csp-button.csp-button:disabled { opacity: .6; cursor: wait; }
:is(.csp-app, .csp-admin) .csp-button.csp-button.csp-icon-button { padding-inline: 0; width: var(--cs-control-h); }
.csp-button .csp-icon { width: 16px; height: 16px; }

/* Alerts (Tabler .alert) */
.csp-demo-note,
.csp-announcement,
.csp-notice {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--cs-surface);
    border: 1px solid var(--cs-line);
    border-radius: var(--cs-radius);
    color: var(--cs-text);
}
.csp-announcement {
    display: block;
    background: var(--cs-surface-2);
    white-space: pre-wrap;
}
.csp-notice {
    background: var(--cs-green-lt);
    border-color: color-mix(in srgb, var(--cs-green) 30%, var(--cs-line));
    color: var(--cs-green-ink);
}
.csp-notice.is-error {
    background: var(--cs-red-lt);
    border-color: color-mix(in srgb, var(--cs-red) 30%, var(--cs-line));
    color: var(--cs-red-ink);
}
.csp-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cs-blue);
}

/* Layout: vertical nav + card */
.csp-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 24px;
    min-height: 520px;
    align-items: start;
}
.csp-sidebar-label {
    margin: 0 12px 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--cs-muted);
}
.csp-sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.csp-sidebar nav :is(button, a) {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    padding: 7px 12px;
    border: 0;
    border-radius: var(--cs-radius);
    background: transparent;
    color: var(--cs-text);
    font-size: 14px;
    text-align: start;
    text-decoration: none;
    cursor: pointer;
}
.csp-sidebar nav :is(button, a) .csp-icon {
    width: 18px;
    height: 18px;
    color: var(--cs-muted);
}
.csp-sidebar nav :is(button, a):hover { background: var(--cs-surface-2); }
.csp-app .csp-sidebar nav :is(button, a).is-active {
    background: var(--cs-accent-lt);
    color: var(--cs-link);
    font-weight: 600;
}
.csp-app .csp-sidebar nav :is(button, a).is-active .csp-icon { color: currentColor; }

/* Card (Tabler .card) */
.csp-content {
    min-width: 0;
    overflow: hidden;
    background: var(--cs-surface);
    border: 1px solid var(--cs-line);
    border-radius: var(--cs-radius-lg);
    box-shadow: var(--cs-shadow-card);
}
.csp-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--cs-line);
}
.csp-search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 160px;
}
.csp-search > .csp-icon {
    position: absolute;
    inset-inline-start: 10px;
    width: 16px;
    height: 16px;
    color: var(--cs-muted);
    pointer-events: none;
}
.csp-toolbar:has(.csp-inbox-filter) { align-items: flex-end; }
.csp-toolbar:has(.csp-inbox-filter) .csp-search { flex-basis: 100%; }
.csp-toolbar:not(:has(.csp-inbox-filter)) { flex-wrap: nowrap; }
.csp-toolbar:not(:has(.csp-inbox-filter)) .csp-search { min-width: 0; }
.csp-inbox-filter {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 150px;
    font-size: 12px;
    font-weight: 500;
    color: var(--cs-muted);
}

/* Form controls (Tabler .form-control / .form-select) */
.csp-app :is(input:not([type="checkbox"], [type="radio"], [type="color"]), textarea, select) {
    min-height: var(--cs-control-h);
    padding: 7px 12px;
    border: 1px solid var(--cs-line-strong);
    border-radius: var(--cs-radius);
    background-color: var(--cs-surface);
    color: var(--cs-text);
    box-shadow: var(--cs-shadow-input);
    font-size: 14px;
    line-height: 1.4286;
}
.csp-app select { padding-inline-end: 32px; }
.csp-app :is(input, textarea, select):focus {
    border-color: color-mix(in srgb, var(--cs-accent) 60%, var(--cs-line-strong));
    box-shadow: 0 0 0 3px var(--cs-ring);
    outline: 0;
}
.csp-app :is(input, textarea)::placeholder { color: var(--cs-muted); opacity: .85; }
.csp-app .csp-search input {
    width: 100%;
    min-width: 0;
    padding-inline-start: 34px;
}
.csp-app textarea {
    width: 100%;
    resize: vertical;
    line-height: 1.6;
}
.csp-app [id$="csp-create-form"] > label {
    display: block;
    margin: 20px 0 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--cs-ink);
}
.csp-app [id$="csp-create-form"] > input { width: 100%; }
.csp-hint,
.csp-muted { color: var(--cs-muted); }
.csp-hint { margin: 6px 0 20px; font-size: 12px; }

/* Ticket list (Tabler .list-group) */
.csp-list-heading {
    display: flex;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--cs-surface-2);
    border-bottom: 1px solid var(--cs-line);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--cs-muted);
}
.csp-ticket-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: 0;
    border-bottom: 1px solid var(--cs-line);
    background: var(--cs-surface);
    color: var(--cs-text);
    text-align: start;
    text-decoration: none;
    cursor: pointer;
}
.csp-app .csp-ticket-row { color: var(--cs-text); }
.csp-ticket-row:hover { background: var(--cs-surface-2); }
.csp-avatar {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--cs-accent-lt);
    color: var(--cs-link);
    font-size: 13px;
    font-weight: 600;
}
.csp-ticket-summary { flex: 1; min-width: 0; }
.csp-ticket-title {
    display: block;
    overflow: hidden;
    margin-bottom: 2px;
    color: var(--cs-ink);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.csp-ticket-meta {
    color: var(--cs-muted);
    font-size: 12px;
}
.csp-ticket-end {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.csp-ticket-end time { color: var(--cs-muted); font-size: 12px; }
.csp-ticket-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    max-width: 280px;
}
.csp-row-arrow {
    display: inline-flex;
    margin-inline-start: 4px;
    color: var(--cs-muted);
}
.csp-row-arrow .csp-icon { width: 16px; height: 16px; }
.csp-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 12px 16px;
    color: var(--cs-muted);
    font-size: 12px;
}
.csp-pagination:has([hidden]):has([id$="csp-page"]:empty) { padding: 0; }
.csp-loading { padding: 48px; text-align: center; color: var(--cs-muted); }

/* Badges (Tabler .badge.bg-*-lt) */
.csp-badge,
.csp-assignment,
.csp-delivery-state {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--cs-radius-sm);
    background: var(--cs-surface-2);
    color: var(--cs-muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
}
.csp-badge .csp-icon { width: 13px; height: 13px; }
.csp-app .csp-badge.open,
.csp-app select.csp-select-status.is-open,
.csp-delivery-state.is-queued,
.csp-delivery-state.is-sending { background-color: var(--cs-blue-lt); color: var(--cs-blue-ink); }
.csp-app .csp-badge.waiting,
.csp-app select.csp-select-status.is-waiting { background-color: var(--cs-yellow-lt); color: var(--cs-yellow-ink); }
.csp-app .csp-badge.resolved,
.csp-app select.csp-select-status.is-resolved,
.csp-delivery-state.is-handed_to_mail { background-color: var(--cs-green-lt); color: var(--cs-green-ink); }
.csp-app .csp-priority.normal,
.csp-app select.csp-select-priority.is-normal { background-color: var(--cs-surface-2); color: var(--cs-muted); }
.csp-app .csp-priority.high,
.csp-app select.csp-select-priority.is-high { background-color: var(--cs-orange-lt); color: var(--cs-orange-ink); }
.csp-app .csp-priority.urgent,
.csp-app select.csp-select-priority.is-urgent,
.csp-delivery-state.is-failed,
.csp-delivery-state.is-delivery_unknown { background-color: var(--cs-red-lt); color: var(--cs-red-ink); }
.csp-assignment { padding: 0 6px; font-size: 11px; }
.csp-assignment.is-assigned { background: var(--cs-purple-lt); color: var(--cs-purple-ink); }
.csp-delivery-state { margin-block: 2px; }
.csp-source {
    display: inline-flex;
    margin-inline-start: 8px;
    padding: 0 8px;
    border-radius: var(--cs-radius-sm);
    background: var(--cs-accent-lt);
    color: var(--cs-link);
    font-size: 12px;
    font-weight: 500;
}

/* Empty state (Tabler .empty) */
.csp-empty {
    padding: 48px 24px 56px;
    text-align: center;
}
.csp-empty h2 { margin: 4px 0 8px; font-size: 1.25rem; }
.csp-empty > p:not(.csp-eyebrow) {
    max-width: 380px;
    margin: 0 auto 20px;
    color: var(--cs-muted);
}
.csp-app .csp-empty-art {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    border-radius: 50%;
    background: var(--cs-accent-lt);
    color: var(--cs-link);
}
.csp-app .csp-empty-art > .csp-icon { width: 36px; height: 36px; }

/* Conversation */
[id$="csp-create"],
[id$="csp-detail"] { padding: 20px 24px 24px; }
.csp-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 6px 0;
    border: 0;
    background: transparent;
    color: var(--cs-link);
    font: inherit;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
}
.csp-back .csp-icon { width: 16px; height: 16px; }
.csp-back:hover { text-decoration: underline; }
.csp-detail-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.csp-ticket-heading {
    padding: 16px 0 20px;
    border-bottom: 1px solid var(--cs-line);
}
.csp-ticket-heading h2 {
    margin: 2px 0 10px;
    overflow-wrap: anywhere;
}
.csp-detail-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    color: var(--cs-muted);
    font-size: 12px;
}
.csp-properties {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--cs-line);
}
.csp-properties label {
    flex: 1;
    min-width: 130px;
    color: var(--cs-muted);
    font-size: 12px;
    font-weight: 500;
}
.csp-properties select {
    display: block;
    width: 100%;
    margin-top: 4px;
}
.csp-customer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 16px 0 4px;
    color: var(--cs-ink);
    font-weight: 500;
}
.csp-customer .csp-icon { width: 16px; height: 16px; color: var(--cs-muted); }
.csp-customer > span:not(.csp-source) { color: var(--cs-muted); font-weight: 400; }
.csp-messages {
    margin: 0;
    padding: 0;
    list-style: none;
}
.csp-message {
    padding: 20px 0;
    border-bottom: 1px solid var(--cs-line);
}
.csp-message-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--cs-ink);
}
.csp-message-head strong { font-weight: 600; }
.csp-message-head time {
    margin-inline-start: auto;
    color: var(--cs-muted);
    font-size: 12px;
}
.csp-message-body {
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.csp-message.is-internal {
    margin: 16px 0;
    padding: 16px;
    border: 1px solid color-mix(in srgb, var(--cs-yellow) 35%, var(--cs-line));
    border-radius: var(--cs-radius);
    background: var(--cs-yellow-lt);
}
.csp-private {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--cs-yellow-ink);
    font-size: 12px;
    font-weight: 500;
}
.csp-private .csp-icon { width: 13px; height: 13px; }
.csp-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}
.csp-attachments li {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--cs-line);
    border-radius: var(--cs-radius);
    background: var(--cs-surface-2);
    font-size: 13px;
}
.csp-attachments a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: var(--cs-link);
    font-weight: 500;
}
.csp-attachments a span { overflow-wrap: anywhere; }
.csp-attachments .csp-icon { width: 14px; height: 14px; }
.csp-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}
.csp-previews a {
    display: block;
    border: 1px solid var(--cs-line);
    border-radius: var(--cs-radius);
    overflow: hidden;
    background: var(--cs-surface-2);
}
.csp-previews img {
    display: block;
    max-width: min(320px, 100%);
    max-height: 240px;
    width: auto;
    height: auto;
    object-fit: contain;
}
.csp-deliveries {
    padding: 16px 0 0;
    color: var(--cs-muted);
    font-size: 13px;
}
.csp-deliveries summary { min-height: 28px; cursor: pointer; color: var(--cs-text); font-weight: 500; }
.csp-deliveries ul { margin: 8px 0 0; padding-inline-start: 18px; }

/* Composer: a card with header and footer */
.csp-composer {
    margin-top: 24px;
    overflow: hidden;
    border: 1px solid var(--cs-line-strong);
    border-radius: var(--cs-radius-lg);
    background: var(--cs-surface);
}
.csp-composer:focus-within {
    border-color: color-mix(in srgb, var(--cs-accent) 60%, var(--cs-line-strong));
    box-shadow: 0 0 0 3px var(--cs-ring);
}
.csp-composer-head,
.csp-composer-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: var(--cs-surface-2);
}
.csp-composer-head { border-bottom: 1px solid var(--cs-line); }
.csp-composer-foot { border-top: 1px solid var(--cs-line); }
.csp-composer-head > label { color: var(--cs-ink); font-weight: 500; }
.csp-composer-foot > span { color: var(--cs-muted); font-size: 12px; }
.csp-app .csp-composer select { min-height: 32px; padding-block: 4px; font-size: 13px; }
.csp-app .csp-composer textarea {
    display: block;
    min-height: 140px;
    padding: 14px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
.csp-app .csp-composer textarea:focus { box-shadow: none; }
.csp-composer.is-internal .csp-composer-head { background: var(--cs-yellow-lt); }
.csp-resolve { margin-top: 12px; }

/* Footer */
.csp-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    padding: 20px 0 28px;
    border-top: 1px solid var(--cs-line);
    color: var(--cs-muted);
    font-size: 12px;
}
.csp-footer span > span { margin: 0 8px; opacity: .6; }

/* Accessibility helpers */
.csp-sr-only,
.csp-skip:not(:focus) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}
.csp-skip:focus {
    position: absolute;
    z-index: 9999;
    top: 16px;
    left: 16px;
    padding: 10px;
    background: #fff;
}

/* ------------------------------------------------------------------ WordPress admin screens */
body.toplevel_page_core-support,
body.core-support_page_core-support-mail { background: var(--cs-admin-bg, #fafafa); }
body.toplevel_page_core-support #wpcontent,
body.core-support_page_core-support-mail #wpcontent { padding-left: 0; }
body.toplevel_page_core-support #wpfooter { display: none; }
body.toplevel_page_core-support .csp-app,
body.core-support_page_core-support-mail .csp-app { padding: 0 32px 24px; }
.wp-admin .csp-app[data-cs-mode="dark"] {
    max-width: none;
    min-height: calc(100vh - 32px);
    padding-inline: max(32px, calc((100% - 1376px) / 2));
    background: var(--cs-bg);
}
@media (prefers-color-scheme: dark) {
    .wp-admin .csp-app[data-cs-mode="auto"] {
        max-width: none;
        min-height: calc(100vh - 32px);
        padding-inline: max(32px, calc((100% - 1376px) / 2));
        background: var(--cs-bg);
    }
}

/* Dark workspace screens fill the whole admin page, below the panel too. */
:is(html:has(> body.csp-workspace-dark), body.csp-workspace-dark, .csp-workspace-dark #wpwrap) { background: #171717; }
:is(html:has(> body.csp-workspace-dark.csp-workspace-slate), body.csp-workspace-dark.csp-workspace-slate, .csp-workspace-dark.csp-workspace-slate #wpwrap) { background: #0f172a; }
:is(html:has(> body.csp-workspace-dark.csp-workspace-gray), body.csp-workspace-dark.csp-workspace-gray, .csp-workspace-dark.csp-workspace-gray #wpwrap) { background: #111827; }
:is(html:has(> body.csp-workspace-dark.csp-workspace-zinc), body.csp-workspace-dark.csp-workspace-zinc, .csp-workspace-dark.csp-workspace-zinc #wpwrap) { background: #18181b; }
:is(html:has(> body.csp-workspace-dark.csp-workspace-stone), body.csp-workspace-dark.csp-workspace-stone, .csp-workspace-dark.csp-workspace-stone #wpwrap) { background: #1c1917; }
.csp-workspace-dark #wpfooter { color: #a3a3a3; }
@media (prefers-color-scheme: dark) {
    :is(html:has(> body.csp-workspace-auto), body.csp-workspace-auto, .csp-workspace-auto #wpwrap) { background: #171717; }
    :is(html:has(> body.csp-workspace-auto.csp-workspace-slate), body.csp-workspace-auto.csp-workspace-slate, .csp-workspace-auto.csp-workspace-slate #wpwrap) { background: #0f172a; }
    :is(html:has(> body.csp-workspace-auto.csp-workspace-gray), body.csp-workspace-auto.csp-workspace-gray, .csp-workspace-auto.csp-workspace-gray #wpwrap) { background: #111827; }
    :is(html:has(> body.csp-workspace-auto.csp-workspace-zinc), body.csp-workspace-auto.csp-workspace-zinc, .csp-workspace-auto.csp-workspace-zinc #wpwrap) { background: #18181b; }
    :is(html:has(> body.csp-workspace-auto.csp-workspace-stone), body.csp-workspace-auto.csp-workspace-stone, .csp-workspace-auto.csp-workspace-stone #wpwrap) { background: #1c1917; }
    .csp-workspace-auto #wpfooter { color: #a3a3a3; }
}

/* Incoming mail reuses the workspace list and conversation styles. */
.csp-mail-list { margin: 0; padding: 0; list-style: none; }
.csp-mail-list li { margin: 0; }
.csp-mail-page .csp-ticket-meta { display: block; overflow-wrap: anywhere; }
.csp-mail-list .csp-ticket-row:visited { color: var(--cs-text); }
.csp-mail-page .csp-message { border-bottom: 0; }
.csp-mail-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-block: 16px;
}
.csp-mail-review {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--cs-line);
}
.csp-mail-review form { display: flex; flex-wrap: wrap; gap: 8px; }
.csp-mail-configuration {
    margin-block: 24px;
    padding: 16px 20px;
    border: 1px solid var(--cs-line);
    border-radius: var(--cs-radius-lg);
    background: var(--cs-surface);
    box-shadow: var(--cs-shadow-card);
    color: var(--cs-muted);
}
.csp-mail-configuration summary { cursor: pointer; color: var(--cs-ink); font-weight: 600; }
.csp-mail-configuration ul { margin: 12px 0; padding-inline-start: 18px; }
.csp-mail-configuration li { margin-bottom: 12px; line-height: 1.7; }
.csp-mail-configuration strong { color: var(--cs-ink); }
.csp-mail-configuration code {
    padding: 1px 6px;
    border-radius: var(--cs-radius-sm);
    background: var(--cs-surface-2);
    color: var(--cs-text);
    font-size: 12px;
    overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ Blocks inside themes */
.csp-block {
    container-type: inline-size;
    min-width: 0;
    margin-block: 24px;
}
.csp-block .csp-app {
    width: 100%;
    max-width: none;
    padding: 0;
    font-size: 14px;
}
.csp-block .csp-intro { padding: 8px 0 20px; }
.csp-block .csp-layout { min-height: 420px; }
.csp-block-new-ticket .csp-sidebar,
.csp-block-new-ticket [id$="csp-new"] { display: none; }
.csp-block-new-ticket .csp-layout { display: block; min-height: 0; }
.csp-block-my-tickets .csp-sidebar-help { display: none; }
@container (max-width: 700px) {
    .csp-block .csp-layout { display: block; }
    .csp-block .csp-sidebar { padding: 0 0 12px; }
    .csp-block .csp-sidebar-label,
    .csp-block .csp-sidebar-help { display: none; }
    .csp-block .csp-sidebar nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
    .csp-block .csp-ticket-row { gap: 10px; padding: 12px; }
    .csp-block .csp-avatar { display: none; }
    .csp-block .csp-toolbar { padding: 12px; }
    .csp-block .csp-composer-foot { flex-wrap: wrap; }
    .csp-block [id$="csp-create"],
    .csp-block [id$="csp-detail"] { padding: 16px; }
}

/* ------------------------------------------------------------------ Responsive */
@media (max-width: 900px) {
    .csp-app,
    body.toplevel_page_core-support .csp-app,
    body.core-support_page_core-support-mail .csp-app { padding-inline: 20px; }
    .csp-layout { grid-template-columns: 180px minmax(0, 1fr); gap: 16px; }
    .csp-ticket-end { max-width: 160px; }
    .csp-row-arrow { display: none; }
    [id$="csp-detail"],
    [id$="csp-create"] { padding: 16px; }
    .csp-composer-foot { flex-wrap: wrap; }
    .csp-standalone-content { padding: 24px 20px; }
}
@media (max-width: 650px) {
    .csp-app,
    body.toplevel_page_core-support .csp-app,
    body.core-support_page_core-support-mail .csp-app { padding-inline: 16px; }
    .csp-header { flex-wrap: wrap; gap: 8px; padding: 12px 0; }
    .csp-header nav { gap: 12px; }
    .csp-intro { align-items: flex-start; flex-wrap: wrap; padding: 20px 0 16px; }
    .csp-intro :is(h1, h2) { font-size: 1.25rem; }
    .csp-layout { display: block; min-height: 420px; }
    .csp-sidebar { padding-bottom: 12px; }
    .csp-sidebar-label,
    .csp-sidebar-help { display: none; }
    .csp-sidebar nav { flex-direction: row; gap: 4px; overflow-x: auto; }
    .csp-sidebar nav :is(button, a) { white-space: nowrap; }
    .csp-toolbar { padding: 12px; }
    .csp-avatar { display: none; }
    .csp-ticket-row { padding: 12px; align-items: flex-start; }
    .csp-ticket-title { white-space: normal; overflow-wrap: anywhere; }
    .csp-ticket-end { flex-shrink: 0; max-width: 130px; }
    .csp-ticket-badges { max-width: 130px; }
    .csp-message-head time { width: 100%; margin: 0; }
    .csp-composer-head { flex-wrap: wrap; }
    .csp-footer { gap: 12px; }
    .csp-standalone .csp-standalone-header { padding-inline: 16px; }
    .csp-standalone .csp-standalone-header .csp-button { min-height: 32px; padding: 4px 10px; font-size: 13px; }
    .csp-standalone .csp-standalone-footer { padding-inline: 16px; }
    .csp-standalone-content { padding: 20px 16px; }
}
@media (prefers-reduced-motion: reduce) {
    .csp-app *,
    .csp-standalone-frame * { transition: none !important; }
}

/* ------------------------------------------------------------------ Badge tones and customer details */
.csp-badge.is-green { background: var(--cs-green-lt); color: var(--cs-green-ink); }
.csp-badge.is-yellow { background: var(--cs-yellow-lt); color: var(--cs-yellow-ink); }
.csp-badge.is-red { background: var(--cs-red-lt); color: var(--cs-red-ink); }
.csp-badge.is-blue { background: var(--cs-blue-lt); color: var(--cs-blue-ink); }
.csp-badge.is-muted { background: var(--cs-surface-2); color: var(--cs-muted); }
.csp-context { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); margin: 4px 0 20px; }
.csp-context-panel { border: 1px solid var(--cs-line); border-radius: var(--cs-radius-lg); background: var(--cs-surface); box-shadow: var(--cs-shadow-card); }
.csp-context-panel > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 12px 16px; cursor: pointer; list-style: none; }
.csp-context-panel > summary::-webkit-details-marker { display: none; }
.csp-context-panel > summary strong { color: var(--cs-ink); font-weight: 600; }
.csp-context-panel > summary .csp-muted { flex-basis: 100%; padding-left: 38px; font-size: 13px; }
.csp-context-panel[open] > summary { border-bottom: 1px solid var(--cs-line); }
.csp-context-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--cs-radius); background: var(--cs-surface-2); color: var(--cs-text); }
.csp-context-icon .csp-icon { width: 16px; height: 16px; }
.csp-context-icon.is-purple { background: var(--cs-purple-lt); color: var(--cs-purple-ink); }
.csp-context-icon.is-blue { background: var(--cs-blue-lt); color: var(--cs-blue-ink); }
.csp-context-icon.is-green { background: var(--cs-green-lt); color: var(--cs-green-ink); }
.csp-context-icon.is-orange { background: var(--cs-orange-lt); color: var(--cs-orange-ink); }
.csp-context-facts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); margin: 0; padding: 14px 16px 4px; }
.csp-context-facts dt { color: var(--cs-muted); font-size: 11px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
.csp-context-facts dd { margin: 2px 0 0; color: var(--cs-ink); font-weight: 500; overflow-wrap: anywhere; }
.csp-context-group { margin: 14px 16px 6px; color: var(--cs-muted); font-size: 11px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
.csp-context-items { margin: 0; padding: 0 16px; list-style: none; }
.csp-context-items li { display: grid; gap: 2px; padding: 8px 0; border-top: 1px solid var(--cs-line); font-size: 13px; }
.csp-context-items li:first-child { border-top: 0; }
.csp-context-item-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.csp-context-items a { color: var(--cs-link); font-weight: 500; }
.csp-context-link { display: inline-flex; align-items: center; gap: 4px; margin: 6px 16px 14px; color: var(--cs-link); font-size: 13px; font-weight: 500; }
.csp-context-link .csp-icon { width: 14px; height: 14px; }
.csp-context-panel:not([open]) .csp-context-link { display: none; }
.csp-context-none { display: flex; align-items: center; gap: 6px; margin: -8px 0 20px; color: var(--cs-muted); font-size: 13px; }
.csp-context-none .csp-icon { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ Account areas (WooCommerce My Account, FluentCart) */
.csp-account .csp-layout { display: block; min-height: 0; }
.csp-account .csp-sidebar { padding: 0 0 12px; }
.csp-account .csp-sidebar-label,
.csp-account .csp-sidebar-help,
.csp-account .csp-intro :is(h1, h2),
.csp-account .csp-intro .csp-eyebrow { display: none; }
.csp-account .csp-sidebar nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
.csp-account .csp-intro { padding-top: 0; }

/* Until the private bootstrap answers, the page does not know who is visiting: keep the controls'
   space but do not show them disabled. Signed-out visitors then see only the sign-in prompt. */
.csp-app[aria-busy="true"] :is([id$="csp-new"], .csp-toolbar, .csp-sidebar nav) { visibility: hidden; }
.csp-app.csp-signed-out :is([id$="csp-new"], .csp-toolbar, .csp-sidebar, .csp-pagination) { display: none; }
.csp-app.csp-signed-out .csp-layout { display: block; min-height: 0; }
