:root {
    --bg: #07111f;
    --bg-2: #0d1b31;
    --panel: rgba(9, 16, 31, 0.9);
    --panel-soft: rgba(16, 28, 48, 0.86);
    --panel-strong: rgba(12, 20, 37, 0.96);
    --line: rgba(148, 163, 184, 0.18);
    --line-strong: rgba(148, 163, 184, 0.28);
    --text: #f8fafc;
    --muted: #9fb0c8;
    --accent: #0060ad;
    --accent-2: #0d79cf;
    --accent-3: #22c55e;
    --user-bubble: linear-gradient(135deg, #0060ad, #0d79cf);
    --bot-bubble: rgba(15, 23, 42, 0.9);
    --shadow: 0 30px 90px rgba(2, 6, 23, 0.48);
    --radius-xl: 30px;
    --radius-lg: 24px;
    --radius-md: 18px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: "Manrope", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(0, 96, 173, 0.24), transparent 25%),
        radial-gradient(circle at top right, rgba(34, 197, 94, 0.12), transparent 22%),
        linear-gradient(180deg, #06101d 0%, #091526 48%, #050b16 100%);
}

a {
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}

input,
button {
    font: inherit;
}

.page-shell {
    min-height: 100vh;
    padding: 18px;
}

.app-card {
    width: 100%;
    max-width: 1380px;
    margin: 0 auto;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 34px;
    background:
        linear-gradient(180deg, rgba(8, 14, 26, 0.98), rgba(6, 10, 20, 0.98));
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}

.hero {
    display: grid;
    justify-items: center;
    text-align: center;
}

.hero-simple {
    gap: 16px;
    margin-bottom: 28px;
}

.hero-logo-only {
    width: min(100%, 220px);
}

.hero-logo-only img {
    max-width: 180px;
    margin: 0 auto;
}

.hero h1,
.chat-header h2,
.side-card h2,
.materials-header h2,
.module-card h3,
.material-card h4 {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    letter-spacing: -0.03em;
}

.hero h1 {
    font-size: clamp(2rem, 4vw, 3.6rem);
    line-height: 1.02;
    max-width: 16ch;
}

.hero-copy {
    max-width: 700px;
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.eyebrow {
    margin: 0;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: #58a9ea;
    font-weight: 700;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(290px, 340px) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.workspace:not(.unlocked) {
    grid-template-columns: 1fr;
    justify-items: center;
}

.workspace.unlocked {
    grid-template-columns: minmax(0, 1fr);
}

.content-stack {
    display: grid;
    gap: 24px;
    min-width: 0;
    width: 100%;
}

.workspace.unlocked .content-stack {
    grid-column: 1 / -1;
}

.workspace:not(.unlocked) .content-stack {
    display: none;
}

.side-card,
.chat-card,
.capture-panel,
.materials-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--panel);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.side-card {
    padding: 22px;
    position: sticky;
    top: 18px;
}

.workspace:not(.unlocked) .side-card {
    position: static;
    width: min(100%, 420px);
    margin: 0 auto;
}

.side-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.status-dot {
    width: 11px;
    height: 11px;
    border-radius: 999px;
    background: var(--accent-3);
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.12);
}

.side-card-copy {
    margin: 0 0 18px;
    color: var(--muted);
    line-height: 1.7;
}

.login-form {
    display: grid;
    gap: 12px;
}

.field-label,
.sr-only {
    font-size: 0.84rem;
    color: var(--muted);
}

.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;
}

input {
    width: 100%;
    padding: 15px 16px;
    color: var(--text);
    background: rgba(15, 23, 42, 0.82);
    border: 1px solid var(--line);
    border-radius: 16px;
    outline: none;
}

input::placeholder {
    color: rgba(159, 176, 200, 0.75);
}

input:focus {
    border-color: rgba(13, 121, 207, 0.58);
    box-shadow: 0 0 0 4px rgba(0, 96, 173, 0.16);
}

button,
.download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 16px;
    padding: 14px 18px;
    font-weight: 700;
    text-decoration: none;
    color: #fff7ed;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    cursor: pointer;
    transition: transform 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
}

button:hover,
.download-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    box-shadow: 0 10px 24px rgba(0, 96, 173, 0.28);
}

button:disabled {
    cursor: not-allowed;
    filter: grayscale(0.1);
    opacity: 0.72;
    transform: none;
    box-shadow: none;
}

