/* MindPush — тёмная тема, mobile-first */

:root {
    --bg: #16182f;
    --surface: #1f2242;
    --surface-2: #262a52;
    --border: #343a6b;
    --text: #e8e9f3;
    --muted: #9a9cb8;
    --accent: #7c6cff;
    --accent-2: #a78bfa;
    --danger: #ff6b81;
    --success: #3ddc97;
    --ring-track: #2c2f58;
}

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

/* Атрибут hidden должен побеждать любые display из авторских правил */
[hidden] {
    display: none !important;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: radial-gradient(1200px 600px at 50% -200px, #232752 0%, var(--bg) 60%);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.app {
    max-width: 560px;
    margin: 0 auto;
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* Верхняя панель */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0 12px;
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.topbar-title span {
    color: var(--accent-2);
}

.icon-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 1.05rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.icon-btn:hover {
    background: var(--surface-2);
}

/* Экраны */
.screen {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.section-title {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Вход */
.login-card {
    margin: auto;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 36px 28px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.logo {
    font-size: 2rem;
    font-weight: 800;
}

.logo span {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.subtitle {
    color: var(--muted);
    font-size: 0.95rem;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

input[type="password"], input[type="text"] {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 13px 16px;
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.15s ease;
}

input:focus {
    border-color: var(--accent);
}

/* Кнопки */
.btn {
    border: none;
    border-radius: 14px;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease, filter 0.15s ease;
    color: var(--text);
    text-align: center;
}

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

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

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #6a5ae0);
    color: #fff;
    box-shadow: 0 6px 18px rgba(124, 108, 255, 0.35);
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.08);
}

.btn-secondary {
    background: var(--surface-2);
    border: 1px solid var(--border);
}

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

.error-msg {
    color: var(--danger);
    font-size: 0.9rem;
    text-align: center;
}

/* Меню */
.modes {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mode-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 22px;
    text-align: left;
    cursor: pointer;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.15s ease, transform 0.1s ease;
}

.mode-card:hover {
    border-color: var(--accent);
}

.mode-card:active {
    transform: scale(0.99);
}

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

.mode-name {
    font-size: 1.25rem;
    font-weight: 700;
}

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

/* Пакеты */
.packs-block {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 6px;
}

.packs-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pack-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.pack-item.selected {
    border-color: var(--accent);
    background: var(--surface-2);
}

.pack-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pack-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pack-meta {
    color: var(--muted);
    font-size: 0.82rem;
}

.pack-delete {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    flex-shrink: 0;
}

.pack-delete:hover {
    color: var(--danger);
    background: rgba(255, 107, 129, 0.1);
}

.upload-btn {
    display: block;
}

.upload-status {
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

.empty-hint {
    color: var(--muted);
    font-size: 0.9rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 14px;
    padding: 16px;
    text-align: center;
}

/* Экран вопроса */
.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.badge {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 999px;
    padding: 5px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge-source {
    color: var(--accent-2);
    border-color: var(--accent);
}

.badge-price {
    color: #ffd166;
    border-color: #6b5f2a;
}

/* Таймер */
.timer-wrap {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 4px auto;
}

.timer-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-track, .timer-progress {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
}

.timer-track {
    stroke: var(--ring-track);
}

.timer-progress {
    stroke: var(--success);
    stroke-dasharray: 326.7;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.95s linear, stroke 0.4s ease;
}

.timer-progress.warning {
    stroke: #ffd166;
}

.timer-progress.danger {
    stroke: var(--danger);
}

.timer-num {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

/* Карточка вопроса */
.question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px;
    font-size: 1.02rem;
    white-space: pre-line;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.question-card img {
    max-width: 100%;
    border-radius: 12px;
    align-self: center;
}

.media-note {
    color: var(--muted);
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
}

/* Ответ */
.answer-card {
    background: linear-gradient(135deg, rgba(61, 220, 151, 0.12), rgba(61, 220, 151, 0.05));
    border: 1px solid rgba(61, 220, 151, 0.4);
    border-radius: 18px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.answer-label {
    color: var(--success);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.answer-text {
    font-size: 1.08rem;
    font-weight: 600;
    white-space: pre-line;
}

.answer-extra {
    color: var(--muted);
    font-size: 0.88rem;
    white-space: pre-line;
    padding-top: 6px;
    border-top: 1px solid rgba(61, 220, 151, 0.2);
}

/* Управление */
.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
    padding-top: 8px;
}

/* Модалка */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 11, 24, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modal-in 0.18s ease;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.05rem;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.context-text {
    font-size: 0.96rem;
    white-space: pre-line;
}

.context-meta {
    color: var(--muted);
    font-size: 0.8rem;
    text-align: right;
}

/* Спиннер */
.spinner {
    width: 36px;
    height: 36px;
    margin: 16px auto;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Тост */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 12px;
    padding: 10px 18px;
    font-size: 0.9rem;
    z-index: 200;
    max-width: 90vw;
    animation: toast-in 0.2s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@media (min-width: 480px) {
    .modes {
        flex-direction: row;
    }
    .mode-card {
        flex: 1;
    }
    .controls {
        flex-direction: row;
    }
    .controls .btn {
        flex: 1;
    }
}
