/* ============================================================================
   ispravi.me - Croatian Spell Checker
   Modern editorial design system (warm · clean · human)
   
   Architecture:
   - Warm paper surfaces with near-black ink accents
   - Colorful error decorations (wavy/solid/dashed)
   - Fixed glassmorphic toolbar
   - Right-sliding drawers
   - Focus mode for distraction-free writing
   
   Browser support: Modern browsers (ES6+, CSS Grid, CSS Custom Properties)
   Last updated: 2026-07-07
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1 · CSS Variables (Design Tokens)
   ---------------------------------------------------------------------------- */
:root {
    /* Colours are NOT defined here: every skin (Svijetlo, Tamno, Izvorno,
       Visoki kontrast) declares its complete palette in skins.css, the single
       source for colour tokens. This block holds layout and type only. */

    /* The spelling wave: a 6×4px SVG used as a CSS mask over a bar in
       --err-spelling, so it follows every skin. One definition for the editor
       markers, the counts line and the tour, so the wave is identical
       everywhere (text-decoration: wavy lets the browser pick the size). */
    --err-wave-mask: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%276%27 height=%274%27 viewBox=%270 0 6 4%27%3E%3Cpath d=%27M0 2 Q1.5 0.5 3 2 T6 2%27 fill=%27none%27 stroke=%27%23000%27 stroke-width=%271.5%27/%3E%3C/svg%3E") repeat-x left center / 6px 4px;

    /* Typography */
    --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

    /* Border radius */
    --radius-sm: 7px;
    --radius-md: 11px;
    --radius-lg: 16px;
    --radius-xl: 22px;

    /* Layout dimensions */
    --header-height: 60px;
    --doc-width: 960px;         /* toolbar/layout reference width (fixed) */
    --editor-width: var(--doc-width); /* editor column width (user-resizable) */
    --toolbar-height: 53px;     /* kept in sync with the real toolbar by V3UIManager */
    --toolbar-gap: 0px;         /* used by skins.css drawer offsets */

    /* Motion */
    --transition-fast: 0.15s ease;
}

/* ----------------------------------------------------------------------------
   2 · Reset & Base
   ---------------------------------------------------------------------------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-gray);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
    min-height: 100vh;
    /* Establish a block formatting context so .main-content's margin-top
       (which clears the fixed header) does not collapse through <body> and
       escape above it — that collapse made the document header-height taller
       than the viewport and left a blank strip below the footer. */
    display: flow-root;
}

/* Form controls don't inherit the page font by default (they fall back to
   Arial / the system UI font), so every button would otherwise render in a
   different face from the text around it. Family only: sizes stay per rule. */
button, input, select, textarea {
    font-family: inherit;
}

:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

