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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top, 0px));
    padding-left: max(20px, env(safe-area-inset-left, 0px));
    padding-right: max(20px, env(safe-area-inset-right, 0px));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
}

.app-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
}

/* iPhone frame — compact height for video safe zones + mobile gap above platform UI. */
.iphone-frame {
    /* logical size (must match @media aspect-ratio below) */
    --frame-w: 375;
    --frame-h: 640;
    width: 375px;
    height: 640px;
    background: #000;
    border-radius: 45px;
    padding: 12px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Horizontal / 16:9 — for recording with the phone rotated (landscape) */
.iphone-frame.layout-landscape {
    --frame-w: 16;
    --frame-h: 9;
    width: min(1000px, 96vw);
    max-width: min(1000px, 96vw);
    height: auto;
    aspect-ratio: 16 / 9;
    max-height: min(88vh, 90dvh);
}

.iphone-frame.layout-landscape .chat-messages {
    max-width: 38rem;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    box-sizing: border-box;
}

.iphone-frame.layout-landscape::before {
    width: min(200px, 32%);
    height: 24px;
    border-radius: 0 0 14px 14px;
}

/* Screen content wrapper - contains and clips all content */
.screen-content {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 33px;
    background: #f2f2f7;
    position: relative;
}

/* iMessage-style dark — toggled on #iphoneFrame; pure CSS, no new DOM */
.iphone-frame.phone-dark .screen-content {
    background: #0d0d0d;
}

.iphone-frame.phone-dark .status-bar,
.iphone-frame.phone-dark .chat-header,
.iphone-frame.phone-dark .input-bar {
    background: #0d0d0d;
    color: #fff;
}

.iphone-frame.phone-dark .status-bar {
    color: #fff;
}

.iphone-frame.phone-dark .time {
    color: #fff;
}

.iphone-frame.phone-dark .status-icons,
.iphone-frame.phone-dark .signal,
.iphone-frame.phone-dark .battery {
    color: #fff;
    filter: none;
}

.iphone-frame.phone-dark .back-btn,
.iphone-frame.phone-dark .video-btn {
    color: #0a84ff;
}

.iphone-frame.phone-dark .chat-header {
    border-bottom: 1px solid #2c2c2e;
}

.iphone-frame.phone-dark .contact-name {
    color: #fff;
}

.iphone-frame.phone-dark .chat-container {
    background: #0d0d0d;
}

.iphone-frame.phone-dark .message.receiver {
    background: #1c1c1e;
    color: #fff;
    border: 0.5px solid #38383a;
}

.iphone-frame.phone-dark .message.sender {
    background: #0a84ff;
    color: #fff;
}

.iphone-frame.phone-dark .timestamp-divider span {
    color: #6e6e70;
    background: rgba(142, 142, 147, 0.15);
}

.iphone-frame.phone-dark .typing-dots {
    background: #1c1c1e;
    border: 0.5px solid #3a3a3c;
}

.iphone-frame.phone-dark .typing-dots span {
    background: rgba(255, 255, 255, 0.4);
}

.iphone-frame.phone-dark .typing-indicator.typing-sender .typing-dots {
    background: #0a84ff;
    border: none;
}

.iphone-frame.phone-dark .input-field {
    background: #1c1c1e;
    border: 0.5px solid #3a3a3c;
    color: #8e8e93;
}

.iphone-frame.phone-dark .screen-content.keyboard-open .composer-typed,
.iphone-frame.phone-dark .composer-typed {
    color: #fff;
}

.iphone-frame.phone-dark .send-btn {
    background: #0a84ff;
}

.iphone-frame.phone-dark .fake-keyboard {
    background: #2c2c2e;
    border-top: 0.5px solid #1c1c1e;
}

.iphone-frame.phone-dark .kb-key {
    background: #4a4a4a;
    color: #fff;
    box-shadow: 0 1px 0 #1c1c1e;
}

.iphone-frame.phone-dark .wait-cue-text {
    color: #8e8e93;
}

.iphone-frame.phone-dark .lock-wallpaper:not([style*='background-image']) {
    background: linear-gradient(165deg, #0a0a12 0%, #1a1530 45%, #242038 100%);
}

/* Jolt the whole “glass” for drama ([shake] or sfx: whoosh) */
.screen-content.screen-shake {
    animation: phoneScreenShake 0.5s ease-in-out 1;
}

@keyframes phoneScreenShake {
    0%,
    100% {
        transform: translate(0, 0);
    }
    15% {
        transform: translate(-4px, 2px) rotate(-0.3deg);
    }
    30% {
        transform: translate(4px, -1px) rotate(0.35deg);
    }
    45% {
        transform: translate(-3px, 2px);
    }
    60% {
        transform: translate(2px, -2px) rotate(-0.2deg);
    }
    75% {
        transform: translate(-1px, 0);
    }
}

/* ========== Lock screen + iOS-style notification ========== */
.lock-screen-overlay {
    position: absolute;
    inset: 0;
    z-index: 60;
    border-radius: inherit;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.lock-screen-overlay.hidden {
    display: none !important;
}

.lock-wallpaper {
    position: absolute;
    inset: 0;
    background: linear-gradient(165deg, #1c1c3e 0%, #3d2a5c 40%, #5c3d6e 100%);
    background-size: cover;
    background-position: center;
}

.lock-scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.45) 100%);
    pointer-events: none;
}

.lock-screen-ui {
    position: relative;
    z-index: 2;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 56px 16px 24px;
    color: #fff;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

.lock-clock-block {
    text-align: center;
    margin-bottom: auto;
    padding-top: 8px;
}

.lock-time {
    font-size: 76px;
    font-weight: 200;
    letter-spacing: -2px;
    line-height: 1;
}

.lock-date {
    font-size: 18px;
    font-weight: 400;
    opacity: 0.95;
    margin-top: 6px;
}

.ios-notification-card {
    width: 100%;
    max-width: 100%;
    margin-bottom: 450px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    animation: notifSlideIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes notifSlideIn {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.notif-app-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    opacity: 0.85;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.notif-icon {
    font-size: 14px;
}

.notif-app-name {
    flex: 1;
    font-weight: 600;
}

.notif-now {
    opacity: 0.75;
}

.notif-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}

.notif-body {
    font-size: 14px;
    line-height: 1.35;
    opacity: 0.92;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.lock-hint {
    margin-top: 18px;
    font-size: 13px;
    opacity: 0.55;
    text-align: center;
}

/* ========== Fake keyboard + composer typing ========== */
.screen-content.keyboard-open .chat-container {
    min-height: 0;
}

.fake-keyboard {
    flex-shrink: 0;
    display: none;
    padding: 6px 4px 10px;
    background: #d1d5db;
    border-top: 1px solid #b8bcc4;
    user-select: none;
}

.fake-keyboard:not(.hidden) {
    display: block;
    animation: keyboardSlideUp 0.28s ease-out;
}

.screen-content.keyboard-open .fake-keyboard:not(.hidden) {
    display: block !important;
}

@keyframes keyboardSlideUp {
    from {
        transform: translateY(100%);
        opacity: 0.5;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 6px;
}

.kb-key {
    min-width: 28px;
    padding: 8px 6px;
    background: #fff;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #000;
    text-align: center;
    box-shadow: 0 1px 0 #898989;
    flex: 1;
    max-width: 36px;
}

.kb-key.kb-shift,
.kb-key.kb-del {
    max-width: 44px;
    flex: 1.2;
}

.kb-key.kb-space {
    flex: 4;
    max-width: none;
    font-size: 12px;
    color: #333;
}

.kb-key.kb-num,
.kb-key.kb-return {
    max-width: 52px;
    font-size: 11px;
}

.keyboard-bottom {
    margin-bottom: 0;
}

.fake-keyboard.typing-active {
    animation: keyboardGlow 1.2s ease-in-out infinite;
}

@keyframes keyboardGlow {
    0%,
    100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.03);
    }
}

/* Device intro panel */
.device-intro .wallpaper-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.wallpaper-file-input {
    font-size: 13px;
    max-width: 220px;
}

.wallpaper-hint {
    font-size: 11px;
    color: #8e8e93;
    margin: 8px 0 0;
    line-height: 1.4;
}

.device-intro-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
}

/* Notch - More minimal */
.iphone-frame::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 25px;
    background: #000;
    border-radius: 0 0 15px 15px;
    z-index: 10;
}

/* Status Bar - Minimal */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px 8px;
    background: #f2f2f7;
    flex-shrink: 0;
}

