/* ==================================================================
   Fwdia app (dashboard) - Bootstrap 5 base with the Fwdia identity
   layered on top. All colour, type and shape values come from the
   active theme's token block (theme-*.css, generated from
   config/themes.php). Nothing here should hardcode a hex.
   ================================================================== */

/* Explicit reset rather than relying on Bootstrap's cascade for it -
   without this, any element combining width:100% with padding/border
   (e.g. .fwb-input) renders wider than its container and causes a
   horizontal scrollbar in narrow places like the builder sidebar. */
* { box-sizing: border-box; }

body.fwapp {
    background: var(--fw-paper); color: var(--fw-ink); min-height: 100vh;
    display: flex; flex-direction: column;
    font-family: var(--fw-font-sans);
}

/* Headings use the theme display face. Under `paper` that is the serif,
   matching the marketing site; under `clean` and `bold` it resolves to a
   sans, so the app stays single-family there by design. */
h1, .fw-display {
    font-family: var(--fw-font-display);
    font-weight: var(--fw-display-weight);
    letter-spacing: var(--fw-display-track);
    line-height: var(--fw-display-line);
}
h1 { font-size: 1.8rem; }

.fw-btn-primary {
    background: var(--fw-accent) !important; border-color: var(--fw-accent) !important;
    color: var(--fw-accent-contrast) !important; font-weight: 700; border-radius: var(--fw-btn-radius);
    transition: background var(--fw-dur) var(--fw-ease);
}
.fw-btn-primary:hover { background: var(--fw-accent-dark) !important; }
.btn-outline-secondary, .btn-outline-danger, .btn-outline-warning { border-radius: var(--fw-btn-radius); font-weight: 600; }
a { color: var(--fw-accent); }

/* Form controls follow the theme's shape and line weight. Without this they
   keep Bootstrap's own radius and grey border and visibly disagree with the
   surrounding cards, most obviously under `bold`. */
.form-control, .form-select, .input-group-text {
    border-radius: var(--fw-radius-sm);
    border: var(--fw-border-width) solid var(--fw-border);
    color: var(--fw-ink); background-color: var(--fw-surface);
}
.form-control::placeholder { color: var(--fw-ink-faint); }
.form-control:focus, .form-select:focus {
    border-color: var(--fw-accent); background-color: var(--fw-surface); color: var(--fw-ink);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fw-accent) 18%, transparent);
}
.form-check-input { border: var(--fw-border-width) solid var(--fw-border); }
.form-check-input:checked { background-color: var(--fw-accent); border-color: var(--fw-accent); }
.form-check-input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--fw-accent) 18%, transparent); }
.form-text { color: var(--fw-ink-soft); }

/* Visible keyboard focus on every interactive surface - Bootstrap's default
   ring disappears against the accent-coloured buttons. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--fw-accent); outline-offset: 2px; border-radius: var(--fw-radius-sm);
}

.fw-sandbox-banner {
    background: var(--fw-highlight); color: var(--fw-highlight-ink); text-align: center;
    font-size: .8rem; font-weight: 700; padding: 5px 10px;
}

/* --- nav ---------------------------------------------------------- */
.fwapp-nav { background: var(--fw-surface); border-bottom: var(--fw-border-width) solid var(--fw-border); }
.fwapp-nav-inner {
    max-width: 1160px; margin: 0 auto; padding: 0 22px; min-height: 60px;
    display: flex; align-items: center; gap: 26px; flex-wrap: wrap;
}
.fwapp-logo, .fwauth-logo {
    font-family: var(--fw-font-display); font-weight: 800; font-size: 1.35rem;
    letter-spacing: -0.03em; color: var(--fw-ink); text-decoration: none;
}
.logo-arrow { color: var(--fw-accent); }
.fwapp-nav-links { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; }
.fwapp-nav-links a { color: var(--fw-ink-soft); text-decoration: none; font-weight: 600; font-size: .93rem; }
.fwapp-nav-links a:hover { color: var(--fw-accent); }
.fwapp-nav-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.fwapp-nav-account { font-weight: 600; text-decoration: none; font-size: .93rem; }
.fwapp-logout { color: var(--fw-ink-soft) !important; text-decoration: none !important; font-size: .88rem; }
.fwapp-nav-account-icon { display: none; } /* phones only, see the responsive section */

