/* ==========================================================================
   homework-hub.css — lesson folders (materials + homework) and homework panels
   js/tools/HomeworkHub.js. Folder parts live inside the library drawer and use
   its --lib-* tokens; the panels (.hwh-*) carry their own tokens.
   ========================================================================== */

/* ── Lesson folder card (row = folder named after the lesson) ────────────── */

html body #onenote-nav.lib-drawer .lf-card {
    --row-accent: var(--lib-accent);
    flex-shrink: 0;
    border: 1px solid var(--lib-border);
    border-radius: 14px;
    background: var(--lib-surface);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
    animation: libRowIn 0.28s var(--lib-ease) backwards;
}

html body #onenote-nav.lib-drawer .lf-card:hover { border-color: color-mix(in srgb, var(--row-accent) 35%, var(--lib-border)); }

html body #onenote-nav.lib-drawer .lf-card.is-open {
    border-color: color-mix(in srgb, var(--row-accent) 45%, var(--lib-border));
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}

html body #onenote-nav.lib-drawer .lf-card > .lib-row.lf-head {
    min-height: 56px;
    padding: 7px 6px 7px 10px;
    border-radius: 0;
    animation: none;
}

html body #onenote-nav.lib-drawer .lf-card > .lib-row.lf-head.active::before { display: none; }
html body #onenote-nav.lib-drawer .lf-card.is-open > .lib-row.lf-head { background: color-mix(in srgb, var(--row-accent) 7%, transparent); }

html body #onenote-nav.lib-drawer .lf-folder-icon {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 1.05rem;
    color: #fff;
    background: linear-gradient(140deg, var(--row-accent), color-mix(in srgb, var(--row-accent) 65%, #000));
    box-shadow: 0 6px 16px color-mix(in srgb, var(--row-accent) 30%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

html body #onenote-nav.lib-drawer .lib-row.is-hidden .lf-folder-icon { background: var(--lib-raised); color: var(--lib-muted); box-shadow: none; }

html body #onenote-nav.lib-drawer .lf-stat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}

html body #onenote-nav.lib-drawer .lf-stat i { font-size: 0.72rem; color: var(--row-accent); margin: 0; }

html body #onenote-nav.lib-drawer .lf-chev {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--lib-raised);
    color: var(--lib-muted);
    font-size: 0.75rem;
    transition: transform 0.3s var(--lib-ease), background 0.2s, color 0.2s;
}

html body #onenote-nav.lib-drawer .lf-head.lf-open .lf-chev {
    transform: rotate(180deg);
    background: var(--row-accent);
    color: #fff;
}

html body #onenote-nav.lib-drawer .lf-dot {
    position: absolute;
    top: -6px;
    inset-inline-end: -6px;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.66rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px var(--lib-surface);
    animation: lfPulse 2s ease-in-out infinite;
}

@keyframes lfPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ── Inside the folder ───────────────────────────────────────────────────── */

html body #onenote-nav.lib-drawer .lf-body {
    padding: 4px 12px 14px;
    border-top: 1px solid var(--lib-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: lfOpen 0.28s var(--lib-ease) backwards;
}

@keyframes lfOpen {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: none; }
}

html body #onenote-nav.lib-drawer .lf-group { display: flex; flex-direction: column; gap: 6px; }

html body #onenote-nav.lib-drawer .lf-group-title,
html body #onenote-nav.lib-drawer .lf-add-title {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 2px 2px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--lib-muted);
}

html body #onenote-nav.lib-drawer .lf-group-title i,
html body #onenote-nav.lib-drawer .lf-add-title i { font-size: 0.68rem; }

html body #onenote-nav.lib-drawer .lf-group-title b {
    margin-inline-start: auto;
    min-width: 22px;
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--lib-raised);
    letter-spacing: 0;
    font-size: 0.7rem;
}

html body #onenote-nav.lib-drawer .lf-group-list { display: flex; flex-direction: column; gap: 6px; }

