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

:root {
    --bg: #0f0f1a;
    --surface: #1a1a2e;
    --surface2: #16213e;
    --border: #2a2a4a;
    --text: #e0e0f0;
    --text-muted: #8888aa;
    --accent: #7c5cbf;
    --accent-hover: #9b7fd4;
    --danger: #e85a5a;
    --success: #5acd85;
}

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

/* ── Header ── */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
header h1 { font-size: 1.2rem; font-weight: 700; }
header h1 span { color: var(--accent-hover); }
.home-link { color: var(--text-muted); font-size: 0.8rem; text-decoration: none; letter-spacing: 0.1em; transition: color 0.15s; }
.home-link:hover { color: var(--text); }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ── Buttons ── */
button {
    cursor: pointer; border: none; border-radius: 6px;
    font-family: inherit; font-size: 0.85rem; font-weight: 500;
    transition: background 0.15s, opacity 0.15s, transform 0.1s;
}
button:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary   { background: var(--accent); color: #fff; padding: 7px 14px; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary { background: var(--surface2); color: var(--text); padding: 7px 14px; border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-danger    { background: transparent; color: var(--danger); padding: 7px 14px; border: 1px solid var(--danger); }
.btn-danger:hover:not(:disabled) { background: rgba(232,90,90,0.12); }

.btn-success   { background: var(--success); color: #0f1f0f; padding: 7px 14px; font-weight: 600; }
.btn-success:hover:not(:disabled) { background: #6fe89b; }

/* ── Main Layout ── */
main {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}
.main-center {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-template-rows: 1fr;
    overflow: hidden;
    min-height: 0;
}

/* ── Wheel Section ── */
.wheel-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    gap: 14px;
    overflow: hidden;
}

.wheel-container { position: relative; flex-shrink: 0; }

.pointer {
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0; height: 0;
    border-top: 11px solid transparent;
    border-bottom: 11px solid transparent;
    border-right: 26px solid #f0c040;
    filter: drop-shadow(0 2px 6px rgba(240,192,64,0.7));
    z-index: 10;
}

#wheel { display: block; }

.spin-btn {
    background: linear-gradient(135deg, #7c5cbf 0%, #4a90d9 100%);
    color: #fff;
    padding: 12px 48px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 50px;
    letter-spacing: 1px;
    box-shadow: 0 4px 20px rgba(124,92,191,0.45);
}
.spin-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(124,92,191,0.65);
}
.spin-btn:active:not(:disabled) { transform: translateY(0); }

/* ── Result Banner ── */
.result-banner {
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 14px 18px;
    width: 100%;
    max-width: 480px;
    min-height: 108px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.result-banner.visible { opacity: 1; pointer-events: auto; }
.result-banner h3 { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 4px; }
.result-task-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 10px; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.result-hint { font-size: 0.7rem; color: var(--text-muted); margin-top: 8px; line-height: 1.5; }

/* ── Task Panel ── */
.task-panel {
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.task-panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.task-panel-header h2 { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.task-list { flex: 1; overflow-y: auto; padding: 6px; min-height: 0; }
.task-list::-webkit-scrollbar { width: 8px; }
.task-list::-webkit-scrollbar-track { background: var(--surface2); border-radius: 4px; }
.task-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.task-list::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.task-item {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 8px 10px;
    margin-bottom: 5px;
    display: flex; align-items: flex-start; gap: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
}
.task-item:hover { border-color: var(--accent); }

.task-cat-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }

.task-item-body { flex: 1; min-width: 0; }
.task-item-title { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-item-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

.task-item-actions { display: flex; gap: 3px; flex-shrink: 0; }
.task-item-actions button { background: transparent; color: var(--text-muted); padding: 2px 5px; font-size: 0.7rem; border-radius: 4px; }
.task-item-actions button:hover { color: var(--text); background: var(--border); }
.task-item-actions .del-btn:hover { color: var(--danger); }

.task-status-badge {
    display: inline-block;
    font-size: 0.6rem; padding: 1px 5px; border-radius: 8px;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-snoozed  { background: rgba(240,173,78,0.18); color: #F0AD4E; }
.badge-completed{ background: rgba(90,205,133,0.18); color: var(--success); }

.panel-footer { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-shrink: 0; }

.section-label {
    font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-muted); padding: 6px 4px 3px; margin-top: 4px;
}
.empty-state { text-align: center; color: var(--text-muted); padding: 28px 12px; font-size: 0.85rem; line-height: 1.6; }

/* ── Modal ── */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.72); z-index: 100;
    align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 22px; width: 460px; max-width: 95vw;
    max-height: 90vh; overflow-y: auto;
}
.modal h2 { font-size: 1.05rem; margin-bottom: 18px; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }

.form-row input[type="text"],
.form-row select,
.form-row textarea {
    width: 100%; background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); padding: 7px 11px; border-radius: 6px;
    font-family: inherit; font-size: 0.875rem;
}
.form-row input[type="text"]:focus,
.form-row select:focus,
.form-row textarea:focus { outline: none; border-color: var(--accent); }
.form-row textarea { resize: vertical; min-height: 56px; }

.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.range-val { font-size: 0.875rem; font-weight: 600; min-width: 24px; text-align: right; }

.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ── Focus Overlay ── */
.focus-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(8,8,18,0.97); z-index: 200;
    flex-direction: column; align-items: center; justify-content: center; gap: 20px;
}
.focus-overlay.open { display: flex; }

.focus-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 2px; color: var(--accent-hover); }
.focus-title { font-size: 1.8rem; font-weight: 700; text-align: center; max-width: 580px; line-height: 1.3; }
.focus-category { font-size: 0.9rem; color: var(--text-muted); }
.focus-timer { font-size: 4.5rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -3px; }
.focus-controls { display: flex; gap: 12px; align-items: center; }
.focus-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ── Toast ── */
.toast {
    position: fixed; bottom: 28px; left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text); padding: 10px 20px; border-radius: 8px;
    font-size: 0.85rem; opacity: 0; pointer-events: none;
    transition: opacity 0.25s, transform 0.25s; z-index: 9999;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5); white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Auto-backup banner ── */
