:root {
    --bg: #0f0f0f;
    --surface: #141418;
    --surface-2: #1a1a20;
    --border: #26262f;
    --accent: #e63939;
    --accent-soft: rgba(230, 57, 57, 0.14);
    --accent-glow: rgba(230, 57, 57, 0.35);
    --text: #f4f4f6;
    --text-muted: #7a7a88;
    --success: #2ec4b6;
    --warn: #e8b84a;
    --radius: 14px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }
input, select { user-select: text; }

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100%;
    overflow: hidden;
    display: flex;
}

.timer-page {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 22px 28px;
    gap: 18px;
    overflow: hidden;
    box-sizing: border-box;
}

.timer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.timer-header h1 {
    font-size: clamp(22px, 2.5vw, 28px);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.timer-header p {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

.header-actions { display: flex; align-items: center; gap: 10px; }

.active-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}

.active-pill b { color: var(--accent); font-size: 14px; }

.active-pill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
    animation: pulse 2s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(0.85); }
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 11px;
    padding: 11px 18px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 22px var(--accent-glow);
    transition: transform 0.2s var(--ease), background 0.2s;
}

.btn-primary:hover { background: #ff4d4d; transform: translateY(-1px); }
.btn-primary svg { width: 14px; height: 14px; fill: currentColor; }

.timer-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(300px, 1fr) minmax(340px, 1.15fr);
    gap: clamp(14px, 2vw, 20px);
    overflow: hidden;
}

.timer-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.panel-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.panel-body {
    padding: 16px 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.preset-list { display: flex; flex-direction: column; gap: 10px; }

.preset-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: border-color 0.2s, transform 0.2s var(--ease);
}

.preset-card:hover { border-color: rgba(230, 57, 57, 0.45); transform: translateX(2px); }

.preset-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.preset-icon svg { width: 18px; height: 18px; fill: var(--accent); }

.preset-info { min-width: 0; }
.preset-name { font-size: 13px; font-weight: 700; line-height: 1.35; }
.preset-duration { font-size: 12px; color: var(--accent); font-weight: 700; margin-top: 2px; }

.btn-launch {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-launch svg { width: 10px; height: 10px; fill: var(--accent); }
.btn-launch:hover { border-color: var(--accent); background: var(--accent-soft); }

.custom-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding-top: 4px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.field label {
    display: block;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* .field input — стили из rmrp-controls.css (единая дизайн-система) */
.field input {
    width: 100%;
}

.time-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 8px;
}

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

.time-step-btn {
    width: 40px;
    height: 18px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #121218;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.time-step-btn svg { width: 8px; height: 8px; fill: #888; }
.time-step-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.time-step-btn:hover svg { fill: var(--accent); }

.time-value {
    width: 44px;
    text-align: center;
    font-size: 20px;
    font-weight: 800;
    font-family: 'Consolas', 'Cascadia Mono', monospace;
    color: var(--text);
    padding: 4px 0;
}

.time-col-label { font-size: 9px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.time-colon { font-size: 18px; font-weight: 800; color: #444; padding-bottom: 16px; }

.sound-row { display: flex; align-items: center; gap: 8px; }
.sound-row svg { width: 14px; height: 14px; fill: var(--accent); flex-shrink: 0; }
.sound-row select { flex: 1; }

.form-footer { display: flex; flex-direction: column; gap: 8px; }
.form-hint { font-size: 11px; color: var(--text-muted); line-height: 1.45; }
.form-error { color: #ff6b6b; font-size: 12px; min-height: 4px; }

.btn-start-custom {
    width: 100%;
    justify-content: center;
    padding: 12px;
}

.timers-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 16px;
}

.timers-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.timer-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.2s;
}

.timer-card:hover { border-color: #35353f; }
.timer-card.running { border-color: rgba(230, 57, 57, 0.35); }
.timer-card.completed { border-color: rgba(46, 196, 182, 0.35); }
.timer-card.paused { opacity: 0.82; }

.timer-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.timer-name { font-size: 13px; font-weight: 700; line-height: 1.35; flex: 1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.timer-badge {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 4px 7px;
    border-radius: 6px;
    flex-shrink: 0;
}

.timer-badge.running { color: var(--accent); background: var(--accent-soft); }
.timer-badge.paused { color: var(--warn); background: rgba(232, 184, 74, 0.12); }
.timer-badge.completed { color: var(--success); background: rgba(46, 196, 182, 0.12); }

.timer-display {
    display: flex;
    align-items: center;
    gap: 14px;
}

.timer-ring-wrap {
    position: relative;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
}

.timer-ring {
    --progress: 0%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(var(--accent) var(--progress), #222228 0);
    position: relative;
    transition: background 0.12s linear;
}

.timer-card.completed .timer-ring { background: conic-gradient(var(--success) var(--progress), #222228 0); }

.timer-ring::after {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    background: var(--surface-2);
}

.timer-ring-wrap .timer-remaining {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    font-family: 'Consolas', monospace;
    text-align: center;
    z-index: 1;
}

.timer-card.completed .timer-remaining { color: var(--success); }

.timer-progress-track {
    flex: 1;
    height: 4px;
    background: #101014;
    border-radius: 999px;
    overflow: hidden;
}

.timer-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.12s linear;
    will-change: width;
}

.timer-card.completed .timer-progress-fill { background: var(--success); }

.timer-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.timer-btn {
    flex: 1 1 auto;
    min-width: 76px;
    padding: 8px 6px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #121218;
    color: #bbb;
    font-size: 10.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.timer-btn:hover { border-color: #3a3a46; color: #fff; }
.timer-btn.danger:hover { border-color: var(--accent); color: var(--accent); }
.timer-btn svg { width: 10px; height: 10px; fill: currentColor; }

.empty-state {
    height: 100%;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    color: var(--text-muted);
    padding: 24px;
}

.empty-state svg { width: 48px; height: 48px; fill: #333; opacity: 0.7; }
.empty-state h3 { color: #ccc; font-size: 15px; font-weight: 700; }
.empty-state p { font-size: 12px; max-width: 280px; line-height: 1.5; }

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: #18181e;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s var(--ease);
    z-index: 10000;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.modal-overlay.open { display: flex; }

.edit-modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: min(92vw, 400px);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55);
}

.edit-modal-title { font-size: 16px; font-weight: 800; }
.edit-modal-error { color: #ff6b6b; font-size: 12px; min-height: 4px; }

.edit-modal-actions { display: flex; gap: 8px; margin-top: 4px; }

.edit-modal-btn {
    flex: 1;
    padding: 11px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.edit-modal-btn.save { background: var(--accent); color: #fff; border: none; }
.edit-modal-btn.save:hover { background: #ff4d4d; }
.edit-modal-btn.cancel { background: transparent; color: #aaa; }
.edit-modal-btn.cancel:hover { background: var(--surface-2); color: #fff; }

@media (max-width: 900px) {
    .timer-layout { grid-template-columns: 1fr; overflow-y: auto; }
    .timer-page { overflow-y: auto; }
}