/* ============================================================
   style.css – Generator pedagoških bilješki
   Mobile-first, touch-friendly
   ============================================================ */

/* ── VARIJABLE ─────────────────────────────────────────────── */
:root {
    --primary:      #2563eb;
    --primary-dark: #1d4ed8;
    --secondary:    #64748b;
    --success:      #16a34a;
    --danger:       #dc2626;
    --warning:      #d97706;
    --info:         #0891b2;

    --bg:           #f1f5f9;
    --bg-card:      #ffffff;
    --border:       #e2e8f0;
    --text:         #1e293b;
    --text-muted:   #64748b;

    --radius:       0.75rem;
    --radius-sm:    0.375rem;
    --shadow:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);

    /* Ocjene */
    --grade-5: #16a34a;
    --grade-4: #2563eb;
    --grade-3: #d97706;
    --grade-2: #ea580c;
    --grade-1: #dc2626;
}

/* ── RESET & BASE ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; overflow-y: scroll; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── LAYOUT ─────────────────────────────────────────────────── */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

.row-flex { display: flex; align-items: center; flex-wrap: wrap; }
.gap-sm   { gap: 0.5rem; }
.gap-md   { gap: 1rem; }
.wrap     { flex-wrap: wrap; }
.flex-1   { flex: 1; min-width: 0; }
.float-right { float: right; }
.mt-sm    { margin-top: 0.5rem; }
.mt-md    { margin-top: 1rem; }
.mb-sm    { margin-bottom: 0.5rem; }
.hidden   { display: none !important; }
.overflow-x { overflow-x: auto; }

/* ── HEADER (unified with tabs) ─────────────────────────────── */
.app-header {
    background: var(--primary);
    color: #fff;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}
.header-inner {
    display: flex;
    align-items: stretch;
    max-width: 1400px;
    margin: 0 auto;
    height: 52px;
}
.app-title {
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    display: flex;
    align-items: center;
    padding-right: 1rem;
    flex-shrink: 0;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.app-title:hover { opacity: .85; }
.header-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    padding-left: 1rem;
}
.header-limit-badge {
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,.85);
    white-space: nowrap;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,.12);
}
.header-limit-badge.header-limit-low {
    background: rgba(220,38,38,.7);
    color: #fff;
}
.header-username {
    font-size: 0.82rem;
    opacity: 0.85;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.btn-outline-white {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,.55);
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
    line-height: 1.4;
}
.btn-outline-white:hover { background: rgba(255,255,255,.15); }

/* ── HEADER SPACER & RIGHT NAV ─────────────────────────────── */
.header-spacer { flex: 1; }

.header-right-nav {
    display: flex;
    align-items: stretch;
    border-right: 1px solid rgba(255,255,255,.2);
    padding-right: 0.375rem;
    margin-right: 0.375rem;
}

