/* Al-Fahd (الفهد) — palm-green ink, cheetah amber used sparingly, grey-green paper. */
:root {
    --bg: #f2f4f1;
    --panel: #ffffff;
    --panel-2: #f7f9f6;
    --ink: #16211f;
    --muted: #5d6b67;
    --line: #dce2de;
    --line-strong: #c3ccc7;
    --accent: #0f6b5e;
    --accent-ink: #ffffff;
    --accent-soft: #e2f0ec;
    --amber: #d99a1e;
    --amber-soft: #fbf0d9;
    --side: #0e3b36;
    --side-2: #0a2e2a;
    --side-ink: #b9d3cc;
    --side-hi: #ffffff;
    --ok: #18794e;
    --ok-soft: #e4f4ea;
    --warn: #8a5a00;
    --warn-soft: #fcf1d6;
    --bad: #b42318;
    --bad-soft: #fcebe9;
    --cell: #edf4f1;
    --lesson-l: 94%;
    --lesson-s: 55%;
    --lesson-edge-l: 38%;
    --radius-s: 6px;
    --radius: 10px;
    --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
    --focus: 0 0 0 3px rgba(217, 154, 30, .45);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1513;
        --panel: #15201d;
        --panel-2: #192622;
        --ink: #e5ece9;
        --muted: #93a49f;
        --line: #26342f;
        --line-strong: #34463f;
        --accent: #4fbfa8;
        --accent-ink: #062520;
        --accent-soft: #173832;
        --amber: #f0b544;
        --amber-soft: #352914;
        --side: #08201d;
        --side-2: #061815;
        --side-ink: #9dbab2;
        --ok: #4cc38a;
        --ok-soft: #13301f;
        --warn: #e8b339;
        --warn-soft: #33290f;
        --bad: #ff7a6b;
        --bad-soft: #3a1714;
        --cell: #1b2b27;
        --lesson-l: 20%;
        --lesson-s: 35%;
        --lesson-edge-l: 62%;
        color-scheme: dark;
    }
}

html, body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-s); }
.num, .stat .v, .tt th.hour, .lesson .time { font-variant-numeric: tabular-nums; }

/* ---- Frame ---- */
.app { display: flex; min-height: 100vh; }
.side { width: 248px; flex-shrink: 0; background: var(--side); color: var(--side-ink); padding: 20px 14px 28px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: thin; }
.main { flex: 1; min-width: 0; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--side-hi); text-decoration: none; padding: 2px 8px 18px; }
.brand:hover { color: var(--side-hi); }
.brand .word { font-size: 1.6rem; font-weight: 700; letter-spacing: 0; line-height: 1; }
.brand .spots { display: inline-grid; grid-template-columns: repeat(2, 7px); gap: 3px; transform: translateY(1px); }
.brand .spots i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.brand .spots i:nth-child(2) { opacity: .55; }
.brand .spots i:nth-child(3) { opacity: .3; }
.brand .spots i:nth-child(4) { background: transparent; border: 1.5px solid var(--amber); opacity: .7; }

.menu { display: flex; flex-direction: column; gap: 1px; }
.menu .item { position: relative; color: var(--side-ink); text-decoration: none; padding: 7px 12px; border-radius: var(--radius-s); font-size: .95rem; }
.menu .item:hover { background: rgba(255, 255, 255, .06); color: var(--side-hi); }
.menu .item.active { background: rgba(255, 255, 255, .1); color: var(--side-hi); font-weight: 600; }
.menu .item.active::before { content: ""; position: absolute; inset-inline-start: -14px; top: 7px; bottom: 7px; width: 4px;
    border-start-end-radius: 4px; border-end-end-radius: 4px; background: var(--amber); }
[dir=rtl] .menu .item.active::before { border-radius: 4px 0 0 4px; }
.menu .section { display: flex; align-items: center; gap: 8px; font-size: .8rem; font-weight: 600; color: var(--side-ink); opacity: .8; padding: 16px 12px 4px; }
.menu .section .step { display: inline-flex; width: 18px; height: 18px; border-radius: 50%; border: 1px solid currentColor;
    align-items: center; justify-content: center; font-size: .7rem; font-weight: 600; opacity: .9; }
.menu .project-name { color: var(--side-hi); font-weight: 600; font-size: 1rem; padding: 16px 12px 0; border-top: 1px solid rgba(255, 255, 255, .1);
    margin-top: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar { display: flex; gap: 16px; align-items: center; padding: 10px 28px; border-bottom: 1px solid var(--line); background: var(--panel); min-height: 52px; }
.topbar .grow { flex: 1; }
.topbar .crumb { font-weight: 600; color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .user-link { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-size: .9rem; }
.topbar .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.topbar .logout { color: var(--muted); text-decoration: none; font-size: .88rem; }
.topbar .lang { text-decoration: none; font-weight: 600; font-size: .9rem; padding: 3px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--ink); }
.topbar .lang:hover { border-color: var(--accent); color: var(--accent); }
.content { padding: 26px 28px 64px; max-width: 1400px; }

/* ---- Type ---- */
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.25; margin-bottom: 4px; }
h2 { font-size: 1.12rem; font-weight: 650; line-height: 1.35; margin: 22px 0 10px; }
h3 { font-size: 1rem; font-weight: 650; }
.lead-muted { color: var(--muted); margin-bottom: 20px; max-width: 72ch; }
.muted { color: var(--muted); }
.small-note { font-size: .86rem; color: var(--muted); }