html body #onenote-nav.lib-drawer .lf-item {
    --item-accent: var(--lib-accent);
    position: relative;
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 6px 8px 10px;
    border-radius: 14px;
    background: var(--lib-bg);
    border: 1px solid var(--lib-border);
    cursor: pointer;
    transition: transform 0.12s, border-color 0.15s, background 0.15s;
}

html body #onenote-nav.lib-drawer .lf-item:hover {
    border-color: color-mix(in srgb, var(--item-accent) 50%, transparent);
    background: color-mix(in srgb, var(--item-accent) 5%, var(--lib-bg));
}

html body #onenote-nav.lib-drawer .lf-item:active { transform: scale(0.985); }
html body #onenote-nav.lib-drawer .lf-item.is-hidden { opacity: 0.6; }

html body #onenote-nav.lib-drawer .lf-item.is-active {
    border-color: var(--item-accent);
    background: color-mix(in srgb, var(--item-accent) 10%, var(--lib-bg));
}

html body #onenote-nav.lib-drawer .lf-item-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--item-accent) 15%, transparent);
    color: var(--item-accent);
    font-size: 0.95rem;
}

html body #onenote-nav.lib-drawer .lf-item-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

html body #onenote-nav.lib-drawer .lf-item-title {
    font-size: 0.9rem;
    font-weight: 650;
    color: var(--lib-text);
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

html body #onenote-nav.lib-drawer .lf-item-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    font-size: 0.74rem;
    color: var(--lib-muted);
}

/* One right-hand action shape for every item → straight right edge */
html body #onenote-nav.lib-drawer .lf-open-btn,
html body #onenote-nav.lib-drawer .lf-start {
    flex-shrink: 0;
    width: 74px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
}

html body #onenote-nav.lib-drawer .lf-open-btn {
    background: var(--lib-raised);
    color: var(--lib-muted);
    transition: background 0.15s, color 0.15s;
}

html body #onenote-nav.lib-drawer .lf-open-btn i { font-size: 0.62rem; }

html body #onenote-nav.lib-drawer .lf-item:hover .lf-open-btn {
    background: var(--item-accent);
    color: #fff;
}

html body #onenote-nav.lib-drawer .lf-start { background: var(--item-accent); color: #fff; }
html body #onenote-nav.lib-drawer .lf-start i { font-size: 0.58rem; }

html body #onenote-nav.lib-drawer .lf-item-more {
    width: 30px;
    height: 36px;
    flex-shrink: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--lib-muted);
    cursor: pointer;
    opacity: 0.6;
}

html body #onenote-nav.lib-drawer .lf-item-more:hover { opacity: 1; background: var(--lib-hover); }

/* items without a menu keep the same right edge */
html body #onenote-nav.lib-drawer .lf-item:not(:has(.lf-item-more)) { padding-inline-end: 48px; }

html body #onenote-nav.lib-drawer .lf-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.7rem;
    background: var(--lib-raised);
    color: var(--lib-muted);
}

html body #onenote-nav.lib-drawer .lf-pill--accent { background: color-mix(in srgb, var(--row-accent) 16%, transparent); color: var(--row-accent); }
html body #onenote-nav.lib-drawer .lf-pill--amber { background: color-mix(in srgb, var(--lib-amber) 16%, transparent); color: var(--lib-amber); }
html body #onenote-nav.lib-drawer .lf-pill--danger { background: color-mix(in srgb, var(--lib-danger) 16%, transparent); color: var(--lib-danger); }
html body #onenote-nav.lib-drawer .lf-pill--ok { background: color-mix(in srgb, var(--lib-success) 16%, transparent); color: var(--lib-success); }

html body #onenote-nav.lib-drawer .lf-progress {
    height: 6px;
    border-radius: 999px;
    background: var(--lib-raised);
    overflow: hidden;
    margin-top: 2px;
}

html body #onenote-nav.lib-drawer .lf-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #10b981, #34d399);
    transition: width 0.5s var(--lib-ease);
}