/* ── HEADER TABS (inline in header) ─────────────────────────── */
.header-tabs {
    display: flex;
    align-items: stretch;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.header-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
    flex: 0 0 auto;
    padding: 0 1.1rem;
    border: none;
    background: none;
    color: rgba(255,255,255,.7);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    height: 100%;
    display: flex;
    align-items: center;
}
.tab-btn:hover  { color: #fff; }
.tab-btn.active { color: #fff; border-bottom-color: rgba(255,255,255,.9); }

.tab-content      { display: none; padding: 0.75rem 0 2rem; }
.tab-content.active { display: block; }

/* ── FILTER TABS (Rječnik) ──────────────────────────────────── */
.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: 0.75rem 0;
    align-items: center;
}
.filter-group-label {
    width: 100%;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.5rem;
    padding-bottom: 0.1rem;
    border-bottom: 1px solid var(--border);
}
.filter-btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 2rem;
    background: var(--bg-card);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all .15s;
    touch-action: manipulation;
}
.filter-btn.active,
.filter-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    overflow: hidden;
}
.card-header {
    padding: 0.875rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.card-body { padding: 1rem; }

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    line-height: 1.25;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-secondary { background: var(--secondary); color: #fff; border-color: var(--secondary); }
.btn-secondary:hover:not(:disabled) { background: #475569; }

.btn-outline   { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary); color: #fff; }

.btn-dashed    { background: var(--bg); color: var(--primary); border: 2px dashed var(--border); }
.btn-dashed:hover:not(:disabled) { border-color: var(--primary); background: var(--bg); }

.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }

.btn-full  { width: 100%; }
.btn-large { padding: 1rem 1.5rem; font-size: 1.05rem; border-radius: var(--radius); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font-size: inherit; text-decoration: underline; }

/* ── FORMS ──────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-group label { font-size: 0.85rem; font-weight: 500; color: var(--text); }

.form-control {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    line-height: 1.4;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-control[type="number"] { -moz-appearance: textfield; }
.form-control[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2364748b'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }

/* Ocjene select */
.grade-select { font-weight: 600; }

/* ── ALERTS ─────────────────────────────────────────────────── */
.alert {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.alert-error   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-info    { background: #ecfeff; border-color: #a5f3fc; color: #155e75; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ── BADGES ─────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--border);
    color: var(--text-muted);
}

/* ── OCJENE BADGE ───────────────────────────────────────────── */
.grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    font-size: 1rem;
}
.grade-5 { background: var(--grade-5); }
.grade-4 { background: var(--grade-4); }
.grade-3 { background: var(--grade-3); }
.grade-2 { background: var(--grade-2); }
.grade-1 { background: var(--grade-1); }

/* ── GRADE BUTTONS (Pojmovi) ────────────────────────────────── */
.grade-btn-group {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}
.grade-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 2px solid transparent;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    color: #fff;
    transition: transform .1s, box-shadow .1s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    background: var(--border);
    color: var(--text-muted);
}
.grade-btn:active { transform: scale(0.92); }

.grade-btn[data-grade="5"].selected { background: var(--grade-5); color: #fff; border-color: var(--grade-5); box-shadow: 0 0 0 3px rgba(22,163,74,.25); }
.grade-btn[data-grade="4"].selected { background: var(--grade-4); color: #fff; border-color: var(--grade-4); box-shadow: 0 0 0 3px rgba(37,99,235,.25); }
.grade-btn[data-grade="3"].selected { background: var(--grade-3); color: #fff; border-color: var(--grade-3); box-shadow: 0 0 0 3px rgba(217,119,6,.25); }
.grade-btn[data-grade="2"].selected { background: var(--grade-2); color: #fff; border-color: var(--grade-2); box-shadow: 0 0 0 3px rgba(234,88,12,.25); }
.grade-btn[data-grade="1"].selected { background: var(--grade-1); color: #fff; border-color: var(--grade-1); box-shadow: 0 0 0 3px rgba(220,38,38,.25); }

/* ── POJMOVI LISTA ──────────────────────────────────────────── */
.pojam-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.pojam-row:last-child { border-bottom: none; }
.pojam-input { flex: 1; min-width: 120px; }
.pojam-remove { color: var(--danger); background: none; border: none; cursor: pointer; font-size: 1.2rem; padding: 0.25rem; line-height: 1; flex-shrink: 0; touch-action: manipulation; }
.pojam-tip-btn { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: 1rem; padding: 0.2rem 0.35rem; line-height: 1; flex-shrink: 0; touch-action: manipulation; opacity: 0.6; transition: opacity .15s, border-color .15s; }
.pojam-tip-btn:hover { opacity: 1; border-color: var(--primary); }
.pojam-tip-btn[data-tip="prakticno"] { opacity: 1; border-color: var(--primary); background: var(--primary-light, #e8f4ff); }

/* Zadaci (pismeni) */
.zadatak-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: nowrap;
}
.zadatak-row:last-child { border-bottom: none; }
.zadatak-naziv { flex: 1 1 auto; min-width: 80px; }
.zadatak-bodovi-wrap {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-shrink: 0;
}
.zadatak-slash { flex-shrink: 0; color: var(--text-muted); }
.zadatak-bodovi, .zadatak-max { width: 60px; flex-shrink: 0; }
.zadatak-ocjena-badge { flex-shrink: 0; }
.zadatak-akcije {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* ── SKALA ──────────────────────────────────────────────────── */
.scale-grid  { display: flex; flex-direction: row; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: center; justify-content: center; }
.scale-row   { display: flex; align-items: center; gap: 0.5rem; }
.scale-label { font-size: 0.85rem; color: var(--text-muted); margin-right: 0.25rem; }
.scale-values { font-size: 0.8rem; color: var(--text-muted); }
.scale-input { width: 80px !important; }
.scale-input-static { display: inline-block; padding: 0.5rem 0.75rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); width: 80px; font-size: 0.9rem; }
.link-sm { font-size: 0.8rem; }

/* ── GENERATOR 2-COLUMN LAYOUT ──────────────────────────────── */
.generator-layout {
    display: grid;
    grid-template-columns: 5fr 6fr;
    gap: 1.5rem;
    align-items: start;
}
.generator-form  { min-width: 0; }
#ishodi-container { display: flex; flex-direction: column; gap: 0.5rem; }
.generator-preview {
    position: sticky;
    top: calc(52px + 1rem);
    align-self: start;
}
.preview-card { margin-bottom: 0; }
.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
}
.preview-placeholder span { font-size: 2.5rem; opacity: .35; }
.preview-placeholder p    { font-size: 0.9rem; max-width: 280px; line-height: 1.6; }

/* ── HAMBURGER ─────────────────────────────────────────────── */
.header-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    align-self: center;
    margin-left: 0.25rem;
    -webkit-tap-highlight-color: transparent;
}
.header-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: rgba(255,255,255,.9);
    border-radius: 2px;
    transition: transform .22s ease, opacity .22s ease;
}
.header-hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.header-hamburger.is-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.header-hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── MOBILE NAV ─────────────────────────────────────────────── */
.mobile-nav {
    background: var(--primary-dark);
    border-top: 1px solid rgba(255,255,255,.15);
    padding: 0.375rem 0 0.75rem;
}
.mob-item {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    padding: 0.875rem 1.25rem !important;
    height: auto !important;
    background: none !important;
    border: none !important;
    border-bottom: none !important;
    color: rgba(255,255,255,.82);
    font-size: 0.975rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background .15s;
    flex: unset !important;
    white-space: normal;
}
.mob-item:hover, .mob-item:focus-visible {
    background: rgba(255,255,255,.1) !important;
    color: #fff;
}
.mob-item.active {
    color: #fff;
    font-weight: 600;
    background: rgba(255,255,255,.13) !important;
}
.mob-sep {
    height: 1px;
    background: rgba(255,255,255,.15);
    margin: 0.25rem 1.25rem;
}
.mob-user-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    flex-wrap: wrap;
}
.mob-username {
    color: rgba(255,255,255,.65);
    font-size: 0.875rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── MOD BUTTONS (header) ───────────────────────────────────── */
.header-mod-tabs {
    display: flex;
    align-items: stretch;
    border-left: 1px solid rgba(255,255,255,.2);
    padding-left: 0.25rem;
    margin-left: 0.25rem;
}
.mod-btn {
    flex: 0 0 auto;
    padding: 0 0.9rem;
    border: none;
    background: none;
    color: rgba(255,255,255,.7);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    height: 100%;
    display: flex;
    align-items: center;
}
.mod-btn:hover  { color: #fff; }
.mod-btn.active { color: #fff; border-bottom-color: rgba(255,255,255,.6); }

/* ── MOD TOGGLE – segmented control ────────────────────────── */
.mode-segment-wrap  { margin-bottom: 1rem; }
.mode-segment {
    display: inline-flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
    gap: 2px;
    width: 100%;
}
.mode-seg-label input[type="radio"] { display: none; }
.mode-seg-label {
    flex: 1;
    cursor: pointer;
}
.mode-seg-label span {
    display: block;
    padding: 0.6rem 1rem;
    border-radius: calc(var(--radius) - 2px);
    font-weight: 500;
    font-size: 0.9rem;
    text-align: center;
    color: var(--text-muted);
    transition: all .15s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.mode-seg-label input:checked + span {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow);
    font-weight: 600;
}

/* ocjena row inline */
.ocjena-row {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}
.ocjena-row .predlozena-wrap { margin-top: 0; flex-shrink: 0; }

@media (max-width: 1024px) {
    .generator-layout { grid-template-columns: 1fr; }
    .generator-preview { position: static; max-height: none; }
}

/* ── PREVIEW OUTPUT ─────────────────────────────────────────── */
.preview-output {
    font-family: 'Georgia', serif;
    font-size: 0.95rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    min-height: 80px;
}
.preview-actions {
    display: flex;
    gap: 0.5rem;
}
.preview-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* ── TOKEN CHIP ─────────────────────────────────────────────── */
.token-chip {
    display: inline-block;
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 4px;
    padding: 1px 7px;
    cursor: pointer;
    font-weight: 500;
    font-size: inherit;
    line-height: inherit;
    transition: background .15s, border-color .15s;
    user-select: none;
    outline: none;
}
.token-chip:hover  { background: #bfdbfe; border-color: #93c5fd; }
.token-chip.chip-flash { background: #bbf7d0; border-color: #4ade80; }

/* ── CHIP POPOVER ────────────────────────────────────────────── */
.chip-popover {
    position: absolute;
    z-index: 9999;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,.13);
    padding: 4px;
    min-width: 180px;
    max-width: 360px;
    max-height: 260px;
    overflow-y: auto;
}
.chip-popover.hidden { display: none; }
.chip-option {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 7px 12px;
    cursor: pointer;
    border-radius: 5px;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--text);
}
.chip-option:hover { background: #f1f5f9; }

/* ── PREVIEW UVODNA ─────────────────────────────────────────── */
.preview-uvodna {
    border-radius: 4px;
    padding: 2px 5px;
    margin-bottom: 2px;
    outline: none;
    cursor: text;
    transition: background .15s;
    font-weight: 500;
}
.preview-uvodna:hover { background: #f1f5f9; }
.preview-uvodna:focus { background: #f0f9ff; outline: 1px solid #7dd3fc; }

/* ── NATUKNICA ROW (SortableJS) ──────────────────────────────── */
.natuknice-lista { display: flex; flex-direction: column; gap: 2px; padding-left: .5rem; }
.natuknica-row {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 3px 4px 3px 0;
    border-radius: 5px;
    transition: background .1s;
    flex-wrap: wrap;
}
.natuknica-row:hover { background: #f8fafc; }
.chips-wrap {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}
.preview-uvodna-chip { margin-bottom: 2px; font-weight: 500; display: inline-block; }
.sortable-ghost  { opacity: .35; background: #eff6ff; }
.sortable-chosen { background: #f0f9ff; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.drag-handle {
    cursor: grab;
    color: #cbd5e1;
    font-size: 1rem;
    user-select: none;
    padding: 0 4px 0 0;
    flex-shrink: 0;
    transition: color .12s;
}
.drag-handle:hover  { color: #64748b; }
.drag-handle:active { cursor: grabbing; }

.preview-grupa    { margin-bottom: .25rem; }

/* ── ZAKLJUČAK / PREPORUKA REDOVI ──────────────────────────── */
.zak-lista { display: flex; flex-direction: column; gap: 4px; margin-top: .5rem; }
.zak-row {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 4px;
    border-radius: 5px;
    transition: background .1s;
}
.zak-row:hover { background: #f8fafc; }
.zak-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.8rem;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1;
    flex-shrink: 0;
    transition: color .12s, background .12s;
}
.zak-delete:hover { color: #ef4444; background: #fee2e2; }

/* ── RJEČNIK LISTA ──────────────────────────────────────────── */
.rjecnik-lista { display: flex; flex-direction: column; gap: 0.375rem; }
.rjecnik-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: opacity .2s;
}
.rjecnik-item.inactive { opacity: 0.45; }
.rjecnik-item-tekst { flex: 1; font-size: 0.9rem; }
.rjecnik-badge-sistem { font-size: 0.7rem; color: var(--text-muted); flex-shrink: 0; }
.rjecnik-toggle { flex-shrink: 0; }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: #cbd5e1; border-radius: 22px; transition: .2s;
}
.toggle-slider::before {
    content: ''; position: absolute;
    width: 16px; height: 16px; left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%; transition: .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── PREDLOŽENA OCJENA ──────────────────────────────────────── */
.predlozena-wrap {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.875rem;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* ── MODALS ─────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
.modal-content {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 20px 40px rgba(0,0,0,.2);
    width: min(95vw, 600px);
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 1rem;
    position: sticky;
    top: 0;
    background: var(--bg-card);
}
.modal-body    { padding: 1.25rem; flex: 1; }
.modal-footer  { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: 0.5rem; justify-content: flex-end; }
.modal-close {
    background: none; border: none; cursor: pointer;
    font-size: 1.2rem; color: var(--text-muted);
    padding: 0.25rem 0.5rem; border-radius: var(--radius-sm);
    line-height: 1;
    touch-action: manipulation;
}
.modal-close:hover { background: var(--bg); }

/* ── CUSTOM DIALOG MODAL ─────────────────────────────────────── */
@keyframes dialog-backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes dialog-card-in {
    from { opacity: 0; transform: translate(-50%, -46%) scale(.94); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes dialog-backdrop-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}
@keyframes dialog-card-out {
    from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    to   { opacity: 0; transform: translate(-50%, -46%) scale(.94); }
}

#modal-dialog .modal-backdrop {
    animation: dialog-backdrop-in 180ms ease forwards;
}
#modal-dialog.is-closing .modal-backdrop {
    animation: dialog-backdrop-out 160ms ease forwards;
}
.modal-dialog-content {
    width: min(95vw, 380px);
    padding: 2rem 1.75rem 1.5rem;
    text-align: center;
    gap: 0;
    animation: dialog-card-in 220ms cubic-bezier(.34,1.28,.64,1) forwards;
}
#modal-dialog.is-closing .modal-dialog-content {
    animation: dialog-card-out 160ms ease forwards;
}
.modal-dialog-icon {
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: 0.75rem;
}
.modal-dialog-body p {
    font-size: 0.975rem;
    color: var(--text);
    margin: 0 0 1rem;
    line-height: 1.5;
}
.modal-dialog-body .mt-sm { margin-top: 0.5rem; }
.modal-dialog-footer {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.25rem;
}
.modal-dialog-footer .btn { min-width: 90px; }

/* ── PRIRUČNIK ───────────────────────────────────────────────── */
.prirucnik-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 480px), 1fr));
    gap: 1.25rem;
    margin-top: 1.25rem;
}
.prirucnik-skupina {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
}
.prirucnik-naslov {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 1rem;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: .6rem;
}
.faq-item {
    border-bottom: 1px solid var(--border);
    padding: .1rem 0;
}
.faq-item:last-child { border-bottom: none; }
.faq-item summary {
    cursor: pointer;
    padding: .65rem .25rem;
    font-weight: 600;
    font-size: .9rem;
    color: var(--text);
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    user-select: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: '›';
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: transform 220ms ease;
    flex-shrink: 0;
    transform: rotate(90deg);
}
.faq-item[open] > summary::after {
    transform: rotate(270deg);
}
.faq-item summary:hover { color: var(--primary); }
.faq-body {
    padding: .25rem .25rem 1rem 1rem;
    font-size: .875rem;
    color: var(--text);
    line-height: 1.65;
    animation: faq-open 180ms ease;
}
@keyframes faq-open {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.faq-body p, .faq-body ul, .faq-body ol { margin: 0 0 .6rem; }
.faq-body p:last-child, .faq-body ul:last-child, .faq-body ol:last-child { margin-bottom: 0; }
.faq-body strong { color: var(--text); }
.faq-body ol, .faq-body ul { padding-left: 1.5rem; }
.faq-body li { margin-bottom: .3rem; }

/* ── DATA TABLE ─────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.data-table th {
    text-align: left;
    padding: 0.625rem 0.75rem;
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    white-space: nowrap;
}
.data-table td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:hover td { background: #f8fafc; }
.data-table td .btn { padding: 0.25rem 0.5rem; font-size: 0.75rem; }

/* ── BILJEŠKE LISTA ─────────────────────────────────────────── */
.biljeska-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color .15s;
    margin-bottom: 0.5rem;
}
.biljeska-item:hover { border-color: var(--primary); }
.biljeska-ocjena { flex-shrink: 0; }
.biljeska-info { flex: 1; min-width: 0; }
.biljeska-naslov { font-weight: 500; font-size: 0.9rem; }
.biljeska-meta { font-size: 0.8rem; color: var(--text-muted); }

/* ── AUTH PAGES ─────────────────────────────────────────────── */
.auth-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 1rem; }
.auth-container { width: 100%; max-width: 440px; }
.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 2rem 1.75rem;
}
.auth-logo { text-align: center; margin-bottom: 1.75rem; }
.auth-icon { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; }
.auth-logo h1 { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.auth-logo p  { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.25rem; }
.auth-footer  { text-align: center; margin-top: 1.5rem; font-size: 0.875rem; color: var(--text-muted); }

.auth-card .form-group { margin-bottom: 1rem; }
.auth-card .btn-full   { margin-top: 0.5rem; padding: 0.875rem; font-size: 1rem; }

/* ── LOADING ─────────────────────────────────────────────────── */
.loading { color: var(--text-muted); font-size: 0.875rem; padding: 1rem 0; text-align: center; }
.loading::before { content: '⏳ '; }
.text-muted { color: var(--text-muted); font-size: 0.875rem; }

/* ── POSTAVKE LAYOUT ─────────────────────────────────────────── */
.postavke-container {
    width: 100%;
}
.postavke-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 640px) {
    .postavke-grid-2 { grid-template-columns: 1fr; }
}
.justify-end { justify-content: flex-end; }

/* ── KARTICE MODAL LISTA ────────────────────────────────────── */
.kartica-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.35rem;
    transition: border-color .15s;
}
.kartica-item:hover { border-color: var(--primary); background: #eff6ff; }
.kartica-tip-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 2rem;
    font-weight: 500;
}
.tip-usmeni { background: #eff6ff; color: var(--primary); }
.tip-pismeni { background: #fef9c3; color: #854d0e; }

/* ── KARTICE ACCORDION (Postavke) ────────────────────────────── */
.kartice-tip-details,
.kartice-cjelina-details { margin-bottom: 0.25rem; }

.kartice-tip-details > summary.kartice-tip-summary {
    list-style: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0.7rem 0 0.3rem;
    border-top: 1px solid var(--border);
    user-select: none;
}
.kartice-tip-details > summary.kartice-tip-summary::before { content: '▶ '; font-size:.65rem; }
.kartice-tip-details[open] > summary.kartice-tip-summary::before { content: '▼ '; }

.kartice-cjelina-details { margin-left: 0.5rem; }
.kartice-cjelina-details > summary.kartice-cjelina-summary {
    list-style: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    padding: 0.45rem 0.25rem;
    user-select: none;
}
.kartice-cjelina-details > summary.kartice-cjelina-summary::before { content: '▶ '; font-size:.65rem; color: var(--text-muted); }
.kartice-cjelina-details[open] > summary.kartice-cjelina-summary::before { content: '▼ '; }
.kartice-cjelina-details .kartica-item { margin-left: 1rem; }

/* ── KARTICE SEARCH INPUT ────────────────────────────────────── */
.kartice-search-input {
    max-width: 180px;
    font-size: 0.82rem;
    padding: .25rem .6rem;
    height: auto;
}

/* ── UČITAJ PREDLOŽAK MODAL ──────────────────────────────────── */
.predlozak-group-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    padding: 0.85rem 0 0.35rem;
    border-top: 1px solid var(--border);
    margin-top: 0.25rem;
}
.predlozak-group-header:first-child {
    border-top: none;
    padding-top: 0.1rem;
}
.predlozak-load-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background .12s;
}
.predlozak-load-row:hover { background: var(--bg-muted); }
.predlozak-load-icon { font-size: 1rem; flex-shrink: 0; }
.predlozak-load-naziv {
    flex: 1;
    min-width: 0;
    font-size: 0.9rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .header-tabs,
    .header-mod-tabs,
    .header-right-nav,
    .header-user    { display: none !important; }
    .header-hamburger { display: flex; }
    .app-title { padding-right: 0; }
}

@media (max-width: 640px) {
    .app-title { font-size: 0.95rem; }
    .tab-btn   { padding: 0.75rem 0.875rem; font-size: 0.8rem; }
    .card-body { padding: 0.75rem; }
    .auth-card { padding: 1.5rem 1.25rem; }
    .modal-content { width: 98vw; }
    .btn-large { font-size: 1rem; padding: 0.875rem 1.25rem; }
    .data-table { font-size: 0.8rem; }
    .data-table th, .data-table td { padding: 0.5rem 0.5rem; }

    /* Pojam-row: naziv na prvom redu, gumbi na drugom */
    .pojam-row {
        flex-wrap: wrap;
        gap: 0.375rem 0.25rem;
    }
    .pojam-input {
        flex: 1 1 100%;
        min-width: 0;
    }
    .grade-btn-group {
        flex: 1;
        justify-content: flex-start;
    }
    .grade-btn {
        width: 2.4rem;
        height: 2.4rem;
        font-size: 0.875rem;
    }
    .pojam-tip-btn, .pojam-remove { flex-shrink: 0; }

    /* Zadatak-row: jedan red na mobilnom */
    .zadatak-row { flex-wrap: nowrap; gap: 0.3rem; }
    .zadatak-naziv { flex: 1 1 0; min-width: 60px; }
    .zadatak-bodovi-wrap { flex-shrink: 0; gap: 0.2rem; }
    .zadatak-bodovi, .zadatak-max { width: 46px; padding: 0.45rem 0.25rem; font-size: 0.78rem; }
}

/* ── UTILITY ─────────────────────────────────────────────────── */
.mt-xs  { margin-top: 0.25rem; }
.mt-sm  { margin-top: 0.5rem; }
.mt-md  { margin-top: 1rem; }
.mb-sm  { margin-bottom: 0.5rem; }
.mb-md  { margin-bottom: 1rem; }
.flex-1 { flex: 1; }
.row-flex { display: flex; align-items: center; }
.gap-sm  { gap: 0.5rem; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); }

/* ── STIL SELECTOR CARD ─────────────────────────────────────── */
.stil-selector-card {
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
}
.stil-selector-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}
.stil-selector-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

/* ── PREVIEW – contenteditable ──────────────────────────────── */
.preview-output[contenteditable="true"] {
    cursor: text;
}
.preview-output[contenteditable="true"]:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    background: #fff;
}
.preview-output[contenteditable="true"]:not(:empty)::after {
    content: '';
}

/* ── REGENERATE BUTTON ──────────────────────────────────────── */
#btn-regeneriraj {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

/* ── PREDLOŠCI TAB ──────────────────────────────────────────── */
.predlozak-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    border-bottom: 1px solid var(--border);
    transition: background .12s;
}
.predlozak-item:last-child { border-bottom: none; }
.predlozak-item:hover:not(.predlozak-default) { background: #f8fafc; }
.predlozak-default {
    background: #f8fafc;
    opacity: 0.75;
    border-bottom: 1px solid var(--border);
}
.predlozak-naziv {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text);
}
.predlozak-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}
.predlozak-actions {
    display: flex;
    gap: 0.375rem;
    flex-shrink: 0;
}
.format-badge, .ton-badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 2rem;
    font-size: 0.72rem;
    font-weight: 500;
}
.format-badge-strukturirano { background: #dbeafe; color: #1d4ed8; }
.format-badge-kompaktno     { background: #dcfce7; color: #166534; }
.ton-badge-formalan  { background: #f1f5f9; color: #475569; }
.ton-badge-topliji   { background: #fef3c7; color: #92400e; }
.ton-badge-pohvalan  { background: #d1fae5; color: #065f46; }
.ton-badge-vlastiti  { background: #ede9fe; color: #5b21b6; }

/* ── FORMAT CARDS (radio selectors) ────────────────────────── */
.format-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
}
.format-card {
    position: relative;
    cursor: pointer;
    display: block;
}
.format-card input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.format-card-inner {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    transition: border-color .15s, background .15s, box-shadow .15s;
    height: 100%;
}
.format-card:hover .format-card-inner { border-color: var(--primary); background: #f0f7ff; }
.format-card input:checked + .format-card-inner {
    border-color: var(--primary);
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.format-card-icon  { font-size: 1.5rem; margin-bottom: 0.375rem; }
.format-card-title { font-weight: 600; font-size: 0.9rem; color: var(--text); margin-bottom: 0.25rem; }
.format-card-desc  { font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; }

@media (max-width: 480px) {
    .format-cards { grid-template-columns: 1fr; }
}

/* ── THEME STYLING (usmeni/pismeni) ────────────────────── */
