/* contents.css — Essay Vocab Creator (Contents tab) + custom-set styling.
   Matches Butomi's calm, paper-ish aesthetic (DM Sans, soft cards). */

.cv-wrap {
    max-width: 1080px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.cv-form {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    padding: 20px 22px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.05);
}
.cv-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--bd-ink-soft, #7a7166);
    margin-bottom: 6px;
}
.cv-topic {
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    padding: 12px 14px;
    font: inherit;
    font-size: 15px;
    resize: vertical;
    background: #fff;
    margin-bottom: 14px;
}
.cv-topic:focus { outline: none; border-color: var(--primary, #4F46E5); }
.cv-row {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.cv-field { display: flex; flex-direction: column; }
.cv-select, .cv-input {
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    font-size: 15px;
    background: #fff;
}
.cv-input { width: 110px; }
.cv-go { margin-left: auto; white-space: nowrap; }

.cv-recent-wrap {
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    padding: 16px 18px;
}
.cv-recent-head {
    font-size: 13px;
    font-weight: 700;
    color: var(--bd-ink, #4a4239);
    margin-bottom: 12px;
}
.cv-recent-head i { color: var(--primary, #4F46E5); margin-right: 6px; }
.cv-recent-list { display: flex; flex-wrap: wrap; gap: 10px; }
.cv-recent-item {
    position: relative;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 10px 34px 10px 14px;
    min-width: 180px;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
}
.cv-recent-item:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08); }
.cv-recent-title { font-weight: 600; font-size: 14px; color: var(--bd-ink, #4a4239); }
.cv-recent-sub { font-size: 12px; color: var(--bd-ink-soft, #8a8175); margin-top: 3px; }
.cv-recent-assigned {
    display: inline-block; background: #eef6ee; color: #3c7a45;
    border-radius: 6px; padding: 1px 6px; font-size: 11px; margin-left: 4px;
}
.cv-recent-del {
    position: absolute; top: 8px; right: 8px;
    border: none; background: transparent; color: #c0b8ac;
    cursor: pointer; font-size: 13px; padding: 4px;
}
.cv-recent-del:hover { color: var(--primary, #4F46E5); }
.cv-recent-empty, .cv-recent-loading { font-size: 13px; color: #9a9185; }

.cv-results { display: flex; flex-direction: column; gap: 16px; }
.cv-loading, .cv-empty {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 14px; padding: 28px; text-align: center;
    color: var(--bd-ink-soft, #7a7166); font-size: 15px;
}
.cv-loading i { color: var(--primary, #4F46E5); margin-right: 8px; }

.cv-result-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 14px; padding: 14px 18px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}
.cv-result-meta { font-size: 14px; color: var(--bd-ink, #4a4239); }
.cv-result-meta strong { color: var(--primary, #4F46E5); }

.cv-angle {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}
.cv-angle-head {
    display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding-bottom: 10px; margin-bottom: 12px;
}
.cv-angle-name {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 20px; color: var(--bd-ink, #3a342c);
}
.cv-angle-blurb { font-size: 13px; color: var(--bd-ink-soft, #8a8175); flex: 1; }
.cv-angle-count {
    background: var(--primary, #4F46E5); color: #fff;
    border-radius: 20px; font-size: 12px; font-weight: 700;
    padding: 2px 10px;
}
.cv-word-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}
.cv-word {
    background: #fbf9f6;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    padding: 10px 12px;
}
.cv-word-top { display: flex; align-items: baseline; gap: 8px; }
.cv-word-text { font-weight: 700; font-size: 15px; color: var(--bd-ink, #3a342c); }
.cv-word-pos { font-size: 12px; font-style: italic; color: #a89f93; }
.cv-word-def { font-size: 13px; color: #6a6258; margin-top: 3px; line-height: 1.4; }
.cv-word-why {
    font-size: 12px; color: var(--primary, #4338ca); margin-top: 6px;
    background: rgba(79, 70, 229, 0.07); border-radius: 6px; padding: 4px 8px;
}
.cv-word-why i { font-size: 10px; margin-right: 4px; }

/* Staff-only nav link visibility is handled in JS via .hidden, but ensure
   non-staff never see a flash of the Contents tab. */
body:not(.butomi-staff) .nav-contents-link { display: none !important; }

/* ---- Custom sets in the Exercises tab -------------------------------- */
.cs-creator {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 14px;
    margin-bottom: 18px;
    overflow: hidden;
}
.cs-creator-head { padding: 4px; }
.cs-creator-toggle {
    width: 100%; text-align: left;
    background: transparent; border: none; cursor: pointer;
    font: inherit; font-weight: 600; font-size: 15px;
    color: var(--primary, #4338ca); padding: 12px 16px;
}
.cs-creator-toggle i { margin-right: 8px; }
.cs-creator-body { padding: 0 16px 16px; }
.cs-paste {
    width: 100%; border: 1px solid rgba(0, 0, 0, 0.12); border-radius: 10px;
    padding: 12px; font: inherit; font-size: 14px; resize: vertical; background: #fff;
}
.cs-creator-actions { margin-top: 10px; }
.cs-preview { margin-top: 14px; }
.cs-preview-head { font-size: 13px; font-weight: 600; color: #6a6258; margin-bottom: 8px; }
.cs-prows { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.cs-prow {
    display: flex; align-items: center; gap: 8px;
    background: #fbf9f6; border-radius: 8px; padding: 6px 10px; font-size: 13px;
}
.cs-pword { font-weight: 700; color: #3a342c; min-width: 110px; }
.cs-pbadge { font-size: 10px; border-radius: 5px; padding: 1px 6px; font-weight: 700; }
.cs-pbadge-butomi { background: #eef4fb; color: #2d6cb3; }
.cs-pbadge-custom { background: #f6efe9; color: #a06a3a; }
.cs-pdef { color: #6a6258; flex: 1; }
.cs-save-row { display: flex; gap: 10px; margin-top: 12px; }
.cs-title-input {
    flex: 1; border: 1px solid rgba(0, 0, 0, 0.12); border-radius: 10px;
    padding: 10px 12px; font: inherit; font-size: 14px;
}
.cs-note { font-size: 13px; color: #6a6258; padding: 8px 0; }
.cs-note i { color: #3c7a45; margin-right: 4px; }

.cs-list-heading { font-size: 15px; color: var(--bd-ink, #4a4239); margin: 8px 0 12px; }
.cs-list-heading i { color: var(--primary, #4F46E5); margin-right: 6px; }
.cs-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px; margin-bottom: 22px;
}
.cs-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 12px; padding: 14px;
}
.cs-card-title { font-weight: 700; color: #3a342c; font-size: 15px; }
.cs-card-meta { font-size: 12px; color: #8a8175; margin-top: 4px; }
.cs-due { color: #b45309; font-weight: 600; }
.cs-card-actions { display: flex; gap: 8px; margin-top: 12px; }
.btn.small { padding: 6px 12px; font-size: 13px; }

/* ---- Student insight (Phase B): mastery panel + view-as overlay ------ */
.si-pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
.si-pill {
    border: 1px solid var(--si-c, #ccc); background: #fff; border-radius: 10px;
    padding: 8px 12px; cursor: pointer; text-align: center; min-width: 76px;
    transition: background 0.12s;
}
.si-pill-active { background: var(--si-c, #eee); }
.si-pill-active .si-pill-count, .si-pill-active .si-pill-label { color: #fff; }
.si-pill-count { display: block; font-size: 20px; font-weight: 800; color: var(--si-c, #333); }
.si-pill-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: #6a6258; }
.si-levels { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 14px; }
.si-level { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.si-level-name { min-width: 64px; color: #4a4239; }
.si-level-bar { flex: 1; height: 8px; background: #eee; border-radius: 5px; overflow: hidden; }
.si-level-bar > span { display: block; height: 100%; background: #5a9b6b; }
.si-level-num { min-width: 92px; text-align: right; color: #8a8175; font-size: 12px; }
.si-lists { display: flex; flex-direction: column; gap: 14px; }
.si-list-h { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.si-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.si-chip {
    background: #f4f1ec; border-radius: 6px; padding: 3px 8px; font-size: 12px; color: #4a4239;
    display: inline-flex; align-items: center; gap: 5px;
}
.si-chip-lvl { font-size: 9px; background: #e0d8cc; border-radius: 4px; padding: 0 4px; color: #8a7a5a; }
.si-chip-more { background: transparent; color: #9a9185; font-style: italic; }
.si-empty { color: #9a9185; font-size: 13px; padding: 6px 0; }

.si-viewas {
    position: fixed; inset: 0; z-index: 9000; background: #f6f3ee;
    display: flex; flex-direction: column;
}
.si-viewas-bar {
    display: flex; align-items: center; justify-content: space-between;
    background: #2a2630; color: #fff; padding: 12px 20px;
}
.si-viewas-who i { margin-right: 8px; }
.si-viewas-ro {
    background: #4F46E5; color: #fff; border-radius: 6px; font-size: 11px;
    padding: 2px 8px; margin-left: 10px; text-transform: uppercase; letter-spacing: 0.04em;
}
.si-viewas-close {
    background: rgba(255, 255, 255, 0.15); color: #fff; border: none; border-radius: 8px;
    padding: 8px 14px; cursor: pointer; font: inherit;
}
.si-viewas-close:hover { background: rgba(255, 255, 255, 0.28); }
.si-viewas-tabs { display: flex; gap: 4px; background: #fff; padding: 0 20px; border-bottom: 1px solid #e5e0d8; }
.si-tab {
    background: transparent; border: none; border-bottom: 3px solid transparent;
    padding: 14px 18px; cursor: pointer; font: inherit; font-size: 15px; color: #6a6258;
}
.si-tab-active { color: #4F46E5; border-bottom-color: #4F46E5; font-weight: 600; }
.si-viewas-body { flex: 1; overflow-y: auto; padding: 24px; }
.si-card {
    max-width: 920px; margin: 0 auto; background: #fff; border-radius: 16px;
    padding: 22px 24px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
}
.si-card h3 { font-family: 'DM Serif Display', Georgia, serif; font-size: 22px; margin: 0 0 6px; color: #3a342c; }
.si-sub { color: #8a8175; margin: 0 0 16px; }
.si-stats { display: flex; gap: 18px; margin-bottom: 18px; }
.si-stat { background: #fbf9f6; border-radius: 12px; padding: 16px 22px; text-align: center; flex: 1; }
.si-stat-n { font-size: 28px; font-weight: 800; color: #4F46E5; }
.si-stat-l { font-size: 12px; text-transform: uppercase; color: #8a8175; }

/* ---- View-as HOME (read-only login dashboard) ----------------------- */
.si-home { max-width: 920px; margin: 0 auto; }
.si-home-note { font-size: 13px; color: #8a8175; background: #fbf9f6; border: 1px solid #ece4d6; border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; }
.si-home-note b { color: #7c1d1d; }
.si-home-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 720px) { .si-home-grid { grid-template-columns: 1fr; } }
.si-home-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: #8a8175; font-weight: 700; margin: 0 0 8px; }
.si-rings { display: flex; gap: 12px; margin-top: 16px; }
.si-ring { flex: 1; background: #fff; border: 1px solid #ece4d6; border-radius: 12px; padding: 12px; text-align: center; }
.si-ring-top { font-size: 13px; color: #6a6258; } .si-ring-top b { font-size: 22px; color: #3a342c; font-family: 'DM Serif Display', Georgia, serif; }
.si-ring-bar { height: 6px; background: #efe7d8; border-radius: 4px; overflow: hidden; margin: 8px 0 6px; }
.si-ring-bar > div { height: 100%; background: var(--primary, #7c1d1d); border-radius: 4px; }
.si-ring-lbl { font-size: 11px; color: #8a8175; text-transform: uppercase; letter-spacing: 0.04em; }
.si-streak { background: #fff; border: 1px solid #ece4d6; border-radius: 12px; padding: 16px; text-align: center; margin-bottom: 16px; }
.si-streak-num { display: block; font-size: 26px; font-weight: 800; color: #3a342c; }
.si-streak-lbl { font-size: 12px; color: #8a8175; text-transform: uppercase; letter-spacing: 0.04em; }
.si-weekstrip { display: flex; gap: 6px; }
.si-wk { flex: 1; text-align: center; padding: 8px 0; border-radius: 8px; background: #f3f0ea; color: #b3a89a; font-size: 12px; font-weight: 700; }
.si-wk-on { background: #1f7a4e; color: #fff; }

/* ---- Attendance email + reminder tools (Phase C) --------------------- */
.at-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .at-tools { grid-template-columns: 1fr; } }
.at-block { background: #fbf9f6; border-radius: 12px; padding: 14px; }
.at-h { font-weight: 700; font-size: 13px; color: #4a4239; margin-bottom: 10px; }
.at-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.at-input, .at-select {
    border: 1px solid rgba(0, 0, 0, 0.14); border-radius: 8px; padding: 8px 10px;
    font: inherit; font-size: 13px; background: #fff; flex: 1; min-width: 0;
}
.at-check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #6a6258; margin-bottom: 10px; }
.at-msg { display: block; font-size: 12px; color: #6a6258; margin-top: 6px; min-height: 14px; }
.at-reminder-list { margin-top: 12px; }
.at-rl-h { font-size: 11px; text-transform: uppercase; color: #9a9185; margin-bottom: 6px; }
.at-rl-item {
    display: flex; align-items: center; justify-content: space-between;
    background: #fff; border-radius: 7px; padding: 6px 10px; font-size: 12px; margin-bottom: 4px;
}
.at-rl-del { background: none; border: none; color: #c0b8ac; cursor: pointer; }
.at-rl-del:hover { color: #4F46E5; }

/* ---- Assign-this-word button + popup (Phase D) ----------------------- */
.assign-word-btn {
    position: absolute; top: 14px; right: 14px; z-index: 40;
    background: linear-gradient(135deg, #4F46E5, #4338ca); color: #fff;
    border: none; border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 13px;
    font-weight: 600; cursor: pointer; box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
    opacity: 0.55; transition: opacity 0.15s, transform 0.15s;
}
.assign-word-btn:hover { opacity: 1; transform: translateY(-1px); }
.assign-word-btn i { margin-right: 5px; }
body:not(.butomi-staff) .assign-word-btn { display: none !important; }

.aw-scrim {
    position: fixed; inset: 0; z-index: 10050; background: rgba(15, 15, 25, 0.5);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.aw-modal { background: #fff; border-radius: 14px; width: 100%; max-width: 360px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
.aw-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px; border-bottom: 1px solid #eee; font-size: 15px; color: #2a2630;
}
.aw-head i { color: #4F46E5; margin-right: 6px; }
.aw-close { background: none; border: none; font-size: 22px; line-height: 1; color: #999; cursor: pointer; }
.aw-body { padding: 16px 18px; }
.aw-label { display: block; font-size: 12px; font-weight: 600; color: #6b7280; margin: 10px 0 5px; }
.aw-label:first-child { margin-top: 0; }
.aw-input { width: 100%; border: 1px solid #e5e7eb; border-radius: 8px; padding: 9px 11px; font: inherit; font-size: 14px; background: #fff; }
.aw-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-top: 1px solid #eee; }
.aw-msg { font-size: 12px; color: #6a6258; }

/* ---- Worksheet finalize: live preview + AI refine -------------------- */
.ws-final-controls { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 6px; }
.ws-tmpl-pills { display: flex; gap: 6px; }
.ws-tmpl-pill {
    border: 1px solid #d8d2c8; background: #fff; border-radius: 8px; padding: 8px 10px;
    font: inherit; font-size: 12px; cursor: pointer; color: #6a6258; white-space: nowrap;
}
.ws-tmpl-pill-on { background: #4F46E5; color: #fff; border-color: #4F46E5; }
.ws-final-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 18px; }
@media (max-width: 900px) { .ws-final-grid { grid-template-columns: 1fr; } }
.ws-col-head { font-weight: 700; font-size: 13px; color: #4a4239; margin-bottom: 8px; }
.ws-col-head i { color: #4F46E5; margin-right: 6px; }
.ws-col-head span { color: #9a9185; font-weight: 400; }
.ws-preview-host {
    height: 70vh; min-height: 460px; border: 1px solid #ddd; border-radius: 10px;
    overflow: auto; background: #e9e7e2;
}
.ws-chat-col { display: flex; flex-direction: column; height: 70vh; min-height: 460px; }
.ws-chat-log {
    flex: 1; overflow-y: auto; border: 1px solid #eee; border-radius: 10px; padding: 12px;
    background: #fbfaf8; display: flex; flex-direction: column; gap: 8px;
}
.ws-chat-empty { color: #9a9185; font-size: 13px; line-height: 1.5; }
.ws-msg { padding: 8px 12px; border-radius: 12px; font-size: 13px; line-height: 1.45; max-width: 90%; white-space: pre-wrap; }
.ws-msg-user { align-self: flex-end; background: #4F46E5; color: #fff; border-bottom-right-radius: 4px; }
.ws-msg-ai { align-self: flex-start; background: #fff; border: 1px solid #e8e2d8; color: #3a342c; border-bottom-left-radius: 4px; }
.ws-msg-typing { color: #9a9185; font-style: italic; }
.ws-chat-input-row { display: flex; gap: 8px; margin-top: 10px; }
.ws-chat-input {
    flex: 1; border: 1px solid #d8d2c8; border-radius: 10px; padding: 10px 12px;
    font: inherit; font-size: 13px; resize: none; background: #fff;
}
.ws-chat-input-row .btn { align-self: stretch; padding: 0 16px; }

/* Worksheet library: set vs random mode toggle */
.ws-lib-mode {
    border: 1px solid #d8d2c8; background: #fff; border-radius: 9px; padding: 9px 14px;
    font: inherit; font-size: 13px; cursor: pointer; color: #6a6258;
}
.ws-lib-mode i { margin-right: 6px; }
.ws-lib-mode-on { background: #4F46E5; color: #fff; border-color: #4F46E5; }

/* ---- Admin sidebar: Teacher's Contents marking --------------------- */
/* Teachers only ever see teacher-visible items, so hide the Admin-only
   group entirely for them (every item in it is already teacher-hidden). */
body.admin-role-teacher .admin-only-group { display: none !important; }
/* For the owner/admin, mark which sidebar items teachers can also see with a
   small green dot, so it's clear at a glance what's shared with teachers. */
body.admin-role-owner .admin-sidebar .teacher-visible,
body.admin-role-admin .admin-sidebar .teacher-visible { position: relative; }
body.admin-role-owner .admin-sidebar .teacher-visible > span::after,
body.admin-role-admin .admin-sidebar .teacher-visible > span::after {
    content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
    background: #16a34a; margin-left: 7px; vertical-align: middle;
}
/* Legend explaining the green dot — only the owner/admin (who see the dots). */
.admin-sidebar-legend { display: none; }
body.admin-role-owner .admin-sidebar-legend,
body.admin-role-admin .admin-sidebar-legend {
    display: flex; align-items: center; gap: 7px;
    padding: 12px 16px 4px; margin-top: 6px;
    font-size: 11px; color: #9aa0aa; border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.atl-dot { width: 6px; height: 6px; border-radius: 50%; background: #16a34a; display: inline-block; flex: 0 0 auto; }

/* ---- Custom Sets (admin) ------------------------------------------- */
#admin-cs-creator { margin-bottom: 18px; }
.cs-empty-hint { color: #9a9185; font-size: 13px; padding: 12px 0; }
.cs-assigned-count { background: #eef6ee; color: #3c7a45; border-radius: 6px; padding: 1px 7px; font-size: 11px; }
