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

/* ========== VARIABLES ========== */
:root[data-theme="dark"] {
    --bg: #09090b;
    --surface: #18181b;
    --surface2: #27272a;
    --surface3: #3f3f46;
    --border: #27272a;
    --border2: #3f3f46;
    --text: #fafafa;
    --text2: #a1a1aa;
    --text3: #52525b;
    --accent: #a78bfa;
    --accent2: #8b5cf6;
    --accent-soft: rgba(167, 139, 250, 0.12);
    --accent-glow: rgba(139, 92, 246, 0.25);
    --green: #34d399;
    --green-soft: rgba(52, 211, 153, 0.12);
    --red: #f87171;
    --red-soft: rgba(248, 113, 113, 0.1);
    --cyan: #22d3ee;
    --cyan-soft: rgba(34, 211, 238, 0.12);
    --overlay-bg: rgba(0,0,0,0.6);
    --shadow: 0 16px 48px rgba(0,0,0,0.4);
}

:root[data-theme="light"] {
    --bg: #fafafa;
    --surface: #ffffff;
    --surface2: #f4f4f5;
    --surface3: #e4e4e7;
    --border: #e4e4e7;
    --border2: #d4d4d8;
    --text: #18181b;
    --text2: #71717a;
    --text3: #a1a1aa;
    --accent: #7c3aed;
    --accent2: #6d28d9;
    --accent-soft: rgba(124, 58, 237, 0.08);
    --accent-glow: rgba(124, 58, 237, 0.15);
    --green: #059669;
    --green-soft: rgba(5, 150, 105, 0.08);
    --red: #dc2626;
    --red-soft: rgba(220, 38, 38, 0.06);
    --cyan: #0891b2;
    --cyan-soft: rgba(8, 145, 178, 0.08);
    --overlay-bg: rgba(0,0,0,0.25);
    --shadow: 0 16px 48px rgba(0,0,0,0.08);
}

/* ========== BASE ========== */
html {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
    transition: background 0.4s, color 0.4s;
    -webkit-font-smoothing: antialiased;
}

/* ========== BACKGROUND ========== */
.bg-gradient {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 60% 50% at 20% 20%, var(--accent-soft) 0%, transparent 70%),
        radial-gradient(ellipse 50% 40% at 80% 80%, var(--cyan-soft) 0%, transparent 70%);
}

.bg-noise {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ========== APP ========== */
.app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 1360px;
    margin: 0 auto;
    padding: 0 48px;
}

/* ========== TOPBAR ========== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 72px;
    flex-shrink: 0;
    transition: opacity 0.5s, transform 0.5s;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.logo svg { color: var(--accent); }

.topbar-right { display: flex; gap: 6px; }

.icon-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.icon-btn:hover {
    border-color: var(--border2);
    color: var(--text);
    background: var(--surface2);
    transform: translateY(-1px);
}

[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

/* ========== MAIN ========== */
.main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 40px;
    padding-bottom: 20px;
    min-height: 0;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== TIMER ========== */
.timer-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 20px 0;
}

.mode-switcher {
    display: flex;
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px;
    transition: opacity 0.5s, transform 0.5s;
}

.mode-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text3);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.3s;
    position: relative;
    z-index: 1;
    white-space: nowrap;
}

.mode-btn:hover { color: var(--text2); }
.mode-btn.active { color: #fff; }

.mode-slider {
    position: absolute;
    top: 4px;
    height: calc(100% - 8px);
    background: var(--accent);
    border-radius: 9px;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.timer-wrap {
    position: relative;
    width: 300px;
    height: 300px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.track {
    fill: none;
    stroke: var(--surface2);
    stroke-width: 6;
}

.progress {
    fill: none;
    stroke: var(--accent);
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.4s ease;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.timer-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.timer-time {
    font-size: 68px;
    font-weight: 200;
    letter-spacing: -2px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s, font-size 0.5s;
}

.timer-label {
    margin-top: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 4px;
    color: var(--text3);
}

.timer-content.pulse .timer-time {
    animation: pulse 1s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Tab status */
.tab-status {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: var(--green-soft);
    border: 1px solid var(--green);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--green);
    animation: fadeUp 0.3s ease;
}

.tab-status.visible { display: flex; }

.tab-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    animation: blink 1.5s ease infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Controls */
.controls {
    display: flex;
    align-items: center;
    gap: 16px;
    transition: opacity 0.5s, transform 0.5s;
}

.ctrl-btn {
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.ctrl-primary {
    width: 72px;
    height: 72px;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 24px var(--accent-glow);
}

.ctrl-primary:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 32px var(--accent-glow);
}

.ctrl-primary:active { transform: scale(0.96); }

.ctrl-secondary {
    width: 48px;
    height: 48px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text2);
}

.ctrl-secondary:hover {
    border-color: var(--border2);
    color: var(--text);
    transform: scale(1.08);
}

/* Sessions */
.sessions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: opacity 0.5s, transform 0.5s;
}

.dots { display: flex; gap: 8px; }

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--surface2);
    border: 1.5px solid var(--border2);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.dot.filled {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
    transform: scale(1.15);
}

.session-text {
    font-size: 12px;
    color: var(--text3);
    font-weight: 500;
}

/* Shortcuts */
.shortcuts {
    display: flex;
    gap: 20px;
    font-size: 11px;
    color: var(--text3);
    transition: opacity 0.5s, transform 0.5s;
}

kbd {
    display: inline-block;
    padding: 2px 7px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 5px;
    margin-right: 4px;
}

/* ========== SIDEBAR ========== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
    transition: opacity 0.5s, transform 0.5s;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    transition: border-color 0.3s;
}

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

.card-grow {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 16px;
}

.card-head .card-title { margin-bottom: 0; }
.card-title svg { color: var(--accent); }

.badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent);
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.stat {
    background: var(--surface2);
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    transition: transform 0.2s;
}

.stat:hover { transform: translateY(-2px); }

.stat-num {
    display: block;
    font-size: 26px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.stat:nth-child(2) .stat-num { color: var(--cyan); }
.stat:nth-child(3) .stat-num { color: var(--green); }

.stat-lbl {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text3);
    margin-top: 4px;
}

/* Tasks */
.task-form {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.task-input {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--surface2);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: all 0.25s;
}

.task-input::placeholder { color: var(--text3); }

.task-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.task-add {
    width: 44px;
    min-width: 44px;
    height: 44px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--surface2);
    color: var(--text2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.task-add:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.task-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.task-list::-webkit-scrollbar { width: 3px; }
.task-list::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }

.task-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--surface2);
    border-radius: 10px;
    transition: all 0.25s;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.task-item:hover { background: var(--surface3); }
