/* --- ОСНОВНІ ЗМІННІ ТА СТИЛІ (ВЕСНА) --- */
:root {
    --bg-gradient: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 10px 30px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    
    --text: #1e3a8a;
    --text-inv: #ffffff;
    --text-secondary: #64748b;
    --accent: #2563eb;
    
    --on: #059669;
    --off: #dc2626;
    --chunk-on: #10b981;
    --chunk-off: #ef4444;
    
    --modal-overlay: rgba(255, 255, 255, 0.4);
    --blur-strength: 15px;
    --dev-gradient: linear-gradient(90deg, #2563eb 0%, #10b981 100%);
    --gap-size: 12px;
}

body.dark-mode {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #064e3b 100%);
    --glass-bg: rgba(30, 41, 59, 0.65);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    
    --text: #f1f5f9;
    --accent: #34d399; 
    --on: #34d399;
    --off: #fb7185;
    --chunk-on: #34d399;
    --chunk-off: #f87171;
    
    --modal-overlay: rgba(0, 0, 0, 0.7);
    --dev-gradient: linear-gradient(90deg, #38bdf8 0%, #34d399 100%);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; }

body {
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text);
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Nunito', sans-serif;
    margin: 0; padding: 10px 16px 20px 16px;
    min-height: 100vh; user-select: none; overflow-x: hidden;
    transition: background 0.5s ease, color 0.3s ease;
}

/* --- SPA Анімації --- */
.view-section { display: none; animation: fadeInView 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.view-section.active { display: block; }
@keyframes fadeInView { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.glass-panel { background: var(--glass-bg); backdrop-filter: blur(var(--blur-strength)); -webkit-backdrop-filter: blur(var(--blur-strength)); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); border-radius: 24px; position: relative; z-index: 1; transform: translateZ(0); will-change: transform; transition: all 0.4s ease; padding: 20px 15px; }

.header, .donate-wrap, .weather-widget, .date-wrap, .queue-grid, .action-buttons-grid, .hero, .bar-wrap, .stats, .list-card, .warning-box { margin-bottom: var(--gap-size); margin-top: 0; }

.header { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 20; min-height: 44px; padding-top: 5px; }
.header-left { display: flex; align-items: center; gap: 10px; z-index: 21; }
.title-wrap { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; white-space: nowrap; pointer-events: none; }
.app-title { font-size: 22px; font-weight: 900; background: var(--dev-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: 0.5px; margin: 0; line-height: 1; }
.app-subtitle { font-size: 11px; font-weight: 700; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

.info-btn, .weather-toggle-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--glass-bg); border: 1px solid var(--glass-border); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; color: var(--accent); cursor: pointer; transition: 0.2s; }
.info-btn:active, .weather-toggle-btn:active { transform: scale(0.9); }
.weather-toggle-btn { opacity: 0.6; filter: grayscale(1); margin-left: 8px; }
.weather-toggle-btn.active { opacity: 1; filter: grayscale(0); background: rgba(255,255,255,0.2); }

/* Buttons */
.action-buttons-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; position: relative; z-index: 5; }
.glass-btn { display: flex; align-items: center; justify-content: center; width: 100%; gap: 8px; padding: 12px; border-radius: 16px; text-decoration: none; font-size: 14px; font-weight: 800; color: var(--text); background: var(--glass-bg); border: 1px solid var(--glass-border); backdrop-filter: blur(10px); box-shadow: 0 2px 10px rgba(0,0,0,0.03); transition: transform 0.2s, background 0.3s; line-height: 1.2; cursor: pointer; }
.glass-btn:active { transform: scale(0.96); }
.btn-icon { font-size: 16px; }

/* Lang Switch */
.lang-switch { background: rgba(0, 0, 0, 0.05); border-radius: 18px; padding: 3px; display: flex; border: 1px solid var(--glass-border); z-index: 21;}
.lang-btn { padding: 6px 12px; font-size: 13px; font-weight: 700; border-radius: 14px; opacity: 0.7; cursor: pointer; transition: 0.2s; }
.lang-btn.active { background: var(--glass-bg); opacity: 1; color: var(--accent); box-shadow: 0 2px 5px rgba(0,0,0,0.05); }

/* Dates */
.date-wrap { position: relative; z-index: 5; mask-image: linear-gradient(to right, transparent, black 5%, black 95%, transparent); -webkit-mask-image: linear-gradient(to right, transparent, black 5%, black 95%, transparent); }
.date-container { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px; scroll-behavior: smooth; scrollbar-width: none; }
.date-container::-webkit-scrollbar { display: none; }
.date-tab { flex: 0 0 auto; min-width: 60px; text-align: center; padding: 8px 10px; border-radius: 16px; background: var(--glass-bg); border: 1px solid var(--glass-border); cursor: pointer; transition: all 0.2s; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.weekday-label { font-size: 10px; text-transform: uppercase; font-weight: 700; opacity: 0.7; line-height: 1; margin-bottom: 2px; }
.date-value { font-size: 15px; font-weight: 800; line-height: 1; }
.is-weekend { color: #ff453a !important; opacity: 1 !important; }
.date-tab.active { background: #fbc02d; border-color: #fbc02d; color: #000; transform: scale(1.05); }
.date-tab.active .is-weekend { color: #d32f2f !important; }

/* Weather */
.weather-widget { padding: 20px 15px 15px 15px; display: flex; flex-direction: column; gap: 15px; transition: all 0.4s ease; overflow: hidden; max-height: 500px; }
.weather-widget.hidden { max-height: 0; padding: 0 15px; margin-bottom: 0; opacity: 0; border: none; }
.w-current { display: flex; justify-content: space-between; align-items: center; }
.w-main { display: flex; align-items: center; gap: 12px; }
.w-icon { width: 70px; height: 70px; display: flex; align-items: center; justify-content: center; }
.w-icon img { width: 100%; height: 100%; object-fit: contain; }
body.dark-mode .w-icon { filter: drop-shadow(0 8px 12px rgba(0,0,0,0.4)); }
.w-temp { font-size: 38px; font-weight: 900; margin-left: -5px; }
.w-info { text-align: right; display: flex; flex-direction: column; justify-content: center; }
.w-desc { font-size: 15px; font-weight: 800; margin-bottom: 4px; text-transform: capitalize; }
.w-feel { font-size: 12px; opacity: 0.7; font-weight: 600; }
.w-hourly { display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 5px 2px; scrollbar-width: none; mask-image: linear-gradient(to right, transparent, black 15px, black 90%, transparent); }
.w-hour { display: flex; flex-direction: column; align-items: center; min-width: 58px; background: rgba(255,255,255,0.06); padding: 12px 5px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.05); transition: 0.3s; }
.w-hour.current-hour { background: var(--accent); color: #fff; transform: scale(1.1) translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.2); }
.w-hour.past-hour { opacity: 0.3; transform: scale(0.95); filter: grayscale(1); }
.wh-time { font-size: 11px; opacity: 0.7; margin-bottom: 6px; font-weight: 700; }
.wh-icon { width: 38px; height: 38px; margin-bottom: 6px; }
.wh-icon img { width: 100%; height: 100%; object-fit: contain; }
.wh-temp { font-size: 14px; font-weight: 900; }
.w-advice { margin-top: 5px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.1); text-align: center; }
.w-advice-text { font-size: 13px; font-style: italic; opacity: 0.85; line-height: 1.4; font-weight: 500; }

/* =========================================
   ИКОНКИ: СЧЕТЧИК (ДЕНЬ) И ФОНАРИК (НОЧЬ)
   ========================================= */
.hero { text-align: center; padding: 30px 20px; overflow: hidden; }

/* Общий контейнер, который меняет размер */
.main-icon-wrap { 
    margin: 0 auto 10px auto; 
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
#main-svg-container { width: 100%; height: 100%; display: flex; justify-content: center; }

/* --- Светлая тема: Счетчик --- */
.main-icon-wrap.meter-mode {
    width: 100%;
    max-width: 200px; /* Крупный и красивый размер */
    height: 160px;
    filter: drop-shadow(0 15px 30px rgba(0,0,0,0.08)); 
}
.meter-wrapper {
    width: 100%; height: 100%;
}
.meter-svg { 
    width: 100%; 
    height: 100%; 
    overflow: visible; 
    transform: translateZ(0); 
}

/* --- Темная тема: Интерактивный Фонарик --- */
.main-icon-wrap.flashlight-mode {
    width: 100%;
    max-width: 380px;
    height: 160px;
    filter: drop-shadow(0 20px 40px rgba(0,0,0,0.4));
}
.flashlight-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.fl-svg { 
    width: 100%; 
    height: 100%; 
    overflow: visible; 
    transform: translateZ(0); 
}

/* Подсказка (Эмодзи) */
.fl-hint-icon {
    animation: bounceHintSVG 0.6s infinite alternate ease-in-out;
    transition: opacity 0.2s ease;
    pointer-events: none;
    will-change: transform, opacity;
}
.flashlight-wrapper.is-on .fl-hint-icon {
    opacity: 0;
}
@keyframes bounceHintSVG {
    0% { transform: translateY(0); }
    100% { transform: translateY(8px); }
}

/* ОПТИМИЗАЦИЯ СВЕТА: Ускорено появление луча, включен GPU рендеринг */
.fl-beam, .fl-lens { 
    opacity: 0; 
    transition: opacity 0.05s ease-out;
    will-change: opacity; 
}
.flashlight-wrapper.is-on .fl-beam,
.flashlight-wrapper.is-on .fl-lens {
    opacity: 1;
    animation: beamFlicker 5s infinite alternate ease-in-out;
}
@keyframes beamFlicker {
    0%, 100% { opacity: 0.95; }
    50% { opacity: 0.85; }
    55% { opacity: 1; }
    80% { opacity: 0.9; }
}

/* Нажатие кнопки */
.fl-btn { 
    transition: transform 0.05s ease-out; 
    transform-box: fill-box; 
    will-change: transform;
}
.flashlight-wrapper.is-on .fl-btn { transform: translateY(3px); }

/* ШВИДКА АНІМАЦІЯ ПОХИТУВАННЯ ПРИ КЛІКУ */
.fl-sway {
    transform-origin: 180px -35px;
    transform-box: fill-box;
    will-change: transform;
}
.shake-anim {
    animation: quickShake 0.4s ease-in-out both; 
}
@keyframes quickShake {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-2.5deg); }
    50% { transform: rotate(1.0deg); }
    75% { transform: rotate(-0.5deg); }
    100% { transform: rotate(0deg); }
}

/* ========================================= */

.status-main { font-size: 28px; font-weight: 900; margin-bottom: 8px; }
.timer { font-size: 18px; font-weight: 700; background: rgba(255,255,255,0.2); padding: 8px 20px; border-radius: 12px; display: inline-block; margin-bottom: 10px; border: 1px solid rgba(255,255,255,0.3); }
.timer-note { font-size: 13px; opacity: 0.8; display: block; margin-top: 4px; font-weight: 500;}
.quote-box { margin-top: 10px; padding-top: 15px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 15px; font-style: italic; opacity: 0.9; line-height: 1.4; font-weight: 500; min-height: 40px; display: flex; align-items: center; justify-content: center; transition: opacity 0.3s; }
.last-update { font-size: 11px; margin-top: 15px; opacity: 0.5; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }

/* Queues */
.queue-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; position: relative; z-index: 1; }
.queue-btn { background: var(--glass-bg); border: 1px solid var(--glass-border); padding: 12px 0; border-radius: 16px; font-weight: 800; font-size: 15px; text-align: center; cursor: pointer; transition: 0.2s; }
.queue-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); transform: scale(1.05); }

/* Timeline Visual */
.bar-wrap { position: relative; height: 50px; z-index: 1;}
.bar { display: flex; height: 34px; border-radius: 12px; overflow: hidden; border: 1px solid var(--glass-border); background: rgba(0,0,0,0.05); }
.chunk { flex: 1; height: 100%; position: relative; transition: width 0.3s; }
.chunk.on { background: var(--chunk-on); }
.chunk.off { background: var(--chunk-off); }
.marker { position: absolute; top: -4px; bottom: 12px; width: 4px; background: var(--text); border-radius: 4px; z-index: 5; transition: left 1s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 0 10px rgba(0,0,0,0.3); }
.labels { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; opacity: 0.6; margin-top: 4px; padding: 0 5px; }

/* Stats & List */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; z-index: 1; position: relative;}
.stat-card { padding: 16px; text-align: center; background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 20px; }
.stat-label { font-size: 11px; font-weight: 800; text-transform: uppercase; opacity: 0.6; display: block; margin-bottom: 4px; }
.stat-val { font-size: 22px; font-weight: 900; }
.stat-val.on { color: var(--on); } .stat-val.off { color: var(--off); }

