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

html {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    position: relative;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden !important;
    position: relative;
    font-family: 'Arial', sans-serif;
}

.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
}

/* พื้นหลังหน้า Home (ของเดิม) */
.home-bg {
    background-image: url("bg.png");
    background-size: cover;
    background-position: center;
}

/* พื้นหลังหน้า History */
.history-bg {
    background-image: url("base.png");
}

.scan-bg {
    width: 100%;
    background-image: url("base.png");
    background-size: cover;
    background-position: center;
}

/* ============================================
   NAVBAR - เมนูชิดซ้ายติดโลโก้
   ============================================ */
.navbar {
    display: flex;
    justify-content: flex-start; /* ชิดซ้าย */
    align-items: center;
    gap: clamp(40px, 5vw, 80px); /* ระยะห่างระหว่างโลโก้กับเมนู */
    padding: 20px clamp(20px, 5vw, 60px);
    background: transparent;
    color: white;
}

.logo {
    font-size: clamp(24px, 3vw, 30px);
    font-weight: 800;
}

.menu {
    display: flex;
    gap: clamp(20px, 2.5vw, 30px);
}

.menu a {
    position: relative;
    color: white;
    text-decoration: none;
    font-size: clamp(16px, 1.5vw, 20px);
    padding-bottom: 5px;
}

.menu a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background: white;
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.menu a:hover::after,
.menu a.active::after {
    transform: scaleX(1);
}

.scan-btn {
    padding: 8px 20px;
    background: white;
    color: black;
    border-radius: 20px;
    text-decoration: none;
    font-weight: bold;
    font-size: clamp(14px, 1.2vw, 16px);
    white-space: nowrap;
    margin-left: auto; /* ผลักไปขวาสุด */
}

/* ============================================
   HERO SECTION - หน้า Home (ไม่แก้)
   ============================================ */
.hero-section {
    position: absolute;
    top: 45%;
    left: 17%;
    transform: translateY(-50%);
    text-align: center;
}

.hero-title {
    color: white;
    font-size: clamp(24px, 3vw, 32px);
    font-weight: 600;
    margin-bottom: 20px;
}

.analyze-btn {
    display: inline-block;
    padding: clamp(8px, 1.2vh, 10px) clamp(40px, 6vw, 60px);
    border-radius: 20px;
    background: #7834ff;
    color: white;
    border: 2px solid #9b7cff;
    box-shadow: 0 0 0 2px #5e17eb;
    text-decoration: none;
    font-size: clamp(14px, 1.5vw, 16px);
    transition: all 0.3s ease;
}

.analyze-btn:hover {
    background: #5e17eb;
    border-color: #b29bff;
    box-shadow: 0 0 0 4px rgba(178, 155, 255, 0.7);
}

/* ============================================
   HISTORY PAGE - กล่องใหญ่ขึ้น
   ============================================ */
.history-page {
    min-height: 100vh; /* เปลี่ยนจาก height เป็น min-height */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto; /* ให้เลื่อนได้ */
    padding: 20px 0; /* เพิ่ม padding บนล่าง */
}

/* กล่องใสใหญ่ - ขนาดใหญ่ขึ้น */
.history-container {
    position: relative;
    width: 90%;
    max-width: 1300px;
    padding: clamp(30px, 4vw, 50px);
    border-radius: 25px;
    overflow: visible;
    margin: 0 auto;
    min-height: 60vh; /* เปลี่ยนจาก height เป็น min-height */
    justify-content: center;
    transform: translateY(clamp(-50px, -4vh, -60px));  
}

.history-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(120, 52, 255, 0.25);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 2px solid rgba(155, 124, 255, 0.6);
    box-shadow: 0 0 20px rgba(94, 23, 235, 0.2);
    border-radius: 25px;
    z-index: -1;
}

.history-title {
    color: white;
    margin-bottom: 40px;
    text-align: center;
    font-size: clamp(30px, 4.5vw, 40px);
}