/* ---- Surfaces ---- */
.card-x { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; margin-bottom: 18px;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stat { padding: 14px 18px; border-inline-end: 1px solid var(--line); }
.stat .v { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat .k { color: var(--muted); font-size: .86rem; }

/* ---- Tables ---- */
.table-x { width: 100%; border-collapse: collapse; background: var(--panel); }
.table-x th, .table-x td { border-bottom: 1px solid var(--line); padding: 8px 10px; vertical-align: middle; text-align: start; }
.table-x th { font-size: .82rem; color: var(--muted); font-weight: 600; background: var(--panel-2); position: sticky; top: 0; z-index: 1; }
.table-x tbody tr:hover td { background: var(--panel-2); }
.table-x .num { text-align: end; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: 70vh; background: var(--panel); }
.table-wrap .table-x tr:last-child td { border-bottom: 0; }

/* ---- Controls ---- */
.form-control, .form-select { background-color: var(--panel); color: var(--ink); border-color: var(--line-strong); border-radius: var(--radius-s); }
.form-control:focus, .form-select:focus { background-color: var(--panel); color: var(--ink); border-color: var(--amber); box-shadow: var(--focus); }
.form-control-sm, .form-select-sm { font-size: .9rem; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: var(--focus); border-color: var(--amber); }
.btn { border-radius: var(--radius-s); font-weight: 500; }
.btn:focus-visible { box-shadow: var(--focus); }
.btn-primary, .btn-primary:disabled { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover, .btn-primary:active { background: color-mix(in srgb, var(--accent) 86%, #000); border-color: color-mix(in srgb, var(--accent) 86%, #000); color: var(--accent-ink); }
.btn-outline-primary { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.btn-outline-primary:hover, .btn-outline-primary:active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.btn-success, .btn-success:disabled { background: var(--amber); border-color: var(--amber); color: #2b1d00; font-weight: 600; }
.btn-success:hover { background: color-mix(in srgb, var(--amber) 88%, #000); border-color: color-mix(in srgb, var(--amber) 88%, #000); color: #2b1d00; }
.btn-outline-success { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.btn-outline-success:hover { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.btn-link { color: var(--accent); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.inline-form label { font-size: .82rem; color: var(--muted); display: block; margin-bottom: 3px; }

/* ---- Feedback ---- */
.msg { padding: 10px 14px; border-radius: var(--radius-s); margin: 8px 0 14px; font-size: .93rem; border-inline-start: 4px solid currentColor; }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.msg.err { background: var(--bad-soft); color: var(--bad); }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.pill.hard { background: var(--bad-soft); color: var(--bad); }
.pill.soft { background: var(--accent-soft); color: var(--accent); }
.pill.off { background: var(--line); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 99px; background: var(--panel); color: var(--ink);
    font-size: .86rem; border: 1px solid var(--line-strong); cursor: pointer; user-select: none; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-box { max-height: 170px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 6px; background: var(--panel); }

/* ---- Availability grid ---- */
.slots { border-collapse: separate; border-spacing: 2px; user-select: none; }
.slots th, .slots td { padding: 0; text-align: center; }
.slots th { font-size: .78rem; color: var(--muted); padding: 3px 6px; cursor: pointer; font-weight: 600; }
.slots td { width: 44px; height: 26px; cursor: pointer; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; }
.slots td:hover { border-color: var(--accent); }
.slots td.on { background: var(--bad); border-color: var(--bad); }

.tree .year { font-weight: 650; }
.tree .indent-1 { padding-inline-start: 26px; }
.tree .indent-2 { padding-inline-start: 52px; }

/* ---- The timetable: the one loud thing. Each course keeps its own hue. ---- */
.tt { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; background: var(--panel);
    border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tt th, .tt td { border-bottom: 1px solid var(--line); border-inline-end: 1px solid var(--line); padding: 4px; vertical-align: top; }
.tt tr > :last-child { border-inline-end: 0; }
.tt tbody tr:last-child > * { border-bottom: 0; }
.tt thead th { background: var(--side); color: var(--side-hi); font-size: .88rem; font-weight: 600; text-align: center; padding: 8px 4px; border-color: rgba(255,255,255,.08); }
.tt th.hour { width: 84px; background: var(--panel-2); color: var(--muted); font-size: .82rem; font-weight: 600; text-align: center; vertical-align: middle; }
.tt thead th.hour { background: var(--side-2); color: var(--side-ink); }
.tt td { height: 58px; }
.tt .lesson { --h: 165; background: hsl(var(--h) var(--lesson-s) var(--lesson-l)); border-inline-start: 4px solid hsl(var(--h) 55% var(--lesson-edge-l));
    border-radius: 5px; padding: 4px 7px; margin-bottom: 3px; font-size: .82rem; line-height: 1.35; }
.tt .lesson .s { font-weight: 650; }
.tt .lesson .o { color: var(--muted); }
.tt .lesson .time { direction: ltr; text-align: start; }
[dir=rtl] .tt .lesson .time { text-align: right; }
.tt-title { font-size: 1.15rem; font-weight: 700; margin: 22px 0 10px; }
.tt-block { margin-bottom: 30px; }

.progress-x { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-x > div { height: 100%; background: var(--amber); transition: width .3s; }

.editor { background: var(--panel); border: 1px solid var(--accent); box-shadow: inset 4px 0 0 var(--accent); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
[dir=rtl] .editor { box-shadow: inset -4px 0 0 var(--accent); }
.editor .row-f { margin-bottom: 12px; }
.editor .row-f > label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 4px; }

#blazor-error-ui { background: var(--warn-soft); color: var(--ink); bottom: 0; border-top: 2px solid var(--amber); display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* ---- Accounts, sharing, live editing ---- */
.auth-box { max-width: 420px; margin: 48px auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.auth-box label { font-size: .86rem; color: var(--muted); }
fieldset.ro { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.card-x.ro { border: 1px solid var(--line); padding: 18px 20px; margin-bottom: 16px; }
fieldset.ro:disabled .btn, fieldset.ro:disabled input, fieldset.ro:disabled select, fieldset.ro:disabled textarea { opacity: .65; }
.kind-badge { font-size: .8rem; color: var(--side-ink); opacity: .75; padding: 0 12px 6px; }
.here { font-size: .8rem; color: #7fe0b0; padding: 0 12px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kind-pick { display: flex; gap: 10px; flex-wrap: wrap; }
.kind-pick label { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); cursor: pointer; }
.kind-pick label:hover { border-color: var(--accent); }
.kind-pick label.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.kind-pick input { position: absolute; opacity: 0; pointer-events: none; }
.kind-pick label:focus-within { box-shadow: var(--focus); }
.kind-pick span { font-size: .84rem; color: var(--muted); }
.help-box { background: var(--amber-soft); border-radius: var(--radius-s); padding: 9px 13px; font-size: .9rem; }
.help-dot { display: inline-flex; width: 17px; height: 17px; border-radius: 50%; background: var(--line); color: var(--muted); font-size: .72rem; align-items: center; justify-content: center; cursor: help; }
.table-x.example td, .table-x.example th { padding: 4px 8px; }

/* ---- Home ---- */
.home-head { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 24px; margin-bottom: 18px; }
.home-head .lead-muted { margin-bottom: 0; }
.project-link { font-weight: 600; text-decoration: none; }
.project-link:hover { text-decoration: underline; }

/* ---- Study plan page ---- */
.plan-layout { display: grid; grid-template-columns: minmax(230px, 270px) 1fr; gap: 18px; align-items: start; }
.plan-main { min-width: 0; }
.plan-tree .prog { border-bottom: 1px solid var(--line); padding: 10px 0; }
.levels { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.level-btn { display: flex; flex-direction: column; align-items: flex-start; text-align: start; border: 1px solid var(--line);
    background: var(--panel); color: var(--ink); border-radius: var(--radius-s); padding: 7px 11px; }
.level-btn:hover { border-color: var(--accent); }
.level-btn.on { background: var(--accent-soft); border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
[dir=rtl] .level-btn.on { box-shadow: inset -3px 0 0 var(--accent); }
.course-edit { padding: 8px 4px; }
.course-edit h4 { font-size: 0.95rem; font-weight: 650; margin: 6px 0; }
.table-x tr.sel > td { background: var(--accent-soft); }
.wiz-row { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.seg-btn { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 6px 12px; border: 1px solid var(--line-strong);
    border-radius: var(--radius-s); background: var(--panel); color: var(--ink); font-size: .9rem; line-height: 1.3; text-align: start; }
.seg-btn:hover { border-color: var(--accent); }
.seg-btn .len { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.seg-btn.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.seg-btn.on .len { color: var(--accent); }
.scope-tabs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

@media (max-width: 900px) { .plan-layout { grid-template-columns: 1fr; } }

@media (max-width: 860px) {
    .app { flex-direction: column; }
    .side { width: 100%; height: auto; position: static; padding: 14px 16px; }
    .brand { padding-bottom: 10px; }
    .menu { flex-direction: row; flex-wrap: wrap; gap: 2px; }
    .menu .item.active::before { display: none; }
    .menu .section, .menu .project-name { width: 100%; }
    .topbar { padding: 8px 16px; }
    .content { padding: 18px 16px 48px; }
    h1 { font-size: 1.45rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

@media print {
    body, html { background: #fff; color: #000; }
    .content { padding: 0; max-width: none; }
    .tt-block { page-break-after: always; break-after: page; }
    .tt { border-color: #999; }
    .tt thead th { background: #eee !important; color: #000 !important; }
    .tt .lesson { background: #f3f3f3 !important; border-inline-start-color: #777 !important; }
}