html body #onenote-nav.lib-drawer .lf-counts { display: flex; gap: 12px; font-size: 0.74rem; }
html body #onenote-nav.lib-drawer .lf-counts b { font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
html body #onenote-nav.lib-drawer .lf-counts .ok { color: var(--lib-success); }
html body #onenote-nav.lib-drawer .lf-counts .wait { color: var(--lib-amber); }

html body #onenote-nav.lib-drawer .lf-new {
    display: inline-block;
    margin-inline-start: 6px;
    padding: 1px 6px;
    border-radius: 6px;
    background: #ef4444;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    vertical-align: 2px;
}

/* Student: done homework is unmistakable */
html body #onenote-nav.lib-drawer .lf-hw.is-done,
html body #onenote-nav.lib-drawer .lf-hw.is-pending {
    --item-accent: var(--lib-success);
    background: color-mix(in srgb, var(--lib-success) 8%, var(--lib-bg));
    border-color: color-mix(in srgb, var(--lib-success) 35%, transparent);
}

html body #onenote-nav.lib-drawer .lf-hw.is-done .lf-item-icon,
html body #onenote-nav.lib-drawer .lf-hw.is-pending .lf-item-icon { background: var(--lib-success); color: #fff; }
html body #onenote-nav.lib-drawer .lf-hw.is-missed { opacity: 0.7; }

html body #onenote-nav.lib-drawer .lib-row.lf-row-done .lib-row-icon {
    background: color-mix(in srgb, var(--lib-success) 18%, transparent);
    color: var(--lib-success);
}

/* ── Add tiles ──────────────────────────────────────────────────────────── */

html body #onenote-nav.lib-drawer .lf-add-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

html body #onenote-nav.lib-drawer .lf-tile {
    --tile: var(--lib-accent);
    aspect-ratio: 1.15;
    min-height: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 4px;
    border: 1px dashed color-mix(in srgb, var(--tile) 40%, var(--lib-border));
    border-radius: 14px;
    background: color-mix(in srgb, var(--tile) 4%, transparent);
    color: var(--lib-text);
    cursor: pointer;
    transition: transform 0.15s var(--lib-ease), background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

html body #onenote-nav.lib-drawer .lf-tile:hover {
    transform: translateY(-2px);
    border-style: solid;
    border-color: var(--tile);
    background: color-mix(in srgb, var(--tile) 10%, transparent);
    box-shadow: 0 8px 18px color-mix(in srgb, var(--tile) 20%, transparent);
}

html body #onenote-nav.lib-drawer .lf-tile:active { transform: scale(0.96); }

html body #onenote-nav.lib-drawer .lf-tile-ic {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tile);
    color: #fff;
    font-size: 0.9rem;
    box-shadow: 0 4px 10px color-mix(in srgb, var(--tile) 35%, transparent);
}

html body #onenote-nav.lib-drawer .lf-tile-label { font-size: 0.78rem; font-weight: 750; }

@media (max-width: 420px) {
    html body #onenote-nav.lib-drawer .lf-add-grid { grid-template-columns: repeat(2, 1fr); }
    html body #onenote-nav.lib-drawer .lf-tile { aspect-ratio: auto; min-height: 64px; flex-direction: row; }
}

/* ── Panels (create / teacher detail / student list) ─────────────────────── */