.fwapp-main { flex: 1; padding: 30px 0 60px; }
.fwapp-container { max-width: 1160px; margin: 0 auto; padding: 0 22px; }
.fwapp-flash { max-width: 1160px; margin: 0 auto 18px; }
.fwapp-page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap; margin-bottom: 26px; }
.fwapp-page-head h1 { margin: 0 0 4px; }
.fwapp-head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Long-form text (legal copy, help text) needs a comfortable measure -
   a 1160px container would otherwise run well past 100 characters. */
.fwapp-prose { max-width: 68ch; }
.fwapp-prose p, .fwapp-prose li { line-height: 1.6; }

/* --- panels ------------------------------------------------------- */
.fw-panel {
    background: var(--fw-surface); border: var(--fw-border-width) solid var(--fw-border);
    border-radius: var(--fw-radius-lg); padding: 22px; margin-bottom: 20px;
}
.fw-panel-title { font-size: 1.02rem; font-weight: 700; margin: 0 0 14px; }
.fw-panel-link { font-weight: 600; text-decoration: none; }
.fw-panel-danger { border-color: var(--fw-danger); }
.fw-panel-highlight { border: 2px solid var(--fw-accent); }
.fw-pro-tag {
    background: var(--fw-highlight); color: var(--fw-highlight-ink); font-size: .72rem; font-weight: 800;
    text-transform: uppercase; padding: 2px 8px; border-radius: var(--fw-radius-pill); vertical-align: 2px;
}

/* --- dashboard site cards ----------------------------------------- */
.fw-site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.fw-site-card {
    background: var(--fw-surface); border: var(--fw-border-width) solid var(--fw-border); border-radius: var(--fw-radius-lg);
    padding: 20px; text-decoration: none; color: var(--fw-ink); display: block;
    transition: transform var(--fw-dur) var(--fw-ease), border-color var(--fw-dur) var(--fw-ease);
}
.fw-site-card:hover { transform: translateY(-2px); border-color: var(--fw-accent); color: var(--fw-ink); }
.fw-site-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.fw-site-card-name { font-weight: 700; font-size: 1.08rem; }
.fw-site-card-url { color: var(--fw-ink-soft); font-size: .88rem; margin: 6px 0 12px; font-family: var(--fw-font-mono); }
.fw-site-card-meta { display: flex; gap: 14px; font-size: .85rem; color: var(--fw-ink-soft); }
.fw-site-card-unread { color: var(--fw-highlight-deep); font-weight: 700; }
.fw-status { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 3px 10px; border-radius: var(--fw-radius-pill); }
.fw-status-published { background: var(--fw-success-soft); color: var(--fw-accent-dark); }
.fw-status-draft { background: var(--fw-paper-deep); color: var(--fw-ink-soft); }
.fw-status-unpublished { background: var(--fw-highlight-soft); color: var(--fw-highlight-deep); }
.fw-badge-verified { color: var(--fw-accent); font-weight: 800; }

/* --- template picker ---------------------------------------------- */
.fw-template-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.fw-template-option input { position: absolute; opacity: 0; }
.fw-template-option-card {
    display: flex; flex-direction: column; gap: 3px; background: var(--fw-surface); height: 100%;
    border: 2px solid var(--fw-border); border-radius: var(--fw-radius-md); padding: 14px;
    cursor: pointer; position: relative;
    transition: border-color var(--fw-dur) var(--fw-ease);
}
.fw-template-option input:checked + .fw-template-option-card {
    border-color: var(--fw-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fw-accent) 18%, transparent);
}
.fw-template-option input:focus-visible + .fw-template-option-card { outline: 2px solid var(--fw-accent); outline-offset: 2px; }
/* Icon sits inline with the label rather than stacked in a tile above it. */
.fw-template-option-icon { color: var(--fw-accent); display: inline-flex; }
.fw-template-option-name { font-weight: 700; font-size: .95rem; }
.fw-template-option-desc { color: var(--fw-ink-soft); font-size: .8rem; }