.ghost-button {
    color: var(--text);
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--line-strong);
}

.form-error {
    display: none;
    margin-top: 12px;
    color: #fda4af;
    font-size: 0.92rem;
}

.chat-card {
    padding: 24px;
    min-width: 0;
    width: 100%;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.chat-heading {
    display: grid;
    gap: 4px;
}

.chat-header h2,
.materials-header h2 {
    font-size: clamp(1.55rem, 2vw, 2.1rem);
}

.chat-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.instructions-panel {
    margin-bottom: 16px;
    padding: 16px;
    border-radius: 22px;
    border: 1px solid rgba(88, 169, 234, 0.22);
    background: rgba(15, 23, 42, 0.68);
    display: grid;
    gap: 12px;
}

.instructions-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.instructions-panel-copy {
    margin: 0;
    color: rgba(232, 244, 255, 0.86);
    font-size: 0.95rem;
    line-height: 1.5;
}

.instructions-textarea {
    width: 100%;
    resize: vertical;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(88, 169, 234, 0.24);
    background: rgba(15, 23, 42, 0.74);
    color: var(--text);
    font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
    line-height: 1.45;
    outline: none;
}

.instructions-textarea:focus {
    border-color: rgba(88, 169, 234, 0.44);
    box-shadow: 0 0 0 4px rgba(0, 96, 173, 0.18);
}

.instructions-panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.instructions-panel-status {
    min-height: 20px;
    font-size: 0.92rem;
    color: rgba(217, 239, 255, 0.9);
}

.model-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 136px;
    padding: 12px 16px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(0, 96, 173, 0.98), rgba(13, 121, 207, 0.94));
    color: var(--text);
    font-weight: 700;
    border: 1px solid rgba(88, 169, 234, 0.28);
}

.model-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.meta-card {
    display: grid;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.72);
}

.meta-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #6cbcf2;
}

.classroom-note {
    margin-bottom: 16px;
    padding: 13px 15px;
    border-radius: 16px;
    border: 1px solid rgba(88, 169, 234, 0.2);
    background: rgba(0, 96, 173, 0.14);
    color: #d9efff;
    line-height: 1.6;
    font-size: 0.94rem;
}

.classroom-note[data-tone="success"] {
    border-color: rgba(34, 197, 94, 0.22);
    background: rgba(21, 128, 61, 0.16);
    color: #dcfce7;
}

.classroom-note[data-tone="warning"] {
    border-color: rgba(250, 204, 21, 0.22);
    background: rgba(113, 63, 18, 0.22);
    color: #fef08a;
}

.chat-box {
    display: grid;
    gap: 14px;
    min-height: 520px;
    max-height: 64vh;
    width: 100%;
    padding: 12px 4px 12px 0;
    overflow-y: auto;
}

.chat-box::-webkit-scrollbar {
    width: 8px;
}

.chat-box::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.22);
    border-radius: 999px;
}

.message {
    max-width: min(100%, 760px);
    width: fit-content;
    padding: 16px 18px;
    border-radius: 20px;
    line-height: 1.65;
    border: 1px solid var(--line);
    white-space: pre-wrap;
    word-break: break-word;
}

.message.user {
    justify-self: end;
    background: var(--user-bubble);
    color: #fff7ed;
    border-top-right-radius: 6px;
}

.message.bot {
    justify-self: start;
    background: var(--bot-bubble);
    color: var(--text);
    border-top-left-radius: 6px;
}

.message.system {
    justify-self: center;
    text-align: center;
    background: rgba(15, 23, 42, 0.65);
    color: var(--muted);
}

.chat-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    margin-top: 8px;
}

.chat-form button {
    min-width: 132px;
}

.capture-panel {
    padding: 24px;
    background: linear-gradient(180deg, rgba(9, 18, 33, 0.98), rgba(8, 16, 29, 0.98));
}

.capture-header {
    display: grid;
    gap: 6px;
    margin-bottom: 18px;
}

.capture-intro {
    margin: 0;
    max-width: 760px;
    color: var(--muted);
    line-height: 1.7;
}

.capture-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 14px;
    align-items: end;
}

.capture-field {
    display: grid;
    gap: 8px;
}

.capture-form button {
    min-width: 220px;
}

.capture-feedback {
    display: none;
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(88, 169, 234, 0.2);
    background: rgba(0, 96, 173, 0.14);
    color: #d9efff;
    line-height: 1.6;
    font-size: 0.95rem;
}

