/* ==========================================================================
   Farr Hub – application design system

   Loaded after Bootstrap and hub-tokens.css. Declares no colour: every value
   is a token from hub-tokens.css, so both themes come from one block.
   Order: 1. scale, 2. Bootstrap mapping, 3. base, 4. primitives, 5. shell,
   6. pages, 7. right to left and Persian.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Scale
   -------------------------------------------------------------------------- */
:root {
    --hub-space-1: 0.25rem;
    --hub-space-2: 0.5rem;
    --hub-space-3: 0.75rem;
    --hub-space-4: 1rem;
    --hub-space-5: 1.5rem;
    --hub-space-6: 2rem;
    --hub-gap: 1.5rem;

    --hub-radius-sm: 0.375rem;
    --hub-radius:    0.5rem;
    --hub-radius-lg: 0.75rem;

    --hub-caps-tracking: 0.06em;
    --hub-sidebar-width: 248px;
    --hub-header-height: 60px;
}

/* --------------------------------------------------------------------------
   2. Bootstrap mapping
   -------------------------------------------------------------------------- */
:root,
:root[data-bs-theme="dark"] {
    --bs-primary:       var(--hub-accent);
    --bs-primary-rgb:   var(--hub-accent-rgb);
    --bs-secondary:     var(--hub-text-secondary);
    --bs-secondary-rgb: var(--hub-text-secondary-rgb);
    --bs-success:       var(--hub-status-done);
    --bs-success-rgb:   var(--hub-status-done-rgb);
    --bs-warning:       var(--hub-status-open);
    --bs-warning-rgb:   var(--hub-status-open-rgb);
    --bs-danger:        var(--hub-status-error);
    --bs-danger-rgb:    var(--hub-status-error-rgb);
    --bs-info:          var(--hub-accent-text);
    --bs-info-rgb:      var(--hub-accent-text-rgb);

    --bs-body-font-family:    var(--hub-font-text);
    --bs-body-font-size:      0.9375rem;
    --bs-body-color:          var(--hub-text-primary);
    --bs-body-color-rgb:      var(--hub-text-primary-rgb);
    --bs-body-bg:             var(--hub-bg);
    --bs-body-bg-rgb:         var(--hub-bg-rgb);
    --bs-emphasis-color:      var(--hub-text-primary);
    --bs-secondary-color:     var(--hub-text-secondary);
    --bs-secondary-color-rgb: var(--hub-text-secondary-rgb);
    --bs-tertiary-color:      var(--hub-text-secondary);
    --bs-secondary-bg:        var(--hub-bg-subtle);
    --bs-tertiary-bg:         var(--hub-bg-subtle);
    --bs-heading-color:       var(--hub-text-primary);

    --bs-link-color:           var(--hub-accent-text);
    --bs-link-color-rgb:       var(--hub-accent-text-rgb);
    --bs-link-hover-color:     var(--hub-accent-text);
    --bs-link-hover-color-rgb: var(--hub-accent-text-rgb);
    --bs-code-color:           var(--hub-text-primary);

    --bs-border-color:             var(--hub-border);
    --bs-border-color-translucent: var(--hub-border);
    --bs-border-radius:    var(--hub-radius);
    --bs-border-radius-sm: var(--hub-radius-sm);
    --bs-border-radius-lg: var(--hub-radius-lg);

    --bs-box-shadow-sm: 0 0 0 1px var(--hub-border), var(--hub-shadow-sm);
    --bs-box-shadow:    var(--hub-shadow-md);
    --bs-box-shadow-lg: var(--hub-shadow-lg);
    --bs-focus-ring-color: var(--hub-focus-ring);

    --bs-primary-text-emphasis: var(--hub-accent-text);
    --bs-danger-text-emphasis:  var(--hub-status-error);
    --bs-success-text-emphasis: var(--hub-status-done);
    --bs-warning-text-emphasis: var(--hub-status-open);
    --bs-primary-bg-subtle: color-mix(in srgb, var(--hub-accent-text) 12%, transparent);
    --bs-danger-bg-subtle:  color-mix(in srgb, var(--hub-status-error) 12%, transparent);
    --bs-success-bg-subtle: color-mix(in srgb, var(--hub-status-done) 12%, transparent);
    --bs-warning-bg-subtle: color-mix(in srgb, var(--hub-status-open) 12%, transparent);
    --bs-primary-border-subtle: color-mix(in srgb, var(--hub-accent-text) 32%, transparent);
    --bs-danger-border-subtle:  color-mix(in srgb, var(--hub-status-error) 32%, transparent);
    --bs-success-border-subtle: color-mix(in srgb, var(--hub-status-done) 32%, transparent);
    --bs-warning-border-subtle: color-mix(in srgb, var(--hub-status-open) 32%, transparent);
}

/* --------------------------------------------------------------------------
   3. Base
   -------------------------------------------------------------------------- */
body {
    background-color: var(--hub-bg);
    color: var(--hub-text-primary);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--hub-text-primary);
    font-family: var(--hub-font-display);
    letter-spacing: -0.01em;
}

h1:focus {
    outline: none;
}

code, kbd, pre, .font-monospace {
    font-family: var(--hub-font-mono);
}

