:root {
    color-scheme: dark;
    --bg: #071015;
    --panel: rgba(12, 24, 31, .88);
    --panel-strong: rgba(15, 35, 45, .96);
    --ink: #e8fbff;
    --muted: #9fb9c3;
    --line: rgba(112, 220, 240, .22);
    --accent: #25d7ff;
    --accent-2: #7cf7c7;
    --warn: #ffd166;
    --danger: #ff6b7d;
    --shadow: 0 22px 52px rgba(0, 0, 0, .34);
}

* {
    box-sizing: border-box;
}

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

body {
    background:
        linear-gradient(90deg, rgba(37, 215, 255, .06) 1px, transparent 1px),
        linear-gradient(180deg, rgba(37, 215, 255, .05) 1px, transparent 1px),
        radial-gradient(circle at 18% 0%, rgba(37, 215, 255, .18), transparent 34%),
        radial-gradient(circle at 90% 12%, rgba(124, 247, 199, .14), transparent 28%),
        var(--bg);
    background-size: 38px 38px, 38px 38px, auto, auto, auto;
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.65;
    -webkit-text-size-adjust: 100%;
}

button,
a,
select,
input,
textarea {
    -webkit-tap-highlight-color: transparent;
}

button,
select {
    font: inherit;
}

a {
    color: inherit;
}

.noscript {
    background: #fff3cd;
    color: #663c00;
    padding: 12px;
    text-align: center;
}

.site-shell {
    margin: 0 auto;
    max-width: 1180px;
    padding: clamp(18px, 4vw, 48px);
}

.hero {
    max-width: 880px;
    padding: 30px 0 22px;
}

.series-label,
.panel-kicker,
.section-kicker,
.ad-label {
    color: var(--accent);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .16em;
    margin: 0 0 8px;
}

h1 {
    font-size: clamp(42px, 9vw, 88px);
    letter-spacing: 0;
    line-height: .95;
    margin: 0;
}

h2 {
    font-size: 18px;
    letter-spacing: 0;
    margin: 0 0 8px;
}

p {
    margin-top: 0;
}

.subtitle {
    color: var(--accent-2);
    font-size: clamp(18px, 3vw, 24px);
    font-weight: 800;
    margin: 12px 0 0;
}

.lead {
    font-size: clamp(18px, 3vw, 25px);
    font-weight: 800;
    line-height: 1.5;
    margin: 26px 0 0;
}

.note,
.small-note {
    color: var(--muted);
    margin: 14px 0 0;
}

.camera-console {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr);
    margin: 24px 0;
}

.control-panel,
.preview-panel,
.stat-card,
.mode-notes article,
.main-lab-tools,
.about-diagnosis,
.app-comment-section,
.ad-row {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 18px;
}

.control-panel {
    display: grid;
    gap: 16px;
}

.control-panel p,
.stat-card p,
.mode-notes p,
.about-diagnosis p,
.main-lab-tools p {
    color: var(--muted);
    margin-bottom: 0;
}

.device-label {
    color: var(--accent);
    display: grid;
    font-size: 12px;
    font-weight: 900;
    gap: 8px;
    letter-spacing: .12em;
}

.device-label select {
    background: rgba(3, 10, 14, .88);
    border: 1px solid rgba(112, 220, 240, .28);
    border-radius: 8px;
    color: var(--ink);
    min-height: 44px;
    padding: 8px 10px;
    width: 100%;
}

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

.primary-button,
.quiet-button {
    appearance: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
    min-height: 46px;
    padding: 10px 16px;
}

.primary-button {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: 0;
    color: #041014;
}

.quiet-button {
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .18);
    color: var(--ink);
}

.danger-button {
    border-color: rgba(255, 107, 125, .36);
    color: #ffd7dd;
}

.quiet-button:disabled,
.primary-button:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.status-message {
    border-left: 3px solid var(--accent);
    color: #c8eef6;
    margin: 0;
    padding-left: 12px;
}

.preview-panel {
    background: var(--panel-strong);
}

.preview-frame {
    aspect-ratio: 16 / 9;
    background:
        linear-gradient(90deg, rgba(37, 215, 255, .08) 1px, transparent 1px),
        linear-gradient(180deg, rgba(37, 215, 255, .08) 1px, transparent 1px),
        #030a0e;
    background-size: 34px 34px;
    border: 1px solid rgba(112, 220, 240, .22);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

#cameraVideo {
    display: block;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity .2s ease;
    width: 100%;
}

#cameraVideo.is-active {
    opacity: 1;
}

#cameraVideo.is-mirrored {
    transform: scaleX(-1);
}

