/* ============================================
   PyMasters — Ivory Circuit Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Design Tokens --- */
:root {
    --bg-primary: #fafaf9;
    --bg-card: #ffffff;
    --bg-elevated: #f5f5f4;
    --border: #e7e5e4;
    --border-subtle: #f0eeec;
    --text-primary: #18181b;
    --text-secondary: #57534e;
    --text-muted: #a8a29e;
    --accent: #18181b;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.06), 0 4px 6px -4px rgba(0,0,0,0.04);

    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-weight: 400;
    color: var(--text-secondary);
    background: var(--bg-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: opacity var(--transition);
}

a:hover {
    opacity: 0.75;
}

img, video {
    max-width: 100%;
    display: block;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-sans);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.3;
}

h1 { font-size: 1.875rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

code, pre {
    font-family: var(--font-mono);
}

/* --- App Shell --- */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#content {
    flex: 1;
}

/* --- Navigation --- */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    background: rgba(255,255,255,0.92);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0;
}

.logo-text {
    font-size: 1.1rem;
}

.nav-center {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.nav-link:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    opacity: 1;
}

.nav-link.active {
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-weight: 600;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-username {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 4px 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    color: var(--text-primary);
    transition: all var(--transition);
    outline: none;
}

.input::placeholder {
    color: var(--text-muted);
}

.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(24,24,27,0.08);
    background: var(--bg-card);
}

.input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

textarea.input {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

select.input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2357534e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover {
    opacity: 0.85;
    box-shadow: var(--shadow);
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
    opacity: 1;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    opacity: 0.85;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8125rem;
}

.btn-full {
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Loading spinner inside button */
.btn .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-secondary .spinner {
    border-color: rgba(24,24,27,0.15);
    border-top-color: var(--text-primary);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Status Pills --- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.pill-active {
    background: #fef3c7;
    color: var(--warning);
}

.pill-completed {
    background: #dcfce7;
    color: var(--success);
}

.pill-queued {
    background: var(--bg-elevated);
    color: var(--text-muted);
}

.pill-error {
    background: #fee2e2;
    color: var(--danger);
}

.pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* --- Metric Cards --- */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: box-shadow var(--transition);
}

.metric-card:hover {
    box-shadow: var(--shadow-md);
}

.metric-card .metric-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 4px;
}

.metric-card .metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.metric-card .metric-detail {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- Module Cards --- */
.module-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 28px;
}

.module-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    transition: all var(--transition);
}

.module-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #d6d3d1;
}

.module-info {
    flex: 1;
    min-width: 0;
}

.module-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.module-info p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 10px;
}

.module-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.module-tag {
    font-size: 0.75rem;
    padding: 2px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-weight: 500;
}

.module-difficulty {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.module-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.module-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* --- Chat --- */
.chat-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin-bottom: 24px;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.chat-header-dots {
    display: flex;
    gap: 6px;
}

.chat-header-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
}

.chat-header-dots span:nth-child(1) { background: #f87171; }
.chat-header-dots span:nth-child(2) { background: #fbbf24; }
.chat-header-dots span:nth-child(3) { background: #4ade80; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 300px;
    max-height: 500px;
}

.chat-message {
    max-width: 85%;
    line-height: 1.6;
    font-size: 0.9375rem;
}

.chat-message-user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    padding: 10px 16px;
    border-radius: 16px 16px 4px 16px;
}

.chat-message-assistant {
    align-self: flex-start;
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 14px 18px;
    border-radius: 4px 16px 16px 16px;
    border: 1px solid var(--border-subtle);
}

.chat-message-assistant h1,
.chat-message-assistant h2,
.chat-message-assistant h3,
.chat-message-assistant h4 {
    margin-top: 12px;
    margin-bottom: 6px;
}

.chat-message-assistant h1:first-child,
.chat-message-assistant h2:first-child,
.chat-message-assistant h3:first-child {
    margin-top: 0;
}

.chat-message-assistant p {
    margin-bottom: 8px;
}

.chat-message-assistant p:last-child {
    margin-bottom: 0;
}

.chat-message-assistant pre {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    overflow-x: auto;
    margin: 10px 0;
    font-size: 0.8125rem;
    line-height: 1.7;
}

.chat-message-assistant code {
    font-size: 0.85em;
    background: rgba(0,0,0,0.04);
    padding: 2px 6px;
    border-radius: 4px;
}

.chat-message-assistant pre code {
    background: none;
    padding: 0;
}

.chat-message-assistant ul,
.chat-message-assistant ol {
    margin: 8px 0;
    padding-left: 20px;
}

.chat-message-assistant li {
    margin-bottom: 4px;
}

.chat-message-assistant table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 0.875rem;
}