code {
    font-size: 0.8125rem;
    padding: 0.0625rem 0.3125rem;
    border-radius: var(--hub-radius-sm);
    background-color: var(--hub-bg-subtle);
    color: var(--hub-text-primary);
}

::selection {
    background-color: var(--hub-accent);
    color: var(--hub-on-accent);
}

a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 2px solid var(--hub-focus-ring) !important;
    outline-offset: 2px;
    box-shadow: none !important;
}

.text-secondary,
.text-body-secondary,
.text-muted {
    color: var(--hub-text-secondary) !important;
}

/* --------------------------------------------------------------------------
   4. Primitives
   -------------------------------------------------------------------------- */

/* ── Button ─────────────────────────────────────────────────────────────── */
.btn {
    --bs-btn-font-weight: 600;
    --bs-btn-font-size: 0.875rem;
    --bs-btn-border-radius: var(--hub-radius);
    --bs-btn-disabled-opacity: 0.5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--hub-space-2);
}

.btn-sm {
    --bs-btn-font-size: 0.8125rem;
    --bs-btn-border-radius: var(--hub-radius-sm);
}

.btn-primary {
    --bs-btn-color: var(--hub-on-accent);
    --bs-btn-bg: var(--hub-accent);
    --bs-btn-border-color: var(--hub-accent);
    --bs-btn-hover-color: var(--hub-on-accent);
    --bs-btn-hover-bg: var(--hub-accent-hover);
    --bs-btn-hover-border-color: var(--hub-accent-hover);
    --bs-btn-active-color: var(--hub-on-accent);
    --bs-btn-active-bg: var(--hub-accent-hover);
    --bs-btn-active-border-color: var(--hub-accent-hover);
    --bs-btn-disabled-color: var(--hub-on-accent);
    --bs-btn-disabled-bg: var(--hub-accent);
    --bs-btn-disabled-border-color: var(--hub-accent);
}

.btn-outline-primary {
    --bs-btn-color: var(--hub-accent-text);
    --bs-btn-border-color: color-mix(in srgb, var(--hub-accent-text) 48%, transparent);
    --bs-btn-hover-color: var(--hub-on-accent);
    --bs-btn-hover-bg: var(--hub-accent);
    --bs-btn-hover-border-color: var(--hub-accent);
    --bs-btn-active-color: var(--hub-on-accent);
    --bs-btn-active-bg: var(--hub-accent);
    --bs-btn-active-border-color: var(--hub-accent);
    --bs-btn-disabled-color: var(--hub-accent-text);
    --bs-btn-disabled-border-color: var(--hub-border-strong);
}

.btn-secondary,
.btn-outline-secondary,
.btn-light {
    --bs-btn-color: var(--hub-text-primary);
    --bs-btn-bg: var(--hub-bg-elevated);
    --bs-btn-border-color: var(--hub-border-strong);
    --bs-btn-hover-color: var(--hub-text-primary);
    --bs-btn-hover-bg: var(--hub-bg-subtle);
    --bs-btn-hover-border-color: var(--hub-border-strong);
    --bs-btn-active-color: var(--hub-text-primary);
    --bs-btn-active-bg: var(--hub-bg-subtle);
    --bs-btn-active-border-color: var(--hub-accent-text);
    --bs-btn-disabled-color: var(--hub-text-secondary);
    --bs-btn-disabled-bg: var(--hub-bg-elevated);
    --bs-btn-disabled-border-color: var(--hub-border);
}

.btn-danger {
    --bs-btn-color: var(--hub-on-status);
    --bs-btn-bg: var(--hub-status-error);
    --bs-btn-border-color: var(--hub-status-error);
    --bs-btn-hover-color: var(--hub-on-status);
    --bs-btn-hover-bg: color-mix(in srgb, var(--hub-status-error) 88%, var(--hub-text-primary));
    --bs-btn-hover-border-color: var(--bs-btn-hover-bg);
    --bs-btn-active-color: var(--hub-on-status);
    --bs-btn-active-bg: var(--bs-btn-hover-bg);
    --bs-btn-disabled-color: var(--hub-on-status);
    --bs-btn-disabled-bg: var(--hub-status-error);
}

.btn-outline-danger,
.btn-outline-success,
.btn-outline-warning {
    --bs-btn-border-color: color-mix(in srgb, var(--hub-button-status) 48%, transparent);
    --bs-btn-color: var(--hub-button-status);
    --bs-btn-hover-color: var(--hub-button-status);
    --bs-btn-hover-bg: color-mix(in srgb, var(--hub-button-status) 12%, transparent);
    --bs-btn-hover-border-color: var(--hub-button-status);
    --bs-btn-active-color: var(--hub-button-status);
    --bs-btn-active-bg: color-mix(in srgb, var(--hub-button-status) 12%, transparent);
    --bs-btn-active-border-color: var(--hub-button-status);
}

.btn-outline-danger  { --hub-button-status: var(--hub-status-error); }
.btn-outline-success { --hub-button-status: var(--hub-status-done); }
.btn-outline-warning { --hub-button-status: var(--hub-status-open); }

.btn-link {
    --bs-btn-color: var(--hub-accent-text);
    --bs-btn-hover-color: var(--hub-accent-text);
    --bs-btn-active-color: var(--hub-accent-text);
    --bs-btn-font-weight: 600;
    text-decoration: none;
}