.hwh-overlay,
.hwh-pop,
.hwh-fab,
.hwh-toasts {
    --h-bg: #0f1522;
    --h-surface: #161e2e;
    --h-raised: #1e283b;
    --h-border: rgba(255, 255, 255, 0.09);
    --h-text: #eaf0f8;
    --h-muted: #8d99ae;
    --h-accent: #6d6afe;
    --h-ok: #10b981;
    --h-amber: #f59e0b;
    --h-danger: #ef4444;
    --h-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    font-family: 'Outfit', 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

html[data-theme="light"] .hwh-overlay,
html[data-theme="light"] .hwh-pop,
html[data-theme="light"] .hwh-fab,
html[data-theme="light"] .hwh-toasts {
    --h-bg: #f6f7fb;
    --h-surface: #ffffff;
    --h-raised: #eef1f7;
    --h-border: rgba(15, 23, 42, 0.1);
    --h-text: #152033;
    --h-muted: #5f6b82;
    --h-accent: #5b57f0;
    --h-shadow: 0 30px 80px rgba(15, 23, 42, 0.22);
}

.hwh-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1000001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(8, 12, 22, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.2s ease;
    box-sizing: border-box;
}

.hwh-overlay.show { opacity: 1; }
.hwh-overlay *, .hwh-overlay *::before, .hwh-overlay *::after { box-sizing: border-box; }

.hwh-sheet {
    width: 100%;
    max-width: 640px;
    max-height: min(88vh, calc(var(--app-vh, 100vh) - 32px));
    display: flex;
    flex-direction: column;
    background: var(--h-bg);
    color: var(--h-text);
    border: 1px solid var(--h-border);
    border-radius: 22px;
    box-shadow: var(--h-shadow);
    overflow: hidden;
    transform: translateY(14px) scale(0.98);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.hwh-overlay.show .hwh-sheet { transform: none; }
.hwh-sheet--detail { max-width: 760px; --t: var(--h-accent); }
.hwh-sheet--student { max-width: 560px; }

.hwh-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 18px 14px 20px;
    border-bottom: 1px solid var(--h-border);
}

.hwh-head-icon {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    background: linear-gradient(135deg, var(--t, var(--h-accent)), color-mix(in srgb, var(--t, var(--h-accent)) 60%, #000));
    box-shadow: 0 8px 20px color-mix(in srgb, var(--t, var(--h-accent)) 35%, transparent);
}

.hwh-head-text { flex: 1; min-width: 0; }
.hwh-title { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.01em; line-height: 1.25; overflow-wrap: anywhere; }
.hwh-sub { margin-top: 2px; font-size: 0.82rem; color: var(--h-muted); }
.hwh-sub b { color: var(--h-text); letter-spacing: 0.08em; }

.hwh-x {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 1px solid var(--h-border);
    border-radius: 11px;
    background: var(--h-surface);
    color: var(--h-muted);
    cursor: pointer;
    font-size: 0.95rem;
}

.hwh-x:hover { color: var(--h-danger); }

.hwh-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.hwh-foot {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--h-border);
    background: var(--h-surface);
}

.hwh-foot-note { flex: 1 1 200px; font-size: 0.78rem; color: var(--h-muted); }
.hwh-grow { flex: 1; }

.hwh-btn {
    min-height: 40px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--h-border);
    border-radius: 11px;
    background: var(--h-raised);
    color: var(--h-text);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s, transform 0.12s, opacity 0.15s;
}

.hwh-btn:hover { filter: brightness(1.12); }
.hwh-btn:active { transform: scale(0.97); }
.hwh-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.hwh-btn--primary { border-color: transparent; background: var(--h-accent); color: #fff; }
.hwh-sheet--detail .hwh-btn--primary { background: var(--t); }

.hwh-label { display: block; margin-bottom: 7px; font-size: 0.74rem; font-weight: 800; color: var(--h-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.hwh-input {
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--h-border);
    border-radius: 11px;
    background: var(--h-surface);
    color: var(--h-text);
    font: inherit;
    font-size: 0.9rem;
    outline: none;
    color-scheme: dark;
}

html[data-theme="light"] .hwh-input { color-scheme: light; }
.hwh-input:focus { border-color: var(--h-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--h-accent) 22%, transparent); }

/* Create: type cards */
.hwh-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.hwh-type {
    --t: var(--h-accent);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 14px;
    border: 2px solid var(--h-border);
    border-radius: 16px;
    background: var(--h-surface);
    color: var(--h-text);
    font: inherit;
    text-align: start;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.12s, background 0.15s;
}

.hwh-type:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--t) 50%, transparent); }
.hwh-type.is-picked { border-color: var(--t); background: color-mix(in srgb, var(--t) 10%, var(--h-surface)); }

.hwh-type-ic {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--t) 18%, transparent);
    color: var(--t);
}

