/* מבשלים במתמטיקה — ספר מתכונים מודפס, לא אפליקציה. */

:root {
    --paper: #FEF3E2;
    --paper-light: #FFF9EF;
    --paper-deep: #FBE5C4;
    --honey: #F4AE52;
    --rust: #D4621A;
    --rust-dark: #A9480F;
    --ink: #2A1A0E;
    --ink-soft: #5C4330;
    --ink-faint: #8A6F58;
    --rule: #E8CDA3;
    --danger: #9B2C10;

    --font-head: 'Frank Ruhl Libre', 'David', serif;
    --font-body: 'Assistant', 'Segoe UI', Arial, sans-serif;
    --font-math: 'STIX Two Text', 'Cambria Math', 'Times New Roman', serif;

    --measure: 46rem;
    --wide: 68rem;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.7;
    overflow-x: hidden;
}

h1, h2, h3 {
    font-family: var(--font-head);
    line-height: 1.25;
    margin: 0;
    font-weight: 700;
}

a { color: var(--rust-dark); text-underline-offset: 3px; }
a:hover { color: var(--ink); }

:focus-visible {
    outline: 3px solid var(--honey);
    outline-offset: 2px;
}

img { max-width: 100%; }

code {
    font-family: var(--font-math);
    background: var(--paper-deep);
    padding: 0 .3em;
    border-radius: 3px;
}

kbd {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: .95em;
    border: 1px solid var(--ink-soft);
    border-bottom-width: 3px;
    border-radius: 4px;
    padding: 0 .45em;
    background: var(--paper-light);
}

/* ---------- סרגל עליון ---------- */

.topbar {
    border-bottom: 4px double var(--ink);
    background: var(--paper);
}

.topbar-inner {
    max-width: var(--wide);
    margin: 0 auto;
    padding: .7rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem 1.5rem;
}

.brand {
    font-family: var(--font-head);
    font-weight: 900;
    font-size: 1.35rem;
    color: var(--ink);
    text-decoration: none;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1.25rem;
    align-items: center;
}

