/* ==========================================================================
   fw-components.css — the shared component layer.

   Load order: design-tokens.css → THIS FILE → feature stylesheets →
   fw-unify.css. Element defaults here use :where() (zero specificity), so a
   feature class always wins over them; they only fill the gaps where a
   control had no styling of its own.

   New UI uses the .fw-* classes below instead of a new button/card/input
   family. See design/DESIGN_LANGUAGE.md.
   ========================================================================== */

/* ---- Element defaults ---------------------------------------------------- */
:where(html) {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

:where(body) {
    font-family: var(--fw-font);
    font-size: var(--fw-fs-md);
    line-height: var(--fw-lh-snug);
    color: var(--fw-text);
    accent-color: var(--fw-accent);
}

:where(h1, h2, h3, h4) {
    font-family: var(--fw-font-display);
    letter-spacing: var(--fw-tracking-title);
    line-height: var(--fw-lh-tight);
    color: var(--fw-text);
}

:where(button, input, select, textarea) {
    font-family: inherit;
}

:where(a) {
    color: var(--fw-link);
}

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]), select, textarea) {
    color: var(--fw-text);
    border-color: var(--fw-border);
    transition: border-color var(--fw-dur-fast) var(--fw-ease), box-shadow var(--fw-dur-fast) var(--fw-ease);
}

:where(input, select, textarea)::placeholder {
    color: var(--fw-text-tertiary);
}

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea):focus-visible {
    outline: none;
    border-color: var(--fw-accent);
    box-shadow: var(--fw-focus-ring);
}

:where(button, [role="button"], a, summary):focus-visible {
    outline: 2px solid var(--fw-accent);
    outline-offset: 2px;
}

::selection {
    background: rgba(0, 109, 186, 0.18);
}

/* Thin, quiet scrollbars (macOS-style overlay look on desktop browsers). */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.22) transparent;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--fw-radius-pill);
    border: 3px solid transparent;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.32);
}

/* ---- Button ---------------------------------------------------------------
   One recipe, four roles: primary (the one main action of a view),
   secondary (gray fill), plain (text only), destructive. */
.fw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--fw-space-2);
    min-height: var(--fw-control-md);
    padding: 0 var(--fw-space-4);
    border: none;
    border-radius: var(--fw-radius-sm);
    background: var(--fw-fill);
    color: var(--fw-text);
    font: var(--fw-fw-medium) var(--fw-fs-md) / 1 var(--fw-font);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background-color var(--fw-dur-fast) var(--fw-ease),
                color var(--fw-dur-fast) var(--fw-ease),
                transform var(--fw-dur-press) var(--fw-ease-out);
}

.fw-btn:hover { background: var(--fw-fill-strong); }
.fw-btn:active:not(:disabled) { transform: scale(0.97); }
.fw-btn:disabled { opacity: 0.4; cursor: default; }

.fw-btn--primary { background: var(--fw-accent); color: var(--fw-on-accent); font-weight: var(--fw-fw-semibold); }
.fw-btn--primary:hover { background: var(--fw-accent-hover); }
.fw-btn--primary:active:not(:disabled) { background: var(--fw-accent-pressed); }

.fw-btn--plain { background: transparent; color: var(--fw-accent); }
.fw-btn--plain:hover { background: var(--fw-accent-tint-subtle); }

.fw-btn--danger { background: var(--fw-danger-tint); color: var(--fw-danger); }
.fw-btn--danger:hover { background: var(--fw-danger-border); }

.fw-btn--sm { min-height: var(--fw-control-sm); padding: 0 var(--fw-space-3); font-size: var(--fw-fs-sm); }
.fw-btn--lg { min-height: var(--fw-control-lg); padding: 0 var(--fw-space-6); font-size: var(--fw-fs-base); border-radius: var(--fw-radius-md); }

/* Round icon button (close, more, back). */
.fw-icon-btn {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: var(--fw-radius-pill);
    background: transparent;
    color: var(--fw-text-secondary);
    cursor: pointer;
    transition: background-color var(--fw-dur-fast) var(--fw-ease), transform var(--fw-dur-press) var(--fw-ease-out);
}

.fw-icon-btn:hover { background: var(--fw-fill); color: var(--fw-text); }
.fw-icon-btn:active { transform: scale(0.94); }