/* ปุ่ม Clear History */
.clear-history-btn {
    background: #e74c3c;
    color: white;
    border: 2px solid #ff6b6b;
    border-radius: 25px;
    padding: clamp(10px, 1.5vh, 12px) clamp(30px, 5vw, 50px);
    font-size: clamp(14px, 1.5vw, 16px);
    cursor: pointer;
    transition: all 0.3s ease;
    display: block;
    margin: 0 auto 30px auto;
}

.clear-history-btn:hover {
    background: #c0392b;
    border-color: #ff8787;
    box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.3);
}

.clear-history-btn:active {
    transform: scale(0.98);
}

.card-image {
    width: 100%;
    height: 180px;
    background: black;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
}

.history-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Card Grid - 3 กล่องข้างใน */
.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(20px, 3vw, 35px);
    justify-items: center;
    max-width: 1300px;
    margin: 0 auto;
}

/* ให้กล่องตัวสุดท้ายที่อยู่คนเดียวในแถวอยู่ตรงกลาง */
.card-grid > .history-card:nth-child(3n+1):last-child {
    grid-column: 1 / -1;
    justify-self: center;
}

.history-card {
    background: white;
    width: 100%;
    max-width: 380px;
    border-radius: 20px;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.history-card:hover {
    transform: translateY(-5px);
}

.card-image {
    width: 100%;
    height: clamp(220px, 32vh, 290px);
    background: black;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-content {
    padding: 18px 20px 22px;
}

.card-content h3 {
    margin: 0 0 10px 0;
    font-size: clamp(18px, 2vw, 22px);
}

.card-content p {
    margin: 5px 0;
    font-size: clamp(14px, 1.2vw, 16px);
}

/* ============================================
   SCAN PAGE
   ============================================ */
.scan-page {
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
}

.scan-container {
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow-x: hidden;
    padding: 60px 20px 40px;
    text-align: center;
    position: relative;
}

.scan-container h1 {
    color: white;
    font-size: clamp(32px, 5vw, 48px);
    margin: 0 0 clamp(5px, 1vh, 10px) 0; /* ลดระยะห่างด้านล่าง */
}

/* ===== กล่องสีม่วงใส ===== */
.scan-card {
    background: rgba(120, 52, 255, 0.25);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);

    padding: clamp(30px, 4vw, 40px) clamp(20px, 4vw, 25px) clamp(20px, 4vw, 25px);
    width: 85%;
    max-width: min(600px, calc(100vw - 40px));

    border-radius: 26px;
    text-align: center;
    border: 2px solid rgba(155, 124, 255, 0.6);
    box-shadow: 0 0 20px rgba(94, 23, 235, 0.2);
    box-sizing: border-box;
}

/* คำว่า wait for images... (ชิดกับหัวข้อ) */
.wait-text {
    margin-top: 0;
    margin-bottom: 35px; /* เพิ่มระยะห่างกับปุ่ม */
    font-size: clamp(14px, 1.2vw, 16px);
    font-weight: 400;
    opacity: 0.8;
    color: #e6ddff;
}

/* Container สำหรับรูปและผลลัพธ์ */
.content-container {
    width: 100%;
    max-width: 100%;
    margin: 20px auto 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* กลุ่มปุ่ม */
.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    max-width: 100%;
    width: 100%;
}

/* ปุ่มเมื่ออยู่ใน content-container (หลังอัพโหลด) */
.content-container .button-group {
    margin-top: 30px;
    margin-bottom: 10px; /* เพิ่มระยะห่างด้านล่างเพื่อให้ชิดขอบ */
}

.hand-image {
    width: 100%;
    max-width: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.hand-image img {
    max-width: 100%;
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: block;
}

.upload-btn {
    background: #7b3fe4;
    color: white;
    border: 2px solid #9b6bff;
    border-radius: 30px;
    padding: clamp(10px, 1.5vh, 14px) clamp(60px, 10vw, 100px);
    font-size: clamp(16px, 1.8vw, 18px);
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-btn:hover {
    background: #5e17eb;
    border-color: #b29bff;
    box-shadow: 0 0 0 4px rgba(178, 155, 255, 0.7);
}

.upload-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

/* ปุ่ม Reset สีแดง */
.reset-btn {
    background: #e74c3c;
    color: white;
    border: 2px solid #ff6b6b;
    border-radius: 30px;
    padding: clamp(10px, 1.5vh, 14px) clamp(40px, 8vw, 60px);
    font-size: clamp(16px, 1.8vw, 18px);
    cursor: pointer;
    transition: all 0.3s ease;
}

.reset-btn:hover {
    background: #c0392b;
    border-color: #ff8787;
    box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.3);
}

.preview-img {
    width: 100%;
    height: auto;
    display: block;
}

/* ===== ผลลัพธ์การตรวจจับ ===== */
.result-box {
    background: white;
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    animation: slideIn 0.4s ease-out;
    display: none; /* ซ่อนตอนเริ่มต้น */
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-box.result-cancer {
    border: 3px solid #e74c3c;
}

.result-box.result-safe {
    border: 3px solid #27ae60;
}

.result-content {
    text-align: center;
}

.result-icon {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.result-icon svg {
    animation: scaleIn 0.5s ease-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

.result-box h2 {
    margin: 0 0 15px 0;
    font-size: clamp(24px, 3vw, 32px);
    font-weight: 700;
}

.result-box p {
    color: #555;
    font-size: clamp(14px, 1.2vw, 16px);
    line-height: 1.6;
    margin-bottom: 20px;
}

/* คำเตือน AI Disclaimer */
.ai-disclaimer {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 12px;
    padding: 15px 20px;
    margin-top: 20px;
    text-align: left;
}

.ai-disclaimer p {
    color: #856404;
    font-size: clamp(13px, 1.1vw, 15px);
    margin: 0;
    line-height: 1.5;
}

.ai-disclaimer strong {
    color: #664d03;
    display: block;
    margin-bottom: 5px;
}

/* Confidence Bar */
.confidence-bar {
    margin-top: 25px;
}

.confidence-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
    font-size: clamp(14px, 1.2vw, 16px);
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #ecf0f1;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
}

.progress-fill {
    height: 100%;
    background: #27ae60;
    border-radius: 15px;
    transition: width 1s ease-out;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    color: white;
    font-weight: bold;
}

/* Spinner Loading */
.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #7b3fe4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}   

/* ============================================
   ABOUT PAGE - เพิ่มระยะห่างระหว่างกล่อง
   ============================================ */
.about-bg {
    width: 100%;
    min-height: 100vh; /* เปลี่ยนจาก height เป็น min-height */
    background-image: url("base.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto; /* ให้เลื่อนได้ */
}

.about-page {
    min-height: 90vh; /* เปลี่ยนจาก height เป็น min-height */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto; /* ให้เลื่อนได้ */
    padding: 40px 0; /* เพิ่ม padding */
}

.about-container {
    width: 95%;
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
}

/* 2 กล่อง - เพิ่มระยะห่าง */
.about-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(50px, 6vw, 80px);
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    justify-content: center;
}

.about-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 25px;
    padding: clamp(20px, 3vw, 30px);
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
}

.about-card h2 {
    margin-top: 0;
    font-size: clamp(22px, 2.5vw, 26px);
}

.about-card ul {
    padding-left: 20px;
}

.about-card li {
    margin-bottom: 8px;
    font-size: clamp(14px, 1.2vw, 16px);
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
    .navbar {
        gap: 30px;
        flex-wrap: wrap;
    }
    
    .menu {
        gap: 15px;
    }
    
    /* History - 2 คอลัมน์ */
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* กล่องที่เหลือ 1 อันให้อยู่ตรงกลาง */
    .card-grid > .history-card:nth-child(2n+1):last-child {
        grid-column: 1 / -1;
        justify-self: center;
    }
    
    /* ยกเลิก rule ของ 3 คอลัมน์ */
    .card-grid > .history-card:nth-child(3n+1):last-child {
        grid-column: auto;
        justify-self: center;
    }
    
    /* About - ยังคง 2 คอลัมน์ */
    .about-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: clamp(30px, 5vw, 50px);
    }
    
    .history-container {
        transform: translateY(0);
        margin-top: 20px;
        margin-bottom: 20px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        width: 100%;
        max-width: 100vw;
    }
    
    .navbar {
        padding: 15px 20px;
        gap: 15px;
        flex-wrap: wrap;
    }
    
    .menu {
        gap: 12px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .scan-btn {
        width: 100%;
        text-align: center;
        margin-top: 10px;
    }
    
    /* History - 1 คอลัมน์ */
    .card-grid {
        grid-template-columns: 1fr;
    }
    
    .history-container {
        transform: translateY(0);
        margin: 20px auto;
        min-height: auto;
    }
    
    .history-page {
        min-height: auto;
        padding: 20px 0 40px;
    }
    
    /* About - 1 คอลัมน์ */
    .about-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }
    
    .about-page {
        min-height: auto;
        padding: 20px 0 40px;
    }
    
    .hero-section {
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
    }
    
    /* Scan Page - ปรับให้ responsive */
    .scan-container {
        padding: 40px 10px 30px;
        max-width: 100vw;
    }
    
    .scan-card {
        width: calc(100% - 20px);
        max-width: calc(100vw - 30px);
        padding: 30px 15px 20px;
        margin: 0 10px;
    }
    
    .content-container {
        max-width: 100%;
        width: 100%;
        padding: 0 5px;
    }
    
    .upload-btn {
        padding: 12px 50px;
        font-size: 16px;
    }
    
    .reset-btn {
        padding: 12px 35px;
        font-size: 16px;
    }
    
    .button-group {
        gap: 12px;
    }
    
    .wait-text {
        margin-bottom: 25px;
        font-size: 14px;
    }
    
    .content-container {
        min-height: 180px;
        margin-top: 30px;
    }
    
    .hand-image {
        max-width: 100%;
    }
    
    .hand-image img {
        max-height: 300px;
    }
    
    .result-box {
        padding: 20px;
    }
    
    .result-box h2 {
        font-size: 22px;
    }
    
    .result-icon svg {
        width: 60px;
        height: 60px;
    }
    
    .spinner {
        width: 50px;
        height: 50px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .history-container,
    .about-container {
        padding: 15px;
    }
    
    .navbar {
        gap: 10px;
    }
    
    .menu a {
        font-size: 14px;
    }
    
    /* Scan Page - Mobile เล็ก */
    .scan-container {
        padding: 30px 5px 20px;
    }
    
    .scan-container h1 {
        font-size: 28px;
        margin-bottom: 5px;
    }
    
    .scan-card {
        width: calc(100% - 10px);
        max-width: calc(100vw - 20px);
        padding: 25px 10px 18px;
        margin: 0 5px;
    }
    
    .upload-btn {
        padding: 10px 30px;
        font-size: 15px;
        max-width: 100%;
    }
    
    .reset-btn {
        padding: 10px 25px;
        font-size: 15px;
        max-width: 100%;
    }
    
    .button-group {
        gap: 8px;
        width: 100%;
        padding: 0 5px;
    }
    
    .wait-text {
        font-size: 13px;
        margin-bottom: 20px;
    }
    
    .content-container {
        min-height: 150px;
        margin-top: 25px;
    }
    
    .hand-image img {
        max-height: 250px;
    }
    
    .result-box {
        padding: 15px;
    }
    
    .result-box h2 {
        font-size: 20px;
    }
    
    .result-box p {
        font-size: 13px;
    }
    
    .result-icon svg {
        width: 50px;
        height: 50px;
    }
    
    .spinner {
        width: 40px;
        height: 40px;
    }
    
    .progress-bar {
        height: 25px;
    }
    
    .confidence-label {
        font-size: 13px;
    }
    
    .ai-disclaimer {
        padding: 12px 15px;
    }
    
    .ai-disclaimer p {
        font-size: 12px;
    }
}

/* Extra Small (iPhone SE 1st gen - 320px) */
@media (max-width: 375px) {
    .scan-card {
        width: calc(100% - 10px);
        max-width: calc(100vw - 15px);
        padding: 20px 8px 15px;
    }
    
    .upload-btn, .reset-btn {
        padding: 8px 20px;
        font-size: 14px;
    }
    
    .scan-container h1 {
        font-size: 24px;
    }
}
/* ============================================
   CAMERA / SCAN PAGE (scan.html)
   ============================================ */

.camera-page {
    position: fixed;
    inset: 0;
    background: #000;
    overflow: hidden;
    font-family: 'IBM Plex Sans', 'Segoe UI', sans-serif;
}

#cameraFeed {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    pointer-events: none;
}
#cameraFeed::-webkit-media-controls,
#cameraFeed::-webkit-media-controls-enclosure,
#cameraFeed::-webkit-media-controls-panel,
#cameraFeed::-webkit-media-controls-play-button,
#cameraFeed::-webkit-media-controls-overlay-play-button {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ── back button ── */
.back-btn {
    position: absolute;
    top: clamp(16px, 3vh, 24px);
    left: clamp(16px, 3vw, 24px);
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(10,10,20,0.60);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 8px 14px 8px 10px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s, border-color 0.2s;
    z-index: 20;
}
.back-btn:hover {
    background: rgba(30,30,50,0.80);
    border-color: rgba(255,255,255,0.28);
}

/* ── scan overlay & frame ── */
.scan-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse 70% 70% at 50% 50%, transparent 40%, rgba(0,0,0,0.55) 100%);
    pointer-events: none;
    transition: opacity 0.4s;
}