.camera-guide {
    inset: 0;
    opacity: 1;
    pointer-events: none;
    position: absolute;
    transition: opacity .2s ease;
}

.camera-guide.is-hidden {
    opacity: 0;
}

.guide-line {
    background: rgba(124, 247, 199, .36);
    position: absolute;
}

.guide-line.vertical {
    bottom: 0;
    left: 50%;
    top: 0;
    width: 1px;
}

.guide-line.horizontal {
    height: 1px;
    left: 0;
    right: 0;
    top: 50%;
}

.guide-box {
    border: 1px solid rgba(37, 215, 255, .42);
    border-radius: 999px;
    height: 58%;
    left: 50%;
    position: absolute;
    top: 47%;
    transform: translate(-50%, -50%);
    width: 34%;
}

.side-label {
    background: rgba(3, 10, 14, .68);
    border: 1px solid rgba(112, 220, 240, .24);
    border-radius: 999px;
    color: var(--accent-2);
    font-weight: 900;
    min-width: 32px;
    padding: 3px 9px;
    position: absolute;
    text-align: center;
    top: 12px;
}

.left-label {
    left: 12px;
}

.right-label {
    right: 12px;
}

.preview-placeholder {
    align-items: center;
    color: rgba(232, 251, 255, .7);
    display: flex;
    flex-direction: column;
    gap: 8px;
    inset: 0;
    justify-content: center;
    padding: 20px;
    position: absolute;
    text-align: center;
}

.preview-placeholder strong {
    color: var(--accent);
    font-size: clamp(22px, 5vw, 42px);
    letter-spacing: .08em;
}

.preview-placeholder.is-hidden {
    display: none;
}

#sampleCanvas {
    display: none;
}

.stat-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 18px 0;
}

.stat-card {
    min-height: 178px;
}

.stat-card span {
    color: var(--accent);
    display: block;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .12em;
    margin-bottom: 8px;
}

.stat-card strong {
    color: var(--accent-2);
    display: block;
    font-size: clamp(28px, 5vw, 44px);
    line-height: 1.1;
    margin: 12px 0;
    overflow-wrap: anywhere;
}

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

.mode-notes ol {
    color: var(--muted);
    margin-bottom: 0;
    padding-left: 1.3em;
}

.ad-row {
    margin: 18px 0;
    min-height: 120px;
}

.main-lab-tools,
.about-diagnosis,
.app-comment-section {
    margin: 18px 0;
}

.lab-footer {
    color: rgba(232, 251, 255, .54);
    font-size: 12px;
    letter-spacing: .04em;
    margin: 22px 0 0;
    text-align: center;
}

.lab-footer p {
    margin: 0;
}

.tool-links {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tool-links a {
    background: rgba(3, 10, 14, .48);
    border: 1px solid rgba(112, 220, 240, .18);
    border-radius: 8px;
    color: var(--ink);
    display: grid;
    gap: 4px;
    min-height: 96px;
    padding: 14px;
    text-decoration: none;
}

.tool-links a:hover {
    border-color: rgba(124, 247, 199, .46);
}

.tool-links span {
    color: var(--muted);
    font-size: 13px;
}

.app-comments,
.app-comment-form-section,
.app-comment-list,
.app-comment-item {
    background: rgba(12, 24, 31, .92);
    border-color: rgba(112, 220, 240, .22);
    color: var(--ink);
}

.app-comments h2,
.app-comments h3,
.app-comment-form-section h2,
.app-comment-form-section h3 {
    color: var(--ink);
}

.app-comments p,
.app-comments li,
.app-comment-form-section p,
.app-comment-item {
    color: #cfe8ee;
}

.app-comment-form input,
.app-comment-form textarea,
.app-comment-form select {
    background: rgba(3, 10, 14, .88);
    border: 1px solid rgba(112, 220, 240, .28);
    color: var(--ink);
}

.app-comment-form input::placeholder,
.app-comment-form textarea::placeholder {
    color: rgba(232, 251, 255, .48);
}

.app-comment-form button {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: 0;
    color: #041014;
}

@media (max-width: 900px) {
    .camera-console,
    .mode-notes {
        grid-template-columns: 1fr;
    }

    .stat-grid,
    .tool-links {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .site-shell {
        padding: 16px;
    }

    .hero {
        padding-top: 18px;
    }

    .control-panel,
    .preview-panel,
    .stat-card,
    .mode-notes article,
    .main-lab-tools,
    .about-diagnosis,
    .app-comment-section,
    .ad-row {
        padding: 14px;
    }

    .control-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .stat-grid,
    .tool-links {
        grid-template-columns: 1fr;
    }

    .guide-box {
        width: 46%;
    }
}