::selection {
    background: color-mix(in srgb, var(--err-info) 22%, transparent);
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 9px;
    border: 2px solid var(--bg-gray);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ----------------------------------------------------------------------------
   3 · Header
   ---------------------------------------------------------------------------- */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    /* Edge to edge: logo in the top-left corner, icons at the right edge. */
    padding: 0 18px;
    /* Alternative (tried 2026-10-10, reverted): same column as the toolbar and
       the sheet, so header and toolbar line up as one grid on wide screens.
    padding: 0 max(18px, calc((100% - var(--doc-width)) / 2)); */
    background: color-mix(in srgb, var(--bg-white) 86%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: none;
    z-index: 1070;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: opacity 0.45s ease;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-image {
    /* Brand wordmark (images/brand/natpis-*.svg); its box runs from the
       i-dot to the p-descender, so the height sets the size. */
    --logo-h: 30px;
    height: var(--logo-h);
    width: auto;
    display: block;
}

/* Pozitiv on light headers; skins.css swaps in the negativ on dark ones. */
.logo-image-dark {
    display: none;
}

/* Trial: app icon + wordmark as one lockup, a tighter gap than the tagline's */
.logo-lockup {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Toned down so the icon doesn't outshine the wordmark (both tiles) */
.logo-mark {
    opacity: 0.85;
}

/* Brand tagline "na temeljima / Hašekova nasljeđa" next to the wordmark, as
   text (the logo SVG's outlined copy is cropped away). */
.site-tagline {
    margin: 0;
    padding-left: 12px;
    border-left: 1px solid var(--border-color);
    font-size: 12px;
    font-weight: 450;
    line-height: 1.3;
    white-space: nowrap;
    color: var(--text-secondary);
}

/* Present for screen readers and search, not drawn */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.site-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.header-separator {
    width: 1px;
    height: 22px;
    background: var(--border-color);
    margin: 0 6px;
}

/* Theme toggle (quiet segmented pill) */
.theme-toggle-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 9px;
}

.theme-toggle-btn {
    width: 30px;
    height: 28px;
    border: none;
    background: none;
    border-radius: 7px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.theme-toggle-btn:hover {
    color: var(--text-secondary);
}

.theme-toggle-btn.active {
    background: var(--bg-white);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* Settings + help buttons in header */
.app-header .sidebar-toggle,
.app-header .tour-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    border-radius: 9px;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.app-header .sidebar-toggle:hover,
.app-header .tour-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.app-header .tour-btn.active,
.toolbar .focus-btn.active,
.toolbar .history-toggle.active {
    background: var(--primary-light);
    color: var(--text-primary);
}

body.sidebar-open .app-header .sidebar-toggle {
    background: var(--primary-light);
    color: var(--text-primary);
}

.user-info {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 36px;
    height: 36px;
    padding: 0 7px;
    font: inherit;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-secondary);
}

.user-info svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.user-info:hover,
.user-info.is-open {
    background: var(--bg-hover);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Only hide the direct userName span (icon-only display); NOT the spans
   nested inside the dropdown, which lives inside .user-info too. */
.user-info > span {
    display: none;
}

/* Tier label ("Gost") → the account button becomes a quiet outlined pill */
.user-info > .user-info-label:not(:empty) {
    display: inline;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.user-info:has(> .user-info-label:not(:empty)) {
    border-color: var(--border-color);
    border-radius: 999px;
    padding: 0 12px 0 9px;
}

/* ----------------------------------------------------------------------------
   4 · Main Content & Editor
   ---------------------------------------------------------------------------- */
.main-content {
    margin-top: var(--header-height);
    margin-left: 0 !important;
    margin-right: 0 !important;
    min-height: calc(100vh - var(--header-height));
    display: flex;
    flex-direction: column;
    background: var(--bg-gray);
}

.editor-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: var(--editor-width);
    margin: 0 auto;
    /* The sheet sits the same distance below the toolbar as above the footer:
       --sheet-gap (main-content already starts below the header). */
    --sheet-gap: 30px;
    padding: calc(var(--toolbar-height) + var(--sheet-gap)) 32px var(--sheet-gap);
    position: relative;
    flex: 1;
}

.editor-container.resizing {
    user-select: none;
}

/* Counts line (#doc-info) — just ABOVE the sheet, right-aligned to its edge,
   in the gap under the toolbar: per-category error counts
   (features.errorSummary) and word/character counts (features.docStats).
   The page itself holds only the user's text. Absolutely positioned and
   anchored by its bottom edge 6px above the sheet (translateY(-100%)), so it
   takes no layout space and, even if it wraps, grows upward — the text and
   the error overlay never move. Phones (≤ 480px, no gap) keep it inside the
   sheet's top margin instead; see that breakpoint. */
.doc-info {
    position: absolute;
    top: calc(var(--toolbar-height) + var(--sheet-gap) - 6px);
    transform: translateY(-100%);
    right: 32px;   /* = container side padding → flush with the sheet's edge */
    left: 32px;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: baseline;
    gap: 2px 14px;
    font-family: var(--font-ui);
    font-size: 11.5px;
    line-height: 16px;
    color: var(--text-secondary);
    pointer-events: none; /* clicks in the margin still reach the editor */
    transition: opacity 0.4s ease;
}

.error-summary,
.check-time,
.doc-counts {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 2px 12px;
}

.error-summary:empty,
.check-time:empty,
.doc-counts:empty,
.error-summary[hidden],
.check-time[hidden],
.doc-counts[hidden] {
    display: none;
}

/* Hairline between the check's line (error counts, check time) and the
   word/character counts */
.error-summary:not(:empty) ~ .doc-counts,
.check-time:not([hidden]):not(:empty) + .doc-counts {
    padding-left: 14px;
    border-left: 1px solid var(--border-color);
}

.doc-info b {
    color: var(--text-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Each category label is drawn like its marker in the text: tint + the
   category's underline shape (wavy / solid / dashed) */
.error-summary .es-label {
    padding: 0 2px;
    text-decoration-line: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    text-decoration-skip-ink: none;
}

.error-summary .es-spelling .es-label {
    background: var(--err-spelling-soft);
    text-decoration-style: wavy; /* fallback: no CSS masks */
    text-decoration-color: var(--err-spelling);
}

/* The same wave as the editor markers (same mask, same geometry: 4px tall,
   centred on the tinted box's bottom edge), not the browser's larger one */
@supports (mask-image: none) or (-webkit-mask-image: none) {
    .error-summary .es-spelling .es-label {
        position: relative;
        text-decoration: none;
    }

    .error-summary .es-spelling .es-label::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: -2px;
        height: 4px;
        background-color: var(--err-spelling);
        -webkit-mask: var(--err-wave-mask);
        mask: var(--err-wave-mask);
    }
}

.error-summary .es-grammar .es-label {
    background: var(--err-grammar-soft);
    text-decoration-style: solid;
    text-decoration-color: var(--err-grammar);
}

.error-summary .es-info .es-label {
    background: var(--err-info-soft);
    text-decoration-style: dashed;
    text-decoration-color: var(--err-info);
}

body.focus-mode .doc-info {
    opacity: 0.35;
}

/* Featured announcement (announcement.json → index.php, js/ui/Announcement.js):
   the LEFT end of the counts line, "Novo na blogu · <title> →  ×".
   flex-basis 0 + min-width: it takes only the room the counts leave and
   truncates the title; below 160px it wraps onto its own line, which grows
   upward like the rest of the counts line. Phones get the footer copy. */
.announcement {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 0;
    min-width: 160px;
    margin-right: auto;
    pointer-events: auto; /* the counts line lets clicks through; this must not */
}

.announcement[hidden],
.announcement--footer {
    display: none;
}

.announcement-link {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
    color: var(--text-secondary);
    text-decoration: none;
}

.announcement-label {
    flex-shrink: 0;
    font-weight: 600;
    color: var(--text-primary);
}

.announcement-sep,
.announcement-arrow {
    flex-shrink: 0;
}

.announcement-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.announcement-arrow {
    transition: transform 0.15s ease;
}

.announcement-link:hover .announcement-title,
.announcement-link:focus-visible .announcement-title {
    color: var(--primary-color);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.announcement-link:hover .announcement-arrow {
    transform: translateX(2px);
}

.announcement-close {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin: -4px -2px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.announcement-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.announcement-close svg {
    width: 12px;
    height: 12px;
}

body.focus-mode .announcement {
    display: none;
}

/* Phones: no gap above the sheet, and the sheet's top margin belongs to the
   counts — the announcement becomes the footer's first line instead. */
@media (max-width: 480px) {
    .doc-info .announcement {
        display: none;
    }

    .announcement--footer:not([hidden]) {
        display: flex;
        flex-basis: 100%;
        min-width: 0;
        font-size: 12px;
        line-height: 1.4;
    }
}

/* Editor (contenteditable) — paper sheet appearance */
.editor {
    /* Fill the space the flex container leaves (viewport minus header, toolbar,
       paddings and footer) instead of a hardcoded 100vh calc — the old calc
       fought the flex layout and left a 2-3px overflow on an empty page. */
    flex: 1 0 auto;
    min-height: 0 !important;
    max-height: none !important;
    height: auto !important;
    padding: 75px 75px 92px !important;   /* 2026-10-21: 1/6 off the old 90px 90px 110px */
    border: 1px solid var(--border-color) !important;
    border-radius: 2px !important;
    background: var(--bg-white) !important;
    box-shadow: 
        0 1px 3px rgba(40, 33, 22, 0.04),
        0 4px 12px rgba(40, 33, 22, 0.03) !important;
    overflow: visible !important;
    font-family: var(--editor-font, 'Atkinson Hyperlegible Next', system-ui, -apple-system, 'Segoe UI', sans-serif); /* JS sets the chosen font inline (EditorFonts.js) */
    font-size: var(--editor-size, 20px);
    line-height: 1.75;
    color: var(--text-primary);
    caret-color: var(--primary-color);
}

.editor:focus,
.editor:focus-visible {
    box-shadow: 
        0 1px 3px rgba(40, 33, 22, 0.04),
        0 4px 12px rgba(40, 33, 22, 0.03) !important;
    border: 1px solid var(--border-color) !important;
    outline: none !important;
}

/* Empty state (EmptyState.js): one quiet line under the placeholder, placed
   by JS from the editor's padding/line height. Clicks pass through to the
   sheet except on the button. */
.empty-hint {
    position: absolute;
    z-index: 2;
    margin: 0;
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-muted);
    pointer-events: none;
}

.empty-hint[hidden],
body.focus-mode .empty-hint {
    display: none;
}

.empty-hint-try {
    pointer-events: auto;
    padding: 2px 0;
    border: none;
    background: none;
    font: inherit;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: underline;
    text-decoration-color: var(--border-hover, var(--border-color));
    text-underline-offset: 3px;
    cursor: pointer;
}

.empty-hint-try:hover {
    text-decoration-color: currentColor;
}

.empty-hint-try:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 3px;
}

.editor:empty::before {
    content: attr(data-placeholder);
    pointer-events: none;
    color: var(--text-muted);
    font-style: normal;
}

/* Dark theme editor */
html[data-skin="tamno"] .editor {
    background: var(--bg-white) !important;
    border-color: var(--border-color) !important;
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.08),
        0 4px 12px rgba(0, 0, 0, 0.06) !important;
}

html[data-skin="tamno"] .editor:focus,
html[data-skin="tamno"] .editor:focus-visible {
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.08),
        0 4px 12px rgba(0, 0, 0, 0.06) !important;
    border: 1px solid var(--border-color) !important;
}

/* ----------------------------------------------------------------------------
   5 · Toolbar (Fixed full-width bar)
   ---------------------------------------------------------------------------- */
.toolbar {
    position: fixed !important;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: auto !important;
    transform: none !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    margin: 0 !important;
    padding: 8px max(16px, calc((100% - var(--doc-width)) / 2)) !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;   /* phones: wraps to two rows; V3UIManager syncs --toolbar-height */
    gap: 6px;
    row-gap: 4px;
    background: color-mix(in srgb, var(--bg-white) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    box-shadow: var(--shadow-sm);
    z-index: 1024;
    transition: opacity 0.4s ease;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 3px;
}

.toolbar-right {
    margin-left: auto;
}

.toolbar-separator,
.toolbar-divider {
    width: 1px;
    height: 22px;
    background: var(--border-color);
    margin: 0 4px;
}

.toolbar-btn {
    height: 36px;
    padding: 0 12px;
    border: none;
    background: none;
    border-radius: 9px;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.toolbar-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border: none;
    color: var(--text-primary);
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.toolbar-btn-icon {
    width: 36px;
    padding: 0;
}

.toolbar-btn-primary {
    background: var(--primary-color);
    color: var(--primary-ink);
    border: none;
    padding: 0 16px;
}

.toolbar-btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    color: var(--primary-ink);
}

/* Shortcut hint inside the check button ("Ctrl+↵") */
/* Platform label (html.is-apple, set before first paint) and the hint's
   limited run (html.check-hint-done, see js/ui/ShortcutHint.js) */
.kbd-apple,
html.is-apple .kbd-pc,
html.check-hint-done .toolbar-kbd {
    display: none;
}

html.is-apple .kbd-apple {
    display: inline;
}

.toolbar-kbd {
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
    padding: 4px 6px;
    margin-right: -6px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--primary-ink) 16%, transparent);
    color: inherit;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

/* ShortcutHint: fade out once the hint has done its job, then .check-hint-done */
html.check-hint-leaving .toolbar-kbd {
    opacity: 0;
}

/* "Prihvati sve (4)" — a labelled, quiet outline button */
.toolbar-btn-accept {
    border: 1px solid var(--border-hover);
    color: var(--text-primary);
    gap: 6px;
    white-space: nowrap;
}

.toolbar-btn-accept:hover:not(:disabled) {
    border: 1px solid var(--text-secondary);
}

.toolbar-btn-count {
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

#error-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0 8px;
    min-width: 92px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

#error-count:empty {
    min-width: 0;
    padding: 0;
}

#error-count.error-count-has-errors {
    color: var(--text-primary);
    /* While there are errors the arrows sit to the left of the counter in a
       right-aligned group, so the counter must not change width when it
       switches between "5 pogrešaka" and "3 / 5" (hover/navigation): fixed
       width for up to "1234 pogrešaka", text centred, tabular digits. */
    width: 14ch;
    min-width: 14ch;
    padding: 0;
}

#error-count.error-count-success {
    color: var(--success-color);
}

#error-count.error-count-failed {
    color: var(--error-color);
}

