/* ============================================
   Remote Sync — Long-Distance Co-Regulation
   Space/connection aesthetic
   ============================================ */

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

:root {
    --bg-dark: #0a0a14;
    --bg-card: #12121f;
    --bg-hover: #1a1a2e;
    
    --accent: #6366f1;
    --accent-dim: rgba(99, 102, 241, 0.15);
    --accent-glow: rgba(99, 102, 241, 0.4);
    
    --signal: #22d3ee;
    --signal-dim: rgba(34, 211, 238, 0.15);
    
    --success: #10b981;
    
    --text-primary: #f0f0ff;
    --text-secondary: rgba(240, 240, 255, 0.7);
    --text-muted: rgba(240, 240, 255, 0.4);
    
    --font-mono: 'Space Mono', monospace;
    --font-body: 'Inter', sans-serif;
    
    --radius: 16px;
    --radius-sm: 10px;
    --transition: 0.3s ease;
}

body {
    font-family: var(--font-body);
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, #1a1a3e 0%, var(--bg-dark) 60%);
    position: relative;
}

/* Stars Background */
.stars-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    opacity: 0.5;
    animation: twinkle 3s ease-in-out infinite;
}

.star:nth-child(1) { top: 10%; left: 20%; animation-delay: 0s; }
.star:nth-child(2) { top: 25%; left: 80%; animation-delay: 0.5s; }
.star:nth-child(3) { top: 40%; left: 15%; animation-delay: 1s; }
.star:nth-child(4) { top: 60%; left: 70%; animation-delay: 1.5s; }
.star:nth-child(5) { top: 75%; left: 30%; animation-delay: 2s; }
.star:nth-child(6) { top: 85%; left: 85%; animation-delay: 2.5s; }
.star:nth-child(7) { top: 15%; left: 50%; animation-delay: 0.3s; }
.star:nth-child(8) { top: 50%; left: 40%; animation-delay: 0.8s; }
.star:nth-child(9) { top: 35%; left: 60%; animation-delay: 1.3s; }
.star:nth-child(10) { top: 70%; left: 10%; animation-delay: 1.8s; }
.star:nth-child(11) { top: 90%; left: 55%; animation-delay: 2.3s; }
.star:nth-child(12) { top: 5%; left: 35%; animation-delay: 2.8s; }

@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Screens */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease;
    padding: 30px 20px;
    overflow-y: auto;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

.screen-content {
    max-width: 420px;
    width: 100%;
    text-align: center;
}

/* Logo */
.logo {
    margin-bottom: 25px;
}

.logo-icon {
    font-size: 1.5rem;
    color: var(--accent);
    opacity: 0.8;
}

/* Welcome */
.welcome-title {
    font-family: var(--font-mono);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--signal) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

/* Globe Visual */
.globe-visual {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 0 auto 35px;
}

.globe {
    position: absolute;
    inset: 20px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    opacity: 0.4;
}

.globe.small {
    inset: 0;
}

.globe-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    opacity: 0.3;
}

.globe-line:nth-child(2) {
    transform: rotate(30deg);
}

.globe-line:nth-child(3) {
    transform: rotate(-30deg);
}

.connection-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--signal);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--signal);
}

.connection-dot.dot-1 {
    top: 30%;
    left: 25%;
    animation: pulse-dot 2s ease-in-out infinite;
}

.connection-dot.dot-2 {
    bottom: 30%;
    right: 25%;
    animation: pulse-dot 2s ease-in-out infinite 1s;
}

.connection-wave {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, var(--signal), transparent, var(--signal));
    transform: translate(-50%, -50%) rotate(-20deg);
    opacity: 0.5;
    animation: wave-pulse 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

@keyframes wave-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* Session Options */
.session-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-btn {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all var(--transition);
}

.option-btn.primary {
    background: linear-gradient(135deg, var(--accent) 0%, #818cf8 100%);
}

.option-btn.secondary {
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.1);
}

.option-btn:hover {
    transform: translateY(-2px);
}

.option-btn.primary:hover {
    box-shadow: 0 10px 30px var(--accent-glow);
}

.btn-icon {
    font-size: 1.3rem;
}

.btn-text {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.join-row {
    display: flex;
    gap: 10px;
}

.join-input {
    flex: 1;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.join-input:focus {
    outline: none;
    border-color: var(--accent);
}

.join-btn {
    padding: 14px 20px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

/* Setup - Relationships */
.setup-title, .mode-title, .schedule-title, .async-title {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 25px;
}

.relationship-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 25px;
}

.rel-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}

.rel-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.rel-icon {
    font-size: 1.8rem;
}

.rel-name {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}

.rel-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.back-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
}

/* Mode Selection */
.mode-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 25px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}

.mode-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.mode-icon {
    font-size: 2rem;
}

.mode-info {
    flex: 1;
}

.mode-name {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}

.mode-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.mode-time {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent);
}

/* Waiting Room */
.waiting-globe {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 25px;
}

.signal-rings {
    position: absolute;
    inset: 0;
}

.signal-ring {
    position: absolute;
    inset: 0;
    border: 2px solid var(--signal);
    border-radius: 50%;
    opacity: 0;
    animation: signal-expand 2s ease-out infinite;
}

.signal-ring:nth-child(2) { animation-delay: 0.7s; }
.signal-ring:nth-child(3) { animation-delay: 1.4s; }

@keyframes signal-expand {
    0% { transform: scale(0.5); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}

.waiting-title {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.code-display {
    margin-bottom: 20px;
}

.code-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.code-box {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    color: var(--signal);
    background: var(--bg-card);
    padding: 16px 32px;
    border-radius: var(--radius);
    display: inline-block;
    letter-spacing: 0.15em;
    margin-bottom: 10px;
}

.copy-btn {
    display: block;
    margin: 0 auto;
    padding: 8px 20px;
    background: transparent;
    border: 1px solid var(--text-muted);
    border-radius: 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
}

.copy-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.waiting-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.distance-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--accent-dim);
    border-radius: 25px;
    margin-bottom: 25px;
}