.hwh-type-name { font-weight: 800; font-size: 0.95rem; }
.hwh-type-desc { font-size: 0.74rem; color: var(--h-muted); line-height: 1.3; }

.hwh-step2 { display: flex; flex-direction: column; gap: 10px; }
.hwh-step2[hidden] { display: none; }

.hwh-acts {
    max-height: 210px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 2px;
}

.hwh-act {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--h-border);
    border-radius: 11px;
    background: var(--h-surface);
    color: var(--h-text);
    font: inherit;
    font-size: 0.9rem;
    text-align: start;
    cursor: pointer;
}

.hwh-act span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.hwh-act small { color: var(--h-muted); font-size: 0.74rem; }
.hwh-act i { color: var(--h-muted); }
.hwh-act:hover { background: var(--h-raised); }
.hwh-act.is-picked { border-color: var(--h-accent); background: color-mix(in srgb, var(--h-accent) 12%, var(--h-surface)); }
.hwh-act.is-picked i { color: var(--h-accent); }

.hwh-grid2 { display: grid; grid-template-columns: 1.4fr 1.2fr 0.9fr; gap: 10px; }

.hwh-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 22px 12px;
    text-align: center;
    color: var(--h-muted);
    font-size: 0.84rem;
}

.hwh-empty i { font-size: 1.3rem; opacity: 0.8; }
.hwh-empty b { color: var(--h-text); }
.hwh-empty--ok i { color: var(--h-ok); }
.hwh-empty--big { padding: 40px 16px; }
.hwh-empty--big i { font-size: 2.2rem; }

/* Teacher detail: share & settings */
.hwh-share {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 270px);
    gap: 14px;
    align-items: center;
    padding: 14px;
    border-radius: 18px;
    background: var(--h-surface);
    border: 1px solid var(--h-border);
}

.hwh-qr {
    width: 128px;
    height: 128px;
    padding: 8px;
    border: none;
    border-radius: 14px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 1.4rem;
    cursor: zoom-in;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.hwh-qr img, .hwh-qr canvas { display: block; width: 112px !important; height: 112px !important; }
.hwh-share-main { min-width: 0; display: flex; flex-direction: column; gap: 10px; }

.hwh-code {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 10px 14px;
    border: 1px solid color-mix(in srgb, var(--t) 35%, transparent);
    border-radius: 14px;
    background: color-mix(in srgb, var(--t) 10%, transparent);
    color: var(--h-text);
    font: inherit;
    cursor: zoom-in;
    text-align: start;
}

.hwh-code span { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--h-muted); }
.hwh-code b { font-size: 1.7rem; font-weight: 900; letter-spacing: 0.22em; color: var(--t); line-height: 1.1; }

.hwh-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px 4px 12px;
    border: 1px solid var(--h-border);
    border-radius: 12px;
    background: var(--h-bg);
}

.hwh-link input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--h-muted);
    font: inherit;
    font-size: 0.78rem;
    outline: none;
    text-overflow: ellipsis;
}

.hwh-btn--sm { min-height: 32px; padding: 0 12px; font-size: 0.78rem; border-radius: 9px; }

.hwh-settings { display: flex; flex-direction: column; gap: 8px; }

.hwh-set {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    margin: 0;
}

.hwh-set > span { font-size: 0.76rem; font-weight: 700; color: var(--h-muted); white-space: nowrap; }
.hwh-set > span i { width: 14px; margin-inline-end: 4px; color: var(--t); }
.hwh-set .hwh-input { width: 100%; min-width: 0; min-height: 36px; font-size: 0.8rem; padding: 0 8px; }

.hwh-switch {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 12px 0 4px;
    border: 1px solid var(--h-border);
    border-radius: 999px;
    background: var(--h-surface);
    color: var(--h-muted);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
}

.hwh-switch i {
    position: relative;
    width: 40px;
    height: 26px;
    border-radius: 999px;
    background: var(--h-raised);
    transition: background 0.2s;
}