/* ----------------------------------------------------------------------------
   6 · Progress & Status
   ---------------------------------------------------------------------------- */
.progress-bar {
    position: fixed !important;
    top: calc(var(--header-height) + var(--toolbar-height));
    left: 0;
    right: 0;
    width: 100%;
    height: 2px;
    background: transparent;
    z-index: 1023;
    margin: 0 !important;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    overflow: hidden;
}

.progress-bar.active {
    opacity: 1;
    visibility: visible;
}

.progress-bar-fill {
    background: var(--primary-color);
    height: 100%;
    width: 100%;
    animation: progressIndeterminate 1.5s cubic-bezier(0.65, 0.05, 0.35, 1) infinite;
}

@keyframes progressIndeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Toast (StatusLine.js) — one quiet card, bottom-left. Bottom-left because
   the settings/history drawers open from the right and would cover it. The
   type is a coloured icon, never a coloured fill. Phones: bottom, full width,
   lifted above the on-screen keyboard via --toast-keyboard. */
.toast {
    position: fixed;
    left: 24px;
    /* Clears the footer row (≈ 45px) so the toast never covers the copyright */
    bottom: calc(60px + var(--toast-keyboard, 0px));
    z-index: 1058;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: max-content;
    max-width: min(420px, calc(100vw - 48px));
    padding: 10px 8px 10px 14px;
    background: var(--bg-white);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.45;
    animation: toast-in 0.2s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.toast-icon {
    flex: 0 0 18px;
    display: inline-flex;
    margin-top: 7px;
    color: var(--text-secondary);
}

.toast-success .toast-icon { color: var(--success-color); }
.toast-warning .toast-icon { color: var(--warning-color); }
.toast-error .toast-icon { color: var(--error-color); }

.toast-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;            /* a long message pushes the action below it */
    align-items: center;
    gap: 4px 10px;
}

.toast-message {
    flex: 1 1 200px;
    padding: 5px 0;
    overflow-wrap: anywhere;
}

.toast-action {
    flex: none;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border-hover);
    border-radius: 8px;
    background: var(--bg-white);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.toast-action:hover {
    background: var(--bg-hover);
}

.toast-action[hidden] {
    display: none;
}

.toast-close {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.toast-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

@media (max-width: 720px) {
    .toast {
        left: 12px;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px) + var(--toast-keyboard, 0px));
        width: auto;
        max-width: none;
    }
}

/* ----------------------------------------------------------------------------
   7 · Drawers (Sidebar & History) - Full-height right overlays
   ---------------------------------------------------------------------------- */
.sidebar,
.history-panel,
.user-dropdown {
    position: fixed;
    /* Below the toolbar (its real height, synced by V3UIManager), so the
       drawer's own title and close button are never hidden under it and the
       header gear / toolbar history toggle stay usable while it is open. */
    top: calc(var(--header-height) + var(--toolbar-height) + var(--toolbar-gap)) !important;
    height: calc(100dvh - var(--header-height) - var(--toolbar-height) - var(--toolbar-gap)) !important;
    right: 0;
    left: auto !important;
    width: min(340px, 92vw);
    border-left: 1px solid var(--border-color);
    border-right: none;
    border-top-left-radius: 0;
    background: var(--bg-white);
    /* Parked off-screen while closed: no shadow (it bled into the viewport as
       a dark strip on the right edge) and hidden, so its controls are out of
       the tab order. Visibility flips only after the slide-out finishes. */
    box-shadow: none;
    visibility: hidden;
    z-index: 1040;
    transform: translateX(100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s, box-shadow 0s linear 0.25s;
}

.sidebar.open,
.history-panel.open,
.user-dropdown.open {
    transform: translateX(0);
    visibility: visible;
    box-shadow: var(--shadow-lg);
    transition: transform 0.25s ease;
}

.drawer-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-white);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.drawer-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drawer-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0;
}

.sidebar-overlay {
    position: fixed;
    top: calc(var(--header-height) + var(--toolbar-height) + var(--toolbar-gap)) !important;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    background: color-mix(in srgb, var(--bg-white) 88%, transparent);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

body.sidebar-open .sidebar-overlay,
body.history-open .sidebar-overlay,
body.user-menu-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
}

/* ----------------------------------------------------------------------------
   8 · Settings Sections (Modern toggle rows)
   ---------------------------------------------------------------------------- */
.sidebar-section {
    padding: 18px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-section-title {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 14px;
}

/* Toggle rows */
.stog-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border-color);
}

.stog-row:last-child {
    border-bottom: none;
}

.stog-label {
    font-size: 13.5px;
    color: var(--text-primary);
}

.stog-desc {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.45;
}

.toggle {
    position: relative;
    width: 38px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
    display: inline-block;
}

.toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    position: absolute;
    inset: 0;
    border-radius: 22px;
    background: var(--border-hover);
    transition: background 0.2s ease;
}

.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle input:checked ~ .toggle-track {
    background: var(--primary-color);
}

.toggle input:checked ~ .toggle-thumb {
    transform: translateX(16px);
}