/* ---- Input ----------------------------------------------------------------- */
.fw-input {
    min-height: var(--fw-control-md);
    padding: 0 var(--fw-space-3);
    border: 1px solid var(--fw-border);
    border-radius: var(--fw-radius-sm);
    background: var(--fw-surface);
    color: var(--fw-text);
    font: var(--fw-fs-md) / var(--fw-lh-snug) var(--fw-font);
}

/* ---- Card / grouped surface ---------------------------------------------- */
.fw-card {
    background: var(--fw-surface);
    border-radius: var(--fw-radius-lg);
    box-shadow: var(--fw-shadow-2);
    padding: var(--fw-space-5);
}

.fw-card__title {
    margin: 0 0 var(--fw-space-1);
    font: var(--fw-fw-semibold) var(--fw-fs-lg) / var(--fw-lh-tight) var(--fw-font-display);
    letter-spacing: var(--fw-tracking-title);
}

.fw-card__subtitle {
    margin: 0 0 var(--fw-space-4);
    color: var(--fw-text-secondary);
    font-size: var(--fw-fs-sm);
}

/* ---- Segmented control ---------------------------------------------------- */
.fw-segmented {
    display: inline-flex;
    padding: 2px;
    gap: 2px;
    border-radius: var(--fw-radius-sm);
    background: var(--fw-fill);
}

.fw-segmented > button {
    min-height: calc(var(--fw-control-md) - 4px);
    padding: 0 var(--fw-space-3);
    border: none;
    border-radius: calc(var(--fw-radius-sm) - 2px);
    background: transparent;
    color: var(--fw-text);
    font: var(--fw-fw-medium) var(--fw-fs-sm) / 1 var(--fw-font);
    cursor: pointer;
}

.fw-segmented > button[aria-pressed="true"],
.fw-segmented > button.is-active {
    background: var(--fw-surface);
    box-shadow: var(--fw-shadow-1);
}

/* ---- Badge ------------------------------------------------------------------ */
.fw-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--fw-radius-pill);
    background: var(--fw-fill);
    color: var(--fw-text-secondary);
    font: var(--fw-fw-medium) var(--fw-fs-2xs) / 1.4 var(--fw-font);
    letter-spacing: var(--fw-tracking-caption);
}

.fw-badge--accent { background: var(--fw-accent-tint); color: var(--fw-accent-pressed); }
.fw-badge--success { background: var(--fw-success-tint); color: var(--fw-success); }
.fw-badge--warning { background: var(--fw-warning-tint); color: var(--fw-warning); }
.fw-badge--danger { background: var(--fw-danger-tint); color: var(--fw-danger); }

/* ---- Tool start panel -----------------------------------------------------
   One layout for every tool that starts from a link or a file: a centred
   column with the tool's glyph, its name, one line of what it does, the
   inputs, and the one main action. Used by כלי עבודה. */
.fw-btn { text-decoration: none; }

/* A tool's root; scripts show it with display: flex. */
.fw-tool {
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
}

.fw-task {
    display: flex;
    flex-direction: column;
    gap: var(--fw-space-4);
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: var(--fw-space-10) var(--fw-space-5) var(--fw-space-6);
    box-sizing: border-box;
    direction: rtl;
}

.fw-task__head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--fw-space-2);
    margin-bottom: var(--fw-space-2);
    text-align: center;
}

.fw-task__icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin-bottom: var(--fw-space-1);
    border-radius: var(--fw-radius-lg);
    background: var(--fw-accent-tint);
}

/* The toolbar's own glyphs, tinted the same blue as in the toolbar
   (.clients-icon in base-layout-tooltips.css). */
.fw-task__icon img {
    width: 30px;
    height: 30px;
    filter: brightness(0) saturate(100%) invert(27%) sepia(51%) saturate(2878%) hue-rotate(190deg) brightness(104%) contrast(97%);
}

.fw-task__title {
    margin: 0;
    font: var(--fw-fw-semibold) var(--fw-fs-xl) / var(--fw-lh-tight) var(--fw-font-display);
    letter-spacing: var(--fw-tracking-title);
    color: var(--fw-text);
}

.fw-task__subtitle {
    margin: 0;
    max-width: 44ch;
    color: var(--fw-text-secondary);
    font-size: var(--fw-fs-md);
    line-height: var(--fw-lh-snug);
}