.hwh-switch i::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.hwh-switch em { font-style: normal; }
.hwh-switch.is-on { color: var(--h-ok); border-color: color-mix(in srgb, var(--h-ok) 40%, transparent); }
.hwh-switch.is-on i { background: var(--h-ok); }
.hwh-switch.is-on i::after { transform: translateX(14px); }

.hwh-foot-note--sync { flex: 0 1 auto; display: inline-flex; align-items: center; gap: 6px; }
.hwh-foot-note--sync i { color: var(--h-ok); }

/* Big code + QR for the classroom screen */
.hwh-big {
    position: fixed;
    inset: 0;
    z-index: 1000006;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    background: rgba(5, 8, 16, 0.94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-family: 'Outfit', 'Inter', system-ui, sans-serif;
    cursor: zoom-out;
}

.hwh-big-qr { padding: 16px; border-radius: 22px; background: #fff; }
.hwh-big-qr img, .hwh-big-qr canvas { display: block; }
.hwh-big-code { font-size: clamp(3rem, 12vw, 9rem); font-weight: 900; letter-spacing: 0.18em; line-height: 1; }
.hwh-big-hint { font-size: 1rem; opacity: 0.6; text-align: center; padding: 0 16px; }

/* Teacher detail: stats */
.hwh-stats { display: grid; grid-template-columns: auto repeat(4, 1fr); gap: 10px; align-items: stretch; }

.hwh-ring { position: relative; width: 96px; height: 96px; }
.hwh-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.hwh-ring circle { fill: none; stroke-width: 3.4; }
.hwh-ring .bg { stroke: var(--h-raised); }
.hwh-ring .fg { stroke: var(--h-ok); stroke-linecap: round; transition: stroke-dasharray 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
.hwh-ring-txt { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.hwh-ring-txt b { font-size: 1.15rem; font-weight: 900; }
.hwh-ring-txt span { font-size: 0.68rem; color: var(--h-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.hwh-stat {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--h-surface);
    border: 1px solid var(--h-border);
}

.hwh-stat b { font-size: 1.35rem; font-weight: 900; line-height: 1.1; }
.hwh-stat span { font-size: 0.72rem; color: var(--h-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.hwh-stat--ok b { color: var(--h-ok); }
.hwh-stat--wait b { color: var(--h-amber); }
.hwh-stat--due b { font-size: 1.05rem; }
.hwh-stat.is-over b { color: var(--h-danger); }

.hwh-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; flex-shrink: 0; }
.hwh-stats, .hwh-others, .hwh-types, .hwh-step2 { flex-shrink: 0; }

.hwh-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-radius: 16px;
    border: 1px solid var(--h-border);
    background: var(--h-surface);
    overflow: hidden;
}

.hwh-col-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 14px;
    font-weight: 800;
    font-size: 0.86rem;
    border-bottom: 1px solid var(--h-border);
}

.hwh-col-head span { margin-inline-start: auto; padding: 1px 9px; border-radius: 999px; background: var(--h-raised); font-size: 0.76rem; }
.hwh-col--ok .hwh-col-head { color: var(--h-ok); background: color-mix(in srgb, var(--h-ok) 8%, transparent); }
.hwh-col--wait .hwh-col-head { color: var(--h-amber); background: color-mix(in srgb, var(--h-amber) 8%, transparent); }

.hwh-list { max-height: 340px; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 2px; }

.hwh-stu {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 4px 6px;
    border-radius: 10px;
}

.hwh-stu:hover { background: var(--h-raised); }

.hwh-av {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    background: var(--h-raised);
    color: var(--h-muted);
}

.hwh-col--ok .hwh-av { background: color-mix(in srgb, var(--h-ok) 18%, transparent); color: var(--h-ok); }

.hwh-stu-name { flex: 1; min-width: 0; font-size: 0.88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hwh-stu-name small { margin-inline-start: 6px; color: var(--h-muted); font-weight: 500; font-size: 0.72rem; }

.hwh-score {
    --s: var(--h-ok);
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--s);
    background: color-mix(in srgb, var(--s) 15%, transparent);
}

.hwh-score--pending { --s: var(--h-amber); }

.hwh-mini {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--h-muted);
    cursor: pointer;
    opacity: 0.5;
}

.hwh-stu:hover .hwh-mini { opacity: 1; }
.hwh-mini:hover { background: color-mix(in srgb, var(--h-amber) 16%, transparent); color: var(--h-amber); }

.hwh-others { font-size: 0.78rem; color: var(--h-muted); padding: 10px 12px; border-radius: 12px; background: var(--h-surface); border: 1px dashed var(--h-border); }
.hwh-others[hidden] { display: none; }

/* Popup menu */
.hwh-pop {
    position: fixed;
    z-index: 1000005;
    min-width: 190px;
    padding: 6px;
    border-radius: 14px;
    background: var(--h-surface);
    border: 1px solid var(--h-border);
    box-shadow: var(--h-shadow);
    display: flex;
    flex-direction: column;
}

.hwh-pop button {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 0 12px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--h-text);
    font: inherit;
    font-size: 0.88rem;
    text-align: start;
    cursor: pointer;
}

.hwh-pop button i { width: 16px; color: var(--h-muted); }
.hwh-pop button:hover { background: var(--h-raised); }
.hwh-pop button.danger, .hwh-pop button.danger i { color: var(--h-danger); }

/* ── Student: floating button, toasts, panel ─────────────────────────────── */

.hwh-fab {
    position: fixed;
    z-index: 1000000;
    left: max(16px, env(safe-area-inset-left));
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 76px); /* clear of the bottom toolbar */
    height: 52px;
    padding: 0 18px 0 16px;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #6d6afe, #8b5cf6);
    color: #fff;
    font-family: 'Outfit', 'Inter', system-ui, sans-serif;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(109, 106, 254, 0.45);
    transition: transform 0.15s, box-shadow 0.15s;
}

.hwh-fab:hover { transform: translateY(-2px); }
.hwh-fab:active { transform: scale(0.96); }
.hwh-fab i { font-size: 1.1rem; }
.hwh-fab.all-done { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 12px 30px rgba(16, 185, 129, 0.4); }

.hwh-fab-badge {
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    background: #fff;
    color: #6d28d9;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hwh-fab.has-new { animation: hwhRing 1.6s ease-in-out infinite; }
.hwh-fab.has-new .hwh-fab-badge { background: #ef4444; color: #fff; }

@keyframes hwhRing {
    0%, 100% { box-shadow: 0 12px 30px rgba(109, 106, 254, 0.45), 0 0 0 0 rgba(239, 68, 68, 0.5); }
    50% { box-shadow: 0 12px 30px rgba(109, 106, 254, 0.45), 0 0 0 10px rgba(239, 68, 68, 0); }
}

.hwh-toasts {
    position: fixed;
    z-index: 1000004;
    left: 50%;
    top: max(16px, env(safe-area-inset-top));
    transform: translateX(-50%);
    width: min(440px, calc(100% - 32px));
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.hwh-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 16px;
    background: var(--h-surface);
    color: var(--h-text);
    border: 1px solid var(--h-border);
    box-shadow: var(--h-shadow);
    cursor: pointer;
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 0.25s, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.hwh-toast.show { opacity: 1; transform: none; }

.hwh-toast-ic {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--h-accent);
}

.hwh-toast--new .hwh-toast-ic i { animation: hwhBell 1s ease-in-out 2; }
.hwh-toast--done .hwh-toast-ic { background: var(--h-ok); }
.hwh-toast-txt { flex: 1; min-width: 0; font-weight: 700; font-size: 0.9rem; }
.hwh-toast-go { font-size: 0.8rem; font-weight: 800; color: var(--h-accent); }

@keyframes hwhBell {
    0%, 100% { transform: rotate(0); }
    20% { transform: rotate(18deg); }
    40% { transform: rotate(-14deg); }
    60% { transform: rotate(8deg); }
}

.hwh-tabs {
    display: flex;
    gap: 6px;
    margin: 12px 20px 0;
    padding: 4px;
    border-radius: 14px;
    background: var(--h-surface);
    border: 1px solid var(--h-border);
}

.hwh-tabs button {
    flex: 1;
    min-height: 40px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--h-muted);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
}

.hwh-tabs button b { margin-inline-start: 4px; padding: 1px 8px; border-radius: 999px; background: var(--h-raised); font-size: 0.76rem; }
.hwh-tabs button.is-on { background: var(--h-accent); color: #fff; }
.hwh-tabs button.is-on b { background: rgba(255, 255, 255, 0.22); }

.hwh-cards { gap: 10px; }

.hwh-card {
    --t: var(--h-accent);
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px;
    border: 1px solid var(--h-border);
    border-radius: 18px;
    background: var(--h-surface);
    color: var(--h-text);
    font: inherit;
    text-align: start;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}

.hwh-card:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--t) 50%, transparent); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.15); }