.time {
    font-weight: 600;
    font-size: 14px;
    min-width: 2.75rem;
    display: inline-block;
}

.status-icons {
    display: flex;
    gap: 5px;
    font-size: 12px;
}

/* Chat Header - Compact */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 15px;
    background: #f2f2f7;
    border-bottom: 1px solid #e5e5ea;
    flex-shrink: 0;
}

.back-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #007aff;
    cursor: pointer;
    padding: 0 8px;
}

.contact-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.profile-circle {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.contact-name {
    font-size: 10px;
    color: #000;
}

.video-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.7;
}

/* Chat Container - Positioning wrapper for overlays */
.chat-container {
    flex: 1;
    min-height: 0;
    background: #fff;
    position: relative;
    overflow: hidden;
}

/* Scrollable area for messages */
.chat-scroll {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

/* Zoom effect - applied to messages, not container */
.chat-container.zooming .chat-messages {
    animation: subtleZoom 30s ease-out forwards;
}

@keyframes subtleZoom {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.02);
    }
}

.chat-messages {
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    min-height: 0;
    transform-origin: center top;
}

/* Hook Screen Overlay */
.hook-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, #1a1a2e 0%, #0d0d1a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.hook-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.hook-overlay.fade-out {
    opacity: 0;
}

.hook-content {
    text-align: center;
    padding: 30px;
    animation: hookPulse 2s ease-in-out infinite;
}

