/* Development Screen D-score - Day/Night Themes
   Enhanced readability: 15px-16px base font, responsive video containers, distinct buttons */

:root {
    /* Night / Dark Theme (Default) */
    --bg: #0d1117;
    --bg-card: #161b22;
    --bg-input: #0d1117;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --text-dim: #6e7681;
    --accent: #58a6ff;
    --accent-hover: #79b8ff;
    --green: #3fb950;
    --green-bg: rgba(63, 185, 80, 0.15);
    --red: #f85149;
    --red-bg: rgba(248, 81, 73, 0.15);
    --yellow: #d29922;
    --yellow-bg: rgba(210, 153, 34, 0.15);
    --radius: 8px;
    --sidebar-w: 320px;
    --canvas-bg: #0d1117;
    --canvas-grid: rgba(48, 54, 61, 0.6);
    --header-title: #ffffff;
    --item-bg: #161b22;
}

[data-theme="light"] {
    /* Day / Light Theme */
    --bg: #f6f8fa;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --border: #d0d7de;
    --text: #1f2328;
    --text-muted: #656d76;
    --text-dim: #8c959f;
    --accent: #0969da;
    --accent-hover: #0860ca;
    --green: #1a7f37;
    --green-bg: rgba(26, 127, 55, 0.12);
    --red: #cf222e;
    --red-bg: rgba(207, 34, 46, 0.12);
    --yellow: #9a6700;
    --yellow-bg: rgba(154, 103, 0, 0.12);
    --canvas-bg: #ffffff;
    --canvas-grid: rgba(208, 215, 222, 0.8);
    --header-title: #1f2328;
    --item-bg: #ffffff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.header-left h1 { font-size: 22px; font-weight: 700; color: var(--header-title); }
.subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; display: block; }
.header-right { display: flex; gap: 10px; align-items: center; }

/* Buttons */
.btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
[data-theme="dark"] .btn-primary, :root:not([data-theme="light"]) .btn-primary { color: #000; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
[data-theme="dark"] .btn-primary:hover, :root:not([data-theme="light"]) .btn-primary:hover { color: #000; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: transparent; }
.btn-lg { padding: 12px 28px; font-size: 16px; font-weight: 600; }
.btn-theme {
    font-size: 16px;
    padding: 6px 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    line-height: 1;
}
.btn-theme:hover {
    border-color: var(--accent);
    transform: scale(1.05);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
}
.tab {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Tab content */
main { flex: 1; overflow: hidden; }
.tab-content { display: none; height: calc(100vh - 140px); overflow-y: auto; padding: 20px 24px; }
.tab-content.active { display: block; }

/* Screening layout */
.screening-layout { display: flex; gap: 20px; height: 100%; }
.sidebar { width: var(--sidebar-w); flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; }
.content-area { flex: 1; overflow-y: auto; padding-right: 4px; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}
.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 12px; color: var(--text); }

/* Form */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
input[type="text"], input[type="number"], select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
select { cursor: pointer; }

.age-inputs { display: flex; gap: 10px; }
.age-inputs > div { flex: 1; }
.age-inputs input { text-align: center; font-size: 15px; font-weight: 600; }
.age-label { font-size: 12px; color: var(--text-dim); text-align: center; display: block; margin-top: 4px; }

input[type="range"] { width: 100%; accent-color: var(--accent); margin-top: 6px; }
.range-val { font-size: 15px; color: var(--accent); font-weight: 600; margin-left: 8px; }

/* Age display */
.age-display { font-size: 22px; font-weight: 700; color: var(--text); }
.expected-d { font-size: 14px; color: var(--text-muted); margin-top: 6px; }

/* Items */
.items-container { display: flex; flex-direction: column; gap: 12px; }
.empty-state {
    text-align: center;
    padding: 50px 24px;
    color: var(--text-dim);
    font-size: 15px;
    line-height: 1.6;
}

.item-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.15s, background-color 0.15s;
}
.item-card:hover { border-color: var(--text-dim); }
.item-card.resp-pass { border-left: 4px solid var(--green); }
.item-card.resp-fail { border-left: 4px solid var(--red); }

.item-main-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.item-info { flex: 1; }
.item-label { font-size: 16px; font-weight: 500; color: var(--text); line-height: 1.45; }

/* --- Item header layout --- */
.item-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.item-code { font-size: 12px; color: var(--text-dim); font-family: monospace; }
.item-domain {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-muted);
    font-weight: 500;
}