/* The field and its button side by side; stacked on a phone. */
.fw-task__row {
    display: flex;
    gap: var(--fw-space-2);
    align-items: stretch;
}

.fw-task__row > .fw-input { flex: 1; min-width: 0; }

.fw-task__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--fw-space-3);
    justify-content: center;
}

.fw-task__actions > .fw-btn { min-width: 140px; }

@media (max-width: 600px) {
    .fw-task { padding: var(--fw-space-6) var(--fw-space-4); }
    .fw-task__row { flex-direction: column; }
    .fw-task__actions > .fw-btn { flex: 1; }
}

/* ---- Link bar --------------------------------------------------------------
   A tool whose results fill the space below keeps its link field in a bar at
   the top (בחינת מסמכי לקוח). Scripts swap the field for the folder's summary
   and switch flex-direction inline. */
.fw-linkbar {
    position: relative;
    display: flex;
    flex-direction: row;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--fw-space-3);
    padding: var(--fw-space-3) var(--fw-space-5);
    border-bottom: 1px solid var(--fw-separator);
    background: var(--fw-surface);
    direction: rtl;
}

.fw-linkbar__group {
    display: flex;
    flex: 0 1 760px;
    gap: var(--fw-space-2);
    align-items: center;
    min-width: 0;
}

.fw-linkbar__group > .fw-input { flex: 1; min-width: 0; }

.fw-linkbar__summary {
    display: flex;
    flex: 0 1 auto;
    gap: var(--fw-space-3);
    align-items: stretch;
    min-width: 0;
}

.fw-linkbar__card {
    flex-shrink: 0;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 6px 14px;
    border-radius: var(--fw-radius-md);
    background: var(--fw-bg);
}

.fw-linkbar__links { flex: 1 1 auto; flex-direction: row; overflow-x: auto; }

.fw-linkbar__name { color: var(--fw-text); font-size: var(--fw-fs-base); font-weight: var(--fw-fw-semibold); white-space: nowrap; }
.fw-linkbar__name a { color: var(--fw-link); text-decoration: none; }
.fw-linkbar__name a:hover { text-decoration: underline; }
.fw-linkbar__meta { color: var(--fw-text-secondary); font-size: var(--fw-fs-xs); white-space: nowrap; }

.fw-linkbar__chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.fw-linkbar__actions {
    flex-shrink: 0;
    flex-direction: row;
    gap: var(--fw-space-1);
    align-items: center;
    align-self: center;
}

.fw-linkbar > .fw-field-error { flex-basis: 100%; margin: 0; }

.fw-icon-btn--lg { width: 40px; height: 40px; }
.fw-icon-btn--lg > img { width: 24px; height: 24px; }

/* ---- Chip: a filter that can be on or off --------------------------------- */
.fw-chip {
    --chip: var(--fw-text-secondary);
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 12px;
    border: 1px solid color-mix(in srgb, var(--chip) 45%, transparent);
    border-radius: var(--fw-radius-pill);
    background: transparent;
    color: var(--chip);
    font-size: var(--fw-fs-sm);
    font-weight: var(--fw-fw-medium);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background-color var(--fw-dur-fast) var(--fw-ease), color var(--fw-dur-fast) var(--fw-ease);
}

.fw-chip:hover { background: color-mix(in srgb, var(--chip) 10%, transparent); }
.fw-chip:active { transform: scale(0.97); }
.fw-chip.is-active { border-color: var(--chip); background: var(--chip); color: var(--fw-on-accent); font-weight: var(--fw-fw-semibold); }
.fw-chip:focus-visible { outline: 2px solid var(--fw-accent); outline-offset: 2px; }

.fw-chip--folder { --chip: var(--fw-accent); }
.fw-chip--danger { --chip: var(--fw-danger); }
.fw-chip--warning { --chip: var(--fw-warning); }
.fw-chip--neutral { --chip: var(--fw-gray-600); }

/* ---- Field parts ------------------------------------------------------------ */
.fw-input--lg {
    min-height: var(--fw-control-lg);
    padding: 0 var(--fw-space-4);
    border-radius: var(--fw-radius-md);
    font-size: var(--fw-fs-base);
}