.fw-template-preview-btn {
    position: absolute; top: 8px; right: 8px; z-index: 1;
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--fw-surface); border: 1px solid var(--fw-border); border-radius: var(--fw-radius-pill);
    padding: 3px 10px 3px 8px; font-size: .72rem; font-weight: 700; color: var(--fw-ink-soft);
    cursor: pointer; transition: border-color var(--fw-dur) var(--fw-ease), color var(--fw-dur) var(--fw-ease);
}
.fw-template-preview-btn:hover, .fw-template-preview-btn:focus-visible { border-color: var(--fw-accent); color: var(--fw-accent); }

/* --- template preview modal (app + marketing share this structure) --- */
.fw-preview-modal {
    position: fixed; inset: 0; background: color-mix(in srgb, var(--fw-ink) 55%, transparent); z-index: 200;
    display: flex; align-items: center; justify-content: center; padding: 24px;
}
/* The [hidden] attribute alone loses to the class rule above (author CSS always
   beats the UA stylesheet's un-!important [hidden] rule) - this higher-specificity
   variant is what actually keeps the modal hidden until JS clears the attribute. */
.fw-preview-modal[hidden] { display: none; }
.fw-preview-box {
    background: var(--fw-surface); border-radius: var(--fw-radius-lg); padding: 0; width: min(420px, 100%);
    display: flex; flex-direction: column; max-height: 92vh;
}
.fw-preview-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 14px 16px; border-bottom: 1px solid var(--fw-border);
}
.fw-preview-title { font-weight: 700; }
.fw-preview-close-btn {
    border: 1px solid var(--fw-border); background: var(--fw-surface); border-radius: var(--fw-radius-sm);
    width: 32px; height: 32px; cursor: pointer; color: var(--fw-ink-soft);
    display: inline-flex; align-items: center; justify-content: center;
}
.fw-preview-close-btn:hover { border-color: var(--fw-accent); color: var(--fw-accent); }
.fw-preview-frame-wrap {
    flex: 1; min-height: 0; padding: 16px; display: flex; justify-content: center;
    overflow: auto; background: var(--fw-paper-deep);
}
.fw-preview-frame-wrap iframe {
    width: 100%; max-width: 340px; height: 600px; border: 10px solid var(--fw-ink);
    border-radius: 28px; background: var(--fw-surface); flex-shrink: 0;
}
.fw-preview-foot { padding: 14px 16px; border-top: 1px solid var(--fw-border); }
.fw-preview-foot .btn { width: 100%; }

/* --- stats -------------------------------------------------------- */
.fw-stat-row { display: flex; gap: 26px; flex-wrap: wrap; }
.fw-stat b {
    display: block; font-size: 1.7rem; font-weight: 800;
    font-family: var(--fw-font-display); letter-spacing: var(--fw-display-track);
}
.fw-stat span { color: var(--fw-ink-soft); font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; }
.fw-chart { display: flex; align-items: flex-end; gap: 3px; height: 140px; }
.fw-chart-bar { flex: 1; min-width: 3px; background: var(--fw-accent); border-radius: 3px 3px 0 0; height: max(3px, var(--h)); opacity: .85; }
.fw-chart-bar:hover { opacity: 1; background: var(--fw-accent-dark); }

