:root {
    color-scheme: light;
    --bg: #ecf1f7;
    --surface: #f1f5f9;
    --surface-alt: #e6edf6;
    --surface-dark: #111827;
    --text: #1f2937;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-soft: #dbeafe;
    --success: #15803d;
    --warning: #d97706;
    --border: #dbe2ea;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #020617;
    --surface: #0f172a;
    --surface-alt: #1e293b;
    --surface-dark: #020617;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --primary: #60a5fa;
    --primary-soft: #1e3a8a;
    --success: #22c55e;
    --warning: #f59e0b;
    --border: #334155;
    --shadow: 0 18px 40px rgba(2, 6, 23, 0.5);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background:
        radial-gradient(circle at top, rgba(37, 99, 235, 0.12), transparent 30%),
        linear-gradient(180deg, var(--surface-alt) 0%, var(--bg) 100%);
    color: var(--text);
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
}

.sidebar {
    padding: 28px 20px;
    border-right: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow: auto;
}

.brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 28px;
}

.brand h1,
.hero h2,
.card h3,
.card h4 {
    margin: 0;
}

.brand-badge {
    width: 52px;
    height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: white;
    font-size: 24px;
    box-shadow: var(--shadow);
}

.sidebar-section + .sidebar-section {
    margin-top: 26px;
}

.main-content {
    padding: 32px;
}

.hero,
.card {
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.hero {
    padding: 28px;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}

.hero-copy {
    max-width: 760px;
    color: var(--muted);
    margin: 12px 0 0;
}

.hero-actions,
.resource-row,
.guided-actions,
.editor-toolbar,
.section-heading {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.overview-panel,
.card {
    padding: 24px;
}

.overview-panel {
    margin-top: 24px;
    padding: 18px 20px;
}

.overview-grid,
.content-grid,
.workspace-grid {
    display: grid;
    gap: 20px;
}

.overview-grid {
    margin-top: 18px;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.content-grid,
.workspace-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 20px;
}

.overview-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    background: linear-gradient(180deg, var(--surface), var(--surface-alt));
    min-width: 0;
}

.overview-card h4 {
    font-size: 15px;
    line-height: 1.35;
}

.overview-card h4,
.module-button strong,
.project-card strong {
    display: block;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
}

.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    background: var(--surface-alt);
    color: var(--primary);
    font-weight: 600;
}

.pill.neutral {
    color: var(--muted);
}

.progress-track {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: #e5edf8;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #2563eb, #7c3aed);
    transition: width 0.25s ease;
}

.module-list,
.project-list,
.resource-links {
    display: grid;
    gap: 10px;
}

.module-button,
.project-card {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 18px;
    padding: 14px 16px;
    text-align: left;
}

.module-button {
    display: block;
    text-decoration: none;
    color: inherit;
}

.module-button.is-active {
    border-color: var(--primary);
    background: var(--surface-alt);
}

.module-button.is-done {
    border-color: rgba(21, 128, 61, 0.24);
}

.project-card {
    background: linear-gradient(180deg, var(--surface), var(--surface-alt));
}

.content-card,
.guided-card,
.studio-card,
.preview-card {
    min-width: 0;
}

.markdown-body {
    line-height: 1.65;
}

.markdown-body :first-child {
    margin-top: 0;
}

.markdown-body code {
    font-family: "SFMono-Regular", Consolas, monospace;
    background: var(--surface-alt);
    border-radius: 6px;
    padding: 2px 6px;
}

.markdown-body pre {
    overflow: auto;
    padding: 14px;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 14px;
    border: 1px solid var(--border);
}

.markdown-body pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

.markdown-body blockquote {
    margin: 16px 0;
    padding: 12px 16px;
    border-left: 4px solid var(--primary);
    background: var(--surface-alt);
    border-radius: 12px;
}

.guided-actions {
    margin-top: 20px;
    justify-content: flex-start;
}

.progress-block {
    margin-bottom: 18px;
}

.progress-copy {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-button {
    border-radius: 999px;
    padding: 10px 16px;
    border: 1px solid transparent;
    font-weight: 600;
}

.primary-button {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: white;
}

.secondary-button {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.ghost-button {
    background: transparent;
    border-color: var(--border);
    color: var(--muted);
}

.hidden {
    display: none;
}

.CodeMirror {
    margin-top: 14px;
    border-radius: 18px;
    border: 1px solid var(--border);
    min-height: 520px;
    height: 520px;
    font-size: 14px;
}

.embedded-readable,
#preview-frame,
.markdown-body iframe,
.markdown-body embed,
.markdown-body object {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-alt);
    color: var(--text);
}

[data-theme="dark"] #preview-frame,
[data-theme="dark"] .markdown-body iframe,
[data-theme="dark"] .markdown-body embed,
[data-theme="dark"] .markdown-body object {
    background: #0b1220;
}

#preview-frame {
    min-height: 420px;
    margin-top: 14px;
}

.markdown-body iframe,
.markdown-body embed,
.markdown-body object {
    min-height: 320px;
    margin: 16px 0;
}

.console-panel {
    margin-top: 16px;
    padding: 18px;
    border-radius: 18px;
    background: #0f172a;
    color: #e2e8f0;
}

#console-output {
    margin: 12px 0 0;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 96px;
    max-height: 220px;
    overflow: auto;
}

.resource-links {
    margin-top: 16px;
}

.inline-panel {
    margin-top: 18px;
}

.resource-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 16px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
}

.panel-stack {
    max-height: 420px;
    overflow: auto;
    padding-right: 4px;
}

.support-grid {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.journal-input,
.admin-grid input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    min-height: 48px;
    background: var(--surface);
    color: var(--text);
}

.journal-input {
    margin-top: 12px;
    min-height: 120px;
    resize: vertical;
}

.admin-grid {
    display: grid;
    gap: 12px;
}

.legal-single-column {
    grid-template-columns: 1fr;
}

.legal-card {
    margin-top: 20px;
}

.legal-note {
    margin: 0 0 14px;
}

.legal-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
}

.legal-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.legal-links a:hover,
.legal-links a:focus-visible {
    text-decoration: underline;
}

@media (max-width: 1180px) {
    .app-shell,
    .content-grid,
    .workspace-grid,
    .support-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        max-height: none;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
}

@media (max-width: 720px) {
    .main-content {
        padding: 20px;
    }

    .hero,
    .overview-panel,
    .card {
        padding: 20px;
        border-radius: 20px;
    }

    .hero-actions {
        width: 100%;
    }

    .hero-actions button {
        flex: 1 1 calc(50% - 10px);
    }
}