/* Settings cards → modern toggle rows */
.settings-cards {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.setting-option {
    display: flex !important;
    align-items: center;
    gap: 14px;
    margin: 0 !important;
    padding: 11px 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.setting-option:last-child {
    border-bottom: none;
}

/* An option the server does not offer (Kraći popis prijedloga without the LM) */
.setting-option[hidden] {
    display: none !important;
}

.setting-option .setting-card {
    order: 1;
    flex: 1;
    display: flex;
    align-items: center;
    border: none !important;
    background: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    transform: none !important;
}

.setting-option .setting-text {
    flex: 1;
}

.setting-option .setting-title {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-primary);
}

.setting-option .setting-desc {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.45;
}

.setting-option > input[type="checkbox"] {
    order: 2;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    display: inline-block !important;
    position: relative !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    width: 38px;
    height: 22px;
    margin: 0;
    border-radius: 22px;
    background: var(--border-hover);
    cursor: pointer;
    transition: background 0.2s ease;
}

.setting-option > input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.setting-option > input[type="checkbox"]:checked {
    background: var(--primary-color);
}

.setting-option > input[type="checkbox"]:checked::after {
    transform: translateX(16px);
}

/* Display mode segmented cards */
.mode-selection {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.mode-option {
    margin: 0;
    cursor: pointer;
}

.mode-option input {
    position: absolute;
    opacity: 0;
}

.mode-card {
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    background: var(--bg-white);
    transition: all 0.15s ease;
    height: 100%;
}

.mode-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.mode-option input:checked + .mode-card {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.mode-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.mode-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
    line-height: 1.4;
}

/* Font picker */
.font-select {
    width: 100%;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 13px;
}

.font-size-slider {
    width: 100%;
    accent-color: var(--primary-color);
}

.font-size-label {
    color: var(--text-muted);
}

/* Skin gallery */
.skin-card {
    border-radius: var(--radius-md);
}

.skin-card.active,
.skin-card[aria-checked="true"] {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.skin-name {
    color: var(--text-secondary);
}

/* ----------------------------------------------------------------------------
   9 · Error Decorations (3 types: error/grammar/info)
   ---------------------------------------------------------------------------- */
.ispravime-spelling,
.ispravime-grammar,
.ispravime-info {
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    text-decoration-skip-ink: none;
    border-radius: 3px;
    padding: 0 1px;
    cursor: text;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.ispravime-spelling {
    text-decoration: underline wavy var(--err-spelling); /* fallback: no CSS masks */
    background: var(--err-spelling-soft);
}

/* Span markers (inline mode) get the same masked wave as the overlay
   markers in popup mode, not the browser's coarser wavy decoration.
   [data-error-id] keeps this off the context menu, which carries the
   category class too. nowrap: an absolutely placed ::after cannot follow an
   inline box split across lines, and a spelling marker is a single token
   (inline mode: <del> + <ins> with no space between them). */
@supports (mask-image: none) or (-webkit-mask-image: none) {
    .ispravime-spelling[data-error-id] {
        position: relative;
        white-space: nowrap;
        text-decoration: none;
    }

    .ispravime-spelling[data-error-id]::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: -2px;
        height: 4px;
        background-color: var(--err-spelling);
        -webkit-mask: var(--err-wave-mask);
        mask: var(--err-wave-mask);
        pointer-events: none;
    }
}

.ispravime-spelling:hover {
    box-shadow: 0 0 0 2px var(--err-spelling-soft);
}

.ispravime-grammar {
    text-decoration: underline 2px solid var(--err-grammar);
    background: var(--err-grammar-soft);
}

.ispravime-grammar:hover {
    box-shadow: 0 0 0 2px var(--err-grammar-soft);
}

.ispravime-info {
    text-decoration: underline 2px dashed var(--err-info);
    background: var(--err-info-soft);
}

.ispravime-info:hover {
    box-shadow: 0 0 0 2px var(--err-info-soft);
}

.ispravime-spelling.current,
.ispravime-spelling.ispravime-highlighted,
.ispravime-grammar.ispravime-highlighted,
.ispravime-info.ispravime-highlighted {
    /* Very subtle background tint only - no box-shadow to avoid orange rectangle appearance */
    background: color-mix(in srgb, var(--err-current) 18%, transparent);
    border-radius: 2px;
}

/* Overlay markers (popup mode) */
/* Keep the caret (text I-beam) over error markers instead of an arrow, so the
   word still reads/behaves as editable text. */
.ispravime-overlay-marker {
    cursor: text;
}

.ispravime-spelling-overlay {
    background: var(--err-spelling-soft);
    border-bottom: 2px solid var(--err-spelling); /* fallback: no CSS masks */
}

/* The three categories differ in SHAPE, not only colour, exactly as in span
   mode: spelling = wavy, grammar = solid, info = dashed. The wave is a CSS
   mask over a token-coloured bar, so it follows every skin. */
@supports (mask-image: none) or (-webkit-mask-image: none) {
    .ispravime-spelling-overlay {
        border-bottom: none;
    }

    .ispravime-spelling-overlay::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: -2px;
        height: 4px;
        background-color: var(--err-spelling);
        -webkit-mask: var(--err-wave-mask);
        mask: var(--err-wave-mask);
        pointer-events: none;
    }
}

.ispravime-grammar-overlay {
    background: var(--err-grammar-soft);
    border-bottom: 2px solid var(--err-grammar);
}

.ispravime-info-overlay {
    background: var(--err-info-soft);
    border-bottom: 2px dashed var(--err-info);
}

/* Current error while navigating: intentionally NO special style. Overlay
   markers sit on top of the text, so any fill covers the word — and the
   correction popup already shows which error is current. Keep base marker look. */

/* Sentence overlay markers - visible hover highlight for sentence boundaries */
.ispravime-sentence-overlay {
    position: absolute;
    pointer-events: auto;
    cursor: default;
    border-radius: 3px;
    background: transparent;
    transition: background 0.15s ease, box-shadow 0.15s ease;
    z-index: 1; /* Below error markers (z-index: 5) but above editor text */
}

.ispravime-sentence-overlay.ispravime-sentence-hovered {
    background: color-mix(in srgb, var(--primary-color) 8%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary-color) 15%, transparent);
}

/* Inline mode (del/ins) */
.ispravime-spelling-inline del,
.ispravime-grammar-inline del,
.ispravime-info-inline del {
    color: var(--err-spelling-text);
    text-decoration-color: var(--err-spelling);
}

.ispravime-spelling-inline ins,
.ispravime-grammar-inline ins,
.ispravime-info-inline ins {
    color: var(--success-color);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

/* ----------------------------------------------------------------------------
   10 · Context Menu (Error Popup)
   ---------------------------------------------------------------------------- */
.ispravime-context-menu {
    width: min(420px, calc(100vw - 1.5rem)) !important;
    max-width: min(420px, calc(100vw - 1.5rem)) !important;
    padding: 0 !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-lg) !important;
    background: var(--bg-white) !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: hidden;
    position: absolute !important;
    text-decoration: none !important;
    cursor: default;
    z-index: 10000;
}

/* Ensure no underlines bleed into menu */
.ispravime-context-menu,
.ispravime-context-menu * {
    text-decoration: none !important;
}

/* Colored left stripe per error type */
.ispravime-context-menu::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--err-spelling);
}

.ispravime-context-menu.ispravime-grammar::before {
    background: var(--err-grammar);
}

.ispravime-context-menu.ispravime-info::before {
    background: var(--err-info);
}

.ispravime-context-menu > * {
    margin-left: 4px;
}

.menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 16px 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--err-spelling-text);
}

/* "‹ 3 / 4 ›": previous / next error; a disabled arrow keeps its slot */
.menu-nav {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    margin: -4px -6px -4px 0;
}

.menu-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
}

.menu-nav-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.menu-nav-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 1px;
}

.menu-nav-btn:disabled {
    visibility: hidden;
}

.menu-position {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* Bottom row under the action bar: keyboard hint (hidden on touch screens)
   on the left, "Korisno? 👍 👎" suggestion feedback on the right. */
.menu-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 8px 4px 16px;
    border-top: 1px solid var(--border-color);
}