.btn-link.text-danger {
    color: var(--hub-status-error) !important;
}

.btn-ghost {
    --bs-btn-color: var(--hub-text-secondary);
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--hub-text-primary);
    --bs-btn-hover-bg: var(--hub-accent-soft);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-color: var(--hub-text-primary);
    --bs-btn-active-bg: var(--hub-accent-soft);
    --bs-btn-active-border-color: transparent;
}

.btn-icon {
    inline-size: 2.25rem;
    block-size: 2.25rem;
    padding: 0;
}

/* ── Icon ───────────────────────────────────────────────────────────────── */
.hub-icon {
    inline-size: 1.125rem;
    block-size: 1.125rem;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn-sm .hub-icon {
    inline-size: 1rem;
    block-size: 1rem;
}

.hub-spin {
    animation: hub-spin 0.9s linear infinite;
}

@keyframes hub-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .hub-spin { animation: none; }
}

/* ── Card ───────────────────────────────────────────────────────────────── */
.card {
    --bs-card-bg: var(--hub-bg-elevated);
    --bs-card-color: var(--hub-text-primary);
    --bs-card-border-color: var(--hub-border);
    --bs-card-border-radius: var(--hub-radius-lg);
    --bs-card-inner-border-radius: calc(var(--hub-radius-lg) - 1px);
    --bs-card-cap-bg: transparent;
    --bs-card-cap-padding-y: 0.875rem;
    --bs-card-cap-padding-x: 1.25rem;
    --bs-card-spacer-x: 1.25rem;
    --bs-card-spacer-y: 1.25rem;
    box-shadow: var(--hub-shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--hub-space-3);
    border-block-end-color: var(--hub-border);
}

.card-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
}

.card-subtitle {
    color: var(--hub-text-secondary);
    font-size: 0.8125rem;
}

/* Positioned, so absolutely positioned content inside a table (.visually-hidden headers) is clipped by
   the scroll container instead of widening the page on a phone. */
.table-responsive {
    position: relative;
}

.card-flush > .table-responsive > .table,
.card-flush > .table {
    margin-block-end: 0;
}

.card-flush .table > :not(caption) > * > * {
    padding-inline: 1.25rem;
}

/* ── Eyebrow and stat tile ─────────────────────────────────────────────── */
.hub-eyebrow {
    color: var(--hub-text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: var(--hub-caps-tracking);
    text-transform: uppercase;
}

.hub-stat {
    display: flex;
    align-items: flex-start;
    gap: var(--hub-space-3);
    padding: 1.125rem 1.25rem;
}

.hub-stat-body {
    display: flex;
    flex-direction: column;
    gap: var(--hub-space-1);
    min-inline-size: 0;
}

.hub-stat-value {
    font-family: var(--hub-font-display);
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.hub-stat-note {
    color: var(--hub-text-secondary);
    font-size: 0.8125rem;
}

.hub-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 2.5rem;
    block-size: 2.5rem;
    border-radius: var(--hub-radius);
    background-color: var(--hub-bg-subtle);
    color: var(--hub-text-secondary);
}

.hub-stat-icon--new  { color: var(--hub-status-new);  background-color: color-mix(in srgb, var(--hub-status-new) 12%, transparent); }
.hub-stat-icon--open { color: var(--hub-status-open); background-color: color-mix(in srgb, var(--hub-status-open) 12%, transparent); }
.hub-stat-icon--done { color: var(--hub-status-done); background-color: color-mix(in srgb, var(--hub-status-done) 12%, transparent); }

/* ── Pill (status) and chip (tag) ──────────────────────────────────────── */
.hub-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.1875rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    color: var(--hub-pill-color, var(--hub-status-muted));
    background-color: color-mix(in srgb, var(--hub-pill-color, var(--hub-status-muted)) 12%, transparent);
}

.hub-pill::before {
    content: "";
    inline-size: 0.4375rem;
    block-size: 0.4375rem;
    border-radius: 50%;
    background-color: currentColor;
}

.hub-pill--plain::before {
    display: none;
}

.hub-pill--new   { --hub-pill-color: var(--hub-status-new); }
.hub-pill--open  { --hub-pill-color: var(--hub-status-open); }
.hub-pill--done  { --hub-pill-color: var(--hub-status-done); }
.hub-pill--error { --hub-pill-color: var(--hub-status-error); }
.hub-pill--muted { --hub-pill-color: var(--hub-status-muted); }

.hub-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border: 1px solid var(--hub-border-strong);
    border-radius: var(--hub-radius-sm);
    font-size: 0.75rem;
    color: var(--hub-text-secondary);
    background-color: var(--hub-bg-elevated);
    white-space: nowrap;
}

.hub-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--hub-space-1);
}

/* ── Table ──────────────────────────────────────────────────────────────── */
.table {
    --bs-table-color: var(--hub-text-primary);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--hub-border);
    --bs-table-hover-color: var(--hub-text-primary);
    --bs-table-hover-bg: var(--hub-accent-soft);
    font-variant-numeric: tabular-nums;
}

.table > :not(caption) > * > * {
    padding-block: 0.75rem;
}