.fw-input--block { display: block; width: 100%; box-sizing: border-box; }

textarea.fw-input {
    padding: 10px var(--fw-space-3);
    line-height: var(--fw-lh-body);
    resize: vertical;
}

/* A link is typed left to right, but its Hebrew prompt reads right to left:
   with one direction for both, "הזן קישור לתיקיית Google Drive" came out in
   the wrong word order. The glyph sits at the start of the prompt. */
.fw-input--ltr {
    direction: ltr;
    text-align: left;
}

.fw-input--ltr:placeholder-shown {
    direction: rtl;
    text-align: right;
}

.fw-input--url:placeholder-shown {
    padding-right: 40px;
    background: var(--fw-surface) no-repeat right 14px center / 18px 18px
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E");
}

.fw-form-field { margin-bottom: var(--fw-space-5); direction: rtl; text-align: right; }

.fw-label {
    display: block;
    margin-bottom: 6px;
    color: var(--fw-text);
    font-size: var(--fw-fs-md);
    font-weight: var(--fw-fw-medium);
}

.fw-required { color: var(--fw-danger); }

.fw-helper,
.fw-field-error {
    margin-top: var(--fw-space-1);
    font-size: var(--fw-fs-xs);
    line-height: var(--fw-lh-snug);
    direction: rtl;
    text-align: right;
}

.fw-helper { color: var(--fw-text-secondary); }
.fw-field-error { color: var(--fw-danger); }

/* A checkbox with its label and a quieter line under it. */
.fw-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    direction: rtl;
    text-align: right;
}

.fw-check > input {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    cursor: pointer;
}

.fw-check__label { color: var(--fw-text); font-size: var(--fw-fs-md); font-weight: var(--fw-fw-medium); }
.fw-check__hint { margin-top: 2px; color: var(--fw-text-secondary); font-size: var(--fw-fs-xs); }

/* A field the script marked wrong. */
.fw-input.is-invalid,
.fw-input.is-invalid:focus-visible {
    border-color: var(--fw-danger);
    box-shadow: 0 0 0 3px var(--fw-danger-tint);
}

.fw-input--short { flex: 0 1 180px; min-width: 0; }

.fw-helper--end { text-align: left; }

.fw-label--inline { display: inline; margin: 0; font-size: var(--fw-fs-sm); white-space: nowrap; }

/* A field with a word beside it (MB, days). */
.fw-inline-field { display: flex; gap: var(--fw-space-2); align-items: center; direction: rtl; }
.fw-unit { color: var(--fw-text-secondary); font-size: var(--fw-fs-md); font-weight: var(--fw-fw-medium); }

/* What a checkbox opens: indented under its label. */
.fw-check__more { margin-top: var(--fw-space-2); padding-right: 28px; direction: rtl; }

.fw-check.is-disabled { opacity: 0.5; cursor: not-allowed; }
.fw-check.is-disabled > input { cursor: not-allowed; }

.fw-grow { flex: 1; min-width: 0; }
.fw-gap-above { margin-top: var(--fw-space-4); }
.fw-gap-below { margin-bottom: var(--fw-space-3); }
.fw-center { text-align: center; }
.fw-break { overflow-wrap: anywhere; }

.fw-prose { margin: 0; color: var(--fw-text); font-size: var(--fw-fs-md); line-height: 1.7; direction: rtl; text-align: right; }
.fw-prose--pre { white-space: pre-wrap; }
.fw-muted-line { margin: 0 0 10px; color: var(--fw-text-secondary); }
.fw-danger-line { margin: 0 0 var(--fw-space-5); color: var(--fw-danger); font-weight: var(--fw-fw-semibold); word-break: break-all; }

/* One item in a report list (a file that did not go out, and why). */
.fw-item-card {
    margin-bottom: var(--fw-space-3);
    padding: var(--fw-space-3) var(--fw-space-4);
    border-radius: var(--fw-radius-md);
    background: var(--fw-bg);
    direction: rtl;
    text-align: right;
}

.fw-item-card__title { margin-bottom: 6px; color: var(--fw-text); font-weight: var(--fw-fw-semibold); }
.fw-item-card__line { color: var(--fw-text-secondary); font-size: var(--fw-fs-sm); line-height: 1.6; }
.fw-item-card__line--danger { color: var(--fw-danger); font-weight: var(--fw-fw-medium); }
.fw-item-card__line a { color: var(--fw-link); word-break: break-all; }