.menu-hint {
    font-size: 11.5px;
    color: var(--text-secondary);
}

.ispravime-context-menu.ispravime-grammar .menu-header {
    color: var(--err-grammar-text);
}

.ispravime-context-menu.ispravime-info .menu-header {
    color: var(--err-info-text);
}

.menu-message {
    padding: 8px 16px 12px;
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.menu-message b {
    color: var(--text-primary);
    font-weight: 600;
}

.menu-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 14px;
}

/* When the informative message is hidden (showinfo off), suggestions follow the
   header directly. Restore the breathing room the .menu-message normally gives. */
.menu-header + .menu-suggestions {
    padding-top: 10px;
}

.suggestion-btn {
    padding: 6px 13px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-white);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.suggestion-btn:first-of-type {
    background: var(--primary-color);
    color: var(--primary-ink);
    border-color: var(--primary-color);
}

.suggestion-btn:hover {
    border-color: var(--text-primary);
}

.suggestion-btn:first-of-type:hover {
    background: var(--primary-hover);
}

.suggestion-expand-btn,
.suggestion-collapse-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 6px 11px;
    border: 1px dashed var(--border-hover);
    border-radius: 999px;
    background: none;
    color: var(--text-muted);
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.suggestion-expand-btn:hover,
.suggestion-collapse-btn:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.menu-actions {
    display: flex;
    align-items: center;
    gap: 0;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.menu-action-btn {
    flex: 1;
    padding: 11px 8px;
    border: none;
    background: none;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    border-right: 1px solid var(--border-color);
}

.menu-action-btn:last-child {
    border-right: none;
}

.menu-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.menu-feedback {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

.menu-feedback-label {
    margin-right: 4px;
    font-size: 11.5px;
    color: var(--text-secondary);
}

.menu-feedback-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    background: none;
    border-radius: 8px;
    color: var(--text-muted);
    transition: all 0.15s ease;
    cursor: pointer;
}

.menu-feedback-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.menu-feedback-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.menu-feedback-link[aria-pressed="true"] {
    color: var(--primary-color);
}

/* ----------------------------------------------------------------------------
   10b · Confirm Dialog (custom, on-brand replacement for window.confirm)
   ---------------------------------------------------------------------------- */
.cdlg-backdrop {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: color-mix(in srgb, var(--text-primary) 34%, transparent);
    backdrop-filter: saturate(1.1) blur(3px);
    -webkit-backdrop-filter: saturate(1.1) blur(3px);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.cdlg-backdrop.cdlg-visible {
    opacity: 1;
}

body.cdlg-lock {
    overflow: hidden;
}

.cdlg-card {
    position: relative;
    width: min(440px, calc(100vw - 2rem));
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: translateY(10px) scale(0.98);
    opacity: 0;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
}

.cdlg-visible .cdlg-card {
    transform: none;
    opacity: 1;
}

/* Accent stripe echoes the error-popup language (meaning through color). */
/* The dialog borrows the error palette: red (default) = destructive,
   amber (.cdlg-warning) = caution. */
.cdlg-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--err-spelling);
}

.cdlg-card.cdlg-warning::before {
    background: var(--err-grammar);
}

.cdlg-card.cdlg-primary::before {
    background: var(--primary-color);
}

.cdlg-body {
    display: flex;
    gap: 14px;
    padding: 22px 22px 18px 24px;
}

.cdlg-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--err-spelling-soft);
    color: var(--err-spelling-text);
}

.cdlg-card.cdlg-warning .cdlg-icon {
    background: var(--err-grammar-soft);
    color: var(--err-grammar-text);
}

.cdlg-card.cdlg-primary .cdlg-icon {
    background: var(--primary-light);
    color: var(--primary-color);
}

.cdlg-icon svg {
    width: 21px;
    height: 21px;
}

.cdlg-text {
    min-width: 0;
    padding-top: 2px;
}