/* Insights: visit sources (a bar behind each row, scaled to the top source) */
.fw-sources { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.fw-source {
    position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 7px 10px; border-radius: var(--fw-radius-sm); isolation: isolate;
}
.fw-source::before {
    content: ""; position: absolute; inset: 0 auto 0 0; width: max(4px, var(--w)); z-index: -1;
    background: var(--fw-accent-soft); border-radius: inherit;
}
.fw-source-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.fw-source-name svg { flex-shrink: 0; color: var(--fw-accent); }
.fw-source-count { font-variant-numeric: tabular-nums; }

/* Insights: tagged share links */
.fw-taglinks { display: grid; gap: 8px; }
.fw-taglink {
    display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; align-items: center; gap: 12px;
    padding: 8px 0; border-bottom: 1px solid var(--fw-border);
}
.fw-taglink:last-child { border-bottom: 0; }
.fw-taglink-label { font-weight: 600; font-size: .9rem; }
.fw-taglink-url { overflow-wrap: anywhere; font-size: .82rem; }
@media (max-width: 560px) {
    .fw-taglink { grid-template-columns: minmax(0, 1fr) auto; }
    .fw-taglink-label { grid-column: 1 / -1; }
}

/* --- pages list / submissions ------------------------------------- */
.fw-page-list { list-style: none; margin: 0; padding: 0; }
.fw-page-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--fw-paper-deep); flex-wrap: wrap; }
.fw-page-list li:last-child { border-bottom: 0; }
.fw-empty {
    background: var(--fw-surface); border: 2px dashed var(--fw-border); border-radius: var(--fw-radius-lg);
    padding: 44px 24px; text-align: center; color: var(--fw-ink-soft);
}
.fw-subs { display: grid; gap: 14px; }
.fw-sub { background: var(--fw-surface); border: var(--fw-border-width) solid var(--fw-border); border-radius: var(--fw-radius-md); padding: 16px 18px; }
/* Unread is marked by a dot and a stronger border, not a thick edge stripe. */
.fw-sub-unread { border-color: var(--fw-border-strong); }
.fw-sub-unread .fw-sub-head::before {
    content: ""; width: 8px; height: 8px; border-radius: 50%;
    background: var(--fw-highlight); flex: 0 0 auto; margin-top: .45em;
}
.fw-sub-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.fw-sub-data { width: 100%; font-size: .92rem; }
.fw-sub-data th { text-align: left; padding: 3px 14px 3px 0; color: var(--fw-ink-soft); font-weight: 600; white-space: nowrap; vertical-align: top; }
.fw-sub-data td { padding: 3px 0; overflow-wrap: anywhere; }

/* --- QR studio ----------------------------------------------------- */
.fw-qr-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.fw-qr-mode input { position: absolute; opacity: 0; }
.fw-qr-mode-card {
    display: flex; gap: 10px; align-items: flex-start; border: 2px solid var(--fw-border);
    border-radius: var(--fw-radius-md); padding: 11px 12px; cursor: pointer; height: 100%;
    transition: border-color var(--fw-dur) var(--fw-ease);
}
.fw-qr-mode input:checked + .fw-qr-mode-card { border-color: var(--fw-accent); background: var(--fw-accent-soft); }
.fw-qr-mode input:focus-visible + .fw-qr-mode-card { outline: 2px solid var(--fw-accent); outline-offset: 2px; }
.fw-qr-mode-locked .fw-qr-mode-card { opacity: .55; cursor: not-allowed; }
.fw-qr-mode-icon { color: var(--fw-accent); display: inline-flex; flex: 0 0 auto; }
.fw-qr-mode-card b { display: block; font-size: .9rem; }
.fw-qr-mode-card small { color: var(--fw-ink-soft); font-size: .8rem; line-height: 1.4; display: block; }
.fw-qr-preview {
    display: grid; place-items: center; background: var(--fw-surface);
    border: var(--fw-border-width) solid var(--fw-border); border-radius: var(--fw-radius-md); padding: 18px;
}
.fw-qr-preview svg, .fw-qr-preview img { width: 100%; max-width: 240px; height: auto; }

/* Site settings tabs: square segmented bar (same language as the builder's
   panel tabs). Panes live inside two different forms, so hide/show them
   here rather than relying on Bootstrap's direct-child .tab-content rule. */