.table > thead > tr > th {
    color: var(--hub-text-secondary);
    background-color: var(--hub-bg-subtle);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: var(--hub-caps-tracking);
    text-transform: uppercase;
    white-space: nowrap;
    padding-block: 0.625rem;
    border-block-end-color: var(--hub-border);
}

.table > tbody > tr:last-child > * {
    border-block-end: 0;
}

.hub-row-title {
    color: var(--hub-text-primary);
    font-weight: 600;
    text-decoration: none;
}

.hub-row-title:hover {
    color: var(--hub-accent-text);
}

/* ── Form ───────────────────────────────────────────────────────────────── */
.form-label {
    color: var(--hub-text-primary);
    font-size: 0.8125rem;
    font-weight: 600;
    margin-block-end: 0.375rem;
}

.form-text {
    color: var(--hub-text-secondary);
    font-size: 0.8125rem;
}

.form-control,
.form-select {
    color: var(--hub-text-primary);
    background-color: var(--hub-bg-elevated);
    border-color: var(--hub-border-strong);
    border-radius: var(--hub-radius);
    font-size: 0.875rem;
}

.form-control::placeholder {
    color: var(--hub-text-disabled);
}

.form-control:focus,
.form-select:focus {
    color: var(--hub-text-primary);
    background-color: var(--hub-bg-elevated);
    border-color: var(--hub-accent-text);
    box-shadow: 0 0 0 3px var(--hub-accent-soft);
}

.form-control-sm,
.form-select-sm {
    border-radius: var(--hub-radius-sm);
    font-size: 0.8125rem;
}

.hub-search {
    position: relative;
}

.hub-search > .hub-icon {
    position: absolute;
    inset-inline-start: 0.625rem;
    inset-block-start: 50%;
    transform: translateY(-50%);
    color: var(--hub-text-secondary);
    pointer-events: none;
}

.hub-search > .form-control {
    padding-inline-start: 2.125rem;
}

.hub-editor {
    font-family: var(--hub-font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
    min-block-size: 18rem;
    resize: vertical;
}

/* ── Alert ──────────────────────────────────────────────────────────────── */
.alert {
    --bs-alert-border-radius: var(--hub-radius);
    display: flex;
    align-items: flex-start;
    gap: var(--hub-space-2);
    font-size: 0.875rem;
    border-width: 1px;
}

.alert-success {
    --bs-alert-color: var(--hub-status-done);
    --bs-alert-bg: color-mix(in srgb, var(--hub-status-done) 10%, var(--hub-bg-elevated));
    --bs-alert-border-color: color-mix(in srgb, var(--hub-status-done) 32%, transparent);
}

.alert-danger {
    --bs-alert-color: var(--hub-status-error);
    --bs-alert-bg: color-mix(in srgb, var(--hub-status-error) 10%, var(--hub-bg-elevated));
    --bs-alert-border-color: color-mix(in srgb, var(--hub-status-error) 32%, transparent);
}

.alert-warning {
    --bs-alert-color: var(--hub-status-open);
    --bs-alert-bg: color-mix(in srgb, var(--hub-status-open) 10%, var(--hub-bg-elevated));
    --bs-alert-border-color: color-mix(in srgb, var(--hub-status-open) 32%, transparent);
}

.alert-info {
    --bs-alert-color: var(--hub-accent-text);
    --bs-alert-bg: color-mix(in srgb, var(--hub-accent-text) 8%, var(--hub-bg-elevated));
    --bs-alert-border-color: color-mix(in srgb, var(--hub-accent-text) 28%, transparent);
}

/* ── State block (loading, empty, error) ───────────────────────────────── */
.hub-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--hub-space-2);
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--hub-text-secondary);
}

.hub-state-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 3rem;
    block-size: 3rem;
    margin-block-end: var(--hub-space-2);
    border-radius: 50%;
    background-color: var(--hub-bg-subtle);
    color: var(--hub-text-secondary);
}

.hub-state-icon .hub-icon {
    inline-size: 1.5rem;
    block-size: 1.5rem;
}

.hub-state--error .hub-state-icon {
    color: var(--hub-status-error);
    background-color: color-mix(in srgb, var(--hub-status-error) 12%, transparent);
}