.chat-message-assistant th,
.chat-message-assistant td {
    padding: 8px 12px;
    border: 1px solid var(--border);
    text-align: left;
}

.chat-message-assistant th {
    background: var(--bg-primary);
    font-weight: 600;
    color: var(--text-primary);
}

.chat-message-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

.chat-input-area .input {
    flex: 1;
}

/* --- Split Layout (Login/Signup) --- */
.split-layout {
    display: flex;
    min-height: 100vh;
}

.split-brand {
    flex: 1;
    background: var(--bg-elevated);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    position: relative;
    overflow: hidden;
}

.split-brand::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(24,24,27,0.02) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(24,24,27,0.02) 0%, transparent 50%);
}

.split-brand-content {
    position: relative;
    text-align: center;
    max-width: 380px;
}

.split-brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.split-brand-logo .logo-icon {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
}

.split-brand-logo .logo-text {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.split-brand-tagline {
    font-size: 1.125rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 28px;
}

.split-brand-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.split-brand-chip {
    padding: 6px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.split-form {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background: var(--bg-card);
}

.split-form-inner {
    width: 100%;
    max-width: 400px;
}

.split-form-inner h2 {
    margin-bottom: 4px;
}

.split-form-inner .form-subtitle {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-bottom: 28px;
}

.split-form-inner .form-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.split-form-inner .form-footer a {
    font-weight: 500;
}

.form-error {
    background: #fee2e2;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 16px;
    display: none;
}

.form-error.visible {
    display: block;
}

/* --- Code Editor --- */
.code-editor-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.code-editor {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.code-editor textarea {
    width: 100%;
    min-height: 350px;
    padding: 16px;
    border: none;
    background: transparent;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--text-primary);
    resize: vertical;
    outline: none;
    tab-size: 4;
}

.code-output {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.code-output-body {
    flex: 1;
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-y: auto;
    min-height: 350px;
    max-height: 500px;
}

.code-output-body.success {
    color: var(--success);
}

.code-output-body.error {
    color: var(--danger);
}

.editor-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.editor-header-dots {
    display: flex;
    gap: 6px;
}

.editor-header-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.editor-header-dots span:nth-child(1) { background: #f87171; }
.editor-header-dots span:nth-child(2) { background: #fbbf24; }
.editor-header-dots span:nth-child(3) { background: #4ade80; }

/* --- Activity Feed --- */
.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.875rem;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-text {
    flex: 1;
    color: var(--text-secondary);
}

.activity-text strong {
    color: var(--text-primary);
    font-weight: 500;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* --- Leaderboard --- */
.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.leader-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.875rem;
    border-radius: var(--radius);
    transition: background var(--transition);
}

.leader-row:last-child {
    border-bottom: none;
}

.leader-row:hover {
    background: var(--bg-elevated);
}

.leader-current {
    background: #fffbeb;
    border: 1px solid #fde68a;
}

.leader-current:hover {
    background: #fef9c3;
}

.leader-rank {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8125rem;
    color: var(--text-muted);
    background: var(--bg-elevated);
    border-radius: 50%;
    flex-shrink: 0;
}

.leader-current .leader-rank {
    background: #fde68a;
    color: var(--text-primary);
}

.leader-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.leader-score {
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* --- Collapsible --- */
.collapsible {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}

.collapsible-header:hover {
    background: var(--bg-elevated);
}

.collapsible-header h3 {
    font-size: 0.9375rem;
    font-weight: 600;
}

.collapsible-chevron {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: transform var(--transition-slow);
    font-size: 0.75rem;
}

.collapsible.open .collapsible-chevron {
    transform: rotate(180deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-slow);
}

.collapsible.open .collapsible-content {
    max-height: 2000px;
}

.collapsible-body {
    padding: 0 20px 20px;
}

/* --- Rich Tutor Content --- */
.concept-card {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin: 12px 0;
}

.concept-card h4 {
    color: #1d4ed8;
    font-size: 0.9375rem;
    margin-bottom: 6px;
}

.concept-card p {
    font-size: 0.875rem;
    color: #1e40af;
}

.steps-timeline {
    position: relative;
    padding-left: 24px;
    margin: 12px 0;
}

.steps-timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.steps-timeline .step {
    position: relative;
    padding: 8px 0;
    font-size: 0.875rem;
}

.steps-timeline .step::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 14px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-card);
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.875rem;
}

.compare-table th {
    background: var(--bg-elevated);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.compare-table td {
    padding: 10px 14px;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.compare-table tr:hover td {
    background: var(--bg-elevated);
}

/* --- Page Layout Helpers --- */
.page-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 24px;
}

.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.page-section {
    margin-bottom: 28px;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* --- Snippet Buttons --- */
.snippet-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.snippet-btn {
    padding: 6px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.snippet-btn:hover {
    background: var(--bg-elevated);
    border-color: #d6d3d1;
    color: var(--text-primary);
}

.snippet-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* --- Preview Area --- */
.preview-area {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    margin-top: 20px;
}

.preview-area img,
.preview-area video {
    max-width: 100%;
    max-height: 500px;
    border-radius: var(--radius);
}

.preview-placeholder {
    color: var(--text-muted);
    font-size: 0.9375rem;
    text-align: center;
}

/* --- Danger Zone --- */
.danger-zone {
    border-color: #fca5a5;
    background: #fef2f2;
}

.danger-zone h3 {
    color: var(--danger);
}

/* --- Settings --- */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.setting-desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Toggle switch stub */
.toggle {
    width: 40px;
    height: 22px;
    background: var(--border);
    border-radius: var(--radius-full);
    position: relative;
    cursor: pointer;
    transition: background var(--transition);
}

.toggle::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    top: 2px;
    left: 2px;
    transition: transform var(--transition);
    box-shadow: var(--shadow-sm);
}

.toggle.active {
    background: var(--accent);
}

.toggle.active::after {
    transform: translateX(18px);
}

.toggle.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Checkbox */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.25s ease-out, toastOut 0.25s ease-in 2.75s forwards;
    color: var(--text-primary);
}

.toast-success {
    border-left: 3px solid var(--success);
}

.toast-error {
    border-left: 3px solid var(--danger);
}

.toast-warning {
    border-left: 3px solid var(--warning);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(12px); }
}

/* --- Studio History --- */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.history-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
}

.history-item:hover {
    box-shadow: var(--shadow-md);
}

.history-item img,
.history-item video {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.history-item-meta {
    padding: 8px 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Tutor Sessions / Notes --- */
.session-item,
.note-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: color var(--transition);
}

.session-item:last-child,
.note-item:last-child {
    border-bottom: none;
}

.session-item:hover,
.note-item:hover {
    color: var(--text-primary);
}

.session-item-title,
.note-item-title {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.session-item-date,
.note-item-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.empty-state-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* --- Loading --- */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: loadPulse 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes loadPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .split-layout {
        flex-direction: column;
    }

    .split-brand {
        padding: 32px 24px;
        min-height: auto;
    }

    .split-form {
        padding: 32px 24px;
    }

    .nav {
        padding: 0 16px;
    }

    .nav-center {
        display: none;
    }

    .nav.mobile-open .nav-center {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border);
        padding: 8px;
        z-index: 99;
    }

    .page-container {
        padding: 20px 16px;
    }

    .code-editor-wrapper {
        grid-template-columns: 1fr;
    }

    .two-col {
        grid-template-columns: 1fr;
    }

    .metrics-row {
        grid-template-columns: 1fr;
    }

    .module-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .module-actions {
        width: 100%;
    }

    .module-actions .btn {
        flex: 1;
    }
}

@media (max-width: 480px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }

    .split-brand {
        padding: 24px 20px;
    }

    .split-brand-tagline {
        font-size: 1rem;
    }

    .metric-card .metric-value {
        font-size: 1.5rem;
    }

    .chat-messages {
        min-height: 200px;
    }
}