/* ---- Result table ------------------------------------------------------------
   The editable tables of בחינת מסמכי לקוח: quiet header, hairline rows,
   inline controls the height of a row. (A table people sort and filter is
   a FinwizTable instead.) */
.fw-grid-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border: 1px solid var(--fw-separator);
    border-radius: var(--fw-radius-md);
    direction: rtl;
    text-align: right;
    font-size: var(--fw-fs-md);
}

.fw-grid-table th {
    padding: 10px 12px;
    border-bottom: 1px solid var(--fw-separator);
    background: var(--fw-bg);
    color: var(--fw-text-secondary);
    font-size: var(--fw-fs-sm);
    font-weight: var(--fw-fw-semibold);
    text-align: right;
}

.fw-grid-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--fw-separator);
    vertical-align: middle;
}

.fw-grid-table tbody tr:last-child td { border-bottom: none; }
.fw-grid-table tbody tr:hover td { background: var(--fw-accent-tint-subtle); }
.fw-grid-table td a { color: var(--fw-link); text-decoration: none; }
.fw-grid-table td a:hover { text-decoration: underline; }

.fw-grid-table__head--danger th { background: var(--fw-danger-tint); color: var(--fw-danger); }
.fw-grid-table__head--warning th { background: var(--fw-warning-tint); color: var(--fw-warning); }

.fw-col-60 { width: 60px; }
.fw-col-130 { width: 130px; white-space: nowrap; }
.fw-cell-nowrap { white-space: nowrap; }
.fw-cell-center { position: relative; text-align: center; }

.fw-results-block { flex-shrink: 0; padding: var(--fw-space-5); }
.fw-results-block--split { border-top: 1px solid var(--fw-separator); }

.fw-cell-select,
.fw-cell-input {
    box-sizing: border-box;
    width: 100%;
    padding: 4px 8px;
    border: 1px solid var(--fw-border);
    border-radius: var(--fw-radius-xs);
    background: var(--fw-surface);
    color: var(--fw-text);
    font: var(--fw-fs-md) / 1.2 var(--fw-font);
}

.fw-cell-input { resize: none; }

.fw-cell-select.is-invalid,
.fw-cell-input.is-invalid { border-color: var(--fw-danger); box-shadow: 0 0 0 2px var(--fw-danger-tint); }

.fw-pager {
    flex-shrink: 0;
    padding: var(--fw-space-3) var(--fw-space-5);
    border-top: 1px solid var(--fw-separator);
    background: var(--fw-surface);
    direction: ltr;
}

.fw-pager__row { display: flex; align-items: center; justify-content: center; gap: var(--fw-space-2); }

.fw-page-info { padding: 6px 12px; color: var(--fw-text-secondary); font-size: var(--fw-fs-md); }

/* ---- Row menu (⋯) ------------------------------------------------------------ */
.fw-menu-anchor { position: relative; display: inline-block; }

.fw-menu-btn { width: 30px; height: 26px; border-radius: var(--fw-radius-xs); font-size: var(--fw-fs-lg); font-weight: var(--fw-fw-bold); line-height: 1; }

.fw-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    z-index: 1000;
    min-width: 180px;
    padding: var(--fw-space-1);
    overflow: hidden;
    border-radius: var(--fw-radius-md);
    background: var(--fw-surface-raised);
    box-shadow: var(--fw-shadow-3);
    transform: translateX(-50%);
    text-align: right;
}

.fw-menu__item {
    padding: 8px 12px;
    border-radius: var(--fw-radius-xs);
    color: var(--fw-text);
    font-size: var(--fw-fs-md);
    white-space: nowrap;
    cursor: pointer;
}

.fw-menu__item:hover { background: var(--fw-fill); }
.fw-menu__item--danger { color: var(--fw-danger); }
.fw-menu__item--danger:hover { background: var(--fw-danger-tint); }

/* ---- Small layout and form parts (calculators and others) ----------------- */
.fw-btn--block { display: flex; width: 100%; }
/* An icon button in a row of equal cells: it fills its cell and never pushes
   past it (a min-width overlapped its neighbour on a phone). */