.hwh-card-ic {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    background: color-mix(in srgb, var(--t) 18%, transparent);
    color: var(--t);
}

.hwh-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.hwh-card-title { font-size: 1rem; font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; }
.hwh-card-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.78rem; color: var(--h-muted); }
.hwh-card-meta .ok { color: var(--h-ok); font-weight: 700; }
.hwh-card-meta .tone-amber { color: var(--h-amber); font-weight: 700; }
.hwh-card-meta .tone-danger { color: var(--h-danger); font-weight: 700; }

.hwh-card-go {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 16px;
    border-radius: 999px;
    background: var(--t);
    color: #fff;
    font-weight: 800;
    font-size: 0.86rem;
}

.hwh-card-go--off { background: var(--h-raised); color: var(--h-danger); }

.hwh-card-score {
    flex-shrink: 0;
    min-width: 54px;
    height: 54px;
    padding: 0 8px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.05rem;
    background: var(--h-ok);
    color: #fff;
}

.hwh-card-score--pending { background: color-mix(in srgb, var(--h-ok) 20%, transparent); color: var(--h-ok); }

.hwh-card.is-done,
.hwh-card.is-pending {
    --t: var(--h-ok);
    background: color-mix(in srgb, var(--h-ok) 7%, var(--h-surface));
    border-color: color-mix(in srgb, var(--h-ok) 30%, transparent);
}