.capture-feedback[data-tone="success"] {
    display: block;
    border-color: rgba(34, 197, 94, 0.22);
    background: rgba(21, 128, 61, 0.16);
    color: #dcfce7;
}

.capture-feedback[data-tone="warning"] {
    display: block;
    border-color: rgba(250, 204, 21, 0.22);
    background: rgba(113, 63, 18, 0.22);
    color: #fef08a;
}

.materials-panel {
    padding: 24px;
    background:
        linear-gradient(180deg, rgba(12, 20, 37, 0.98), rgba(10, 17, 31, 0.98));
}

.materials-header {
    display: grid;
    gap: 6px;
    margin-bottom: 18px;
    grid-template-columns: 1fr auto;
    align-items: start;
}

.materials-header .eyebrow,
.materials-header .materials-intro {
    grid-column: 1 / -1;
}

.materials-actions {
    grid-column: 2;
    justify-self: end;
    align-self: center;
}

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

.materials-intro {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
    max-width: 780px;
}

.materials-list {
    display: grid;
    gap: 18px;
}

.module-card {
    padding: 20px;
    border-radius: 24px;
    border: 1px solid var(--line);
    background:
        linear-gradient(180deg, rgba(14, 24, 44, 0.92), rgba(10, 18, 33, 0.96));
}

.module-card-header {
    display: grid;
    gap: 8px;
    margin-bottom: 0;
    cursor: pointer;
    user-select: none;
}

.module-card > summary {
    list-style: none;
}

.module-card > summary::-webkit-details-marker {
    display: none;
}

.module-card[open] .module-card-header {
    margin-bottom: 16px;
}

.module-card[open] {
    border-color: rgba(88, 169, 234, 0.28);
}

.module-card h3 {
    font-size: clamp(1.2rem, 2vw, 1.55rem);
}

.module-badge,
.material-type {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.77rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 700;
}

.module-badge {
    background: rgba(0, 96, 173, 0.16);
    color: #7cc5ff;
    border: 1px solid rgba(0, 96, 173, 0.24);
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.material-card {
    display: grid;
    gap: 12px;
    padding: 18px;
    border-radius: 20px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(15, 23, 42, 0.76);
}

.material-type {
    background: rgba(34, 197, 94, 0.14);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.material-card h4 {
    font-size: 1rem;
    line-height: 1.5;
    word-break: break-word;
}

.download-btn {
    width: fit-content;
    min-width: 190px;
}

.footer-note {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    text-align: center;
    color: var(--muted);
    font-size: 0.94rem;
}

@media (max-width: 1100px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .side-card {
        position: static;
    }

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

@media (max-width: 720px) {
    .page-shell {
        padding: 10px;
    }

    .app-card {
        padding: 14px;
        border-radius: 24px;
    }

    .hero-simple {
        gap: 12px;
        margin-bottom: 18px;
    }

    .hero h1 {
        font-size: clamp(2rem, 10vw, 2.9rem);
        max-width: none;
    }

    .hero-logo-only img {
        max-width: 150px;
    }

    .side-card,
    .capture-panel,
    .materials-panel,
    .chat-card {
        padding: 16px;
        border-radius: 22px;
    }

    .chat-header {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 14px;
    }

    .chat-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .model-badge,
    .ghost-button,
    .download-btn {
        width: 100%;
    }

    .model-meta {
        grid-template-columns: 1fr;
        gap: 10px;
    }

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

    .chat-box {
        min-height: 280px;
        max-height: 40dvh;
    }

    .message {
        max-width: 100%;
        padding: 14px 15px;
        font-size: 0.95rem;
    }

    .chat-form {
        grid-template-columns: 1fr;
        position: sticky;
        bottom: 0;
        padding-top: 10px;
        background: linear-gradient(180deg, rgba(10, 16, 32, 0), rgba(10, 16, 32, 0.96) 24%);
    }

    .chat-form button {
        width: 100%;
    }

    .footer-note {
        margin-top: 16px;
        padding-top: 14px;
        font-size: 0.88rem;
    }
}

@media (max-width: 420px) {
    .page-shell {
        padding: 8px;
    }

    .app-card {
        padding: 12px;
    }

    .chat-header h2,
    .materials-header h2,
    .module-card h3 {
        font-size: 1.35rem;
    }

    .chat-box {
        min-height: 230px;
        max-height: 34dvh;
    }
}