/* Response buttons */
.item-responses { display: flex; gap: 8px; flex-shrink: 0; }
.resp-btn {
    min-width: 80px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.15s;
}
.resp-btn:hover { border-color: var(--text-dim); color: var(--text); }
.resp-btn.selected.resp-yes { background: var(--green); border-color: var(--green); color: #000; font-weight: 700; }
.resp-btn.selected.resp-no { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }

/* --- Item image/video/description toggles --- */
.btn-img-toggle, .btn-video-toggle, .btn-desc-toggle {
    background: var(--bg-input);
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 500;
    padding: 3px 9px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn-img-toggle { color: var(--accent); }
.btn-img-toggle:hover { border-color: var(--accent); background: rgba(88, 166, 255, 0.12); }

.btn-video-toggle { color: #f85149; border-color: rgba(248, 81, 73, 0.4); }
.btn-video-toggle:hover { border-color: #f85149; background: rgba(248, 81, 73, 0.15); color: #ff7b72; }

.btn-desc-toggle { color: var(--text-muted); }
.btn-desc-toggle:hover { border-color: var(--text-muted); color: var(--text); }

.badge-video {
    background: rgba(248, 81, 73, 0.12);
    border: 1px solid rgba(248, 81, 73, 0.4);
    color: #ff7b72;
    font-size: 12px;
    padding: 3px 9px;
    border-radius: 4px;
}

/* --- Item description --- */
.item-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin: 6px 0;
    padding: 10px 14px;
    background: var(--bg-input);
    border-left: 3px solid var(--border);
    border-radius: 0 6px 6px 0;
    line-height: 1.6;
}

/* --- Item image --- */
.item-image {
    margin: 12px 0;
    text-align: center;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
.item-image img {
    width: 100%;
    max-width: 100%;
    max-height: 520px;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 6px;
}

/* --- Item video --- */
.item-video { margin: 8px 0; }
.video-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 6px;
    background: #000;
    margin-bottom: 10px;
}
.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
.video-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 8px;
}
.btn-video-ext {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(248, 81, 73, 0.12);
    border: 1px solid rgba(248, 81, 73, 0.4);
    color: #ff7b72;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
}
.btn-video-ext:hover {
    background: #f85149;
    color: #fff;
    border-color: #f85149;
}

/* Scoring actions */
.scoring-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Results */
.results-container { max-width: 960px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.results-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
@media (max-width: 900px) { .results-grid { grid-template-columns: 1fr; } }
.result-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px;
}
.result-card h3 { font-size: 15px; color: var(--text-muted); margin-bottom: 8px; }
.result-metric { font-size: 38px; font-weight: 800; color: var(--text); line-height: 1.1; margin-bottom: 4px; }
.result-ci { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; font-family: monospace; }
.daz-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    margin: 6px 0;
}
.daz-badge.daz-normal { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.daz-badge.daz-watch { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow); }
.daz-badge.daz-delay { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }

.percentile-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    margin: 8px 0;
    overflow: hidden;
}
.percentile-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

.chart-card {
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.chart-card h3 { font-size: 17px; margin-bottom: 14px; font-weight: 600; }
#growthChart {
    width: 100%;
    height: 420px;
    display: block;
    border-radius: 8px;
}

.interpretation-text p {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: 10px;
}
.interpretation-text p:last-child { margin-bottom: 0; }

/* Domain summary */
.domain-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.domain-stat-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 14px;
}
.domain-stat-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}
.domain-stat-title { color: var(--text); }
.domain-stat-counts { color: var(--text-muted); }
.domain-stat-bar-bg {
    width: 100%;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}
.domain-stat-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

/* Item results table */
.item-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin-top: 10px;
}
.item-results-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg-input);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.item-results-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.item-results-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}
.badge-status-pass { color: var(--green); font-weight: 600; }
.badge-status-fail { color: var(--red); font-weight: 600; }
.badge-status-na { color: var(--text-dim); }

/* Education */
.education-content { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.education-content p { font-size: 15px; line-height: 1.7; color: var(--text-muted); margin-top: 8px; }
.education-content ul { margin-left: 24px; margin-top: 8px; }
.education-content li { font-size: 15px; line-height: 1.7; color: var(--text-muted); margin-bottom: 6px; }
.education-content strong { color: var(--text); font-weight: 600; }
.education-content code { background: var(--bg-input); padding: 2px 8px; border-radius: 4px; font-size: 14px; }
.ref-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.ref-table th { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text-muted); font-weight: 600; }
.ref-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.disclaimer { font-size: 13px; color: var(--text-dim); font-style: italic; }
hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* Modal */
.modal { display: none; position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); }
.modal.active { display: flex; align-items: center; justify-content: center; }
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 550px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-content h3 { font-size: 18px; margin-bottom: 12px; }
.modal-content p { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 10px; }
.close { float: right; cursor: pointer; font-size: 24px; color: var(--text-muted); }
.close:hover { color: var(--text); }

/* Footer */
footer {
    padding: 10px 24px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* --- Language selector --- */
.lang-selector { display: flex; gap: 2px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; padding: 2px; }
.lang-btn { background: none; border: none; color: var(--text-muted); font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 4px; cursor: pointer; transition: all 0.15s; }
.lang-btn.active { background: var(--accent); color: #000; }
.lang-btn:hover:not(.active) { color: var(--text); }

/* --- Manuals section --- */
.manuals-container { max-width: 960px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.manuals-container h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.manuals-container p { font-size: 15px; color: var(--text-muted); line-height: 1.6; }
.manuals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 16px;
}
.manual-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.15s, border-color 0.15s;
}
.manual-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}
.manual-card-header {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 12px;
}
.manual-card-icon {
    font-size: 32px;
    flex-shrink: 0;
    line-height: 1;
}
.manual-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    margin-bottom: 4px;
}
.manual-card-source {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 500;
}
.manual-card-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 16px;
    flex-grow: 1;
}
.manual-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    flex-wrap: wrap;
    gap: 10px;
}
.manual-badge {
    background: var(--bg-input);
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 4px;
}
.btn-manual-dl {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: #000;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.15s;
    border: none;
    cursor: pointer;
}
.btn-manual-dl:hover {
    background: #79c0ff;
    box-shadow: 0 0 10px rgba(88, 166, 255, 0.4);
}
.external-resources-card {
    margin-top: 10px;
}
.ext-links-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}
.ext-link-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}
.ext-link-btn:hover {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.08);
    color: var(--accent);
}