:root {
    --bg: #eef3f8;
    --surface: #ffffff;
    --surface-soft: #f7f9fc;
    --line: #d8e2ec;
    --text: #253444;
    --muted: #738295;
    --nav: #22324d;
    --nav-soft: #304664;
    --blue: #4d87e2;
    --teal: #39bcc4;
    --gold: #f0c84e;
    --accent: #1f63d8;
    --accent-deep: #1a56bc;
    --success: #1d8f5d;
    --shadow: 0 10px 28px rgba(37, 52, 68, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    color: var(--text);
    background: var(--bg);
    height: 100vh;
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

input,
button,
textarea,
select {
    font: inherit;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 60;
    min-width: 280px;
    padding: 14px 18px;
    border-radius: 12px;
    color: #fff;
    box-shadow: var(--shadow);
    animation: toast-in 0.25s ease, toast-out 0.25s ease 4.75s forwards;
}

.toast-success {
    background: linear-gradient(135deg, #1f9d68, #156849);
}

.toast-error {
    background: linear-gradient(135deg, #c84c4c, #8d3030);
}

.auth-shell,
.dashboard-shell {
    width: 100%;
}

.auth-shell {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 28px;
    align-items: center;
    padding: 40px 0;
}

.auth-shell-simple {
    max-width: 520px;
    grid-template-columns: 1fr;
    justify-content: center;
}

.auth-shell-compact {
    grid-template-columns: 1fr;
    max-width: 560px;
    align-items: center;
}

.auth-hero,
.auth-panel {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(37, 52, 68, 0.12);
    border-radius: 30px;
    box-shadow: var(--shadow);
}

.auth-hero {
    padding: 46px;
    background: linear-gradient(145deg, rgba(24, 52, 47, 0.96), rgba(20, 34, 31, 0.88));
    color: #f3f7f4;
}

.auth-hero h1,
.panel-header h2 {
    font-family: 'Sora', sans-serif;
    letter-spacing: -0.04em;
    margin: 0;
}

.auth-hero h1 {
    font-size: clamp(2.7rem, 5vw, 4.4rem);
    line-height: 1.05;
    max-width: 10ch;
    margin-top: 24px;
}

.auth-hero p {
    max-width: 560px;
    color: rgba(243, 247, 244, 0.78);
    font-size: 1.05rem;
}

.brand-chip,
.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 0.85rem;
}

.brand-chip {
    background: rgba(255, 255, 255, 0.1);
    color: #fff4ec;
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.hero-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 36px;
}

.glass-card {
    padding: 22px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
}

.glass-card span,
.eyebrow,
.auth-hero .brand-chip,
.auth-hero .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
}

.glass-card span,
.auth-hero .brand-chip,
.auth-hero .eyebrow {
    color: rgba(255, 255, 255, 0.62);
}

.glass-card strong {
    display: block;
    margin: 10px 0 8px;
    font-size: 1.05rem;
}

.glass-card p {
    margin: 0;
    font-size: 0.95rem;
}

.auth-panel {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(14px);
    padding: 38px;
}

.panel-header p {
    margin: 0;
}

.panel-header h2 {
    font-size: 2rem;
    margin-top: 10px;
}

.panel-header {
    display: grid;
    gap: 10px;
    margin-bottom: 28px;
}

.auth-logo {
    width: auto;
    height: 52px;
    object-fit: contain;
    margin: 0 auto 8px;
    display: block;
}

.auth-form,
.admin-form {
    display: grid;
    gap: 18px;
}

.auth-form label,
.admin-form label {
    display: grid;
    gap: 9px;
}

.auth-form span,
.admin-form span {
    font-weight: 600;
    font-size: 0.95rem;
}

input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    background: #ffffff;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus {
    border-color: #7aa8ef;
    box-shadow: 0 0 0 3px rgba(77, 135, 226, 0.12);
}

.admin-textarea,
.admin-select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    color: var(--text);
    outline: none;
}

.admin-textarea {
    min-height: 94px;
    resize: vertical;
    padding: 14px 16px;
}

.admin-select {
    min-height: 50px;
    padding: 12px 14px;
}