.hub-state-title {
    color: var(--hub-text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.hub-state-text {
    max-inline-size: 28rem;
    font-size: 0.875rem;
}

.hub-skeleton {
    display: block;
    block-size: 0.875rem;
    border-radius: var(--hub-radius-sm);
    background: linear-gradient(90deg, var(--hub-bg-subtle), var(--hub-border), var(--hub-bg-subtle));
    background-size: 200% 100%;
    animation: hub-shimmer 1.4s ease-in-out infinite;
}

@keyframes hub-shimmer {
    from { background-position: 100% 0; }
    to   { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .hub-skeleton { animation: none; }
}

/* --------------------------------------------------------------------------
   5. Shell
   -------------------------------------------------------------------------- */
.hub-shell {
    min-block-size: 100vh;
}

.hub-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    inline-size: var(--hub-sidebar-width);
    padding: var(--hub-space-4) var(--hub-space-3);
    /* The sidebar scrolls on its own when its links outgrow the window. */
    overflow-y: auto;
    overscroll-behavior: contain;
    background-color: var(--hub-bg-subtle);
    border-inline-end: 1px solid var(--hub-border);
}

.hub-brand {
    display: flex;
    align-items: center;
    gap: var(--hub-space-3);
    padding: var(--hub-space-1) var(--hub-space-2) var(--hub-space-5);
    color: var(--hub-text-primary);
    text-decoration: none;
}

.hub-brand:hover {
    color: var(--hub-text-primary);
}

.hub-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 2.25rem;
    block-size: 2.25rem;
    border-radius: var(--hub-radius);
    background-color: var(--hub-accent);
    color: var(--hub-brand-mark);
    box-shadow: var(--hub-shadow-sm);
}

.hub-brand-mark svg {
    inline-size: 1.375rem;
    block-size: 1.375rem;
    fill: currentColor;
}

.hub-brand-name {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.hub-brand-name strong {
    font-family: var(--hub-font-display);
    font-size: 1.0625rem;
    font-weight: 700;
}

.hub-brand-name span {
    color: var(--hub-text-secondary);
    font-size: 0.75rem;
}

.hub-nav-label {
    padding: var(--hub-space-2) var(--hub-space-3) var(--hub-space-1);
}

.hub-nav {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hub-nav-link {
    display: flex;
    align-items: center;
    gap: var(--hub-space-3);
    padding: 0.5rem var(--hub-space-3);
    border-radius: var(--hub-radius);
    color: var(--hub-text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
}

.hub-nav-link:hover {
    color: var(--hub-text-primary);
    background-color: var(--hub-accent-soft);
}

.hub-nav-link.active {
    color: var(--hub-accent-text);
    background-color: var(--hub-bg-elevated);
    box-shadow: 0 0 0 1px var(--hub-border), var(--hub-shadow-sm);
}

.hub-sidebar-footer {
    margin-block-start: auto;
    padding: var(--hub-space-3);
    border-radius: var(--hub-radius);
    color: var(--hub-text-secondary);
    font-size: 0.75rem;
    line-height: 1.5;
}

.hub-main {
    margin-inline-start: var(--hub-sidebar-width);
    min-block-size: 100vh;
    display: flex;
    flex-direction: column;
}

.hub-topbar {
    position: sticky;
    inset-block-start: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: var(--hub-space-3);
    block-size: var(--hub-header-height);
    padding-inline: var(--hub-space-6);
    background-color: var(--hub-header-bg);
    backdrop-filter: blur(10px);
    border-block-end: 1px solid var(--hub-border);
}

.hub-topbar-spacer {
    flex: 1;
}

.hub-user {
    display: flex;
    align-items: center;
    gap: var(--hub-space-2);
    font-size: 0.875rem;
    font-weight: 600;
}

.hub-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 2rem;
    block-size: 2rem;
    border-radius: 50%;
    background-color: var(--hub-accent-soft);
    color: var(--hub-accent-text);
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
}

.hub-content {
    flex: 1;
    inline-size: 100%;
    max-inline-size: 1440px;
    padding: var(--hub-space-6);
}

/* Theme toggle: one icon per theme. */
.hub-theme-dark-icon { display: none; }
:root[data-bs-theme="dark"] .hub-theme-dark-icon { display: inline; }
:root[data-bs-theme="dark"] .hub-theme-light-icon { display: none; }

.hub-sidebar-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--hub-space-2);
}

/* Desktop-only and mobile-only shell parts. */
.hub-nav-toggle,
.hub-nav-close,
.hub-topbar-brand,
.hub-nav-scrim {
    display: none;
}

/* Mobile: the sidebar becomes a drawer opened from the menu button (hub.js sets
   data-hub-nav="open" on the root); a scrim behind it closes it. */
@media (max-width: 991.98px) {
    .hub-sidebar {
        z-index: 1045;
        inline-size: min(18rem, 85vw);
        box-shadow: var(--hub-shadow-lg);
        visibility: hidden;
        translate: -100% 0;
        transition: translate 0.2s ease, visibility 0.2s;
    }

    [dir="rtl"] .hub-sidebar {
        translate: 100% 0;
    }

    :root[data-hub-nav="open"] .hub-sidebar {
        visibility: visible;
        translate: 0 0;
    }

    .hub-nav-scrim {
        position: fixed;
        inset: 0;
        z-index: 1040;
        background-color: var(--hub-scrim);
    }

    :root[data-hub-nav="open"] .hub-nav-scrim {
        display: block;
    }

    :root[data-hub-nav="open"] body {
        overflow: hidden;
    }

    .hub-nav-toggle,
    .hub-nav-close {
        display: inline-flex;
    }

    .hub-topbar-brand {
        display: flex;
        align-items: center;
        gap: var(--hub-space-2);
        color: var(--hub-text-primary);
        font-family: var(--hub-font-display);
        text-decoration: none;
    }

    .hub-topbar-brand .hub-brand-mark {
        inline-size: 1.875rem;
        block-size: 1.875rem;
    }

    .hub-main { margin-inline-start: 0; }
    .hub-topbar { gap: var(--hub-space-2); padding-inline: var(--hub-space-3); }
    .hub-content { padding: var(--hub-space-4); }
}

@media (max-width: 991.98px) and (prefers-reduced-motion: reduce) {
    .hub-sidebar {
        transition: none;
    }
}

/* --------------------------------------------------------------------------
   6. Pages
   -------------------------------------------------------------------------- */

/* ── Page header ───────────────────────────────────────────────────────── */
.hub-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--hub-space-4);
    margin-block-end: var(--hub-gap);
}