.fw-btn--icon { width: 100%; min-width: 0; padding: 0 var(--fw-space-1); }
/* A white glyph on a filled button. */
.fw-btn-glyph { width: 18px; height: 18px; filter: brightness(0) invert(1); }

.fw-input--w300 { width: min(300px, 100%); }
.fw-check--sm { align-items: center; gap: 6px; font-size: var(--fw-fs-sm); font-weight: var(--fw-fw-medium); }
.fw-check--sm > input,
.fw-check-box { width: 15px; height: 15px; margin: 0; cursor: pointer; }

.fw-section-title--flush { margin: 0; }
.fw-mini-title { color: var(--fw-text); font-size: var(--fw-fs-xs); font-weight: var(--fw-fw-semibold); text-align: right; }
.fw-muted-line--flush { margin: 0; font-size: var(--fw-fs-base); direction: rtl; text-align: right; }
.fw-amount { font-size: var(--fw-fs-lg); font-weight: var(--fw-fw-bold); direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
.fw-amount--success { color: var(--fw-success); }

.fw-stack { display: flex; flex-direction: column; }
.fw-stack--4 { gap: var(--fw-space-1); }
.fw-stack--8 { gap: var(--fw-space-2); }
.fw-stack--12 { gap: var(--fw-space-3); }
.fw-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--fw-space-2); }
.fw-row-between { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--fw-space-5); }
.fw-rule { flex: 1; height: 1px; background: var(--fw-separator); }
.fw-pad-20 { padding: var(--fw-space-5); }
/* A value shown as typed: a link, an id. */
.fw-code {
    display: inline-block;
    padding: 2px 6px;
    border-radius: var(--fw-radius-xs);
    background: var(--fw-fill);
    font: var(--fw-fs-sm) / 1.4 var(--fw-font-mono);
    direction: ltr;
}

/* Underline tabs: the resting look; a script may set the active one inline. */
.fw-underline-tab {
    margin-bottom: -2px;
    padding: 10px 16px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--fw-text-secondary);
    font-size: var(--fw-fs-sm);
    font-weight: var(--fw-fw-medium);
    white-space: nowrap;
    cursor: pointer;
}

.fw-underline-tab.is-active { border-bottom-color: var(--fw-accent); color: var(--fw-accent); font-weight: var(--fw-fw-semibold); }

