:root {
    --bg-base: #08101f;
    --bg-top: rgba(111, 140, 255, 0.25);
    --bg-side: rgba(122, 240, 216, 0.18);
    --panel: rgba(12, 20, 38, 0.78);
    --panel-strong: rgba(10, 16, 31, 0.95);
    --text: #ecf3ff;
    --muted: #aebdd6;
    --line: rgba(255, 255, 255, 0.12);
    --accent: #7f8cff;
    --accent-strong: #68e1fd;
    --accent-soft: rgba(127, 140, 255, 0.18);
    --shadow: 0 28px 60px rgba(0, 0, 0, 0.35);
    --ring-progress: 0deg;
    --ring-track: rgba(255, 255, 255, 0.08);
    --font-display: "Aptos Display", "Segoe UI Variable Display", "Trebuchet MS", sans-serif;
    --font-body: "Aptos", "Segoe UI Variable Text", "Trebuchet MS", sans-serif;
}

:root[data-theme="midnight"] {
    --bg-base: #090610;
    --bg-top: rgba(125, 77, 244, 0.2);
    --bg-side: rgba(250, 146, 92, 0.12);
    --panel: rgba(24, 16, 33, 0.78);
    --panel-strong: rgba(15, 11, 24, 0.96);
    --text: #f5eefe;
    --muted: #d2c1ec;
    --accent: #b98cff;
    --accent-strong: #ffb366;
    --accent-soft: rgba(185, 140, 255, 0.18);
}

:root[data-theme="atlas"] {
    --bg-base: #06141a;
    --bg-top: rgba(125, 208, 181, 0.18);
    --bg-side: rgba(255, 210, 117, 0.14);
    --panel: rgba(12, 29, 34, 0.8);
    --panel-strong: rgba(8, 21, 25, 0.95);
    --text: #e7f7f5;
    --muted: #abcbc7;
    --accent: #8fd9bf;
    --accent-strong: #ffd275;
    --accent-soft: rgba(143, 217, 191, 0.18);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at top left, var(--bg-top), transparent 35%),
        radial-gradient(circle at top right, var(--bg-side), transparent 30%),
        linear-gradient(180deg, var(--bg-base) 0%, #0b1324 100%);
    font-family: var(--font-body);
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-shell {
    max-width: 1240px;
    margin: 0 auto;
    padding: 28px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 28px;
    background: var(--panel);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
}

.panel-strong {
    background: linear-gradient(135deg, var(--accent-soft), transparent), var(--panel-strong);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 24px 28px;
    margin-bottom: 24px;
}

.brand {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.eyebrow {
    margin: 0 0 10px;
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

.header-actions,
.theme-switcher,
.control-row,
.task-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.theme-chip,
.button {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 12px 18px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.theme-chip:hover,
.theme-chip[aria-pressed="true"],
.button:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
}

.button-primary {
    border-color: transparent;
    color: #08101f;
    background: linear-gradient(135deg, var(--accent-strong) 0%, var(--accent) 100%);
    font-weight: 700;
}

.dashboard,
.content-grid,
.timer-layout,
.stats-grid,
.settings-grid {
    display: grid;
    gap: 24px;
}

.hero {
    padding: 34px;
}

.hero-copy {
    max-width: 760px;
}

h1,
h2,
p {
    margin-top: 0;
}

h1,
h2,
.timer-value,
.stat-card strong {
    font-family: var(--font-display);
}

h1 {
    margin-bottom: 16px;
    font-size: clamp(2.8rem, 6vw, 5.5rem);
    line-height: 0.94;
}

h2 {
    margin-bottom: 0;
    font-size: 1.5rem;
}

.lede,
.hint,
.task-meta,
.timer-caption,
.toggle-card small,
.history-copy {
    color: var(--muted);
    line-height: 1.65;
}

.timer-layout {
    grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.7fr);
    align-items: start;
    margin-top: 24px;
}

.timer-card,
.settings,
.stats-panel {
    padding: 26px;
}

.timer-card {
    display: grid;
    gap: 24px;
    justify-items: center;
}

.timer-ring {
    width: min(100%, 360px);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background:
        radial-gradient(circle, rgba(8, 16, 31, 0.9) 0 55%, transparent 56%),
        conic-gradient(var(--accent) var(--ring-progress), var(--ring-track) 0deg);
    box-shadow: inset 0 0 60px rgba(255, 255, 255, 0.04), 0 20px 40px rgba(0, 0, 0, 0.26);
    padding: 20px;
}

.timer-ring-inner {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    text-align: center;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
}

.timer-phase,
.timer-caption {
    margin-bottom: 0;
}

.timer-phase {
    font-size: 0.88rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

.timer-value {
    margin: 6px 0;
    font-size: clamp(3.2rem, 9vw, 5.8rem);
    line-height: 1;
}

.toggle-grid {
    width: 100%;
}

.toggle-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.toggle-card strong,
.toggle-card small,
.task-main strong,
.stat-card span,
.history-row strong,
.history-row span {
    display: block;
}

.toggle-card input {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
}

.section-heading {
    margin-bottom: 18px;
}

.section-heading.compact {
    margin-bottom: 12px;
}

.settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-grid label,
.task-form input,
.task-action,
.task-state,
.task-pomo,
.history-row,
.stat-card {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
}

.settings-grid label {
    display: grid;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 20px;
}

.settings-grid span {
    color: var(--muted);
}

.settings-grid input,
.task-form input {
    border-radius: 14px;
    border: 1px solid transparent;
    padding: 12px 14px;
    color: var(--text);
    background: rgba(0, 0, 0, 0.18);
}

.content-grid {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 0.95fr);
}

.content-grid > .panel {
    padding: 28px;
}

.task-form {
    margin-bottom: 18px;
}

.task-form input {
    flex: 1 1 240px;
}

.task-list,
.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.task-list {
    display: grid;
    gap: 12px;
}

.task-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.03);
}

.task-item.is-complete {
    opacity: 0.74;
}

.task-state,
.task-action,
.task-pomo {
    border-radius: 999px;
    padding: 10px 14px;
    color: var(--text);
}

.task-state {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    cursor: pointer;
}

.task-state input {
    margin: 0;
    accent-color: var(--accent);
}

.task-main {
    min-width: 0;
}

.task-main strong {
    overflow-wrap: anywhere;
}

.task-main .task-meta {
    margin: 4px 0 0;
}

.task-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.task-action {
    min-width: 96px;
}

.task-action.is-active {
    border-color: transparent;
    background: linear-gradient(135deg, var(--accent-strong) 0%, var(--accent) 100%);
    color: #08101f;
}

.task-action.task-delete {
    min-width: auto;
}

.stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card,
.history-row {
    border-radius: 22px;
    padding: 18px;
}

.stat-card span {
    margin-bottom: 8px;
    color: var(--muted);
}

.stat-card strong {
    font-size: 2rem;
}

.history-block {
    margin-top: 24px;
}

.history-list {
    display: grid;
    gap: 10px;
}

.history-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.history-copy {
    margin: 4px 0 0;
}

.empty-state {
    padding: 24px;
    border-radius: 22px;
    border: 1px dashed var(--line);
    color: var(--muted);
    text-align: center;
}

@media (max-width: 1080px) {
    .timer-layout,
    .content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .app-shell {
        padding: 16px;
    }

    .topbar,
    .hero,
    .content-grid > .panel,
    .timer-card,
    .settings,
    .stats-panel {
        padding: 22px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .settings-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .task-item {
        grid-template-columns: 1fr;
    }

    .task-actions {
        justify-content: flex-start;
    }

    .timer-ring {
        width: min(100%, 300px);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}