.hub-page-title {
    margin: 0.125rem 0 0;
    font-size: 1.625rem;
    font-weight: 700;
    line-height: 1.2;
}

.hub-page-lead {
    margin: 0.375rem 0 0;
    max-inline-size: 46rem;
    color: var(--hub-text-secondary);
    font-size: 0.9375rem;
}

.hub-page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--hub-space-2);
}

.hub-back {
    display: inline-flex;
    align-items: center;
    gap: var(--hub-space-1);
    margin-block-end: var(--hub-space-3);
    color: var(--hub-text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
}

.hub-back:hover {
    color: var(--hub-accent-text);
}

.hub-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--hub-space-2) var(--hub-space-4);
    color: var(--hub-text-secondary);
    font-size: 0.8125rem;
}

.hub-meta > span {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.hub-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--hub-space-2);
}

.hub-toolbar > .hub-search {
    flex: 1 1 16rem;
}

.hub-toolbar > .form-select,
.hub-toolbar > .hub-toolbar-field {
    flex: 0 1 11rem;
}

/* ── Conversation ─────────────────────────────────────────────────────── */
.hub-thread {
    display: flex;
    flex-direction: column;
}

.hub-message {
    display: flex;
    gap: var(--hub-space-3);
    padding: var(--hub-space-4) 1.25rem;
    border-block-end: 1px solid var(--hub-border);
}

.hub-message:last-child {
    border-block-end: 0;
}

.hub-message-body {
    min-inline-size: 0;
    flex: 1;
}

.hub-message-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--hub-space-2);
    margin-block-end: 0.25rem;
}

.hub-message-author {
    min-inline-size: 0;
    overflow-wrap: anywhere;
    font-weight: 600;
    font-size: 0.875rem;
}

.hub-message-time {
    color: var(--hub-text-secondary);
    font-size: 0.75rem;
}

/* Discord messages keep the direction of their own text in either language. */
.hub-message-content {
    unicode-bidi: plaintext;
    text-align: start;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 0.875rem;
    line-height: 1.6;
}

.hub-message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: var(--hub-space-1);
    margin-block-start: var(--hub-space-2);
}

/* Insight titles and file names are long: let them wrap inside the message on a phone. */
.hub-message-attachments > * {
    max-inline-size: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
}

.hub-thread-scroll {
    max-block-size: 72vh;
    overflow-y: auto;
}

/* ── Links list ───────────────────────────────────────────────────────── */
.hub-link-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.hub-link-item {
    display: flex;
    align-items: center;
    gap: var(--hub-space-2);
    padding: 0.625rem 0;
    border-block-end: 1px solid var(--hub-border);
    font-size: 0.875rem;
}

.hub-link-item:last-child {
    border-block-end: 0;
}

.hub-link-item .hub-icon {
    color: var(--hub-text-secondary);
}

/* ── Sign-in ──────────────────────────────────────────────────────────── */
.hub-auth {
    position: relative;
    display: grid;
    place-items: center;
    min-block-size: 100vh;
    padding: var(--hub-space-5);
    background:
        radial-gradient(60rem 30rem at 85% -10%, var(--hub-accent-soft), transparent 60%),
        radial-gradient(40rem 24rem at -10% 110%, var(--hub-accent-soft), transparent 60%),
        var(--hub-bg);
}

.hub-auth-card {
    inline-size: min(100%, 26rem);
    padding: 2.25rem;
    border: 1px solid var(--hub-border);
    border-radius: var(--hub-radius-lg);
    background-color: var(--hub-bg-elevated);
    box-shadow: var(--hub-shadow-lg);
}

.hub-auth-card .hub-brand {
    padding: 0 0 var(--hub-space-5);
}

.hub-auth-title {
    margin: 0 0 var(--hub-space-2);
    font-size: 1.5rem;
    font-weight: 700;
}

.hub-auth-text {
    margin: 0 0 var(--hub-space-5);
    color: var(--hub-text-secondary);
    font-size: 0.9375rem;
}

.hub-auth-foot {
    margin: var(--hub-space-5) 0 0;
    color: var(--hub-text-secondary);
    font-size: 0.75rem;
    text-align: center;
}

/* ── Blazor error bar ─────────────────────────────────────────────────── */
#blazor-error-ui {
    position: fixed;
    inset-inline: 0;
    inset-block-end: 0;
    z-index: 1100;
    display: none;
    padding: 0.75rem 1.25rem;
    color: var(--hub-status-error);
    background-color: var(--hub-bg-elevated);
    border-block-start: 2px solid var(--hub-status-error);
    box-shadow: var(--hub-shadow-md);
    font-size: 0.875rem;
}

#blazor-error-ui .reload {
    margin-inline-start: var(--hub-space-3);
    font-weight: 600;
}