.task-item.done { opacity: 0.4; }
.task-item.done .task-text { text-decoration: line-through; }

.checkbox {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--text3);
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.checkbox.checked {
    background: var(--green);
    border-color: var(--green);
}

.checkbox.checked svg { display: block; }
.checkbox svg { display: none; width: 12px; height: 12px; color: #fff; }

.task-text {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.task-del {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    transition: all 0.15s;
}

.task-item:hover .task-del { opacity: 1; }
.task-del:hover { color: var(--red); background: var(--red-soft); }

.task-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text3);
    font-size: 13px;
}

.task-empty.hidden { display: none; }

/* ========== FOCUS MODE ========== */
body.focus-mode {
    overflow: hidden;
}

body.focus-mode .topbar,
body.focus-mode .sidebar,
body.focus-mode .mode-switcher,
body.focus-mode .sessions,
body.focus-mode .shortcuts,
body.focus-mode .footer {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-20px);
}

body.focus-mode .main {
    grid-template-columns: 1fr;
}

body.focus-mode .sidebar {
    position: absolute;
    right: 0;
    transform: translateX(60px);
}

body.focus-mode .timer-section {
    justify-content: center;
    min-height: 100vh;
}

body.focus-mode .timer-wrap {
    width: 380px;
    height: 380px;
}

body.focus-mode .timer-time {
    font-size: 86px;
}

body.focus-mode .controls {
    margin-top: 10px;
}

.focus-exit-hint {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    color: var(--text3);
    font-size: 12px;
    opacity: 0;
    transition: all 0.5s;
    pointer-events: none;
    z-index: 10;
    letter-spacing: 1px;
}

body.focus-mode .focus-exit-hint {
    opacity: 0.5;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
    cursor: pointer;
    animation: hintPulse 3s ease infinite;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* ========== FOOTER ========== */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text3);
    flex-shrink: 0;
    transition: opacity 0.5s, transform 0.5s;
}

.footer-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s;
}

.footer-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.footer-right { display: flex; gap: 8px; }

.footer-social {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--text3);
    transition: all 0.2s;
    text-decoration: none;
}

.footer-social:hover {
    background: var(--surface2);
    color: var(--accent);
    transform: translateY(-2px);
}

/* ========== MODAL ========== */
.overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    backdrop-filter: blur(6px);
    transition: all 0.3s;
}

.overlay.show { opacity: 1; visibility: visible; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 440px;
    padding: 32px;
    box-shadow: var(--shadow);
    transform: scale(0.92) translateY(12px);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 90vh;
    overflow-y: auto;
}

.overlay.show .modal { transform: scale(1) translateY(0); }

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.modal-head h2 { font-size: 18px; font-weight: 700; }

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: var(--surface2);
    color: var(--text2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover { background: var(--red-soft); color: var(--red); }

.modal-body { display: flex; flex-direction: column; gap: 4px; }

.field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.field:last-child { border-bottom: none; }

.field label { font-size: 14px; font-weight: 600; }
.field label small, .field small { font-weight: 400; color: var(--text3); margin-left: 4px; }

.field-info { display: flex; flex-direction: column; gap: 2px; }
.field-info label { margin: 0; }
.field-desc { font-size: 11px; color: var(--text3); margin: 0; }

.field-input {
    width: 72px;
    padding: 10px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--surface2);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: all 0.25s;
}

.field-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.switch {
    width: 46px;
    height: 26px;
    border-radius: 13px;
    background: var(--surface3);
    cursor: pointer;
    position: relative;
    transition: background 0.3s;
    flex-shrink: 0;
}

.switch.active { background: var(--accent); }

.switch::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.switch.active::after { transform: translateX(20px); }

.modal-foot { display: flex; gap: 10px; margin-top: 28px; }

.btn {
    flex: 1;
    padding: 13px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s;
}

.btn-ghost {
    background: var(--surface2);
    color: var(--text2);
    border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--surface3); }

.btn-solid {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-solid:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px var(--accent-glow);
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 22px;
    z-index: 200;
    box-shadow: var(--shadow);
    transform: translateX(140%);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.toast.show { transform: translateX(0); }

.toast-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--accent);
    border-radius: 0 0 14px 14px;
}

.toast.show .toast-bar { animation: shrink 3s linear forwards; }

@keyframes shrink {
    from { width: 100%; }
    to { width: 0%; }
}

.toast-text { font-size: 13px; font-weight: 600; }

/* ========== CONFETTI ========== */
.confetti-wrap {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 150;
}

.confetti-piece {
    position: absolute;
    border-radius: 2px;
    opacity: 0;
    animation: confettiFall 2.5s ease forwards;
}

@keyframes confettiFall {
    0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
    100% { opacity: 0; transform: translateY(95vh) rotate(600deg) scale(0.4); }
}