.fw-spinner {
    width: 32px;
    height: 32px;
    margin: 0 auto;
    border: 3px solid var(--fw-fill-strong);
    border-top-color: var(--fw-accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

/* A hand-built dialog: the scrim (a script shows it with display: flex) and
   its sheet. Inside .overlay the base dialog CSS (base-layout-popups.css)
   sets the header and footer; these hold where it does not reach. */
.fw-scrim {
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    background: var(--fw-scrim);
}

.fw-scrim--top { z-index: 2000; }
.fw-scrim--column { flex-direction: column; }

.fw-sheet,
.overlay .popup.fw-sheet {
    display: flex;
    flex-direction: column;
    width: 90%;
    max-width: 500px;
    padding: 0;
    border-radius: var(--fw-radius-lg);
    background: var(--fw-surface);
    box-shadow: var(--fw-shadow-4);
}

.fw-sheet__head { padding: var(--fw-space-5); border-bottom: 1px solid var(--fw-separator); }
.fw-sheet__foot { display: flex; justify-content: center; gap: 10px; padding: var(--fw-space-5); border-top: 1px solid var(--fw-separator); }

/* ---- Drop zone ---------------------------------------------------------------- */
.fw-dropzone {
    display: block;
    padding: var(--fw-space-8) var(--fw-space-6);
    border: 1.5px dashed var(--fw-border);
    border-radius: var(--fw-radius-lg);
    background: var(--fw-bg);
    text-align: center;
    cursor: pointer;
    direction: rtl;
    transition: border-color var(--fw-dur-fast) var(--fw-ease), background-color var(--fw-dur-fast) var(--fw-ease);
}

.fw-dropzone:hover,
.fw-dropzone.is-dragover {
    border-color: var(--fw-accent);
    background: var(--fw-accent-tint-subtle);
}

.fw-dropzone__glyph { display: block; margin: 0 auto var(--fw-space-3); color: var(--fw-accent); }
.fw-dropzone__text { margin: 0 0 var(--fw-space-4); color: var(--fw-text-secondary); font-size: var(--fw-fs-md); }

/* The chosen file, in place of the prompt. */
.fw-file-chip {
    display: flex;
    align-items: center;
    gap: var(--fw-space-3);
    padding: var(--fw-space-3) var(--fw-space-4);
    border-radius: var(--fw-radius-md);
    background: var(--fw-surface);
    box-shadow: var(--fw-shadow-1);
    text-align: right;
}

.fw-file-chip__body { flex: 1; min-width: 0; }
.fw-file-chip__name { margin: 0; overflow: hidden; color: var(--fw-text); font-weight: var(--fw-fw-semibold); text-overflow: ellipsis; white-space: nowrap; }
.fw-file-chip__meta { margin: 2px 0 0; color: var(--fw-text-secondary); font-size: var(--fw-fs-xs); }

/* ---- Status ------------------------------------------------------------------- */
/* Loading: the first child holds the text (scripts write to it), the
   spinner is drawn above it. */
.fw-loading {
    padding: var(--fw-space-10) var(--fw-space-5);
    color: var(--fw-text-secondary);
    font-size: var(--fw-fs-base);
    text-align: center;
    direction: rtl;
}

.fw-loading::before {
    content: "";
    display: block;
    width: 28px;
    height: 28px;
    margin: 0 auto var(--fw-space-4);
    border: 3px solid var(--fw-fill-strong);
    border-top-color: var(--fw-accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.fw-result { padding: var(--fw-space-2) 0; text-align: center; direction: rtl; }

.fw-result__title {
    margin: 0 0 var(--fw-space-4);
    color: var(--fw-success);
    font-size: var(--fw-fs-lg);
    font-weight: var(--fw-fw-semibold);
}

.fw-notice {
    padding: var(--fw-space-3) 14px;
    border: 1px solid transparent;
    border-radius: var(--fw-radius-md);
    font-size: var(--fw-fs-md);
    direction: rtl;
    text-align: right;
}

.fw-notice__title { margin: 0 0 6px; font-weight: var(--fw-fw-semibold); }
.fw-task__subtitle--center { margin-inline: auto; }

.fw-plain-list {
    margin: 0;
    padding-right: var(--fw-space-5);
    color: var(--fw-text);
    font-size: var(--fw-fs-sm);
    line-height: 1.6;
}

.fw-notice--danger { background: var(--fw-danger-tint); border-color: var(--fw-danger-border); color: var(--fw-danger); }
.fw-notice--warning { background: var(--fw-warning-tint); border-color: var(--fw-warning-border); color: var(--fw-warning); }

/* A row that copies something to the clipboard. */
.fw-copy-row {
    display: flex;
    align-items: center;
    gap: var(--fw-space-2);
    margin-bottom: var(--fw-space-5);
    padding: 10px var(--fw-space-3);
    border-radius: var(--fw-radius-sm);
    background: var(--fw-fill);
    color: var(--fw-text);
    font-size: var(--fw-fs-md);
    font-weight: var(--fw-fw-medium);
    text-decoration: none;
    cursor: pointer;
    direction: rtl;
    transition: background-color var(--fw-dur-fast) var(--fw-ease);
}

.fw-copy-row:hover { background: var(--fw-fill-strong); }
.fw-copy-row > img { width: 18px; height: 18px; }

/* Machine output: logs, error details. */
.fw-log {
    box-sizing: border-box;
    width: 100%;
    padding: 14px;
    overflow-x: auto;
    border-radius: var(--fw-radius-sm);
    background: var(--fw-fill);
    font: var(--fw-fs-xs) / 1.5 var(--fw-font-mono);
    direction: ltr;
    text-align: left;
}

.fw-log > pre { margin: 0; white-space: pre-wrap; word-break: break-all; overflow-wrap: break-word; }

.fw-section-title {
    margin: 0 0 var(--fw-space-3);
    color: var(--fw-text);
    font-size: var(--fw-fs-lg);
    font-weight: var(--fw-fw-semibold);
    direction: rtl;
    text-align: right;
}

/* ---- Reduced motion --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        /* Transitions only: loading spinners are status, so they keep turning. */
        transition-duration: 1ms !important;
        scroll-behavior: auto !important;
    }
}
