:root {
    --bg-main: #0f1218;
    --bg-layer: #171d27;
    --line-color: rgba(255, 255, 255, 0.1);
    --line-color-strong: rgba(255, 255, 255, 0.25);
    --text-main: #f4f7fb;
    --text-muted: #a6b2c5;
    --accent-gradient: linear-gradient(125deg, #39bb9d, #c99a28);
    --danger: #eb6464;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
    color: var(--text-main);
    background: radial-gradient(circle at 15% 15%, #253244 0%, #131922 42%, #0f1218 100%);
}

h2,
h3,
h4 {
    margin: 0;
    font-weight: 700;
}

p {
    margin: 0;
}

a {
    color: inherit;
}

.surface-card {
    background: linear-gradient(150deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
    border: 1px solid var(--line-color);
    border-radius: 18px;
    padding: 1rem 1.1rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.section-title {
    margin: 1.2rem 0 0.8rem;
    font-size: 1.3rem;
}

.home-hero {
    display: grid;
    gap: 0.5rem;
    padding: 1.2rem 1.25rem;
    background:
      radial-gradient(circle at 15% 20%, rgba(57, 187, 157, 0.15), transparent 50%),
      linear-gradient(145deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
}

.home-hero h2 {
    margin: 0.5rem 0 0.25rem;
    font-size: clamp(1.25rem, 2.8vw, 1.7rem);
}

.grid-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.timer-card {
    display: grid;
    gap: 0.85rem;
}

.timer-card.compact {
    min-height: 110px;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(57, 187, 157, 0.16);
    color: #9ce6d6;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
}

.card-actions.wrap {
    flex-wrap: wrap;
}

.button {
    border: 0;
    border-radius: 999px;
    padding: 0.55rem 1rem;
    background: var(--accent-gradient);
    color: #0f1218;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.button.ghost {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--line-color-strong);
}

.input {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--line-color-strong);
    background: var(--bg-layer);
    color: var(--text-main);
    padding: 0.62rem 0.75rem;
}

.switch-row {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.category-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
}

.category-card {
    border: 1px solid var(--line-color);
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    display: grid;
    gap: 0.32rem;
    padding: 1rem 1.05rem;
    transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.category-card:hover {
    transform: translateY(-2px);
    border-color: var(--line-color-strong);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

.category-card:focus-visible {
    outline: 2px solid rgba(102, 255, 214, 0.7);
    outline-offset: 2px;
}

.category-title {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 1.1rem;
}

.category-card span {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.config-panel {
    border-top: 1px solid var(--line-color);
    padding-top: 0.8rem;
    display: grid;
    gap: 0.45rem;
}

.named-preset-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.4rem;
}

.run-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.2rem;
    padding: 1.2rem;
    background:
      radial-gradient(circle at 22% 18%, rgba(102, 255, 214, 0.16), transparent 52%),
      radial-gradient(circle at 82% 72%, rgba(201, 154, 40, 0.16), transparent 52%),
      #0d1118;
    animation: run-bg-shift 9s ease-in-out infinite alternate;
}

.run-header {
    text-align: center;
    display: grid;
    gap: 0.5rem;
}

.progress-wrap {
    position: relative;
    width: min(78vw, 360px);
    aspect-ratio: 1;
    filter: drop-shadow(0 0 18px rgba(57, 187, 157, 0.22));
    animation: floaty 4s ease-in-out infinite;
}

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

.ring-track {
    fill: transparent;
    stroke: rgba(255, 255, 255, 0.14);
    stroke-width: 11;
}

.ring-progress {
    fill: transparent;
    stroke-width: 11;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.step-track {
    stroke: rgba(102, 255, 214, 0.17);
}

.total-track {
    stroke: rgba(201, 154, 40, 0.2);
}

.step-progress-green {
    stroke: url(#stepGradientGreen);
}

.step-progress-blue {
    stroke: url(#stepGradientBlue);
}

.step-progress-green,
.step-progress-blue {
    opacity: 0;
    transition: opacity 140ms ease;
}

.step-progress-green.is-active,
.step-progress-blue.is-active {
    opacity: 1;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.22, 1, 0.36, 1), opacity 140ms ease;
}

.step-progress-green.is-fading-out,
.step-progress-blue.is-fading-out {
    opacity: 0;
    transition: stroke-dashoffset 220ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease;
}

.step-progress-green.is-hidden,
.step-progress-blue.is-hidden {
    opacity: 0;
    transition: none;
}

.total-progress {
    stroke: url(#totalGradient);
}

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

.time-main {
    font-size: clamp(2rem, 10vw, 3.4rem);
    font-weight: 700;
    letter-spacing: 0.03em;
    text-shadow: 0 0 22px rgba(102, 255, 214, 0.2);
}

.time-sub {
    color: var(--text-muted);
}

.run-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.lucide {
    flex: 0 0 auto;
}

@keyframes run-bg-shift {
    from {
        background-position: 0% 0%, 100% 100%, center;
    }
    to {
        background-position: 14% 6%, 86% 92%, center;
    }
}

@keyframes floaty {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.toast-stack {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 20;
    display: grid;
    gap: 0.5rem;
    width: min(330px, calc(100vw - 2rem));
}

.toast-card {
    display: flex;
    justify-content: space-between;
    gap: 0.7rem;
    padding: 0.65rem 0.75rem;
    border-radius: 12px;
    border: 1px solid var(--line-color-strong);
    background: rgba(25, 32, 43, 0.95);
}

.toast-card p {
    color: var(--text-muted);
    margin-top: 0.2rem;
    font-size: 0.88rem;
}

.toast-dismiss {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 1px solid var(--line-color);
    font-size: 0.94rem;
}

#blazor-error-ui {
    background: #ffd7d7;
    bottom: 0;
    display: none;
    left: 0;
    padding: 0.6rem 1rem;
    position: fixed;
    width: 100%;
    color: #501313;
    z-index: 9999;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.6rem;
    top: 0.4rem;
}

.loading-progress {
    margin: 22vh auto 0.6rem;
    display: block;
    width: 7.5rem;
    height: 7.5rem;
}

.loading-progress circle {
    fill: none;
    stroke: rgba(255, 255, 255, 0.22);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #39bb9d;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

@media (min-width: 760px) {
    .grid-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .named-preset-row {
        grid-template-columns: 1fr auto;
    }

    .category-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .category-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