.site-nav a, .btn-link {
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
    background: none;
    border: 0;
    padding: .4rem 0;
    cursor: pointer;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.site-nav a:hover, .btn-link:hover { color: var(--rust); text-decoration: underline; }

body.is-offline .topbar { border-bottom-color: var(--danger); }

/* ---------- עמוד ---------- */

.page {
    max-width: var(--wide);
    margin: 0 auto;
    padding: 1.5rem 1rem 4rem;
}

.loading {
    text-align: center;
    color: var(--ink-soft);
    padding: 4rem 1rem;
    font-size: 1.15rem;
}

.lead {
    font-size: 1.2rem;
    color: var(--ink-soft);
    margin: .5rem 0 0;
}

.empty { color: var(--ink-faint); }

.section-label {
    font-family: var(--font-body);
    font-size: .85rem;
    font-weight: 700;
    letter-spacing: .08em;
    color: var(--rust-dark);
    margin: 0 0 .5rem;
}

/* ---------- כפתורים ---------- */

.btn {
    font: inherit;
    font-weight: 700;
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: .45rem 1.3rem;
    border-radius: 4px;
    border: 2px solid var(--ink);
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    transition: background-color .12s, color .12s;
}

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

.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover:not(:disabled) { background: #46301f; color: var(--paper); }

.btn-secondary { background: transparent; color: var(--ink); }
.btn-secondary:hover:not(:disabled) { background: var(--paper-deep); color: var(--ink); }

.btn-accent { background: var(--rust); border-color: var(--rust); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--rust-dark); border-color: var(--rust-dark); color: #fff; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #7a220b; color: #fff; }

.btn-danger-outline { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger-outline:hover { background: #f8dccf; color: var(--danger); }

.btn-text {
    font: inherit;
    font-size: .95rem;
    font-weight: 600;
    background: none;
    border: 0;
    padding: .35rem .1rem;
    min-height: 40px;
    color: var(--rust-dark);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.btn-text:disabled { color: var(--ink-faint); opacity: .5; cursor: default; text-decoration: none; }
.btn-text.danger { color: var(--danger); }

/* ---------- דף בית / התחברות ---------- */

.hero, .login {
    max-width: var(--measure);
    margin: 1.5rem auto 2.5rem;
    text-align: center;
}

.brand-big {
    font-size: clamp(2.4rem, 7vw, 4rem);
    font-weight: 900;
    letter-spacing: -.01em;
}

.motto {
    font-family: var(--font-head);
    font-size: clamp(1.15rem, 3vw, 1.45rem);
    font-weight: 500;
    color: var(--rust-dark);
    margin: .5rem 0 0;
}

.hero-note {
    margin: 1.4rem auto 0;
    max-width: 36rem;
    color: var(--ink-soft);
    padding-top: 1.2rem;
    border-top: 1px solid var(--rule);
}

.chapters { max-width: 52rem; margin: 0 auto; }

.toc { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }

.toc li { border-bottom: 1px dashed var(--rule); }

.toc-row {
    display: grid;
    grid-template-columns: 5.5rem 1fr auto;
    gap: 1rem;
    align-items: baseline;
    padding: 1.15rem .25rem;
    color: var(--ink);
    text-decoration: none;
}

.toc-row:hover { background: var(--paper-light); color: var(--ink); }
.toc-row:hover .toc-name { color: var(--rust); }

.toc-num {
    font-family: var(--font-head);
    color: var(--rust);
    font-weight: 700;
    font-size: 1.05rem;
}

.toc-main { display: flex; flex-direction: column; gap: .15rem; }

.toc-name {
    font-family: var(--font-head);
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.2;
}

.toc-desc { color: var(--ink-soft); }
.toc-subs { font-size: .95rem; color: var(--ink-faint); }

.toc-count {
    font-size: .95rem;
    color: var(--ink-soft);
    white-space: nowrap;
}

.login { max-width: 24rem; text-align: center; }

.login-form {
    margin-top: 2rem;
    text-align: right;
    background: var(--paper-light);
    border: 1px solid var(--rule);
    border-top: 4px solid var(--rust);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-form .btn { width: 100%; }

.form-error {
    margin: 0;
    color: var(--danger);
    font-weight: 600;
}

.message-screen {
    max-width: var(--measure);
    margin: 3rem auto;
    padding: 1.5rem;
    background: var(--paper-light);
    border: 1px solid var(--rule);
    border-top: 4px solid var(--rust);
}

.message-screen h1 { font-size: 1.8rem; margin-bottom: .75rem; }
.message-screen .btn { margin-top: 1rem; }

/* ---------- Breadcrumb ---------- */

.breadcrumb ol {
    list-style: none;
    margin: 0 0 1.25rem;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .2rem;
    font-size: 1rem;
    color: var(--ink-soft);
}

.breadcrumb li { display: inline-flex; align-items: center; }

.breadcrumb li + li::before {
    content: "←";
    margin-inline: .45rem;
    color: var(--honey);
    font-weight: 700;
}

.breadcrumb a { color: var(--ink-soft); }
.breadcrumb a:hover { color: var(--rust); }
.breadcrumb [aria-current] { color: var(--ink); font-weight: 700; }

/* ---------- עמוד קטגוריה ---------- */

.page-head {
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--ink);
}

.page-head h1 { font-size: clamp(2rem, 5vw, 2.8rem); }

.group { margin-top: 2.25rem; }

.group h2 {
    font-size: 1.5rem;
    margin-bottom: .9rem;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.group h2::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid var(--rule);
}

.group h2 a { color: var(--ink); text-decoration: none; }
.group h2 a:hover { color: var(--rust); }

/* ---------- כרטיסי מתכון (כרטיסיות לימוד) ---------- */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
    gap: 1rem;
}

.card {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    background: var(--paper-light);
    border: 1px solid var(--rule);
    border-top: 3px solid var(--rust);
    border-radius: 2px;
    padding: 1rem 1.1rem;
}

.card-img {
    width: 76px;
    height: 57px;
    flex: none;
    object-fit: contain;
}

.card-body { min-width: 0; flex: 1; }

.card h3 { font-size: 1.2rem; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a:hover { color: var(--rust); }

.card-path {
    margin: .25rem 0 0;
    font-size: .9rem;
    color: var(--ink-faint);
}

.card-meta {
    margin: .25rem 0 0;
    font-size: .9rem;
    color: var(--ink-soft);
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}
.card-meta:empty { display: none; }

.card-open {
    display: inline-block;
    margin-top: .5rem;
    font-weight: 700;
    font-size: 1rem;
    padding: .3rem 0;
}

.tag {
    font-size: .8rem;
    font-weight: 700;
    background: var(--paper-deep);
    color: var(--rust-dark);
    border: 1px solid var(--honey);
    border-radius: 2px;
    padding: 0 .45rem;
}

/* ---------- דף מתכון ---------- */

.recipe { max-width: var(--measure); margin: 0 auto; }

.narrow { max-width: var(--measure); margin: 0 auto; }

.recipe-head {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    justify-content: space-between;
    padding-bottom: 1.25rem;
    border-bottom: 4px double var(--ink);
    margin-bottom: 2rem;
}

.recipe-head h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); }

.recipe-meta {
    margin: 0 0 .35rem;
    font-size: .95rem;
    color: var(--ink-soft);
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    align-items: center;
}
.recipe-meta:empty { display: none; }

.recipe-img { width: 140px; height: 105px; object-fit: contain; flex: none; }

/* שלבים: מספור בצד, קו שמחבר בין השלבים — העין עוברת לפי הסדר */

.steps {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

.steps::before {
    content: "";
    position: absolute;
    inset-inline-start: 21px;
    top: 24px;
    bottom: 24px;
    border-inline-start: 2px dashed var(--honey);
}

.step {
    position: relative;
    padding-inline-start: 64px;
    margin-bottom: 1.75rem;
}

.step-num {
    position: absolute;
    inset-inline-start: 0;
    top: .35rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--paper);
    border: 2px solid var(--rust);
    color: var(--rust);
    font-family: var(--font-head);
    font-weight: 900;
    font-size: 1.4rem;
    display: grid;
    place-items: center;
    line-height: 1;
}

.step-inner {
    background: var(--paper-light);
    border: 1px solid var(--rule);
    padding: 1.1rem 1.35rem 1.25rem;
}

.step-head {
    margin-bottom: .75rem;
    padding-bottom: .6rem;
    border-bottom: 1px solid var(--rule);
}

.step-kicker {
    margin: 0;
    font-size: .85rem;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--rust-dark);
}

.step-head h2 { font-size: 1.65rem; }

.step-question {
    margin: .1rem 0 0;
    color: var(--ink-faint);
    font-size: 1rem;
}

.step-content p, .example p { margin: .35rem 0; }
.step-content ul, .example ul { margin: .35rem 0; padding-inline-start: 1.4rem; }

.empty-step {
    color: var(--ink-faint);
    font-style: italic;
}

/* נוסחאות */

.math {
    font-family: var(--font-math);
    font-size: 1.08em;
    unicode-bidi: isolate;
    background: rgba(244, 174, 82, .18);
    padding: 0 .3em;
    border-radius: 3px;
    white-space: nowrap;
}

.math sup, .work-line sup { font-size: .7em; line-height: 0; }

.work {
    margin: .6rem 0;
    padding: .6rem 1rem;
    background: var(--paper-deep);
    border-inline-start: 4px solid var(--honey);
    overflow-x: auto;
}

.work-line {
    font-family: var(--font-math);
    font-size: 1.22rem;
    line-height: 1.75;
    text-align: right;
    white-space: pre;
    unicode-bidi: isolate;
}

/* דוגמאות */

.example {
    margin-top: 1rem;
    padding: .8rem 1rem;
    border: 1px dashed var(--rust);
    background: var(--paper);
}

.example-label {
    margin: 0 0 .3rem !important;
    font-weight: 700;
    color: var(--rust-dark);
    font-size: .98rem;
}

.recipe-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin: 2rem 0 0;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
}

/* Gemini */

.gemini {
    margin-top: 2.5rem;
    padding: 1.4rem 1.5rem 1.5rem;
    background: var(--paper-deep);
    border: 2px solid var(--ink);
}

.gemini h2 { font-size: 1.55rem; }
.gemini > p { margin: .35rem 0 1rem; color: var(--ink-soft); }

.status-box {
    margin-top: 1rem;
    padding: 1rem 1.15rem;
    background: var(--paper-light);
    border-inline-start: 5px solid var(--rust);
}
.status-box.warn { border-inline-start-color: var(--danger); }
.status-box p { margin: .25rem 0; }

.status-title {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--ink);
}

