* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #252542;
    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --accent-dark: #6d28d9;
    --accent-blue: #3b82f6;
    --accent-blue-light: #60a5fa;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --border: #3d3d5c;
    /* Unified border-radius values */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 50%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ========== HEADER ========== */
.header {
    text-align: center;
    padding: 20px 16px 16px;
    background: linear-gradient(180deg, #1a1a3e 0%, var(--bg-primary) 100%);
}

.header h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.header h1::before {
    content: "✨ ";
}

.stars-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

/* ========== TABS ========== */
.tabs {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 0 8px 16px;
    background: var(--bg-primary);
    overflow-x: auto;
}

.tab {
    flex: 1;
    min-width: 60px;
    max-width: 80px;
    padding: 8px 4px;
    border: none;
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.tab.active {
    background: var(--accent);
    color: white;
}

.tab-icon {
    font-size: 16px;
}

/* ========== CONTENT ========== */
.content {
    padding: 0 16px 100px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ========== FORM ELEMENTS ========== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.form-label::before {
    margin-right: 6px;
}

textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

textarea:focus {
    border-color: var(--accent);
}

textarea::placeholder {
    color: var(--text-secondary);
}

select {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23a0a0b0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

input[type="text"], input[type="time"], input[type="number"] {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
}

input:focus, select:focus {
    border-color: var(--accent);
}

/* ========== SEASON BUTTONS ========== */
.season-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.season-btn {
    flex: 1;
    min-width: 70px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.season-btn.active {
    border-color: var(--accent);
    background: rgba(139, 92, 246, 0.2);
    color: var(--text-primary);
}

/* ========== GENDER BUTTONS ========== */
.gender-buttons {
    display: flex;
    gap: 12px;
}

.gender-btn {
    flex: 1;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 16px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.gender-btn.active {
    border-color: var(--accent);
    background: rgba(139, 92, 246, 0.2);
    color: var(--text-primary);
}

.gender-btn .emoji {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
}

/* ========== VOICE SELECTOR ========== */
.voice-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.voice-card {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.voice-card.active {
    border-color: var(--accent);
    background: rgba(139, 92, 246, 0.2);
}

.voice-avatar {
    font-size: 28px;
    margin-bottom: 4px;
}

.voice-name {
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 4px;
}

.voice-preview {
    font-size: 10px;
    color: var(--accent-light);
}

/* Кнопка превью голоса */
.voice-preview-btn {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.8;
}

.voice-preview-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.voice-preview-btn:active {
    transform: scale(0.95);
}

/* ========== MAIN BUTTON ========== */
.main-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.main-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.main-btn:active:not(:disabled) {
    transform: scale(0.98);
}

/* Кнопка аффирмации - голубой акцент */
.main-btn.affirmation-btn {
    background: linear-gradient(135deg, var(--accent-blue) 0%, #2563eb 100%);
}

/* ========== DREAM CARDS ========== */
.dream-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
}

/* Карточка аффирмации - голубая граница */
.dream-card.affirmation-card {
    border-left: 4px solid var(--accent-blue);
}

.dream-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.dream-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.dream-actions {
    display: flex;
    gap: 8px;
}

.dream-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.dream-action-btn:active {
    transform: scale(0.95);
}

.dream-action-btn.favorite.active {
    color: var(--warning);
}

.dream-text {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dream-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.dream-tag {
    font-size: 11px;
    padding: 4px 8px;
    background: var(--bg-secondary);
    border-radius: 6px;
    color: var(--text-secondary);
}

/* Тег аффирмации */
.dream-tag.affirmation-tag {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent-blue-light);
}

.play-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Кнопка воспроизведения аффирмации */
.play-btn.affirmation-play {
    background: var(--accent-blue);
}

/* ========== AFFIRMATION TAB STYLES ========== */
.affirmation-mode-switch {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 12px;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn.active {
    background: var(--accent-blue);
    color: white;
}

.affirmation-mode {
    display: none;
}

.affirmation-mode.active {
    display: block;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Карточка готовой аффирмации */
.preset-affirmation-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--accent-blue);
    cursor: pointer;
    transition: all 0.2s;
}

.preset-affirmation-card:active {
    transform: scale(0.98);
}

.preset-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.preset-card-icon {
    font-size: 32px;
}

.preset-card-info {
    flex: 1;
}

.preset-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.preset-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.preset-card-duration {
    font-size: 12px;
    color: var(--accent-blue-light);
    padding: 4px 8px;
    background: rgba(59, 130, 246, 0.2);
    border-radius: 8px;
}

.preset-play-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: var(--accent-blue);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
}

/* Выбор количества фраз */
.phrase-count-selector {
    display: flex;
    gap: 12px;
}

.phrase-btn {
    flex: 1;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.phrase-btn.active {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.2);
    color: var(--text-primary);
}

/* ========== PRESET PLAYER MODAL ========== */
.preset-player-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
}

.preset-player-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    text-align: center;
}

/* ========== REMINDER CARDS ========== */
.reminder-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.reminder-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.reminder-time {
    font-size: 24px;
    font-weight: 600;
}

.reminder-days {
    font-size: 12px;
    color: var(--text-secondary);
}

.reminder-dream {
    font-size: 11px;
    color: var(--accent-light);
    margin-top: 4px;
}

.toggle-switch {
    width: 50px;
    height: 28px;
    background: var(--bg-secondary);
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-switch.active {
    background: var(--accent);
}

.toggle-switch::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
}

.toggle-switch.active::after {
    transform: translateX(22px);
}

/* ========== ADD BUTTON ========== */
.add-card {
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.add-card:active {
    transform: scale(0.98);
}

.add-icon {
    font-size: 32px;
    color: var(--accent);
    margin-bottom: 8px;
}

.add-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ========== PROFILE ========== */

.settings-section {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
}

.settings-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    font-size: 14px;
}

.setting-value {
    font-size: 14px;
    color: var(--accent-light);
}

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
}

.modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-secondary);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
}

/* ========== PLAYER ========== */
.player-modal {
    text-align: center;
}

.player-visual {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    border-radius: 50%;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
}

.player-visual.playing {
    animation: pulse 2s infinite;
}

/* Плеер аффирмации - голубой */
.player-visual.affirmation-visual {
    background: linear-gradient(135deg, var(--accent-blue) 0%, #2563eb 100%);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.player-text {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
    max-height: 200px;
    overflow-y: auto;
    text-align: left;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
}

/* Переключатель музыки в плеере */
.player-music-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.player-music-label {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Кнопка повторов аудио */
.repeat-btn {
    background: var(--accent);
    color: #fff;
    border-radius: 20px;
    min-width: 55px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    border: none;
    margin-left: 8px;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0 10px;
    white-space: nowrap;
}
.repeat-btn:hover {
    background: var(--accent-dark);
}
.repeat-btn:active {
    transform: scale(0.95);
}

.player-controls {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.player-btn {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.player-btn.secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ========== LOADING ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 26, 0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 3px solid var(--bg-secondary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 16px;
    color: var(--text-secondary);
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.success {
    border-left: 4px solid var(--success);
}
