:root {
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --accent: #38bdf8;
    --bg: #0b0f1a; /* Deeper background */
    --card-bg: #131c2e; /* Solid, premium surface */
    --glass-border: rgba(148, 163, 184, 0.15);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --radius-lg: 1.5rem;
    --radius-md: 0.75rem;
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    background-image: radial-gradient(circle at top right, #1e293b 0%, #0b0f1a 50%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
}

.app-container {
    width: 100%;
    max-width: 480px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    padding: 2.5rem;
    min-height: 650px;
}

/* Transitions */
.screen {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Auth Screen */
.auth-card {
    text-align: center;
    padding-top: 2rem;
}

.auth-card h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.input-group {
    text-align: left;
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-group input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: white;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--primary);
}

.btn {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: scale(1.02);
}

.error-text {
    color: var(--accent);
    font-size: 0.85rem;
    margin-top: 1rem;
}

/* Main Screen */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.logo {
    font-weight: 700;
    letter-spacing: 1px;
    font-family: 'Outfit', sans-serif;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    justify-content: center;
}

.dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
}

.dot.recording {
    background: var(--accent);
    animation: blink 1s infinite;
}

@keyframes blink {
    50% {
        opacity: 0.4;
    }
}

.recording-controls {
    text-align: center;
    margin-bottom: 3rem;
}

.btn-record {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.1);
    border: 2px solid var(--accent);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}

.btn-record.active {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.4);
}

.record-icon {
    width: 24px;
    height: 24px;
    background: var(--accent);
    border-radius: 50%;
    transition: 0.3s;
}

.btn-record.active .record-icon {
    border-radius: 4px;
}

#timer {
    margin-top: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.history-list h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.history-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: 0.2s;
    gap: 1rem;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.item-date {
    font-size: 0.75rem;
    color: var(--primary-light);
}

.item-info {
    flex: 1;
    min-width: 0; /* Critical for flex truncation */
}

.item-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Result Screen */
.btn-back {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
}

.result-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.result-type {
    font-size: 0.8rem;
    color: var(--primary-light);
    margin-bottom: 1rem;
}

/* Modern Player */
.modern-player {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 2rem;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.player-btn {
    background: var(--primary);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    fill: white;
}

.player-progress-container {
    flex: 1;
}

.player-progress-container input {
    width: 100%;
    accent-color: var(--primary);
    cursor: pointer;
}

.player-time {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.info-block {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    transition: 0.2s;
}

.info-block:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--primary-light);
}

.info-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}

.info-value {
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.4;
    font-weight: 500;
}

/* Выделение тревожных симптомов */
.info-block.warning {
    border-color: rgba(244, 63, 94, 0.4);
    background: rgba(244, 63, 94, 0.08);
}

.info-block.warning .info-label {
    color: var(--accent);
}

.analysis-section {
    margin-bottom: 2rem;
}

.section-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.markdown-body {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
}



.secondary {
    opacity: 0.7;
    font-size: 0.9rem;
}

footer {
    margin-top: auto;
    padding-top: 2rem;
    text-align: center;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.2);
}

.hidden {
    display: none !important;
}
/* Physician Invite UI */
.invite-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-md);
}

.invite-section h3 {
    font-size: 0.9rem;
    margin-bottom: 1rem;
    color: var(--primary-light);
}

.invite-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.invite-form select, .invite-form input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 0.6rem 0.8rem;
    border-radius: 0.5rem;
    color: white;
    outline: none;
}

.btn-secondary {
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid var(--primary);
    color: var(--primary-light);
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
}

#generated-link-container {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
    animation: fadeIn 0.3s ease;
}

#share-link {
    flex: 1;
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-color: var(--primary);
}

/* Patient View */
.patient-info {
    text-align: center;
    margin-bottom: 2rem;
}

.patient-info h2 {
    font-family: 'Outfit', sans-serif;
    margin-bottom: 0.5rem;
}

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

.questions-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 2.5rem;
    border-left: 3px solid var(--primary);
}

.question-item {
    padding: 0.5rem 0;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.question-item:last-child {
    border-bottom: none;
}

.doctor-title {
    font-size: 0.8rem;
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
}

/* Select Fix & Improvements */
.modern-select {
    cursor: pointer;
    background: rgba(255, 255, 255, 0.08) !important;
    color: white !important;
    border: 1px solid var(--primary) !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 1rem center !important;
    background-size: 1em !important;
}

.modern-select option {
    background-color: #18181b;
    color: white;
}

.field-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.link-display {
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
}

.link-display input {
    background: none !important;
    border: none !important;
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--primary-light);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.refresh-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.refresh-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-light);
    transform: rotate(180deg);
    border-color: var(--primary-light);
}

.refresh-btn i {
    width: 18px;
    height: 18px;
}

.item-tag {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary-light);
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    text-transform: uppercase;
}

.item-user {
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
    color: var(--text-primary);
}

.success-msg {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
    padding: 1rem;
    border-radius: var(--radius-md);
    text-align: center;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}
/* App Loading */
.app-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loader {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(59, 130, 246, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
.item-arrow {
    color: var(--primary-light);
    opacity: 0.5;
    font-size: 1.1rem;
    transition: 0.2s;
}

.history-item:hover .item-arrow {
    opacity: 1;
    transform: translateX(4px);
}