.status-main { font-size: 1.1rem; }
.paste-hint { color: var(--ink-soft); }

.prompt-fallback {
    width: 100%;
    margin-top: .5rem;
    font: inherit;
    font-size: .95rem;
    padding: .6rem;
    border: 1px solid var(--ink-soft);
    background: #fff;
}

/* ---------- עורך ---------- */

.editor { max-width: var(--measure); margin: 0 auto; display: flex; flex-direction: column; gap: 1.25rem; }

.editor-head { border-bottom: 2px solid var(--ink); padding-bottom: .9rem; }
.editor-head h1 { font-size: clamp(1.7rem, 4.5vw, 2.3rem); }
.kicker { margin: 0 0 .2rem; color: var(--rust-dark); font-weight: 600; font-size: .98rem; }

.editor-block {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field > span { font-weight: 700; font-size: 1rem; }
.field em { font-weight: 400; font-style: normal; color: var(--ink-faint); }

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

input[type="text"], input[type="email"], input[type="password"], input[type="url"], select, textarea {
    font: inherit;
    font-size: 1.05rem;
    color: var(--ink);
    background: #fff;
    border: 1.5px solid #CFAF85;
    border-radius: 3px;
    padding: .55rem .7rem;
    width: 100%;
    min-height: 46px;
}

textarea { line-height: 1.6; resize: vertical; }

input:focus, select:focus, textarea:focus {
    border-color: var(--rust);
    outline: 2px solid var(--honey);
    outline-offset: 0;
}

.invalid { border-color: var(--danger) !important; background: #fff4ef !important; }

.form-errors {
    background: #fbe3d8;
    border-inline-start: 5px solid var(--danger);
    padding: .8rem 1rem;
    color: var(--danger);
}
.form-errors ul { margin: .3rem 0 0; padding-inline-start: 1.3rem; }

.image-preview img { width: 120px; height: 90px; object-fit: contain; border: 1px solid var(--rule); background: var(--paper-light); }
.image-preview:empty { display: none; }

.syntax-help {
    background: var(--paper-light);
    border: 1px solid var(--rule);
    padding: .6rem 1rem;
    font-size: 1rem;
}
.syntax-help summary { cursor: pointer; font-weight: 700; color: var(--rust-dark); min-height: 32px; }
.syntax-help ul { margin: .5rem 0 .2rem; padding-inline-start: 1.2rem; }
.syntax-help li { margin: .2rem 0; }

.editor-steps { display: flex; flex-direction: column; gap: 1rem; }

.step-editor {
    margin: 0;
    background: var(--paper-light);
    border: 1px solid var(--rule);
    border-top: 3px solid var(--rust);
    padding: .8rem 1.1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: .8rem;
    min-width: 0;
}

.step-editor legend {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.25rem;
    padding: 0 .4rem;
    background: var(--paper);
}

.step-tools { display: flex; flex-wrap: wrap; gap: .2rem 1rem; }

.examples-editor {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    align-items: flex-start;
}

.example-editor {
    width: 100%;
    border: 1px dashed var(--rust);
    padding: .7rem .9rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    background: var(--paper);
}

.example-editor-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

.add-step { align-self: flex-start; }

.editor-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    gap: .75rem;
    padding: .9rem 0;
    background: var(--paper);
    border-top: 2px solid var(--ink);
    z-index: 5;
}

/* ---------- ניהול ---------- */

.manage-block { margin-top: 2rem; }
.manage-block h2 { font-size: 1.45rem; margin-bottom: .6rem; }
.manage-block .count { color: var(--ink-faint); font-family: var(--font-body); font-size: 1rem; font-weight: 400; }

.manage-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.manage-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .2rem 1rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--rule);
}
.manage-list li > a:first-child { font-weight: 700; }
.manage-path { color: var(--ink-faint); font-size: .92rem; flex: 1; }