#blazor-error-ui .dismiss {
    position: absolute;
    inset-inline-end: 1rem;
    inset-block-start: 0.625rem;
    cursor: pointer;
}

/* ── Insights ─────────────────────────────────────────────────────────── */
.hub-insight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
    gap: var(--hub-space-4);
}

.hub-insight-card {
    position: relative;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.hub-insight-card:hover {
    border-color: var(--hub-border-strong);
    box-shadow: var(--hub-shadow-md);
}

.hub-insight-card .card-body {
    flex: 1;
}

.hub-insight-summary {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
    color: var(--hub-text-secondary);
    font-size: 0.875rem;
}

.hub-insight-foot {
    display: flex;
    align-items: center;
    gap: var(--hub-space-2);
    background-color: transparent;
    border-block-start-color: var(--hub-border);
}

.hub-insight-lead {
    margin: 0;
    font-size: 1rem;
    line-height: 1.65;
}

.hub-hashtag {
    color: var(--hub-accent-text);
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
}

a.hub-hashtag:hover {
    text-decoration: underline;
}

button.hub-chip,
a.hub-chip {
    cursor: pointer;
    text-decoration: none;
}

button.hub-chip:hover,
a.hub-chip:hover {
    border-color: var(--hub-accent-text);
    color: var(--hub-accent-text);
}

.hub-chip--active {
    border-color: var(--hub-accent);
    background-color: var(--hub-accent);
    color: var(--hub-on-accent);
}

.hub-chip .hub-icon {
    inline-size: 0.875rem;
    block-size: 0.875rem;
    margin-inline-end: 0.25rem;
}

a.hub-pill {
    text-decoration: none;
}

.hub-thumbs {
    display: flex;
    gap: var(--hub-space-2);
    margin-block-start: var(--hub-space-3);
}

.hub-thumb {
    inline-size: 2.75rem;
    block-size: 2.75rem;
    object-fit: cover;
    border-radius: var(--hub-radius);
    border: 1px solid var(--hub-border);
    background-color: var(--hub-bg-subtle);
}

/* ── Image preview ─────────────────────────────────────────────────────
   A thumbnail button that opens the image full size above the page. The
   button sits above a card's stretched link so a click previews instead of
   navigating. */
.hub-preview-trigger {
    position: relative;
    z-index: 2;
    display: inline-flex;
    padding: 0;
    border: 0;
    border-radius: var(--hub-radius);
    background: none;
    cursor: zoom-in;
}

.hub-preview-trigger:focus-visible {
    outline: 2px solid var(--hub-accent);
    outline-offset: 2px;
}

.hub-preview-hint {
    position: absolute;
    inset-block-end: var(--hub-space-2);
    inset-inline-end: var(--hub-space-2);
    display: flex;
    padding: 0.3125rem;
    border-radius: 999px;
    color: var(--hub-on-accent);
    background-color: var(--hub-accent);
    box-shadow: var(--hub-shadow-md);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.hub-preview-trigger:hover .hub-preview-hint,
.hub-preview-trigger:focus-visible .hub-preview-hint {
    opacity: 1;
}

.hub-thumbs .hub-preview-hint {
    display: none;
}

.hub-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1090;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--hub-space-6) var(--hub-space-4);
    background-color: var(--hub-scrim);
    backdrop-filter: blur(4px);
    cursor: zoom-out;
}

.hub-lightbox:focus {
    outline: none;
}

/* A fixed width, not shrink-to-fit: SVG diagrams carry only a viewBox and would otherwise render at
   their small default size. Height is capped so the whole image stays on screen. */
.hub-lightbox-figure {
    display: flex;
    flex-direction: column;
    inline-size: min(100%, 100rem, calc((100vh - 9rem) * 1.6));
    max-block-size: 100%;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--hub-border);
    border-radius: var(--hub-radius-lg);
    background-color: var(--hub-bg-elevated);
    box-shadow: var(--hub-shadow-lg);
    cursor: default;
}

.hub-lightbox-figure > img {
    display: block;
    min-block-size: 0;
    inline-size: 100%;
    max-block-size: calc(100vh - 9rem);
    object-fit: contain;
    background-color: var(--hub-bg-subtle);
}

.hub-lightbox-figure > figcaption {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--hub-space-2);
    padding: var(--hub-space-3) var(--hub-space-4);
    font-size: 0.875rem;
}

.hub-lightbox-close {
    position: absolute;
    inset-block-start: var(--hub-space-4);
    inset-inline-end: var(--hub-space-4);
    color: var(--hub-text-primary);
    background-color: var(--hub-bg-elevated);
    box-shadow: var(--hub-shadow-md);
}

.hub-points {
    margin: 0;
    padding-inline-start: 1.25rem;
}

.hub-points > li {
    margin-block-end: 0.375rem;
    line-height: 1.55;
}

.hub-points > li::marker {
    color: var(--hub-accent-text);
}

.hub-callout {
    padding: var(--hub-space-4);
    border-inline-start: 3px solid var(--hub-accent);
    border-radius: var(--hub-radius);
    background-color: var(--hub-accent-soft);
}

.hub-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
    gap: var(--hub-space-3);
}

.hub-figure {
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--hub-border);
    border-radius: var(--hub-radius-lg);
    background-color: var(--hub-bg-elevated);
}