.fw-tabs {
    display: flex; flex-wrap: wrap; gap: 3px; padding: 3px;
    background: var(--fw-surface-sunk); border: 1px solid var(--fw-border);
}
.fw-tabs .nav-item { flex: 1 1 auto; }
.fw-tabs .nav-link {
    width: 100%; padding: 9px 14px; border: 0; border-radius: 0; background: transparent;
    color: var(--fw-ink-soft); font-size: .9rem; font-weight: 600; white-space: nowrap;
}
.fw-tabs .nav-link:hover { color: var(--fw-ink); background: var(--fw-surface); }
.fw-tabs .nav-link.active { background: var(--fw-ink); color: var(--fw-accent-contrast); }
.fw-tab-content .tab-pane { display: none; }
.fw-tab-content .tab-pane.active { display: block; }

/* Scheduled redirect status line: tinted box with a status dot */
.fw-schedule-status {
    display: flex; align-items: baseline; gap: 8px;
    font-size: .88rem; font-weight: 600; padding: 8px 12px;
    border-radius: var(--fw-radius-sm); background: var(--fw-surface-sunk);
    --fw-dot: var(--fw-ink-faint);
}
.fw-schedule-status::before {
    content: ""; flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%;
    background: var(--fw-dot); transform: translateY(-1px);
}
.fw-schedule-active { background: var(--fw-success-soft); --fw-dot: var(--fw-success); }
.fw-schedule-upcoming { background: var(--fw-highlight-soft); --fw-dot: var(--fw-highlight-deep); }

/* Site overview: the "Site" card - one calm panel, no nested boxes */
.fw-linklist { display: grid; margin: -6px 0 6px; }
.fw-linklist a {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 11px 0; color: var(--fw-ink); font-weight: 600; text-decoration: none;
    border-bottom: 1px solid var(--fw-paper-deep);
}
.fw-linklist a span:first-child { display: inline-flex; align-items: center; gap: 10px; }
.fw-linklist a svg { color: var(--fw-accent); }
.fw-linklist a span:last-child { color: var(--fw-ink-faint); transition: transform var(--fw-dur) var(--fw-ease); }
.fw-linklist a:hover { color: var(--fw-accent); }
.fw-linklist a:hover span:last-child { transform: translateX(3px); color: var(--fw-accent); }

.fw-site-qr { padding-top: 16px; }
.fw-site-qr-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
/* Light text toggle (Permanent / Custom address) */
.fw-switch { display: flex; gap: 14px; }
.fw-switch .nav-link {
    padding: 2px 0; border: 0; border-radius: 0; background: none;
    color: var(--fw-ink-faint); font-size: .82rem; font-weight: 600;
    border-bottom: 2px solid transparent;
}
.fw-switch .nav-link:hover { color: var(--fw-ink); }
.fw-switch .nav-link.active { color: var(--fw-ink); border-bottom-color: var(--fw-ink); }
.fw-site-qr-img { display: block; width: 100%; max-width: 200px; height: auto; margin: 6px auto 12px; }
.fw-site-qr-note { color: var(--fw-ink-soft); font-size: .84rem; line-height: 1.5; margin: 0 0 8px; }
.fw-site-qr-note code { font-size: .8rem; }
.fw-site-qr-dl { display: flex; align-items: center; gap: 6px; font-size: .86rem; font-weight: 600; margin: 0; color: var(--fw-ink-soft); }
.fw-site-qr-dl svg { color: var(--fw-accent); }