.cdlg-title {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 16.5px;
    font-weight: 650;
    line-height: 1.3;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.cdlg-message {
    margin: 7px 0 0;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.cdlg-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px 18px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.cdlg-btn {
    padding: 9px 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-family: var(--font-ui);
    font-size: 13.5px;
    font-weight: 550;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cdlg-btn-cancel {
    background: var(--bg-white);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.cdlg-btn-cancel:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.cdlg-btn-confirm {
    background: var(--err-spelling);
    color: #fff;
}

.cdlg-btn-confirm:hover {
    background: color-mix(in srgb, var(--err-spelling) 86%, #000);
}

.cdlg-card.cdlg-warning .cdlg-btn-confirm {
    background: var(--err-grammar);
}

.cdlg-card.cdlg-warning .cdlg-btn-confirm:hover {
    background: color-mix(in srgb, var(--err-grammar) 86%, #000);
}

.cdlg-card.cdlg-primary .cdlg-btn-confirm {
    background: var(--primary-color);
    color: var(--primary-ink);
}

.cdlg-card.cdlg-primary .cdlg-btn-confirm:hover {
    background: var(--primary-hover);
}

.cdlg-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .cdlg-actions {
        flex-direction: column-reverse;
    }
    .cdlg-btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cdlg-backdrop,
    .cdlg-card {
        transition-duration: 0.01ms;
    }
}

/* ----------------------------------------------------------------------------
   11 · User Dropdown
   ---------------------------------------------------------------------------- */
.user-dropdown-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0;
}

.user-dropdown-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-dropdown-header strong {
    color: var(--text-primary);
    font-size: 15px;
}

.user-tier-badge {
    padding: 4px 8px;
    background: var(--primary-light);
    color: var(--primary-color);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0 16px;
}

/* Login by e-mail link: the offer under the usage bars (index.php #account-offer,
   js/ui/UserDropdown.js renderAccount). Quiet by default; --urgent when a day or
   month limit is nearly spent — the moment the offer actually helps. */
.account-offer {
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}

.account-offer[hidden] {
    display: none;
}

.account-offer-text {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.account-offer-text strong {
    display: block;
    margin-bottom: 2px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
}

.account-offer-btn {
    width: 100%;
    min-height: 36px;
    padding: 8px 14px;
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    color: var(--primary-color);
    font-family: var(--font-ui);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.account-offer-btn:hover {
    background: var(--primary-light);
}

.account-offer-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* A blocked account's session: a quiet notice, no button */
.account-offer--blocked {
    margin-bottom: 12px;
    border-color: color-mix(in srgb, var(--err-spelling) 45%, var(--border-color));
    background: var(--err-spelling-soft);
}

.account-offer--blocked .account-offer-text {
    margin: 0;
}

.account-offer--blocked a {
    color: inherit;
    text-decoration: underline;
}

.account-offer--urgent {
    border-color: color-mix(in srgb, var(--err-grammar) 45%, var(--border-color));
    background: var(--err-grammar-soft);
}

.account-offer--urgent .account-offer-btn {
    background: var(--primary-color);
    color: var(--primary-ink);
}

.account-offer--urgent .account-offer-btn:hover {
    background: var(--primary-hover);
}

/* Login dialog (js/ui/LoginDialog.js): the confirm-dialog card with a field */
.login-card .cdlg-text {
    flex: 1;
}

.login-label {
    display: block;
    margin: 14px 0 6px;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.login-input {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 15px;
}

.login-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.login-input[aria-invalid="true"] {
    border-color: var(--err-spelling);
}

.login-input--code {
    max-width: 10em;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3em;
    font-size: 18px;
}

.login-error {
    margin: 8px 0 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--err-spelling-text);
}

.login-note {
    margin: 10px 0 0;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--text-muted);
}

.login-note a {
    color: var(--primary-color);
}

.login-label[hidden],
.login-input[hidden],
.login-tg[hidden],
.login-tg-main[hidden],
.login-tg-qr[hidden],
.login-alt[hidden],
.login-google[hidden],
.login-alt-btn[hidden] {
    display: none;
}

/* Login with Telegram: code, QR code (computer) or a button (phone), status */
.login-tg {
    margin-top: 14px;
}

.login-tg-main {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.login-tg-qr {
    line-height: 0;
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #fff;
}

.login-tg-side {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.login-tg-code-label {
    font-family: var(--font-ui);
    font-size: 12.5px;
    color: var(--text-muted);
}

.login-tg-code {
    font-family: var(--font-ui);
    font-size: 30px;
    font-weight: 650;
    letter-spacing: 0.18em;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.login-tg-open {
    margin-top: 6px;
    font-family: var(--font-ui);
    font-size: 13.5px;
    font-weight: 550;
    color: var(--primary-color);
}

.login-tg-open--main {
    padding: 9px 16px;
    border-radius: var(--radius-md);
    background: var(--primary-color);
    color: var(--primary-ink);
    text-decoration: none;
}

.login-tg-open--main:hover {
    background: var(--primary-hover);
}

.login-tg-status {
    margin: 12px 0 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.login-alt {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.login-alt-or {
    font-size: 12.5px;
    color: var(--text-muted);
}

.login-alt-ways {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
}

/* The step without the address field: the ways in stand alone. */
.login-alt--solo {
    padding-top: 0;
    border-top: 0;
}

.login-alt--solo .login-alt-or {
    display: none;
}

/* Google's own button (an iframe, styled by Google) */
.login-google {
    min-height: 40px;
    color-scheme: normal;
}

.login-google-status {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.login-google-status:empty {
    display: none;
}

.login-alt-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 550;
    cursor: pointer;
}

.login-alt-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.cdlg-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.user-stats {
    padding: 16px;
}

#stat-details-container {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    color: var(--text-primary);
}

.stat-item[hidden] {
    display: none;
}

/* Blocked network (user.restricted): why access is limited, above the one counter. */
.stat-restricted-note {
    margin: 0 0 6px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

.stat-restricted-note[hidden] {
    display: none;
}

.stat-restricted-note a {
    color: var(--text-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.stat-item--stack {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 0;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.stat-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.stat-separator {
    color: var(--text-muted);
    padding: 0 6px;
}

.stat-progress {
    position: relative;
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: var(--bg-gray);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.stat-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--primary-color);
    border-radius: inherit;
}

.stat-sub {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.stat-remaining {
    color: var(--text-secondary);
    font-weight: 600;
}

/* A quota with no cap (premium; UserStatsService._setUnlimited): the count
   stands alone, no "/ limit" and no bar; "Preostalo" reads "neograničeno". */
.stat-item--stack.is-unlimited .stat-separator,
.stat-item--stack.is-unlimited .stat-separator + span,
.stat-item--stack.is-unlimited .stat-progress {
    display: none;
}

/* The organisation's shared quota (user.org) as its own section under the
   user's: a framed panel that opens with the rule (the stricter limit
   applies), and a "strože" tag on whichever limit runs out first. Hue is
   reserved for meaning, so org bars take the skin's muted ink (>= 5:1 on the
   track in every skin). Section titles and the panel show only when the
   server sends user.org (#stat-details-container.has-org). */
.stat-value,
.stat-remaining {
    font-variant-numeric: tabular-nums;
}

.stat-section-title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--text-primary);
}

.stat-own-title,
.stat-org {
    display: none;
}

.has-org .stat-own-title {
    display: block;
    margin-bottom: 2px;
}

.has-org .stat-org {
    display: block;
    margin-top: 14px;
    padding: 12px 14px 4px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-gray);
}

.stat-org-rule {
    margin: 8px 0 4px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-secondary);
}

.stat-org-rule strong {
    display: block;
    margin-bottom: 2px;
    font-size: 13px;
    color: var(--text-primary);
}

/* Inside the grey panel the track would vanish into the background. */
.stat-org .stat-progress {
    background: var(--bg-white);
}

.stat-org .stat-progress-bar {
    background: var(--text-muted);
}

.stat-binding {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--primary-color);
    color: var(--primary-ink);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
    vertical-align: 1px;
}

.stat-binding[hidden] {
    display: none;
}

/* Quota note in the account drawer: amber at ≥ 80 % of a daily cap,
   red (.is-reached) once it is used up; hidden otherwise. */
.stat-warning {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    color: var(--warning-color);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
}

.stat-warning svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.is-reached .stat-warning {
    color: var(--error-color);
}

/* Pinned under the scrolling content (index.php): logout sits at the bottom of the drawer */
.user-dropdown-footer {
    flex-shrink: 0;
}

.user-dropdown-footer .dropdown-logout-btn {
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
}

.dropdown-logout-btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--error-color);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.25s ease;
}

.dropdown-logout-btn:hover {
    background-color: var(--error-bg);
}

/* ----------------------------------------------------------------------------
   12 · Dictionary Panel (Desktop)
   ---------------------------------------------------------------------------- */
.dictionary-toggle-btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.25s ease;
}

.dictionary-toggle-btn svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.dictionary-toggle-btn:hover {
    background-color: var(--bg-gray);
}

.dictionary-toggle-btn .dictionary-arrow {
    margin-left: auto;
    transition: transform 0.25s ease;
}

.dictionary-toggle-btn.active .dictionary-arrow {
    transform: rotate(180deg);
}

.dictionary-panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-top: 1px solid var(--border-color);
}

.dictionary-panel.open {
    grid-template-rows: 1fr;
}

.dictionary-content {
    padding: 0 16px;
    overflow: hidden;
    min-height: 0;
}

.dictionary-content > :first-child {
    margin-top: 16px;
}

.dictionary-content > :last-child {
    margin-bottom: 16px;
}


.dictionary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.dictionary-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.dictionary-count {
    background: var(--bg-gray);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.dictionary-words {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 12px;
    padding: 8px;
    background: var(--bg-gray);
    border-radius: 8px;
}

.dictionary-words:empty::before {
    content: "Nema dodanih riječi";
    color: var(--text-muted);
    font-size: 13px;
    width: 100%;
    text-align: center;
    display: block;
    padding: 8px;
}

.dictionary-word-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 13px;
    color: var(--text-primary);
    transition: all 0.25s ease;
}

.dictionary-word-pill:hover {
    border-color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dictionary-word-text {
    font-weight: 500;
}

.dictionary-word-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.15s ease;
    width: 16px;
    height: 16px;
}

.dictionary-word-delete:hover {
    color: var(--error-color);
}

.dictionary-add {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.dictionary-input {
    flex: 1 1 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.25s ease;
}

.dictionary-input:focus {
    border-color: var(--primary-color);
}

.dictionary-add-btn {
    padding: 8px 14px;
    border: none;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.25s ease;
    white-space: nowrap;
    flex: 0 0 auto;
}

.dictionary-add-btn svg {
    opacity: 0.85;
}

.dictionary-add-btn:hover {
    background-color: var(--primary-hover);
}

.dictionary-add-btn:hover svg {
    opacity: 1;
}

.dictionary-add-btn:disabled {
    background-color: var(--bg-gray);
    color: var(--text-muted);
    cursor: not-allowed;
}

.dictionary-clear-btn {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--error-color);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.25s ease;
    white-space: nowrap;
    flex: 0 0 auto;
}

.dictionary-clear-btn:hover {
    background-color: var(--error-bg);
    border-color: var(--error-color);
}

.dictionary-clear-btn:disabled {
    color: var(--text-muted);
    border-color: var(--border-color);
    cursor: not-allowed;
    opacity: 0.5;
}

.dictionary-clear-btn:disabled:hover {
    background-color: transparent;
}

/* Dark theme dictionary */
body.theme-dark .dictionary-toggle-btn:hover {
    background-color: var(--bg-hover);
}

body.theme-dark .dictionary-word-pill {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

body.theme-dark .dictionary-word-pill:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

body.theme-dark .dictionary-input {
    background: var(--bg-hover);
    color: var(--text-primary);
}

body.theme-dark .dictionary-clear-btn:hover {
    background-color: var(--error-bg);
}

/* ----------------------------------------------------------------------------
   13 · History Panel Items
   ---------------------------------------------------------------------------- */
.history-panel-inner {
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    z-index: 1;
    height: 100%;
    min-height: 500px;
}

.history-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0 0 0;
    position: relative;
    z-index: 10;
    flex: 1;
    scroll-behavior: smooth;
    scrollbar-width: thin;
}

.history-items::-webkit-scrollbar {
    width: 6px;
}

.history-items::-webkit-scrollbar-track {
    background: transparent;
}

.history-items::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 6px;
}

.history-arrow {
    width: 100%;
    height: 36px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-secondary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    flex: 0 0 auto;
}

.history-arrow:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.history-arrow svg {
    flex-shrink: 0;
}

.history-panel .history-arrow {
    display: none;
}

/* A card is a plain container holding two sibling buttons: .history-item-open
   (the card's content: time + preview) and .history-item-delete (top right). */
.history-item {
    flex: 0 0 auto;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-white);
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
}

.history-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.history-item-open {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    min-height: 85px;
    padding: 12px 16px 14px;
    border: 0;
    border-radius: inherit;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.history-item-open:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

/* When the text was checked, on top: that is what history is scanned by
   ("the one from this morning"), and on top it sits at the same height on
   every card whatever the preview's length. A thin line only as wide as the
   date sets it apart from the text (align-self: the line follows the date,
   not the card; the short date stays clear of the delete button). */
.history-item-time {
    align-self: flex-start;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--border-color);
    font-size: 11.5px;
    line-height: 16px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.history-item-preview {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* Top right, centred on the date text (12px padding + 8px half-line = 20px) */
.history-item-delete {
    position: absolute;
    top: 6px;
    right: 8px;
    opacity: 0;
    width: 28px;
    height: 28px;
    padding: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-item:hover .history-item-delete,
.history-item:focus-within .history-item-delete {
    opacity: 1;
}

/* No hover on touch screens: keep delete visible, or it can't be found */
@media (hover: none) {
    .history-item-delete {
        opacity: 1;
    }
}

.history-item-delete:hover {
    background: var(--error-bg);
    color: var(--error-color);
}

.history-item-delete:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 0;
}

.history-item-delete svg {
    width: 16px;
    height: 16px;
}

.history-clear-all {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-white);
    color: var(--error-color);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
    flex-shrink: 0;
}

.history-clear-all:hover {
    background: var(--error-bg);
    border-color: var(--error-color);
}

.history-clear-all svg {
    width: 16px;
    height: 16px;
}

.history-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-color) 20%, transparent);
}