.admin-textarea:focus,
.admin-select:focus {
    border-color: #7aa8ef;
    box-shadow: 0 0 0 3px rgba(77, 135, 226, 0.12);
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 14px 18px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: #fff;
    font-weight: 600;
}

.btn-secondary {
    background: #edf2f8;
    color: #475a70;
    font-weight: 600;
}

.auth-links {
    margin-top: 20px;
    font-size: 0.95rem;
    color: var(--muted);
}

.dashboard-shell {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
}

.admin-sidebar {
    background: var(--nav);
    color: #f5f8ff;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.admin-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-brand-logo {
    width: 200px;
    height: 55px;
    object-fit: contain;
    background: transparent;
    padding: 0;
}

.admin-nav-block {
    padding: 18px 14px 0;
}

.admin-nav-title {
    display: block;
    padding: 0 10px 10px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.4);
}

.admin-nav {
    display: grid;
    gap: 6px;
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 8px;
    color: rgba(245, 248, 255, 0.78);
    font-weight: 500;
}

.admin-nav a span:nth-child(2) {
    min-width: 0;
}

.admin-nav a:hover,
.admin-nav a.active {
    background: var(--blue);
    color: #ffffff;
}

.admin-nav-icon {
    width: 20px;
    display: inline-flex;
    justify-content: center;
}

.admin-nav-badge {
    margin-left: auto;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1;
}

.admin-nav a:not(.active) .admin-nav-badge {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(245, 248, 255, 0.92);
}

.admin-sidebar-footer {
    margin-top: auto;
    padding: 12px 14px 14px;
    display: grid;
    gap: 8px;
    position: relative;
}

.admin-sidebar-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 12px;
    right: 12px;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.admin-sidebar-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: rgba(245, 248, 255, 0.8);
    font-weight: 600;
}

.admin-sidebar-logout:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.admin-sidebar-time {
    padding: 0 0 0 42px;
    color: rgba(255, 255, 255, 0.42);
    font-size: 0.72rem;
    line-height: 1.2;
}

.admin-shell-main {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 10px 22px;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
}

.admin-header-minimal {
    justify-content: center;
    padding: 14px 26px;
}

.admin-header h1 {
    margin: 0;
    font-family: 'Sora', sans-serif;
    font-size: 1rem;
}

.admin-header p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.admin-header-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: #2d5aa7;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
}

.admin-header-user small {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
}