.distance-icon {
    font-size: 1.2rem;
}

.distance-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.cancel-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
}

/* Connected Screen */
.connected-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 25px;
}

.connected-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    animation: connected-pulse 2s ease-in-out infinite;
}

.connected-dot.you {
    background: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.connected-dot.them {
    background: var(--signal);
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.4);
    animation-delay: 0.5s;
}

.connection-line-anim {
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--signal));
    border-radius: 2px;
    animation: line-pulse 1s ease-in-out infinite;
}

@keyframes connected-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes line-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.connected-title {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    color: var(--signal);
    margin-bottom: 8px;
}

.connected-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.distance-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-card);
    border-radius: 25px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.start-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--signal) 100%);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
}

/* ============================================
   Main Session
   ============================================ */

.session-layout {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    position: relative;
}

.sync-visual {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 30px;
}

.sync-orb {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 4s ease;
    position: relative;
}

.sync-orb.you-orb {
    background: radial-gradient(circle, var(--accent), #4f46e5);
    box-shadow: 0 0 30px var(--accent-glow);
}

.sync-orb.them-orb {
    background: radial-gradient(circle, var(--signal), #0891b2);
    box-shadow: 0 0 30px rgba(34, 211, 238, 0.4);
}

.sync-orb.inhale {
    transform: scale(1.3);
}

.sync-orb.exhale {
    transform: scale(0.85);
    opacity: 0.8;
}

.orb-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.sync-bridge {
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--signal));
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

.bridge-particles {
    position: absolute;
    inset: 0;
}

.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    top: -1px;
    animation: particle-flow 2s linear infinite;
}

.particle:nth-child(1) { animation-delay: 0s; }
.particle:nth-child(2) { animation-delay: 0.4s; }
.particle:nth-child(3) { animation-delay: 0.8s; }
.particle:nth-child(4) { animation-delay: 1.2s; }
.particle:nth-child(5) { animation-delay: 1.6s; }

@keyframes particle-flow {
    0% { left: -6px; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { left: 100%; opacity: 0; }
}

/* Session Info */
.session-info-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
}

.session-mode {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.session-timer {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Breath Guidance */
.breath-guidance {
    text-align: center;
    margin-bottom: 25px;
}

.breath-text {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    min-height: 30px;
}

.breath-cue {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    color: var(--signal);
    min-height: 50px;
}

/* Sync Meter */
.sync-meter {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.sync-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.sync-bar {
    width: 140px;
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
}

.sync-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--signal));
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 4px;
}

.sync-value {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--signal);
    min-width: 50px;
}

/* Distance Reminder */
.distance-reminder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 30px;
}

.end-btn {
    position: absolute;
    bottom: 30px;
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Async Mode */
.async-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.async-recorder {
    margin-bottom: 25px;
}

.record-orb {
    width: 100px;
    height: 100px;
    margin: 0 auto 15px;
    background: var(--bg-card);
    border: 3px solid var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.record-orb:hover {
    background: var(--accent-dim);
    transform: scale(1.05);
}

.record-orb.recording {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    animation: record-pulse 1s ease-in-out infinite;
}

@keyframes record-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
}

.record-icon {
    font-size: 2.5rem;
}

.record-status {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.record-timer {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    color: var(--text-primary);
}

.breath-message {
    width: 100%;
    height: 100px;
    padding: 15px;
    background: var(--bg-card);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    resize: none;
    margin-bottom: 20px;
}

.breath-message:focus {
    outline: none;
    border-color: var(--accent);
}

.send-btn {
    width: 100%;
    padding: 16px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 15px;
}

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

/* Completion */
.complete-visual {
    margin-bottom: 25px;
}

.complete-globe {
    width: 100px;
    height: 100px;
    margin: 0 auto;
    border: 2px solid var(--accent);
    border-radius: 50%;
    position: relative;
    opacity: 0.5;
}

.complete-dots {
    position: absolute;
    inset: 0;
}

.complete-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.complete-dot.d1 {
    background: var(--accent);
    top: 25%;
    left: 20%;
}

.complete-dot.d2 {
    background: var(--signal);
    bottom: 25%;
    right: 20%;
}

.complete-connection {
    position: absolute;
    top: 50%;
    left: 25%;
    width: 50%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--signal));
    transform: rotate(-20deg);
}

.complete-title {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--signal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.complete-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 25px;
}

.session-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 25px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--signal);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.connection-streak {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-dim);
    padding: 12px 24px;
    border-radius: 30px;
    margin-bottom: 25px;
}

.streak-icon {
    font-size: 1.2rem;
}

.streak-text {
    font-size: 1rem;
    color: var(--text-secondary);
}

.streak-text strong {
    color: var(--signal);
}

.session-quote {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 30px;
}

.done-btn {
    width: 100%;
    padding: 16px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
}

/* Schedule Screen */
.schedule-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 25px;
}

.schedule-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 14px;
    background: var(--bg-card);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
}

.schedule-preview {
    padding: 15px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.schedule-preview p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.preview-time {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    color: var(--signal);
}

.schedule-btn {
    width: 100%;
    padding: 16px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 15px;
}

/* Responsive */
@media (max-width: 400px) {
    .sync-visual {
        gap: 15px;
    }
    
    .sync-orb {
        width: 60px;
        height: 60px;
    }
    
    .sync-bridge {
        width: 50px;
    }
}