.scan-frame {
    position: relative;
    width: min(320px, 70vw);
    height: min(320px, 70vw);
}

.corner {
    position: absolute;
    width: 26px;
    height: 26px;
    border-color: rgba(255,255,255,0.85);
    border-style: solid;
}
.corner.tl { top:0; left:0;   border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.corner.tr { top:0; right:0;  border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.corner.bl { bottom:0; left:0;  border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.corner.br { bottom:0; right:0; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }

.scan-line {
    position: absolute;
    left: 6%;
    width: 88%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(120,180,255,0.9), transparent);
    animation: scanMove 2.4s ease-in-out infinite;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(120,180,255,0.7);
}
@keyframes scanMove {
    0%   { top: 8%;  opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { top: 92%; opacity: 0; }
}

.scan-hint {
    margin-top: 16px;
    color: rgba(255,255,255,0.60);
    font-size: clamp(12px, 2.5vw, 13px);
    letter-spacing: 0.05em;
}

/* ── translation card (live) ── */
.translation-card {
    position: absolute;
    bottom: clamp(90px, 14vh, 110px);
    right: clamp(16px, 4vw, 28px);
    background: rgba(8, 10, 18, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    padding: 13px 16px 15px;
    max-width: min(300px, calc(100vw - 32px));
    min-width: 170px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.45);
    transition: opacity 0.3s;
}

.translation-label {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 9px;
}
.translation-label span {
    color: rgba(255,255,255,0.40);
    font-size: 10px;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    font-weight: 500;
}

.dot {
    width: 7px !important;
    height: 7px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 7px #34d399;
    animation: pulse 1.8s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.35; }
}

.translation-text {
    color: #f0f4ff;
    font-family: 'IBM Plex Sans', 'Segoe UI', sans-serif;
    font-size: clamp(14px, 3vw, 16px);
    font-weight: 400;
    line-height: 1.55;
    margin: 0;
    font-style: normal;
}

/* ── stop button ── */
.stop-btn {
    position: absolute;
    bottom: clamp(24px, 5vh, 36px);
    right: clamp(16px, 4vw, 28px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(220, 38, 38, 0.88);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,100,100,0.4);
    border-radius: 12px;
    color: #fff;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    padding: 11px 24px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    letter-spacing: 0.03em;
    z-index: 20;
}
.stop-btn:hover {
    background: rgba(185, 28, 28, 0.95);
    box-shadow: 0 0 0 3px rgba(220,38,38,0.3);
}

/* ── summary overlay ── */
.summary-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.70);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}
.summary-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.summary-panel {
    background: #0f1117;
    border: 1px solid rgba(255,255,255,0.10);
    border-bottom: none;
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-width: 520px;
    padding: clamp(24px, 4vw, 36px) clamp(20px, 5vw, 40px) clamp(28px, 5vh, 44px);
    transform: translateY(40px);
    transition: transform 0.4s cubic-bezier(0.22,1,0.36,1);
}
.summary-overlay.visible .summary-panel {
    transform: translateY(0);
}

.summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.summary-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #c7d2fe;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.summary-badge svg { color: #818cf8; }

.summary-time {
    color: rgba(255,255,255,0.30);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
}

.summary-divider {
    height: 1px;
    background: rgba(255,255,255,0.07);
    margin-bottom: 22px;
}

.summary-label-text {
    color: rgba(255,255,255,0.38);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    margin: 0 0 10px 0;
}

.summary-text-box {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 20px;
}
.summary-text-box p {
    color: #e8eaf6;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: clamp(15px, 3.5vw, 18px);
    font-weight: 400;
    line-height: 1.6;
    margin: 0;
}

.summary-meta {
    display: flex;
    gap: 24px;
    margin-bottom: 28px;
}
.meta-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.meta-key {
    color: rgba(255,255,255,0.30);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}
.meta-val {
    color: rgba(255,255,255,0.75);
    font-size: 13px;
    font-weight: 500;
}
.status-done { color: #34d399 !important; }

.summary-actions {
    display: flex;
    gap: 12px;
}

.btn-secondary {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.13);
    border-radius: 12px;
    color: rgba(255,255,255,0.75);
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    padding: 12px 0;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-secondary:hover { background: rgba(255,255,255,0.10); }

.btn-primary {
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #4f46e5;
    border: 1px solid rgba(129,140,248,0.4);
    border-radius: 12px;
    color: #fff;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    padding: 12px 0;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    letter-spacing: 0.02em;
}
.btn-primary:hover {
    background: #4338ca;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.35);
}

/* ── camera error ── */
.camera-error {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: rgba(255,255,255,0.55);
    text-align: center;
    padding: 20px;
}
.camera-error p { font-size: 15px; line-height: 1.6; }
/* Local communication integration: controls are HTML, never baked into frames. */
[hidden] { display: none !important; }
.camera-page { font-family: 'Segoe UI', Arial, sans-serif; }
.camera-page button { font-family: inherit; min-height: 44px; }
button:disabled { opacity: .4; cursor: not-allowed; }
.scan-actions { position: absolute; bottom: 24px; right: 28px; left: 16px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; z-index: 20; }
.scan-actions .stop-btn { position: static; }
.scan-actions .btn-secondary { padding: 11px 20px; }
.browser-download-note { color: #d4dbea; font-size: 14px; line-height: 1.6; max-width: 560px; margin: 22px auto 0; padding: 0 16px; text-align: center; }
.translation-card { max-height: 35vh; overflow-y: auto; }
.recognition-status, .finger-hint { color: #c0c6d6; font-size: 12px; line-height: 1.5; margin-top: 10px; }
.summary-words { color: #c7d2fe; margin-bottom: 16px; overflow-wrap: anywhere; }
.summary-panel { max-height: 88vh; overflow-y: auto; }
.summary-text-box p { overflow-wrap: anywhere; }
.speech-status { color: #c7d2fe; font-size: 12px; margin-bottom: 12px; }
.finger-target { outline: 3px solid #facc15; outline-offset: 3px; }
#fingerPointer { position: fixed; width: 34px; height: 34px; border-radius: 50%; transform: translate(-50%, -50%); background: conic-gradient(#facc15 var(--progress, 0deg), rgba(255,255,255,.3) 0); z-index: 150; pointer-events: none; }
#fingerProgress { position: absolute; inset: 6px; border-radius: 50%; background: rgba(20,20,30,.8); border: 2px solid white; }
.camera-error { z-index: 200; gap: 20px; padding: 30px; background: #10121c; }
.camera-error p { white-space: pre-wrap; max-width: 600px; }
.info-page { min-height: calc(100vh - 90px); padding: 40px max(20px, 8vw); color: white; background: #10121c; }
.info-page h1, .info-page p, .info-page h2 { margin-bottom: 20px; line-height: 1.6; }
.info-page article { padding: 20px; border: 1px solid #4b4860; border-radius: 14px; margin-bottom: 20px; }
.info-page .words { color: #c7d2fe; }
body:has(.info-page) { background: #10121c; }
@media (max-width: 600px) { .scan-actions { right: 16px; bottom: 20px; } .summary-actions { flex-wrap: wrap; } .summary-actions button { min-width: 100px; } }