.admin-content {
    padding: 24px 26px;
    display: grid;
    gap: 18px;
    align-content: start;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.dashboard-content {
    grid-template-rows: 1fr;
    align-content: stretch;
    padding-top: 18px;
}

.teacher-dashboard-content {
    grid-template-rows: 1fr;
    gap: 0;
}

.admin-section-card {
    background: var(--surface);
    box-shadow: var(--shadow);
    border-radius: 20px;
    overflow: hidden;
}

.admin-stats-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.admin-stat-card {
    padding: 10px 18px 12px;
    color: #fff;
    box-shadow: var(--shadow);
    min-height: 96px;
    border-radius: 20px;
    display: grid;
    align-content: start;
    gap: 2px;
}

.teacher-stats-row {
    gap: 12px;
}

.teacher-dashboard-chat-only {
    padding-top: 14px;
}

.teacher-stats-row .admin-stat-card {
    min-height: 0;
    padding: 8px 14px;
    border-radius: 18px;
    display: grid;
    grid-template-columns: auto auto auto minmax(0, 1fr);
    align-items: center;
    column-gap: 9px;
    row-gap: 0;
    box-shadow: 0 6px 16px rgba(40, 62, 92, 0.06);
    border: 1px solid transparent;
}

.teacher-stats-row .admin-stat-card .eyebrow {
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    white-space: nowrap;
    font-weight: 700;
}

.teacher-stats-row .admin-stat-card strong {
    margin: 0;
    font-size: 1.08rem;
    display: inline;
    white-space: nowrap;
    line-height: 1;
    font-weight: 700;
}

.teacher-stats-row .admin-stat-card p {
    margin: 0;
    font-size: 0.74rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.teacher-stat-icon {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
}

.teacher-stats-row .admin-stat-teal {
    background: linear-gradient(135deg, #ffffff, #ecfbfc);
    color: #114f56;
    border-color: #8fd9e1;
}

.teacher-stats-row .admin-stat-teal .eyebrow,
.teacher-stats-row .admin-stat-teal p {
    color: #456f75;
}

.teacher-stats-row .admin-stat-teal .teacher-stat-icon {
    background: #c8edf0;
    color: #176b74;
}

.teacher-stats-row .admin-stat-blue {
    background: linear-gradient(135deg, #ffffff, #eef5ff);
    color: #214882;
    border-color: #a8c2f3;
}

.teacher-stats-row .admin-stat-blue .eyebrow,
.teacher-stats-row .admin-stat-blue p {
    color: #4c6794;
}

.teacher-stats-row .admin-stat-blue .teacher-stat-icon {
    background: #d3e2ff;
    color: #2e60b6;
}

.admin-stat-ink {
    background: linear-gradient(135deg, #ffffff, #f0f4f9);
    color: #2f4259;
    border-color: #c2d0e0;
}

.teacher-stats-row .admin-stat-ink strong {
    color: #2f4259;
}

.teacher-stats-row .admin-stat-ink .eyebrow,
.teacher-stats-row .admin-stat-ink p {
    color: #65778d;
}

.teacher-stats-row .admin-stat-ink .teacher-stat-icon {
    background: #d5dee9;
    color: #52667f;
}

.admin-stat-card .eyebrow {
    color: rgba(255, 255, 255, 0.78);
}

.admin-stat-card strong {
    display: block;
    margin: 0 0 2px;
    font-family: 'Sora', sans-serif;
    font-size: 1.2rem;
}

.admin-stat-card p {
    margin: 0;
    color: rgba(255, 255, 255, 0.86);
    font-size: 0.8rem;
}

.admin-stat-teal {
    background: linear-gradient(135deg, var(--teal), #30aab1);
}

.admin-stat-blue {
    background: linear-gradient(135deg, var(--blue), #4378ca);
}

.admin-stat-gold {
    background: linear-gradient(135deg, var(--gold), #e5b932);
    color: #534100;
}

.admin-stat-gold .eyebrow,
.admin-stat-gold p {
    color: rgba(83, 65, 0, 0.8);
}

.admin-work-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 0;
}

.dashboard-content .admin-work-grid,
.dashboard-content .admin-section-card {
    min-height: 0;
}

.dashboard-content .admin-section-card {
    height: 100%;
}

.admin-ai-card {
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 0;
    border: 1px solid #c7d8ea;
    background: linear-gradient(180deg, #f8fbff 0%, #eaf2fb 100%);
    box-shadow: 0 12px 28px rgba(44, 72, 110, 0.08);
}

.admin-section-header {
    padding: 6px 12px;
    border-bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    background: rgba(255, 255, 255, 0.88);
}

.admin-section-heading {
    min-width: 0;
}

.admin-section-header h3 {
    margin: 0;
    font-family: 'Sora', sans-serif;
    font-size: 0.9rem;
}

.admin-section-subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.admin-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-prototype {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100%;
    height: 100%;
    background: linear-gradient(180deg, #eef5fc 0%, #e4edf8 100%);
    border-top: 1px solid #cddceb;
}

.ai-sidebar {
    border-right: 1px solid #cad8e8;
    padding: 12px 10px;
    display: grid;
    align-content: start;
    gap: 10px;
    background: linear-gradient(180deg, #d4dfec 0%, #c9d7e8 100%);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.45);
}

.ai-sidebar-top {
    display: grid;
    gap: 12px;
}

.ai-warning-box {
    display: grid;
    gap: 4px;
    font-size: 0.88rem;
    line-height: 1.45;
}

.ai-warning-box {
    color: #8b5f00;
    background: #fff8df;
    border-color: #f0df9f;
}

.ai-new-chat {
    border: 1px solid var(--line);
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: #ffffff;
    padding: 7px 11px;
    text-align: left;
    font-weight: 600;
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(31, 99, 216, 0.18);
    cursor: pointer;
}

.ai-search-box {
    background: #ffffff;
    border: 1px solid var(--line);
    color: #7a8ca0;
    padding: 10px 12px;
    border-radius: 10px;
}

.ai-recents {
    display: grid;
    gap: 6px;
    min-height: 0;
    min-width: 0;
    padding: 8px;
    border-radius: 16px;
    background: rgba(191, 207, 226, 0.38);
    border: 1px solid rgba(171, 192, 216, 0.72);
}

.ai-recent-list {
    display: grid;
    gap: 8px;
    align-content: start;
    min-width: 0;
}

.ai-recent-row {
    position: relative;
    display: block;
    align-items: center;
    width: 100%;
    min-width: 0;
    overflow: visible;
}

.ai-recent-item {
    display: block;
    padding: 10px 12px;
    border-radius: 12px;
    color: #3f5873;
    border: 1px solid #c5d5e6;
    font-size: 0.88rem;
    background: rgba(255, 255, 255, 0.82);
    text-align: left;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    cursor: pointer;
    transition: background-color 0.22s ease, border-color 0.22s ease, color 0.22s ease, padding 0.22s ease, box-shadow 0.22s ease;
}

.ai-recent-item span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: white-space 0.22s ease;
}

.ai-recent-item.active {
    background: #ffffff;
    border-color: #adc6e4;
    color: var(--text);
    font-weight: 600;
    box-shadow: 0 8px 18px rgba(60, 92, 138, 0.12);
}

.ai-delete-chat {
    position: absolute;
    right: 19px;
    bottom: 8px;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    border: 1px solid rgba(166, 187, 211, 0.65);
    background: rgba(255, 255, 255, 0.72);
    color: #60758e;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease, background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.ai-delete-chat svg {
    width: 16px;
    height: 16px;
}

.ai-recent-meta {
    position: static;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    max-height: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-1px);
    transition: max-height 0.22s ease, opacity 0.22s ease 0.04s, transform 0.22s ease 0.04s, padding 0.22s ease;
}

.ai-recent-date {
    color: rgba(58, 78, 102, 0.48);
    font-size: 0.68rem;
    line-height: 1.1;
    white-space: nowrap;
}

.ai-recent-row:hover .ai-recent-meta,
.ai-recent-row:focus-within .ai-recent-meta {
    max-height: 26px;
    padding: 0 0 3px;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.ai-recent-row:hover .ai-delete-chat,
.ai-recent-row:focus-within .ai-delete-chat {
    opacity: 1;
    pointer-events: auto;
}

.ai-recent-row:hover .ai-recent-item {
    color: rgba(63, 88, 115, 0.7);
    padding: 10px 12px 5px;
}

.ai-recent-row:hover .ai-recent-item span,
.ai-recent-row:focus-within .ai-recent-item span {
    white-space: normal;
}

.ai-recent-row:hover .ai-recent-item > span:first-child,
.ai-recent-row:focus-within .ai-recent-item > span:first-child {
    padding-right: 0;
}

.ai-delete-chat-shell {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
}

.ai-delete-chat:hover {
    background: #ffffff;
    border-color: var(--line);
    color: #c35454;
}

.ai-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(20, 31, 47, 0.48);
    backdrop-filter: blur(8px);
}

.ai-confirm-modal {
    width: min(100%, 420px);
    padding: 22px;
    border-radius: 24px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
    border: 1px solid rgba(214, 227, 240, 0.95);
    box-shadow: 0 28px 60px rgba(18, 34, 56, 0.22);
}

.ai-confirm-badge {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    background: #fff1f1;
    color: #bf4f4f;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ai-confirm-modal h4 {
    margin: 14px 0 8px;
    font-family: 'Sora', sans-serif;
    font-size: 1.15rem;
    color: #1f3149;
}

.ai-confirm-modal p {
    margin: 0;
    color: #667b92;
    line-height: 1.55;
    font-size: 0.92rem;
}

.ai-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.ai-confirm-cancel,
.ai-confirm-delete {
    border: 0;
    border-radius: 12px;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
}

.ai-confirm-cancel {
    background: #edf3f9;
    color: #4f647b;
}

.ai-confirm-delete {
    background: linear-gradient(135deg, #db5a5a, #be4040);
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(190, 64, 64, 0.24);
}

.ai-recent-item-empty {
    color: #7a8ca0;
    font-size: 0.88rem;
    padding: 8px 2px;
}

.ai-conversation {
    display: grid;
    grid-template-rows: 1fr auto;
    min-width: 0;
    background: #e1ebf7;
    height: 100%;
    min-height: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.ai-ghost-action {
    border: 1px solid var(--line);
    background: #ffffff;
    color: #51657c;
    padding: 5px 9px;
    border-radius: 10px;
    cursor: pointer;
}

.ai-conversation-body {
    padding: 14px 16px;
    display: grid;
    align-content: start;
    gap: 16px;
    min-height: 0;
    overflow: auto;
    background: #e1ebf7;
}

.ai-message {
    display: flex;
    gap: 12px;
}

.ai-message-user {
    justify-content: flex-end;
}

.ai-bubble {
    max-width: 78%;
    padding: 12px 14px;
    border-radius: 20px;
    display: grid;
    gap: 4px;
    box-shadow: 0 6px 18px rgba(56, 84, 120, 0.05);
    position: relative;
}

.ai-message-assistant .ai-bubble {
    background: linear-gradient(180deg, #ffffff 0%, #f2f7fd 100%);
    color: #27384b;
    border: 1px solid #cfdef0;
}

.ai-message-user .ai-bubble {
    background: linear-gradient(180deg, #edf5ff 0%, #e6f0fc 100%);
    color: #1f446f;
    border: 1px solid #c6d8ef;
}

.ai-bubble p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.ai-markdown {
    display: grid;
    gap: 10px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.ai-markdown p,
.ai-markdown ul,
.ai-markdown ol,
.ai-markdown h1,
.ai-markdown h2,
.ai-markdown h3 {
    margin: 0;
}

.ai-markdown h1,
.ai-markdown h2,
.ai-markdown h3 {
    color: #20354d;
    line-height: 1.3;
}

.ai-markdown h1 {
    font-size: 1.02rem;
}

.ai-markdown h2 {
    font-size: 0.98rem;
}

.ai-markdown h3 {
    font-size: 0.94rem;
}

.ai-markdown ul,
.ai-markdown ol {
    padding-left: 20px;
    display: grid;
    gap: 4px;
}

.ai-markdown li {
    margin: 0;
}

.ai-markdown strong {
    font-weight: 700;
    color: #1f3349;
}

.ai-markdown em {
    font-style: italic;
}

.ai-markdown code {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 6px;
    background: rgba(49, 81, 120, 0.08);
    color: #21466f;
    font-size: 0.84em;
}

.ai-markdown hr {
    margin: 2px 0;
    border: 0;
    border-top: 1px solid #d5e2f1;
}

.ai-copy-message {
    position: absolute;
    top: -10px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(190, 210, 235, 0.95);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    color: #5b7391;
    opacity: 0;
    pointer-events: none;
    cursor: pointer;
    transition: opacity 0.18s ease, transform 0.18s ease, background-color 0.18s ease, color 0.18s ease;
    transform: translateY(-2px);
    z-index: 2;
    box-shadow: 0 4px 10px rgba(56, 84, 120, 0.08);
}

.ai-copy-message svg {
    width: 18px;
    height: 18px;
}

.ai-copy-message[data-copy-state]::after {
    right: calc(100% + 10px);
    left: auto;
    top: 50%;
    transform: translateY(-50%);
}

.ai-message:hover .ai-copy-message,
.ai-copy-message:focus-visible,
.ai-copy-message.copied {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.ai-copy-message:hover,
.ai-copy-message:focus-visible {
    background: #ffffff;
    color: #2e5d9f;
}

.ai-copy-message.copied {
    opacity: 1;
    pointer-events: auto;
    background: #e6f4ea;
    color: #1f7a46;
}

.ai-copy-message[data-copy-state]::after {
    content: attr(data-copy-state);
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(31, 45, 66, 0.92);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(18, 34, 56, 0.18);
}

.ai-composer {
    margin: 0 16px 14px;
    background: #ffffff;
    border: 1px solid #b8cfe8;
    color: #637487;
    border-radius: 18px;
    padding: 8px 12px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    box-shadow: none;
}

.ai-composer-plus,
.ai-send-button {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ai-composer-plus {
    border: 1px solid #c8dcf3;
    background: #e4effb;
    color: #1f63d8;
    font-size: 1.05rem;
    font-weight: 700;
    box-shadow: 0 3px 10px rgba(74, 117, 173, 0.08);
}

.ai-composer-field {
    min-width: 0;
}

.ai-composer-input {
    width: 100%;
    min-height: 26px;
    max-height: 160px;
    resize: none;
    border: 0;
    outline: none;
    background: transparent;
    color: #7a8ca0;
    font-size: 0.92rem;
    font-family: 'Outfit', sans-serif;
    line-height: 1.4;
    padding: 6px 0;
}

.ai-composer-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #7a8ca0;
    font-size: 0.84rem;
}

.ai-send-button {
    background: linear-gradient(135deg, #1f63d8, #2a76f0);
    border: 0;
    color: #ffffff;
}

.ai-send-button svg {
    width: 18px;
    height: 18px;
    display: block;
}

.ai-send-button:disabled,
.ai-new-chat:disabled,
.ai-refresh-button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.ai-empty-state {
    padding: 18px;
    border: 1px dashed #d3dfec;
    border-radius: 16px;
    background: #f9fbfe;
    color: #65798f;
    line-height: 1.5;
}

.ai-status-note {
    padding: 10px 12px;
    border-radius: 12px;
    background: #eef5fd;
    border: 1px solid #d5e4f3;
    color: #4e667f;
    font-size: 0.86rem;
}

.ai-status-note.ai-status-error {
    background: #fff1f1;
    border-color: #f1c9c9;
    color: #9b3f3f;
}

.ai-typing-indicator {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.ai-typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #92a7bd;
    animation: ai-pulse 1s infinite ease-in-out;
}

.ai-typing-indicator span:nth-child(2) {
    animation-delay: 0.15s;
}

.ai-typing-indicator span:nth-child(3) {
    animation-delay: 0.3s;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes ai-pulse {

    0%,
    80%,
    100% {
        transform: scale(0.75);
        opacity: 0.45;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.admin-form {
    padding: 22px;
}

.admin-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.admin-actions {
    display: flex;
    justify-content: flex-start;
    gap: 12px;
}

.admin-inline-form {
    grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.7fr) minmax(160px, 0.7fr) auto;
    align-items: end;
}

.admin-table-wrap {
    overflow-x: auto;
}

.settings-content {
    display: grid;
    gap: 18px;
}

.settings-note {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #eef5fd;
    border: 1px solid #d5e4f3;
    color: #4c6680;
    line-height: 1.5;
}

.settings-note-success {
    background: rgba(29, 143, 93, 0.1);
    border-color: rgba(29, 143, 93, 0.2);
    color: #1f6f4d;
}

.settings-note-warning {
    background: #fff5df;
    border-color: #efd69a;
    color: #8a6617;
}

.settings-inline-check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0 18px;
    color: #4f647b;
    font-size: 0.92rem;
}

.settings-inline-check input {
    width: 16px;
    height: 16px;
}

.settings-key-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.settings-field-block {
    display: grid;
    gap: 6px;
}

.settings-access-grid {
    align-items: end;
}

.settings-help {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.45;
}

.settings-config-card,
.settings-report-card {
    overflow: visible;
}

.settings-header {
    align-items: flex-start;
}

.settings-toolbar {
    flex-shrink: 0;
}

.settings-form {
    display: grid;
    gap: 24px;
    padding-bottom: 0;
}

.settings-section {
    display: grid;
    gap: 16px;
}

.settings-section+.settings-section {
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

.settings-section-heading h4 {
    margin: 0;
    font-family: 'Sora', sans-serif;
    font-size: 0.98rem;
}

.settings-section-heading p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.settings-save-bar {
    position: static;
    margin: 6px -22px -22px;
    padding: 16px 22px;
    background: #ffffff;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.settings-save-bar strong {
    display: block;
    font-family: 'Sora', sans-serif;
    font-size: 0.95rem;
}

.settings-save-bar p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.settings-save-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: #f8fbff;
    border-bottom: 1px solid var(--line);
}

.admin-table-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.admin-table-meta strong {
    font-family: 'Sora', sans-serif;
    font-size: 1rem;
}

.admin-table-meta span {
    color: var(--muted);
    font-size: 0.9rem;
}

.admin-table-search {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 0.88rem;
}

.admin-table-search input {
    width: 240px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #ffffff;
}

.teacher-overview-grid,
.teacher-calendar-grid,
.teacher-management-grid {
    display: grid;
    gap: 16px;
    padding: 18px;
}

.teacher-overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.teacher-mini-card,
.teacher-calendar-card,
.teacher-management-card {
    background: #f8fbff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
}

.teacher-mini-card strong,
.teacher-calendar-card strong,
.teacher-management-card strong {
    display: block;
    font-family: 'Sora', sans-serif;
    margin: 4px 0 8px;
    font-size: 0.98rem;
}

.teacher-mini-card p,
.teacher-calendar-card p,
.teacher-management-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
    font-size: 0.9rem;
}

.teacher-calendar-shell {
    padding: 18px;
    display: grid;
    gap: 16px;
}

.teacher-calendar-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.teacher-tab {
    padding: 10px 14px;
    border-radius: 999px;
    background: #eef4fb;
    border: 1px solid var(--line);
    color: #58708a;
    font-size: 0.88rem;
    font-weight: 600;
}

.teacher-tab.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    border-color: transparent;
    color: #ffffff;
}

.teacher-calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0;
}

.teacher-calendar-card span {
    display: block;
    color: #34506b;
    font-weight: 600;
    margin-bottom: 6px;
}

.teacher-management-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.teacher-feature-list {
    margin: 12px 0 0;
    padding-left: 18px;
    color: #4d6278;
    line-height: 1.6;
}

.teacher-feature-list li+li {
    margin-top: 4px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}

.admin-table th,
.admin-table td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.admin-table th {
    background: #f3f7fc;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #64758a;
}

.admin-table tbody tr:hover {
    background: #f9fbfe;
}

.table-action {
    color: var(--accent);
    font-weight: 600;
}

.table-action:hover {
    color: var(--accent-deep);
}

.admin-table tbody tr:last-child td {
    border-bottom: 0;
}

.admin-table-empty {
    padding: 32px 18px !important;
}

.admin-table-empty strong,
.admin-table-empty span {
    display: block;
}

.admin-table-empty span {
    margin-top: 6px;
    color: var(--muted);
}

.pill {
    background: #edf2f8;
    color: #53657b;
    padding: 6px 10px;
    font-size: 0.82rem;
}

.pill-success {
    background: rgba(29, 143, 93, 0.12);
    color: var(--success);
}

.admin-empty-box {
    margin: 18px;
    padding: 18px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
}

.admin-empty-box strong {
    display: block;
    margin-bottom: 4px;
}

.admin-footer {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 14px 26px;
    background: #ffffff;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.9rem;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(8px);
        visibility: hidden;
    }
}

@media (max-width: 980px) {

    .auth-shell,
    .dashboard-shell,
    .admin-stats-row,
    .admin-form-grid,
    .ai-prototype {
        grid-template-columns: 1fr;
    }

    .dashboard-shell {
        height: auto;
        overflow: visible;
    }

    .admin-header,
    .admin-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    body {
        height: auto;
        overflow: auto;
    }

    .admin-sidebar,
    .admin-shell-main {
        height: auto;
        overflow: visible;
    }

    .admin-content {
        overflow: visible;
    }

    .admin-inline-form {
        grid-template-columns: 1fr;
    }

    .admin-table-toolbar,
    .admin-table-search,
    .teacher-calendar-tabs {
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-table-search input {
        width: 100%;
    }

    .teacher-overview-grid,
    .teacher-calendar-grid,
    .teacher-management-grid {
        grid-template-columns: 1fr;
    }

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