@keyframes hookPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.hook-text {
    color: #fff;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 15px;
    text-shadow: 0 2px 20px rgba(0,0,0,0.5);
}

.hook-emoji {
    font-size: 48px;
    display: block;
    animation: hookEmoji 1s ease-in-out infinite alternate;
}

@keyframes hookEmoji {
    from { transform: scale(1) rotate(-5deg); }
    to { transform: scale(1.1) rotate(5deg); }
}

/* End CTA Overlay */
.end-cta-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.end-cta-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.end-cta-overlay.hidden {
    display: none;
}

.end-cta-content {
    text-align: center;
    animation: ctaAppear 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes ctaAppear {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.end-cta-text {
    color: #fff;
    font-size: 36px;
    font-weight: 700;
    margin: 0 0 10px;
    text-shadow: 0 4px 30px rgba(0,0,0,0.8);
}

.end-cta-sub {
    color: rgba(255,255,255,0.7);
    font-size: 16px;
    margin: 0;
    font-weight: 500;
}

/* Message Bubbles - readable on desktop; mobile overrides in @media (max-width: 768px) */
.message {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 17px;
    line-height: 1.42;
    font-weight: 400;
    letter-spacing: -0.2px;
    opacity: 0;
    transform: translateY(15px) scale(0.95);
    animation: messageAppear 0.2s ease-out forwards;
}

/* First message - Hook emphasis */
.message.first-message {
    font-size: 19px;
    padding: 12px 16px;
    margin-bottom: 4px;
}

@keyframes messageAppear {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Pop effect variant */
.message.pop {
    animation: messagePop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes messagePop {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
    70% {
        transform: translateY(-2px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message.sender {
    background: #007aff;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 6px;
}

.message.receiver {
    background: #e5e5ea;
    color: #000;
    align-self: flex-start;
    border-bottom-left-radius: 6px;
}

/* Timestamp Divider - Subtle */
.timestamp-divider {
    text-align: center;
    margin: 8px 0;
    opacity: 0;
    animation: fadeIn 0.2s ease forwards;
}

.timestamp-divider span {
    font-size: 11px;
    color: #8e8e93;
    background: rgba(142, 142, 147, 0.1);
    padding: 3px 10px;
    border-radius: 8px;
    letter-spacing: 0.2px;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Typing Indicator — last child in .chat-messages so it stays after bubbles while scrolling */
.typing-indicator {
    padding: 4px 15px 8px;
    display: none;
    align-self: flex-start;
    flex-shrink: 0;
}

.typing-indicator.active {
    display: block;
}

.typing-indicator.typing-sender {
    align-self: flex-end;
    text-align: right;
}

.typing-indicator.typing-sender .typing-dots {
    background: #007aff;
}

.typing-indicator.typing-sender .typing-dots span {
    background: rgba(255, 255, 255, 0.85);
}

.typing-dots {
    background: #e5e5ea;
    padding: 14px 18px;
    border-radius: 20px;
    border-bottom-left-radius: 6px;
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

.typing-indicator.typing-sender .typing-dots {
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 6px;
}

.typing-dots span {
    width: 9px;
    height: 9px;
    background: #8e8e93;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

/* Suspense / “waiting for reply” cue (between messages) */
.wait-cue {
    align-self: center;
    text-align: center;
    margin: 10px 12px;
    padding: 8px 14px;
    animation: waitCuePulse 1.4s ease-in-out infinite;
}

.wait-cue-text {
    font-size: 12px;
    font-weight: 500;
    color: #8e8e93;
    letter-spacing: 0.02em;
}

@keyframes waitCuePulse {
    0%, 100% { opacity: 0.65; }
    50% { opacity: 1; }
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Bar - room for descenders + iOS; avoid bottom clip inside rounded frame */
.input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 14px;
    background: #f2f2f7;
    flex-shrink: 0;
    min-height: 52px;
    box-sizing: border-box;
}

.input-field {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 36px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 18px;
    border: 1px solid #e5e5ea;
    font-size: 15px;
    line-height: 1.25;
    color: #8e8e93;
    display: flex;
    align-items: center;
}

.composer-placeholder {
    color: #8e8e93;
}

.composer-typed {
    color: #000;
    flex: 1;
    min-width: 0;
    word-break: break-word;
    display: none;
}

.composer-typed:not(.hidden) {
    display: block;
}

.screen-content.keyboard-open .composer-placeholder {
    display: none !important;
}

.screen-content.keyboard-open .composer-typed {
    display: block !important;
    color: #000;
}

.send-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    background: #007aff;
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Hide scrollbar for cleaner look */
.chat-scroll::-webkit-scrollbar {
    width: 0;
    display: none;
}

.chat-scroll {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ==================== CONTROL PANEL ==================== */

.control-panel {
    width: 380px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.control-panel h2 {
    color: #1a1a2e;
    margin-bottom: 20px;
    font-size: 24px;
}

.input-group {
    margin-bottom: 18px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.input-group input[type="text"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e5e5ea;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.input-group input[type="text"]:focus {
    outline: none;
    border-color: #007aff;
}

.input-group textarea {
    width: 100%;
    height: 160px;
    padding: 15px;
    border: 2px solid #e5e5ea;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
}

.input-group textarea:focus {
    outline: none;
    border-color: #007aff;
}

/* Speed & Delay Controls */
.control-row {
    display: flex;
    gap: 15px;
    margin-bottom: 18px;
}

.control-row .input-group {
    flex: 1;
    margin-bottom: 0;
}

.speed-controls {
    display: flex;
    gap: 8px;
}

.speed-btn {
    padding: 8px 16px;
    border: 2px solid #e5e5ea;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.3s;
}

.speed-btn:hover {
    border-color: #007aff;
}

.speed-btn.active {
    background: #007aff;
    color: white;
    border-color: #007aff;
}

/* Delay input */
.delay-input {
    display: flex;
    align-items: center;
    gap: 8px;
}

.delay-input input[type="number"] {
    width: 70px;
    padding: 8px 10px;
    border: 2px solid #e5e5ea;
    border-radius: 10px;
    font-size: 14px;
    text-align: center;
}

.delay-input input[type="number"]:focus {
    outline: none;
    border-color: #007aff;
}

.delay-input span {
    font-size: 13px;
    color: #666;
}

/* Checkbox styling */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    cursor: pointer;
    font-size: 14px;
}

/* Text-to-speech (Web Speech API) */
.tts-block {
    width: 100%;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e5ea;
}

.tts-speak-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
}

.tts-voice-row {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tts-voice-pair {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tts-voice-pair label {
    font-size: 12px;
    font-weight: 600;
    color: #444;
}

.tts-voice-select {
    width: 100%;
    max-width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    border-radius: 8px;
    border: 1px solid #c7c7cc;
    background: #fff;
}

.tts-hint {
    margin: 2px 0 0;
    font-size: 11px;
    color: #777;
    line-height: 1.45;
}

/* Viral Features (Hook & CTA) */
.viral-features {
    background: linear-gradient(135deg, rgba(175, 82, 222, 0.08) 0%, rgba(88, 86, 214, 0.08) 100%);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(175, 82, 222, 0.2);
}

.viral-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.viral-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.viral-item label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.viral-item input[type="text"] {
    padding: 10px 12px;
    border: 2px solid #e5e5ea;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.viral-item input[type="text"]:focus {
    outline: none;
    border-color: #af52de;
}

.viral-item select {
    padding: 10px 12px;
    border: 2px solid #e5e5ea;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}

.hook-duration-label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    margin-top: 4px;
}

.hook-duration-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hook-duration-row input[type="number"] {
    width: 110px;
    padding: 8px 10px;
    border: 2px solid #e5e5ea;
    border-radius: 8px;
    font-size: 14px;
}

.hook-ms-suffix {
    font-size: 13px;
    color: #8e8e93;
}

.input-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
    min-width: 100px;
}

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

.btn-primary {
    background: #007aff;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #0056b3;
}

.btn-success {
    background: #34c759;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #2da44e;
}

.btn-warning {
    background: #ff9500;
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #e68600;
}

.btn-info {
    background: #5856d6;
    color: white;
    width: 100%;
}

.btn-info:hover {
    background: #4745b5;
}

.btn-secondary {
    background: #3a3a4a;
    color: #fff;
}

.btn-secondary:hover:not(:disabled) {
    background: #2d2d3a;
}

.record-export-row {
    margin-bottom: 8px;
}

.export-hint {
    font-size: 12px;
    color: #666;
    margin: 0 0 12px;
    line-height: 1.4;
}

/* AI generator */
.ai-generator textarea {
    width: 100%;
    min-height: 72px;
    padding: 12px 14px;
    border: 2px solid #e5e5ea;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.ai-generator textarea:focus {
    outline: none;
    border-color: #af52de;
}

.ai-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.ai-tone-label {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    margin: 0;
}

.ai-row select {
    flex: 1;
    min-width: 140px;
    padding: 10px 12px;
    border: 2px solid #e5e5ea;
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
}

.btn-ai-part2 {
    background: linear-gradient(135deg, #5856d6 0%, #3a3a5c 100%);
    white-space: nowrap;
}

.storage-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.storage-status {
    flex: 1;
    min-width: 140px;
    font-size: 12px;
    color: #5856d6;
}

.storage-hint {
    font-size: 11px;
    color: #8e8e93;
    margin: 8px 0 0;
    line-height: 1.45;
}

.btn-storage {
    padding: 8px 12px;
    border: 1px solid #c7c7cc;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
}

.btn-storage:hover {
    background: #f2f2f7;
}

.btn-ai {
    background: linear-gradient(135deg, #af52de 0%, #5856d6 100%);
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-ai:hover:not(:disabled) {
    filter: brightness(1.06);
}

.btn-ai:disabled {
    opacity: 0.55;
    cursor: wait;
}

.ai-help {
    font-size: 11px;
    color: #8e8e93;
    margin: 10px 0 0;
    line-height: 1.45;
}

.ai-status {
    font-size: 12px;
    color: #5856d6;
    margin: 8px 0 0;
    min-height: 1.2em;
}

.ai-status.ai-error {
    color: #ff3b30;
}

/* Crop target wraps phone only (tab capture + cropTo) */
.capture-root {
    display: inline-block;
    vertical-align: top;
    flex-shrink: 0;
}

/* Clean view (record mode) */
body.record-mode {
    padding: 0;
    min-height: 100vh;
    background: #000;
    align-items: stretch;
}

body.record-mode .app-container {
    flex-wrap: nowrap;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    width: 100%;
    padding: 56px 12px 24px;
    gap: 0;
}

body.record-mode .control-panel {
    display: none !important;
}

body.record-mode .iphone-frame {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    /* Full mockup in record / clean view — not capped by mobile “safe strip” */
    max-height: none;
}

body.record-mode .capture-root {
    margin-bottom: 0;
}

.record-mode-bar,
.export-bar {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 16px;
    background: rgba(20, 20, 28, 0.92);
    color: #eee;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.record-mode-bar {
    top: 0;
}

.export-bar {
    top: 52px;
    background: rgba(40, 30, 20, 0.95);
}

.record-mode-bar.hidden,
.export-bar.hidden {
    display: none !important;
}

.record-mode-controls {
    display: flex;
    gap: 8px;
}

.btn-record-tool {
    min-width: 40px;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: #444;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
}

.btn-record-tool:hover:not(:disabled) {
    background: #555;
}

.btn-record-tool:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-record-exit,
.btn-stop-export {
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    background: #007aff;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.btn-stop-export {
    background: #ff453a;
}

.btn-record-exit:hover,
.btn-stop-export:hover {
    filter: brightness(1.08);
}

.record-mode-label {
    opacity: 0.85;
    font-size: 13px;
}

.export-status {
    font-size: 13px;
}

/* Instructions */
.instructions {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #5856d6;
}

.instructions h3 {
    color: #5856d6;
    margin-bottom: 10px;
}

.instructions ol {
    padding-left: 20px;
    color: #333;
}

.instructions li {
    margin-bottom: 8px;
}

.instructions p {
    margin-top: 10px;
    font-size: 13px;
    color: #666;
}

.hidden {
    display: none;
}

/* Format hint */
.format-hint {
    margin-top: 8px;
    padding: 10px;
    background: #f0f7ff;
    border-radius: 8px;
    font-size: 12px;
    color: #555;
    line-height: 1.5;
}

.format-hint code {
    background: #e0ecff;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 11px;
}

.screen-layout-select {
    width: 100%;
    max-width: 100%;
    padding: 8px 10px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid #c7c7cc;
    background: #fff;
}

.screen-layout-hint {
    margin-top: 8px;
    font-size: 12px;
    color: #555;
    line-height: 1.5;
}

/* Responsive — phone uses full usable width; extra bottom = space for in-app / OS chrome & preview feel */
@media (max-width: 768px) {
    body {
        padding: max(12px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px))
            max(28px, env(safe-area-inset-bottom, 0px) + 48px) max(10px, env(safe-area-inset-left, 0px));
        align-items: stretch;
    }

    .app-container {
        flex-direction: column;
        align-items: stretch;
        gap: 20px;
        max-width: 100%;
    }

    .capture-root {
        display: block;
        width: 100%;
        max-width: 100%;
        /* Empty band below the mockup (above controls) so nothing sits on the “thumb strip” / channel UI in previews */
        margin-bottom: max(20px, 8dvh);
    }

    .iphone-frame {
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        /* Cap height so a visible empty strip stays on screen; keeps upload previews off the bottom */
        /* max-height: min(76dvh, 100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 120px); */
        aspect-ratio: var(--frame-w) / var(--frame-h);
        height: auto;
        border-radius: clamp(28px, 11vw, 45px);
        padding: clamp(8px, 2.8vw, 12px);
    }

    .iphone-frame.layout-landscape {
        /* 16:9 in portrait (narrow) mobile — keep height limited so controls stay reachable */
        max-height: min(72dvh, 92dvh);
    }

    .iphone-frame::before {
        top: clamp(8px, 2.8vw, 12px);
        width: clamp(96px, 28vw, 120px);
        height: clamp(20px, 6vw, 25px);
    }

    .iphone-frame.layout-landscape::before {
        width: clamp(120px, 30vw, 200px);
        height: clamp(20px, 5.5vw, 24px);
    }

    .screen-content {
        border-radius: clamp(20px, 8vw, 33px);
    }

    .control-panel {
        width: 100%;
        max-width: 100%;
        padding: 20px 16px;
    }

    .message {
        font-size: clamp(14px, 4.1vw, 16px);
        padding: clamp(8px, 2.2vw, 10px) clamp(11px, 3.2vw, 14px);
    }

    .message.first-message {
        font-size: clamp(15px, 4.3vw, 18px);
    }

    .hook-text {
        font-size: clamp(20px, 5.5vw, 26px);
    }

    .hook-emoji {
        font-size: clamp(40px, 12vw, 52px);
    }

    .end-cta-text {
        font-size: clamp(28px, 8vw, 38px);
    }

    /* Extra bottom room — iOS often clips the last row inside rounded + aspect-ratio frames */
    .input-bar {
        padding-top: max(10px, 2.5vw);
        padding-bottom: max(14px, 3.5vw);
        min-height: 54px;
    }

    .send-btn {
        width: 36px;
        height: 36px;
    }
}

@media (min-width: 769px) and (max-width: 900px) {
    .app-container {
        flex-direction: column;
        align-items: center;
    }

    .control-panel {
        width: min(380px, 100%);
    }
}

/* Phone physically rotated: width is often >768px, so use a short “height” instead of max-width. */
@media (orientation: landscape) and (max-height: 500px) {
    body {
        padding-top: max(6px, env(safe-area-inset-top, 0px));
        padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
    }

    .app-container {
        gap: 12px;
    }

    .capture-root {
        /* No thumb-strip gap when you’ve rotated for recording */
        margin-bottom: 0;
    }

    .iphone-frame.layout-landscape {
        width: min(100dvw - 20px, calc((100dvh - 8px) * 16 / 9));
        max-width: 100%;
        max-height: min(96dvh, calc(100dvw * 9 / 16));
        height: auto;
    }

    body.record-mode {
        min-height: 100dvh;
    }

    body.record-mode .app-container {
        padding: 50px 6px 4px;
        min-height: 100dvh;
    }

    body.record-mode .iphone-frame.layout-landscape {
        max-height: min(
            calc(100dvh - 58px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)),
            calc(100dvw * 9 / 16)
        );
        width: min(calc(100dvw - 12px), calc(100dvh * 16 / 9));
    }
}
