/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    background: #f4f5f7;
    color: #2c2c2c;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header {
    background: #1e1e2e;
    color: #fff;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 32px;
    max-width: 1100px;
    margin: 0 auto;
    height: 56px;
}
.logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: #e2e8f0;
    letter-spacing: .5px;
}
.logo:hover { text-decoration: none; color: #fff; }
.site-header nav { display: flex; gap: 8px; }
.site-header nav a {
    color: #94a3b8;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: .9rem;
    transition: background .15s, color .15s;
}
.site-header nav a:hover,
.site-header nav a.active {
    background: rgba(255,255,255,.1);
    color: #fff;
    text-decoration: none;
}

/* ── Main content ─────────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 32px auto;
    padding: 0 24px;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
    text-align: center;
    padding: 16px;
    font-size: .82rem;
    color: #888;
    border-top: 1px solid #e2e4e8;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 600;
    transition: opacity .15s, background .15s;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary   { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-secondary:hover { background: #d1d5db; }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-copy      { background: #0d9488; color: #fff; min-width: 80px; }
.btn-copy:hover { background: #0f766e; }
.btn-sm        { padding: 5px 12px; font-size: .82rem; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: .92rem;
    line-height: 1.6;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 22px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; }
.form-group select,
.form-group input[type="file"],
.form-group input[type="text"] {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: .93rem;
    background: #fff;
}
.form-group select:focus,
.form-group input:focus { outline: 2px solid #2563eb; }

.hint { font-size: .83rem; color: #6b7280; margin-top: 5px; }
.hidden { display: none !important; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.input-sm { padding: 4px 8px; font-size: .82rem; border: 1px solid #cbd5e1; border-radius: 5px; }

/* Code / textarea editor */
.code-editor {
    width: 100%;
    font-family: 'Consolas', monospace;
    font-size: .82rem;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #1e1e2e;
    color: #cdd6f4;
    resize: vertical;
    line-height: 1.5;
}

/* ── Home page ───────────────────────────────────────────────────────────── */
.page-home h1 { font-size: 1.8rem; margin-bottom: 8px; }
.lead { font-size: 1.05rem; color: #475569; margin-bottom: 32px; }
.home-cards { display: flex; gap: 20px; margin-bottom: 48px; flex-wrap: wrap; }
.card {
    flex: 1;
    min-width: 240px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 28px 24px;
    transition: box-shadow .15s, border-color .15s;
    color: inherit;
    display: block;
}
.card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.1); border-color: #93c5fd; text-decoration: none; }
.card-primary { border-color: #2563eb; }
.card-icon { font-size: 2rem; display: block; margin-bottom: 12px; }
.card h2 { font-size: 1.1rem; margin-bottom: 6px; }
.card p { font-size: .88rem; color: #64748b; }

.flow-diagram {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px 24px;
    font-size: .88rem;
}
.flow-step {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 14px;
    font-weight: 600;
    white-space: nowrap;
}
.flow-arrow { padding: 0 12px; color: #94a3b8; font-size: 1.2rem; }

/* ── Result page ─────────────────────────────────────────────────────────── */
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    gap: 16px;
    flex-wrap: wrap;
}
.result-header h1 { font-size: 1.6rem; margin-bottom: 4px; }
.meta { font-size: .85rem; color: #6b7280; }

.unit-block { margin-bottom: 36px; }
.unit-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e2e8f0;
}
.lesson-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.07); }
.lesson-table tr { border-bottom: 1px solid #f1f5f9; }
.lesson-table tr:last-child { border-bottom: none; }
.lesson-table td { padding: 13px 16px; vertical-align: middle; }
.lesson-number { width: 100px; color: #6b7280; font-size: .88rem; }
.lesson-title  { font-weight: 500; }
.lesson-action { width: 100px; text-align: right; }

.copy-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #0d9488;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
    z-index: 9999;
    font-size: .95rem;
}

/* ── Templates page ─────────────────────────────────────────────────────── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.section-header h1 { font-size: 1.5rem; }
.template-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.07); margin-bottom: 32px; }
.template-table th { background: #f8fafc; font-size: .82rem; text-transform: uppercase; letter-spacing: .5px; padding: 10px 16px; text-align: left; border-bottom: 1px solid #e2e8f0; color: #6b7280; }
.template-table td { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; font-size: .9rem; }
.template-table tr:last-child td { border-bottom: none; }
.template-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.template-editor {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 24px;
    margin-top: 24px;
}
.template-editor h2 { margin-bottom: 16px; }
.editor-actions { margin-top: 14px; display: flex; gap: 10px; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #93c5fd;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