.hub-figure-media {
    display: block;
    inline-size: 100%;
    border-radius: 0;
}

.hub-figure-media > img,
.hub-figure-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    inline-size: 100%;
    aspect-ratio: 16 / 10;
    /* Contain, not cover: square store icons would lose their top and bottom. */
    object-fit: contain;
    background-color: var(--hub-bg-subtle);
    color: var(--hub-text-secondary);
}

.hub-figure-placeholder .hub-icon {
    inline-size: 2rem;
    block-size: 2rem;
}

.hub-figure > figcaption {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: var(--hub-space-3);
    font-size: 0.8125rem;
}

.hub-figure .hub-chip {
    align-self: flex-start;
}

.hub-source {
    padding: var(--hub-space-3) 0;
    border-block-end: 1px solid var(--hub-border);
}

.hub-source:last-child {
    border-block-end: 0;
}

.hub-quote {
    margin: 0 0 var(--hub-space-2);
    padding-inline-start: var(--hub-space-3);
    border-inline-start: 2px solid var(--hub-border-strong);
    color: var(--hub-text-primary);
    font-size: 0.875rem;
    font-style: italic;
    white-space: pre-wrap;
}

details > summary {
    list-style: none;
}

details > summary::-webkit-details-marker {
    display: none;
}

.hub-highlight {
    background-color: var(--hub-accent-soft);
    transition: background-color 0.6s ease;
}

.hub-row-muted {
    opacity: 0.6;
}

.min-w-0 {
    min-inline-size: 0;
}

/* ── Flag ─────────────────────────────────────────────────────────────── */
.hub-flag {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    padding: 0.1875rem 0.5625rem;
    border: 1px solid color-mix(in srgb, var(--hub-flag-color) 40%, transparent);
    border-radius: var(--hub-radius-sm);
    color: var(--hub-flag-color);
    background-color: color-mix(in srgb, var(--hub-flag-color) 8%, transparent);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.hub-flag .hub-icon {
    inline-size: 0.875rem;
    block-size: 0.875rem;
}

.hub-flag-priority {
    padding-inline-start: 0.375rem;
    border-inline-start: 1px solid color-mix(in srgb, var(--hub-flag-color) 40%, transparent);
    font-weight: 500;
}

.hub-flag--action   { --hub-flag-color: var(--hub-status-error); }
.hub-flag--progress { --hub-flag-color: var(--hub-status-new); }
.hub-flag--done     { --hub-flag-color: var(--hub-status-done); }
.hub-flag--watch    { --hub-flag-color: var(--hub-status-open); }
.hub-flag--muted    { --hub-flag-color: var(--hub-status-muted); }

/* ── Language switch ──────────────────────────────────────────────────── */
.hub-language {
    white-space: nowrap;
}

.hub-auth-toolbar {
    position: absolute;
    inset-block-start: var(--hub-space-4);
    inset-inline-end: var(--hub-space-4);
}

/* --------------------------------------------------------------------------
   7. Right to left and Persian

   The hub's own rules use logical properties (inline-start/end), so they mirror
   under dir="rtl" by themselves. Bootstrap is the left-to-right build: the few
   physical rules of it the hub uses are mirrored here, at Bootstrap's own
   specificity (:where adds none), so a hub class still wins over them.
   -------------------------------------------------------------------------- */

/* Persian text: a Persian-capable system font, and no letter spacing or capitals,
   which break the joined letters of the script. No font file is shipped. */
:root:lang(fa) {
    --hub-font-text: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
    --hub-font-display: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
    --hub-caps-tracking: 0;
}

:lang(fa) :is(h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6) {
    letter-spacing: normal;
}

/* Icons that point a way (back, sign out, send) point the other way. */
[dir="rtl"] .hub-icon--directional {
    transform: scaleX(-1);
}

/* Paths, slugs and ids stay left to right inside Persian sentences. */
:where([dir="rtl"]) code {
    direction: ltr;
    unicode-bidi: isolate;
}

/* Bootstrap reboot and forms. */
:where([dir="rtl"]) :is(ol, ul) {
    padding-left: 0;
    padding-right: 2rem;
}

:where([dir="rtl"]) .form-select {
    padding-left: 2.25rem;
    padding-right: 0.75rem;
    background-position: left 0.75rem center;
}

:where([dir="rtl"]) .form-select-sm {
    padding-right: 0.5rem;
}

:where([dir="rtl"]) .form-check {
    padding-left: 0;
    padding-right: 1.5em;
}

:where([dir="rtl"]) .form-check .form-check-input {
    float: right;
    margin-left: 0;
    margin-right: -1.5em;
}

/* Bootstrap spacing and alignment utilities the pages use. */
[dir="rtl"] .ms-1 { margin-left: 0 !important; margin-right: 0.25rem !important; }
[dir="rtl"] .me-1 { margin-right: 0 !important; margin-left: 0.25rem !important; }
[dir="rtl"] .ms-auto { margin-left: 0 !important; margin-right: auto !important; }
[dir="rtl"] .me-auto { margin-right: 0 !important; margin-left: auto !important; }
[dir="rtl"] .text-start { text-align: right !important; }
[dir="rtl"] .text-end { text-align: left !important; }