.list-card { padding: 0; overflow: hidden; border-radius: 24px; }
.list-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid rgba(0,0,0,0.05); animation: fadeInRow 0.3s ease forwards; opacity: 0; }
@keyframes fadeInRow { to { opacity: 1; } }
.list-row:last-child { border-bottom: none; }
.row-time { font-size: 16px; font-weight: 700; letter-spacing: -0.5px; }

/* Беджі без іконок */
.row-badge { font-size: 13px; font-weight: 800; padding: 8px 16px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: #ffffff; min-width: 130px; letter-spacing: 0.5px; text-transform: uppercase;}
.badge-on { background: var(--chunk-on); } .badge-off { background: var(--chunk-off); }

/* Warnings & Loaders */
.warning-box { background: rgba(255, 152, 0, 0.15); border: 1px solid rgba(255, 152, 0, 0.3); color: #d97706; padding: 10px; border-radius: 16px; font-size: 13px; font-weight: 700; text-align: center; display: flex; align-items: center; justify-content: center; gap: 8px; }
body.dark-mode .warning-box { color: #fcd34d; border-color: rgba(251, 191, 36, 0.3); }
.loader { text-align: center; padding: 30px; font-weight: 700; opacity: 0.6; font-size: 14px; }

/* === ПОШУК (Search) === */
.input-group { margin-bottom: 15px; position: relative; }
.input-group label { display: block; margin-bottom: 6px; font-weight: 700; font-size: 14px; opacity: 0.8; padding-left: 5px; }
.input-group input { width: 100%; padding: 14px; border-radius: 16px; border: 1px solid var(--glass-border); background: rgba(255,255,255,0.3); font-family: 'Nunito', sans-serif; font-size: 16px; font-weight: 600; color: var(--text); box-sizing: border-box; outline: none; transition: all 0.3s; }
body.dark-mode .input-group input { background: rgba(0,0,0,0.2); }
.input-group input:focus { background: rgba(255,255,255,0.8); border-color: var(--accent); box-shadow: 0 4px 15px rgba(37, 99, 235, 0.1); }
.autocomplete-list { position: absolute; top: 105%; left: 0; right: 0; background: var(--glass-bg); backdrop-filter: blur(15px); border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); max-height: 250px; overflow-y: auto; z-index: 100; padding: 5px; border: 1px solid var(--glass-border); display: none; }
.autocomplete-item { padding: 12px 15px; cursor: pointer; border-radius: 10px; margin-bottom: 2px; font-size: 15px; font-weight: 600; }
.autocomplete-item:hover { background-color: rgba(37, 99, 235, 0.1); color: var(--accent); }
#result-card { margin-top: 20px; background: rgba(255,255,255,0.2); border: 1px solid var(--glass-border); padding: 20px; border-radius: 16px; text-align: center; animation: fadeInView 0.3s ease; }
#result-queue { font-size: 48px; font-weight: 900; background: linear-gradient(45deg, #fbc02d, #f57f17); -webkit-background-clip: text; -webkit-text-fill-color: transparent; display: block; line-height: 1; margin-top: 5px; }
.info-notes { margin-top: 20px; border-top: 1px solid rgba(0,0,0,0.1); padding-top: 15px; }
body.dark-mode .info-notes { border-top-color: rgba(255,255,255,0.1); }
.note-item { display: flex; align-items: flex-start; font-size: 13px; line-height: 1.4; opacity: 0.8; }

/* === МАТРИЦЯ (All Queues) === */
.matrix-layout { display: grid; grid-template-columns: 35px 1fr 45px; gap: 8px; align-items: center; }
.matrix-header { margin-bottom: 10px; font-size: 11px; opacity: 0.6; text-transform: uppercase; font-weight: 700; padding: 0 2px; }
.time-labels { display: flex; justify-content: space-between; font-size: 10px; }
.queue-row { padding: 8px 0; border-bottom: 1px solid rgba(0, 0, 0, 0.05); }
body.dark-mode .queue-row { border-bottom-color: rgba(255, 255, 255, 0.05); }
.queue-row:last-child { border-bottom: none; }
.q-name { font-size: 14px; font-weight: 800; }
.q-visual { position: relative; height: 22px; background: rgba(0, 0, 0, 0.05); border-radius: 6px; display: flex; overflow: hidden; }
body.dark-mode .q-visual { background: rgba(255, 255, 255, 0.05); }
.hour-cell { flex: 1; height: 100%; border-right: 1px solid rgba(0,0,0,0.05); }
.hour-cell:last-child { border-right: none; }
.hour-cell.on { background-color: var(--chunk-on); } 
.hour-cell.off { background-color: var(--chunk-off); }

.q-stats { text-align: right; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.time-cursor { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); box-shadow: 0 0 8px var(--text); z-index: 10; border-radius: 2px; }
.time-cursor::before { content: ''; position: absolute; top: -4px; left: -2px; width: 6px; height: 6px; background: var(--text); border-radius: 50%; }

/* Modal */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--modal-overlay); z-index: 2000; align-items: center; justify-content: center; backdrop-filter: blur(10px); opacity: 0; transition: opacity 0.2s ease-in-out; }
.modal.show { opacity: 1; }
.modal-content { background: var(--glass-bg); width: 90%; max-width: 380px; height: 80vh; border-radius: 32px; padding: 25px; display: flex; flex-direction: column; border: 1px solid var(--glass-border); box-shadow: 0 25px 60px rgba(0,0,0,0.3); transform: scale(0.95); transition: transform 0.2s; }
.modal.show .modal-content { transform: scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; flex-shrink: 0; }
.modal-title { font-size: 24px; font-weight: 900; }
.close-btn { width: 32px; height: 32px; border-radius: 50%; background: rgba(0,0,0,0.05); display: flex; align-items: center; justify-content: center; font-size: 20px; cursor: pointer; }
.dev-info { text-align: center; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid var(--glass-border); flex-shrink: 0; }
.dev-nick { font-weight: 900; font-size: 24px; background: var(--dev-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin: 5px 0 10px 0; }
.dev-link { display: inline-block; background: var(--accent); color: white; text-decoration: none; padding: 8px 24px; border-radius: 14px; font-weight: 700; font-size: 14px; }
.changelog-list { overflow-y: auto; flex: 1; padding-right: 5px; }
.cl-item { background: rgba(255,255,255,0.05); border-radius: 16px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--glass-border); }
.cl-ver { display: inline-block; background: var(--accent); color: white; padding: 3px 8px; border-radius: 8px; font-size: 12px; font-weight: 800; margin-bottom: 6px; }
.cl-date { float: right; font-size: 11px; opacity: 0.6; margin-top: 4px; font-weight: 700; }
.cl-desc li { font-size: 13px; margin-bottom: 4px; opacity: 0.9; line-height: 1.4; padding-left: 5px; position: relative; list-style-type: none; }
.cl-desc li::before { content: "•"; color: var(--accent); position: absolute; left: -10px; font-weight: bold; }