.history-item.selected .history-item-time {
    color: var(--primary-color);
    border-bottom-color: color-mix(in srgb, var(--primary-color) 30%, var(--border-color));
}

.history-empty {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 24px 0;
}

/* ----------------------------------------------------------------------------
   14 · Footer
   ---------------------------------------------------------------------------- */
.app-footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    padding: 12px 24px;
    flex-shrink: 0;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.footer-section {
    margin-bottom: 0;
}

.footer-section:last-child {
    margin-bottom: 0;
}

.footer-section h4 {
    display: none;
}

/* Left: copyright. Right: project links + social icons. When the row
   doesn't fit, the right group wraps to its own line. */
.footer-text {
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary);
    margin: 0;
}

.footer-text a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.footer-text a:hover {
    color: var(--primary-color);
}

.footer-end {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 16px;
}

.socials {
    display: flex;
    align-items: center;
    gap: 4px;
    /* the 28px hit areas overhang the 12px text line, not the footer */
    margin: -6px -6px -6px 0;
}

.social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: color 0.15s ease;
}

.social-icon svg {
    width: 18px;
    height: 18px;
}

.social-icon:hover {
    color: var(--primary-color);
}

/* ----------------------------------------------------------------------------
   15 · Terms of Service notice — the footer's first row, not a modal
   ---------------------------------------------------------------------------- */