.fw-site-offline { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--fw-paper-deep); }
.fw-textbtn {
    padding: 0; border: 0; background: none; font: inherit; font-size: .86rem; font-weight: 600;
    color: var(--fw-ink-soft); cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.fw-textbtn-warn { color: var(--fw-highlight-deep); }
.fw-textbtn:hover { color: var(--fw-danger); }
.fw-qr-preview-sm svg { max-width: 180px; }

/* --- misc ---------------------------------------------------------- */
.fw-check-list { list-style: none; padding: 0; display: grid; gap: 7px; font-size: .93rem; margin: 0 0 18px; }
.fw-check-list li::before { content: "✓ "; color: var(--fw-accent); font-weight: 800; }
.fw-addon { display: flex; justify-content: space-between; gap: 14px; align-items: center; flex-wrap: wrap; }
.fw-steps { padding-left: 20px; }

/* Tables should scroll inside their own box rather than widening the page. */
.fw-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --- auth ---------------------------------------------------------- */
.fwauth { background: var(--fw-paper); }
.fwauth-wrap { max-width: 420px; margin: 0 auto; padding: 60px 20px; display: grid; gap: 22px; justify-items: center; }
.fwauth-card {
    background: var(--fw-surface); border: var(--fw-border-width) solid var(--fw-border);
    border-radius: var(--fw-radius-lg); padding: 30px; width: 100%;
}
.fwauth-title {
    font-family: var(--fw-font-display); font-weight: var(--fw-display-weight);
    letter-spacing: var(--fw-display-track); font-size: 1.5rem; margin: 0 0 8px;
}
.fwauth-sub { color: var(--fw-ink-soft); font-size: .93rem; margin-bottom: 18px; }
.fwauth-switch { text-align: center; margin: 16px 0 0; font-size: .92rem; color: var(--fw-ink-soft); }
.fwauth-alert { width: 100%; margin: 0; }
.fwauth-link { font-size: .9rem; }
.fwauth-code { font-size: 1.4rem; letter-spacing: .35em; text-align: center; font-family: var(--fw-font-mono); }

/* --- footer --------------------------------------------------------- */
.fwapp-footer {
    border-top: 1px solid var(--fw-border); padding: 16px 22px; display: flex; gap: 18px;
    justify-content: center; font-size: .82rem; color: var(--fw-ink-soft);
    background: var(--fw-paper-deep); flex-wrap: wrap;
}
.fwapp-footer a { color: var(--fw-ink-soft); text-decoration: none; }
.fwapp-footer a:hover { color: var(--fw-accent); }

/* --- responsive ----------------------------------------------------
   The app had no breakpoints of its own and inherited only Bootstrap's
   grid, which left the fixed two-column QR grid, the nav row and the
   page header cramped on phones.
   ------------------------------------------------------------------- */
@media (max-width: 720px) {
    h1 { font-size: 1.5rem; }
    .fwapp-main { padding: 20px 0 44px; }
    .fwapp-container, .fwapp-nav-inner, .fwapp-flash { padding-left: 16px; padding-right: 16px; }

    .fwapp-nav-inner { gap: 12px; padding-top: 10px; padding-bottom: 10px; }
    .fwapp-nav-links { order: 3; width: 100%; gap: 14px; font-size: .9rem; }
    .fwapp-nav-user { gap: 8px; }
    .fwapp-nav-account { max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .fwapp-page-head { margin-bottom: 18px; }
    .fwapp-head-actions { width: 100%; }
    .fwapp-head-actions .btn { flex: 1 1 auto; }

    .fw-panel { padding: 18px 16px; border-radius: var(--fw-radius-md); }
    .fw-site-grid { grid-template-columns: 1fr; gap: 14px; }
    .fw-qr-modes { grid-template-columns: 1fr; }
    .fw-template-pick { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .fw-stat-row { gap: 18px 26px; }
    .fw-stat b { font-size: 1.45rem; }
    .fw-preview-modal { padding: 12px; }
    .fwauth-wrap { padding: 32px 16px; }
    .fwauth-card { padding: 22px 18px; }
    .fw-empty { padding: 32px 18px; }
}

/* --- phones & touch ------------------------------------------------
   Desktop is unchanged: everything below only applies under 720px.
   ------------------------------------------------------------------- */
@media (max-width: 720px) {
    /* Nav: row 1 = logo + account + log out, row 2 = section tabs with
       full-height tap targets and an active underline. */
    .fwapp-nav-inner { row-gap: 0; padding-bottom: 0; }
    .fwapp-nav-links {
        flex: 0 0 100%; gap: 0; flex-wrap: nowrap; overflow-x: auto;
        margin: 8px -16px 0; padding: 0 8px; border-top: 1px solid var(--fw-paper-deep);
        scrollbar-width: none;
    }
    .fwapp-nav-links::-webkit-scrollbar { display: none; }
    .fwapp-nav-links a {
        display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
        border-bottom: 2px solid transparent; white-space: nowrap;
    }
    .fwapp-nav-links a[aria-current="page"] { color: var(--fw-ink); border-bottom-color: var(--fw-accent); }
    .fwapp-nav-account { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; color: var(--fw-ink); }
    .fwapp-nav-account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; }
    .fwapp-nav-account-icon { display: inline-block; flex-shrink: 0; color: var(--fw-accent); }
    .fwapp-logout { min-height: 40px; padding-left: 4px; padding-right: 4px; }

    /* 16px inputs: iOS Safari zooms the page in on focus below that. */
    .form-control, .form-select, .input-group-text, .fwapp textarea { font-size: 16px; }
    .form-control, .form-select { min-height: 44px; }
    .form-control-color { min-height: 44px; width: 56px; }

    /* Comfortable tap targets for buttons and checkboxes */
    .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
    .btn-sm { min-height: 40px; }
    .btn-link.p-0 { min-height: 0; padding: 8px 0 !important; }
    .form-check { min-height: 32px; display: flex; align-items: flex-start; gap: 8px; padding-left: 0; }
    .form-check .form-check-input { float: none; margin: 2px 0 0; width: 1.25em; height: 1.25em; flex-shrink: 0; }

    /* Confirm-with-text forms (delete site / account, disable 2FA): stack */
    .fw-confirm-group { flex-direction: column; gap: 8px; max-width: none !important; }
    .fw-confirm-group > * { width: 100% !important; border-radius: var(--fw-radius-sm) !important; margin-left: 0 !important; }

    /* Site settings tabs: an even 2 x 2 grid instead of a ragged wrap */
    .fw-tabs { display: grid; grid-template-columns: 1fr 1fr; }
    .fw-tabs .nav-link { min-height: 44px; white-space: normal; line-height: 1.2; }

    /* Site overview card: bigger targets for the small inline links */
    .fw-site-qr-dl a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 6px; }
    .fw-switch .nav-link { min-height: 36px; }
    .fw-textbtn { padding: 10px 0; }

    /* Insights range chips share the row */
    .fwapp-head-actions .btn-sm { flex: 1 1 0; }

    /* Form inbox: label above value, so long answers get the full width */
    .fw-sub { padding: 14px; }
    .fw-sub-data, .fw-sub-data tbody, .fw-sub-data tr, .fw-sub-data th, .fw-sub-data td { display: block; }
    .fw-sub-data th { padding: 8px 0 0; white-space: normal; font-size: .8rem; }
    .fw-sub-data td { padding: 0 0 4px; }

    /* Auth: the remember / forgot row gets its own breathing room */
    .fwauth-link { display: inline-flex; align-items: center; min-height: 40px; }
    .form-check { align-items: center; }
    .form-check .form-check-input { margin: 0; }

    /* Tables (admin, insights) scroll inside their panel */
    .table-responsive { margin: 0 -4px; }
}

@media (max-width: 380px) {
    .fw-sub-head { flex-direction: column; gap: 4px; }
    .fwauth-code { font-size: 1.15rem; letter-spacing: .25em; }
}

/* Respect a reduced-motion preference: keep state changes, drop movement. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important; animation-iteration-count: 1 !important;
        transition-duration: .01ms !important; scroll-behavior: auto !important;
    }
    .fw-site-card:hover, .fw-template-card:hover { transform: none; }
}

/* Bot honeypot (see BotGuard): off-screen rather than display:none, which
   some bots detect and skip. Hidden from assistive tech via aria-hidden. */
.fw-hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* Legal links under the login / register card */
.fwauth-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-top: 22px; font-size: .82rem; }
.fwauth-footer a { color: var(--fw-ink-soft); text-decoration: none; }
.fwauth-footer a:hover { color: var(--fw-accent); }