.hwh-card.is-done .hwh-card-ic,
.hwh-card.is-pending .hwh-card-ic { background: var(--h-ok); color: #fff; }
.hwh-card.is-missed { opacity: 0.65; }

.hwh-card .lf-new {
    display: inline-block;
    margin-inline-start: 8px;
    padding: 1px 7px;
    border-radius: 6px;
    background: #ef4444;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    vertical-align: 3px;
}

/* ── Phones ──────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .hwh-overlay { padding: 0; align-items: flex-end; }
    .hwh-sheet { max-height: calc(var(--app-vh, 100vh) - 24px); border-radius: 22px 22px 0 0; }
    .hwh-types { grid-template-columns: 1fr; }
    .hwh-type { flex-direction: row; align-items: center; }
    .hwh-type-desc { display: none; }
    .hwh-grid2 { grid-template-columns: 1fr 1fr; }
    .hwh-grid2 label:first-child { grid-column: 1 / -1; }
    .hwh-share { grid-template-columns: auto 1fr; }
    .hwh-settings { grid-column: 1 / -1; }
    .hwh-qr { width: 96px; height: 96px; }
    .hwh-qr img, .hwh-qr canvas { width: 80px !important; height: 80px !important; }
    .hwh-code b { font-size: 1.35rem; }
    .hwh-foot-note--sync { display: none; }
    .hwh-stats { grid-template-columns: repeat(2, 1fr); }
    .hwh-ring { grid-column: 1 / -1; justify-self: center; }
    .hwh-cols { grid-template-columns: 1fr; }
    .hwh-list { max-height: none; }
    .hwh-foot .hwh-btn--primary { flex: 1 1 100%; }
    .hwh-fab span { display: none; }
    .hwh-fab { padding: 0 14px; }
}