.tos-notice {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.tos-notice[hidden] {
    display: none;
}

.tos-notice a {
    text-decoration: underline;
    text-underline-offset: 2px;
    color: var(--text-primary);
}

.tos-notice-ok {
    min-height: 28px;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.tos-notice-ok:hover {
    background: var(--bg-hover);
}

.tos-notice-ok:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.tos-notice-ok[hidden] {
    display: none;
}

/* Analytics question (index.php, $ga_measurement_id): text, then
   "Prihvaćam" / "Samo nužno" — the second one visually quieter. */
.tos-notice-text {
    flex: 1 1 320px;
    min-width: 0;
}

.tos-notice-text > [hidden] {
    display: none;
}

.tos-notice-text > span + span {
    margin-left: 4px;
}

.tos-notice-actions {
    display: flex;
    flex-shrink: 0;
    gap: 8px;
}

.tos-notice-quiet {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
    font-weight: 500;
}

.tos-notice-quiet:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

body.focus-mode .tos-notice {
    display: none;
}

/* ----------------------------------------------------------------------------
   15b · Phones (≤ 480px): ☰ menu + compact footer
   The project links move from the footer to a ☰ menu left of the logo
   (SiteMenu.js); the footer keeps only what can't go elsewhere:
     [ToS notice] · [announcement] · copyright … icons (one row)
   Left edge = the editor's text edge on phones (20px).
   ---------------------------------------------------------------------------- */
.menu-toggle,
.site-menu {
    display: none;
}

@media (max-width: 480px) {
    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        border: none;
        border-radius: 9px;
        background: none;
        color: var(--text-secondary);
        cursor: pointer;
    }

    .menu-toggle:hover,
    .menu-toggle[aria-expanded="true"] {
        background: var(--bg-hover);
        color: var(--text-primary);
    }

    /* Room for ☰: ☰ 44 + logo + ? / settings / account (3 × 44) must fit
       360px, so a slightly smaller wordmark, tighter gaps and 12px padding. */
    .app-header {
        padding: 0 12px;
    }

    .header-left {
        gap: 2px;
    }

    .header-right {
        gap: 2px;
    }

    .logo-image {
        --logo-h: 24px;
    }

    /* No room for the icon next to ☰ (see the width budget above) */
    .logo-mark {
        display: none !important;
    }

    .menu-toggle {
        margin-left: -8px;   /* the glyph, not the hit area, sits near the edge */
    }

    /* Under ☰; the header (backdrop-filter) is its containing block */
    .site-menu:not([hidden]) {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: calc(100% + 6px);
        left: 8px;
        z-index: 1080;
        width: min(260px, calc(100vw - 16px));
        padding: 6px;
        background: var(--bg-white);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-lg);
        animation: site-menu-in 0.15s ease;
    }

    .site-menu a {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: 0 12px;
        border-radius: var(--radius-sm);
        font-size: 15px;
        color: var(--text-primary);
        text-decoration: none;
    }

    .site-menu a:hover,
    .site-menu a:focus-visible {
        background: var(--bg-hover);
    }

    /* Footer: notice and announcement full width, then copyright | icons */
    .app-footer {
        padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .footer-content {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px 12px;
    }

    /* contain: inline-size — a full-width row must not size the grid's
       columns by its content (the announcement's one-line title pushed the
       page 20px past the screen edge). */
    .tos-notice:not([hidden]),
    .announcement--footer:not([hidden]) {
        grid-column: 1 / -1;
        contain: inline-size;
        margin: 0;   /* the desktop margin-right: auto would stop it stretching */
    }

    /* "U redu" beside the sentence */
    .tos-notice:not([hidden]) {
        flex-wrap: nowrap;
        gap: 12px;
    }

    .tos-notice > .tos-notice-text {
        flex: 1;
        min-width: 0;
    }

    .tos-notice-ok {
        flex-shrink: 0;
    }

    /* Asking about analytics: two buttons, so they go under the text. */
    .tos-notice.is-asking:not([hidden]) {
        flex-wrap: wrap;
        gap: 8px;
    }

    .tos-notice.is-asking > .tos-notice-text {
        flex-basis: 100%;
    }

    .footer-links {
        display: none;
    }

    .socials {
        margin: 0 -7px 0 0;   /* last glyph on the right edge: (32 − 18) / 2 */
        gap: 0;
    }

    /* 32px: above the 24px minimum, and leaves the copyright one line at 390px */
    .app-footer .social-icon {
        width: 32px;
        height: 32px;
        margin: 0;
    }
}

@keyframes site-menu-in {
    from { opacity: 0; translate: 0 -4px; }
    to { opacity: 1; translate: 0 0; }
}

/* ----------------------------------------------------------------------------
   16 · Focus Mode
   ---------------------------------------------------------------------------- */
body.focus-mode .app-header {
    opacity: 0;
}

body.focus-mode .app-header:hover {
    opacity: 1;
}

body.focus-mode .toolbar {
    opacity: 0.16;
}

body.focus-mode .toolbar:hover {
    opacity: 1;
}

body.focus-mode .app-footer {
    opacity: 0.16;
    transition: opacity 0.4s ease;
}

body.focus-mode .app-footer:hover {
    opacity: 1;
}

.focus-exit-badge {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 1075;
    display: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.focus-exit-badge:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

body.focus-mode .focus-exit-badge {
    display: flex;
}

/* ----------------------------------------------------------------------------
   17 · Motion & Accessibility
   ---------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ----------------------------------------------------------------------------
   18 · Responsive
   ---------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .header-right {
        gap: 10px;
    }

    /* 1/3 off the base .editor padding (75px 75px 92px). */
    .editor {
        padding: 50px 50px 61px !important;
    }
}

@media (max-width: 767px) {
    /* Help "?" stays: the short tour's last step points to it. The skin
       choice (incl. Tamno) is in Postavke → Izgled. */

    .site-tagline {
        display: none;
    }

    .theme-toggle-group {
        display: none;
    }

    /* its divider would be left standing alone */
    .app-header .header-separator {
        display: none;
    }

    /* .focus-btn stays visible here. */

    /* Sides: another 1/3 off the 1024px padding (4/9 of the base), before the
       720px breakpoint's own hand-tuned value takes over. Top/bottom stay at
       that breakpoint's 40px, so the margin never grows as the screen narrows. */
    .editor {
        padding: 40px 33px 40px !important;
    }
}

@media (max-width: 720px) {
    .editor-container {
        --sheet-gap: 40px;
        padding: calc(var(--toolbar-height) + var(--sheet-gap)) 16px var(--sheet-gap);
    }

    /* Shortcut hints are for keyboards; keep the narrow toolbar compact */
    .toolbar-kbd {
        display: none;
    }

    .editor {
        padding: 40px 24px 40px !important;
    }

    .doc-info {
        right: 16px;
        left: 16px;
    }

    .toolbar {
        padding: 6px 10px !important;
        gap: 2px;
    }

    #error-count {
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .user-info > span {
        display: none;
    }

    /* "Provjeri ponovno" → "Provjeri": the label itself always stays */
    .toolbar-btn-long {
        display: none;
    }

    /* Phones: two tidy rows instead of an overflowing right group.
         row 1: clear · copy · Provjeri ……… history
         row 2: ← → · counter ……… Prihvati sve (N)
       The two groups dissolve (display: contents) so their buttons can be
       re-ordered; ::after is a zero-height full-width line break. */
    .toolbar {
        row-gap: 0 !important;
    }

    .toolbar-left,
    .toolbar-right {
        display: contents;
    }

    .toolbar::after {
        content: '';
        flex-basis: 100%;
        height: 0;
        order: 10;
    }

    .toolbar .toolbar-divider {
        display: none;
    }

    .toolbar #history-toggle {
        order: 5;
        margin-left: auto;
    }

    #btn-prev { order: 11; margin-top: 4px; }
    #btn-next { order: 12; margin-top: 4px; }
    #error-count { order: 13; margin-top: 4px; }
    #btn-accept-all { order: 14; margin-top: 4px; margin-left: auto; padding: 0 10px; gap: 4px; }

    /* fixed counter width here too (up to "128 pogrešaka") */
    #error-count.error-count-has-errors {
        width: 12ch;
        min-width: 12ch;
    }

    /* Focus mode is a desktop writing aid; keep the phone toolbar short */
    #focus-toggle {
        display: none;
    }

    .user-info > .user-info-label:not(:empty) {
        display: none;
    }

    .user-info:has(> .user-info-label:not(:empty)) {
        border-color: transparent;
        padding: 0 7px;
    }

    /* Phones: drop the paper-sheet frame and run the text edge to edge with
       20px margins, instead of a framed sheet with 10px of padding. */
    /* top: room for two lines of counts in the margin (constant, so the
       overlay never shifts). The html[data-skin] selector outranks the
       Tamno sheet rule, which is also !important. */
    .editor,
    html[data-skin] .editor {
        padding: 64px 20px 20px !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    /* Edge-to-edge sheet: no gap above or below (it meets toolbar and footer) */
    .editor-container {
        --sheet-gap: 0px;
        padding-left: 0;
        padding-right: 0;
    }

    /* no gap above the sheet here: the line sits inside its top margin */
    .doc-info {
        top: calc(var(--toolbar-height) + var(--sheet-gap) + 14px);
        transform: none;
        right: 20px;
        left: 20px;
    }

    /* the margin is short here: keep the line to one row */
    .check-time {
        display: none;
    }
}

/* Touch screens: 44px targets, no keyboard hints */
@media (pointer: coarse) {
    .toolbar-btn {
        height: 44px;
        min-width: 44px;
    }

    .toolbar-btn-icon {
        width: 44px;
    }

    .toolbar-kbd,
    .menu-hint {
        display: none;
    }

    .menu-action-btn {
        min-height: 44px;
    }

    .menu-feedback-link {
        width: 44px;
        height: 44px;
    }

    .menu-nav-btn {
        width: 36px;
        height: 36px;
    }

    /* Header and drawer controls */
    .app-header .tour-btn,
    .app-header .sidebar-toggle,
    .app-header .user-info,
    .drawer-close {
        min-width: 44px;
        min-height: 44px;
    }

    .theme-toggle-btn {
        width: 44px;
        height: 40px;
    }

    /* Small controls keep their look; the hit area grows around them */
    .social-icon,
    .announcement-close {
        width: 44px;
        height: 44px;
        margin: -12px -8px;
    }

    .tos-notice-ok {
        min-height: 44px;
    }
}

/* ----------------------------------------------------------------------------
   19 · Utility Classes
   ---------------------------------------------------------------------------- */
.hidden {
    display: none !important;
}

.invisible {
    visibility: hidden !important;
}

.no-scroll {
    overflow: hidden !important;
}