.backup-banner {
    background: #1a2a1a; border-bottom: 1px solid #2a4a2a;
    color: #a0d0a0; padding: 8px 20px;
    display: flex; align-items: center; gap: 12px; font-size: 0.82rem;
    flex-shrink: 0;
}
.backup-banner span { flex: 1; }
.backup-banner button {
    background: transparent; color: #a0d0a0; border: 1px solid #2a4a2a;
    padding: 4px 12px; border-radius: 5px; font-size: 0.78rem;
}
.backup-banner button:hover { background: rgba(160,208,160,0.1); }
.backup-banner .dismiss { border: none; padding: 4px 8px; opacity: 0.6; }

/* ── Stats Panel (left) ── */
.stats-panel {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    width: 0;
    transition: width 0.25s ease;
    flex-shrink: 0;
}
.stats-panel.open { width: 260px; }

.stats-panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
    min-width: 240px;
}
.stats-panel-header h2 { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.stats-list { flex: 1; overflow-y: auto; padding: 8px 10px; min-height: 0; min-width: 240px; }
.stats-pie-wrap { display: none; flex: 1; min-height: 0; min-width: 240px; padding: 10px; box-sizing: border-box; overflow-y: auto; flex-direction: column; gap: 8px; }
.stats-pie-wrap.active { display: flex; }
.stats-list.hidden { display: none; }
.stats-list::-webkit-scrollbar { width: 8px; }
.stats-list::-webkit-scrollbar-track { background: var(--surface2); border-radius: 4px; }
.stats-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.stats-list::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.stats-empty { text-align: center; color: var(--text-muted); padding: 20px 12px; font-size: 0.82rem; }

.stats-item {
    padding: 8px 4px;
    border-bottom: 1px solid var(--border);
}
.stats-item:last-child { border-bottom: none; }
.stats-item:hover { background: var(--surface2); border-radius: 4px; }

.stats-item-top {
    display: flex; align-items: flex-start; gap: 6px; margin-bottom: 4px;
}
.stats-item-title {
    flex: 1; font-size: 0.8rem; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    line-height: 1.3;
}
.stats-pct {
    font-size: 0.85rem; font-weight: 700; color: var(--accent-hover);
    flex-shrink: 0; white-space: nowrap;
}
.stats-item-bar-wrap {
    background: var(--surface2); border-radius: 3px; height: 4px; margin-bottom: 4px;
    overflow: hidden;
}
.stats-item-bar {
    height: 100%; background: var(--accent); border-radius: 3px;
}
.stats-item-detail { font-size: 0.67rem; color: var(--text-muted); }

/* ── Odds FAB (bottom-left) ── */
.odds-fab {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 50;
    background: var(--surface);
    border: 1px solid var(--border) !important;
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 14px rgba(0,0,0,0.45);
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.odds-fab:hover {
    background: var(--border);
    color: var(--text);
    border-color: var(--accent) !important;
    box-shadow: 0 4px 18px rgba(124,92,191,0.3);
}
.odds-fab.active {
    border-color: var(--accent) !important;
    color: var(--accent-hover);
}