.danger-zone {
    margin-top: 3rem;
    padding: 1.2rem 1.4rem;
    border: 2px solid var(--danger);
    background: #fdeee6;
}
.danger-zone p { margin: .3rem 0 1rem; }

/* ---------- דיאלוג אישור והודעות ---------- */

dialog.confirm {
    border: 2px solid var(--ink);
    border-top: 5px solid var(--danger);
    background: var(--paper-light);
    color: var(--ink);
    padding: 1.4rem 1.5rem;
    max-width: min(32rem, calc(100vw - 2rem));
    font-family: var(--font-body);
}
dialog.confirm::backdrop { background: rgba(42, 26, 14, .45); }
dialog.confirm h2 { font-size: 1.5rem; margin-bottom: .5rem; }
.confirm-body p { margin: .4rem 0; }
.confirm-body ul { margin: .3rem 0; padding-inline-start: 1.3rem; }
.confirm-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.2rem; }

.toasts {
    position: fixed;
    inset-inline: 0;
    top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    padding: 0 1rem;
    pointer-events: none;
    z-index: 50;
}

.toast {
    max-width: 34rem;
    background: var(--ink);
    color: var(--paper);
    padding: .75rem 1.1rem;
    border-radius: 4px;
    font-weight: 600;
    pointer-events: auto;
    border-inline-start: 5px solid var(--honey);
}
.toast-error { background: var(--danger); border-inline-start-color: #fff; }

.noscript { text-align: center; padding: 2rem; }

/* ---------- מסכים קטנים ---------- */

@media (max-width: 640px) {
    body { font-size: 1.06rem; }

    .page { padding: 1rem .9rem 3rem; }

    .toc-row { grid-template-columns: 1fr; gap: .1rem; padding: 1rem .1rem; }
    .toc-name { font-size: 1.45rem; }

    .cards { grid-template-columns: 1fr; }

    .recipe-head { flex-direction: column-reverse; gap: .75rem; }
    .recipe-img { width: 104px; height: 78px; }

    .steps::before { inset-inline-start: 15px; }
    .step { padding-inline-start: 44px; }
    .step-num { width: 32px; height: 32px; font-size: 1.05rem; }
    .step-inner { padding: .9rem 1rem 1rem; }
    .step-head h2 { font-size: 1.4rem; }

    .work { padding: .5rem .75rem; }
    .work-line { font-size: 1.1rem; }

    .gemini { padding: 1.1rem 1rem; }
    .gemini .btn { width: 100%; }

    .field-row { grid-template-columns: 1fr; }

    .recipe-actions .btn, .editor-actions .btn { flex: 1; }
}

@media print {
    .topbar, .recipe-actions, .gemini, .toasts { display: none; }
    body { background: #fff; }
}

/* =====================================================================
   נוסחאות (MathQuill)
   ===================================================================== */

.mq-math-mode, .mq-editable-field {
    font-family: var(--font-math);
}

.work-line .mq-math-mode {
    font-size: 1.15rem;
    color: var(--ink);
}

.work-line { white-space: normal; padding: .15rem 0; }

/* =====================================================================
   רשימת שורות בעורך — בהשראת רשימת הביטויים של Desmos
   ===================================================================== */

.exprlist {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid #CFAF85;
    border-radius: 3px;
    background: #fff;
}

.expr-row {
    display: grid;
    grid-template-columns: 2.4rem 1fr auto;
    align-items: stretch;
    border-bottom: 1px solid var(--rule);
    min-height: 52px;
}
.expr-row:last-child { border-bottom: 0; }

.expr-num {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: .85rem;
    font-size: .85rem;
    font-weight: 700;
    color: var(--ink-faint);
    background: var(--paper-light);
    border-inline-end: 4px solid var(--rust);
}
.expr-text .expr-num { border-inline-end-color: var(--honey); }
.expr-image .expr-num { border-inline-end-color: var(--ink-soft); }

.expr-row:focus-within .expr-num { background: var(--paper-deep); color: var(--ink); }

.expr-body { min-width: 0; padding: .45rem .7rem; display: flex; align-items: center; }

.expr-body .mq-editable-field {
    display: block;
    width: 100%;
    min-height: 2.2rem;
    padding: .35rem .2rem;
    border: 0;
    font-size: 1.25rem;
    color: var(--ink);
    direction: ltr;
    text-align: left;
    overflow-x: auto;
    overflow-y: hidden;
}
.expr-body .mq-editable-field.mq-focused {
    box-shadow: none;
    border: 0;
}
.expr-row:focus-within { background: #fffdf8; }

.expr-body textarea.expr-text,
.expr-body .latex-fallback {
    border: 0;
    background: transparent;
    padding: .4rem .2rem;
    min-height: 2.2rem;
    resize: none;
    overflow: hidden;
}
.expr-body textarea.expr-text:focus,
.expr-body .latex-fallback:focus { outline: none; }

.expr-imagebox { display: flex; gap: .8rem; align-items: flex-start; width: 100%; flex-wrap: wrap; }
.expr-imagebox img { max-width: 180px; max-height: 140px; object-fit: contain; border: 1px solid var(--rule); background: var(--paper-light); }
.expr-image-side { flex: 1; min-width: 10rem; display: flex; flex-direction: column; gap: .3rem; align-items: flex-start; }
.expr-caption { min-height: 40px !important; font-size: 1rem !important; }

.uploading { color: var(--ink-soft); margin: .3rem 0; font-style: italic; }

.expr-tools {
    display: flex;
    align-items: flex-start;
    gap: 0;
    padding: .45rem .3rem 0;
    opacity: .35;
}
.expr-row:hover .expr-tools, .expr-row:focus-within .expr-tools { opacity: 1; }
.expr-tools button {
    font: inherit;
    font-size: 1rem;
    width: 34px;
    height: 34px;
    border: 0;
    background: none;
    color: var(--ink-soft);
    cursor: pointer;
    border-radius: 3px;
}
.expr-tools button:hover:not(:disabled) { background: var(--paper-deep); color: var(--ink); }
.expr-tools button[data-act="del"]:hover { color: var(--danger); }
.expr-tools button:disabled { opacity: .3; cursor: default; }

.expr-empty { margin: .4rem 0 0; color: var(--ink-faint); font-size: .95rem; font-style: italic; }

.expr-add { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.expr-add button {
    font: inherit;
    font-size: .95rem;
    font-weight: 700;
    min-height: 38px;
    padding: .2rem .8rem;
    border: 1.5px dashed var(--rust);
    border-radius: 3px;
    background: transparent;
    color: var(--rust-dark);
    cursor: pointer;
}
.expr-add button:hover { background: var(--paper-deep); border-style: solid; }

/* לוח המקשים — מופיע כשעומדים בתוך נוסחה */

.mathpad {
    display: flex;
    gap: .3rem;
    overflow-x: auto;
    padding: .1rem 0 .6rem;
    margin-bottom: .6rem;
    border-bottom: 1px solid var(--rule);
    scrollbar-width: thin;
}
.mathpad[hidden] { display: none !important; }
.mathpad button {
    flex: none;
    font-family: var(--font-math);
    font-size: 1.05rem;
    min-width: 44px;
    height: 40px;
    padding: 0 .55rem;
    border: 1px solid #CFAF85;
    border-radius: 4px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}
.mathpad button:hover { background: var(--paper-deep); }
.mathpad button:active { background: var(--honey); }

.editor-actions { flex-direction: column; }
.editor-buttons { display: flex; gap: .75rem; }

.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }

/* תמונות בתוך שלב */

.step-figure { margin: .8rem 0; }
.step-figure img {
    display: block;
    max-width: 100%;
    max-height: 420px;
    object-fit: contain;
    border: 1px solid var(--rule);
    background: #fff;
}
.step-figure figcaption { font-size: .95rem; color: var(--ink-soft); margin-top: .3rem; }

/* הרשמה */

.login-title { font-size: 1.5rem; margin: 0; }
.login-switch { margin: 0; text-align: center; color: var(--ink-soft); }
.btn-link-inline {
    font: inherit;
    font-weight: 700;
    color: var(--rust-dark);
    background: none;
    border: 0;
    padding: .3rem .2rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.login-note { margin: 0; font-size: .92rem; color: var(--ink-faint); text-align: center; }
.field em { font-weight: 400; font-style: normal; color: var(--ink-faint); }

@media (max-width: 640px) {
    .help-cols { grid-template-columns: 1fr; }
    .expr-row { grid-template-columns: 2rem 1fr auto; }
    .expr-tools { flex-direction: column; padding-top: .2rem; opacity: 1; }
    .expr-tools button { width: 32px; height: 28px; }
    .expr-imagebox img { max-width: 100%; }
    .editor-buttons .btn { flex: 1; }
}

/* =====================================================================
   תרגיל בשלבים
   ===================================================================== */

.hero-cta { margin: 1.6rem 0 0; }

.card-step {
    margin: 0 0 .1rem;
    font-size: .85rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--rust-dark);
}

.group-note { margin: -.5rem 0 .8rem; color: var(--ink-faint); font-size: .95rem; }
.group-add { display: inline-block; margin-top: .7rem; font-weight: 700; font-size: 1rem; padding: .3rem 0; }
.node-add { margin-top: 2.5rem; }

/* בעורך */
.exercise-box {
    display: grid;
    grid-template-columns: 11rem 1fr;
    gap: .4rem 1rem;
    align-items: start;
    padding: .8rem 1rem;
    background: var(--paper-light);
    border: 1px dashed var(--honey);
}
.exercise-hint { font-size: .95rem; color: var(--ink-soft); padding-top: 1.7rem; }
.exercise-hint p { margin: 0 0 .3rem; }
.exercise-existing span { white-space: nowrap; }
.exercise-warn { color: var(--danger); font-weight: 600; }
.exercise-preview strong { color: var(--ink); }

/* בדף המתכון */
.exercise-nav {
    margin: -0.75rem 0 2rem;
    padding: .8rem 1.1rem;
    background: var(--paper-light);
    border: 1px solid var(--rule);
    border-inline-start: 4px solid var(--honey);
}
.exercise-nav-title { margin: 0 0 .35rem; font-size: .9rem; font-weight: 700; color: var(--rust-dark); }
.exercise-nav ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; }
.exercise-nav li { font-size: 1rem; }
.exercise-nav li[aria-current] span { font-weight: 700; color: var(--ink); border-bottom: 2px solid var(--rust); }

.exercise-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: .5rem 0 0;
}
.exercise-pager a {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    padding: .8rem 1rem;
    border: 2px solid var(--ink);
    text-decoration: none;
    color: var(--ink);
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.1rem;
    background: var(--paper-light);
}
.exercise-pager a:hover { background: var(--paper-deep); color: var(--ink); }
.exercise-pager small { font-family: var(--font-body); font-size: .85rem; font-weight: 700; color: var(--rust-dark); }
.pager-next { text-align: left; grid-column: 2; }
.pager-prev { grid-column: 1; }

@media (max-width: 640px) {
    .exercise-box { grid-template-columns: 1fr; }
    .exercise-hint { padding-top: 0; }
    .exercise-pager { grid-template-columns: 1fr; }
    .pager-next, .pager-prev { grid-column: auto; text-align: right; }
}
