/* Stopwatch – Premium Dark Theme */

.sw {
    --bg: #0f0f13;
    --surface: #1a1a22;
    --surface-glass: rgba(255, 255, 255, 0.04);
    --border: rgba(255, 255, 255, 0.06);
    --text: #e8e8ed;
    --text-dim: #b4bcc9;
    --accent: #2dd4bf;
    --accent-glow: rgba(45, 212, 191, 0.15);
    --danger: #f87171;
    --danger-glow: rgba(248, 113, 113, 0.15);
    --success: #4ade80;
    --success-glow: rgba(74, 222, 128, 0.15);
    --blue: #93c5fd;

    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2.5rem 1.25rem 3rem;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text);
    position: relative;
}

/* ── Mode Toggle ──────────────────────────────────── */

.sw-mode-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    background: var(--surface-glass);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
}

.sw-mode-btn {
    padding: 0.4rem 1.2rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.sw-mode-btn.sw-mode-active {
    background: var(--accent);
    color: #0f0f13;
}

/* ── Countdown Presets ────────────────────────────── */

.sw-countdown-presets {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: nowrap;
    justify-content: center;
}

.sw-preset-btn {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-glass);
    color: var(--text-dim);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.sw-preset-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.12);
}

.sw-preset-btn.sw-preset-active {
    background: var(--accent);
    color: #0f0f13;
    border-color: var(--accent);
}

/* ── Sound Selector ──────────────────────────────── */

.sw-sound-selector {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.sw-sound-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-glass);
    color: var(--text-dim);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.sw-sound-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.sw-sound-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.12);
}

.sw-sound-btn.sw-sound-active {
    background: var(--accent);
    color: #0f0f13;
    border-color: var(--accent);
}

[data-theme="light"] .sw-sound-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text);
    border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .sw-sound-btn.sw-sound-active {
    color: #ffffff;
}

/* ── Ring ───────────────────────────────────────── */

.sw-ring-wrap {
    position: relative;
    width: 280px;
    height: 280px;
    margin-bottom: 2rem;
}

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

.sw-ring-track {
    fill: none;
    stroke: var(--border);
    stroke-width: 3;
}

.sw-ring-progress {
    fill: none;
    stroke: var(--accent);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 753.98;
    stroke-dashoffset: 753.98;
    transition: stroke 0.3s;
    filter: drop-shadow(0 0 6px var(--accent-glow));
}

.sw-ring-progress.sw-ring-stopped {
    stroke: var(--text-dim);
    filter: none;
}

.sw-ring-tick-60 {
    fill: none;
    stroke: rgba(255, 255, 255, 0.03);
    stroke-width: 1;
    stroke-dasharray: 1 11.57;
    stroke-linecap: butt;
}

/* ── Time Display ──────────────────────────────── */

.sw-time-inner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0;
}

.sw-display {
    font-family: var(--font-family-mono);
    font-size: 3.5rem;
    font-weight: 300;
    letter-spacing: -0.02em;
    line-height: 1;
    user-select: none;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.sw-display .sw-digit {
    font-size: inherit;
    color: inherit;
}

.sw-display-ms {
    font-family: var(--font-family-mono);
    font-size: 1.25rem;
    font-weight: 300;
    color: var(--text-dim);
    line-height: 1;
    user-select: none;
    font-variant-numeric: tabular-nums;
    margin-top: 0.25rem;
}

.sw-hidden {
    display: none;
}

.sw-sep {
    color: var(--text-dim);
    font-weight: 200;
}

.sw-sep-ms {
    color: var(--text-dim);
    font-weight: 200;
}

.sw-digit-ms {
    color: var(--text-dim);
}

.sw.sw-running .sw-display {
    color: var(--text);
}

.sw.sw-running .sw-display .sw-sep {
    color: var(--text);
    animation: sw-blink 1s step-end infinite;
}

.sw.sw-running .sw-display-ms {
    color: var(--text);
}

.sw.sw-running .sw-display-ms .sw-sep-ms {
    animation: none;
    color: var(--text);
}

@keyframes sw-blink {
    50% { opacity: 0.3; }
}

/* ── Actions ───────────────────────────────────── */

.sw-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
}

.sw-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s, background-color 0.2s, box-shadow 0.2s, opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.sw-btn:active:not(:disabled) {
    transform: scale(0.92);
}

.sw-btn:disabled {
    opacity: 0.2;
    cursor: default;
}

.sw-btn svg {
    width: 22px;
    height: 22px;
}

/* Änderungsprotokoll: 2026-08-20 | parent-agent | @skill-css-rules, @skill-change-provenance | Start-Button premium weiß mit Akzent-Icon statt schwarzem Icon */
.sw-btn-start {
    width: 72px;
    height: 72px;
    background: linear-gradient(145deg, #ffffff 0%, #f4f4f8 100%);
    color: var(--accent);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.08),
        0 4px 24px rgba(255, 255, 255, 0.14),
        0 8px 32px rgba(0, 0, 0, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 1);
}

.sw-btn-start:hover:not(:disabled) {
    background: linear-gradient(145deg, #ffffff 0%, #fafafa 100%);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.12),
        0 6px 32px rgba(255, 255, 255, 0.2),
        0 12px 40px rgba(0, 0, 0, 0.48),
        inset 0 1px 0 rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

.sw-btn-start svg {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 1px 2px rgba(45, 212, 191, 0.25));
}

.sw-btn-start.sw-active {
    background: linear-gradient(145deg, #ffffff 0%, #fef2f2 100%);
    color: var(--danger);
    border-color: rgba(248, 113, 113, 0.2);
    box-shadow:
        0 0 0 1px rgba(248, 113, 113, 0.12),
        0 4px 24px rgba(248, 113, 113, 0.22),
        0 8px 32px rgba(0, 0, 0, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 1);
}

.sw-btn-start.sw-active svg {
    filter: drop-shadow(0 1px 2px rgba(248, 113, 113, 0.3));
}

.sw-btn-start.sw-active:hover {
    box-shadow:
        0 0 0 1px rgba(248, 113, 113, 0.18),
        0 6px 32px rgba(248, 113, 113, 0.3),
        0 12px 40px rgba(0, 0, 0, 0.48),
        inset 0 1px 0 rgba(255, 255, 255, 1);
}

.sw-btn-reset,
.sw-btn-lap {
    width: 52px;
    height: 52px;
    background: var(--surface-glass);
    color: var(--text-dim);
    border: 1px solid var(--border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.sw-btn-reset:hover:not(:disabled),
.sw-btn-lap:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.sw-icon-hidden {
    display: none;
}

/* ── Labels ────────────────────────────────────── */

.sw-label-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 2rem;
}

.sw-label {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 500;
}

/* Änderungsprotokoll: 2026-08-19 | parent-agent | @skill-css-rules, @skill-change-provenance | Tastatur-Hinweis dunkles Theme kontrastreicher */
.sw-kbd-hint {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.72);
    letter-spacing: 0.04em;
    font-weight: 500;
}

/* ── Laps ──────────────────────────────────────── */

.sw-laps {
    width: 100%;
}

.sw-div-table {
    width: 100%;
}

.sw-div-table-header {
    display: none;
}

.sw-div-table.has-laps .sw-div-table-header {
    display: grid;
    grid-template-columns: 1fr 2fr 2fr;
}

.sw-div-table-header > .sw-div-table-cell {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-weight: 500;
    color: var(--text-dim);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sw-div-table-header > .sw-div-table-cell:last-child {
    text-align: right;
}

.sw-div-table-row {
    display: grid;
    grid-template-columns: 1fr 2fr 2fr;
    transition: background-color 0.15s;
}

.sw-div-table-row > .sw-div-table-cell {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.sw-div-table-row > .sw-div-table-cell:first-child {
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.75rem;
}

.sw-div-table-row > .sw-div-table-cell:last-child {
    text-align: right;
}

.sw-div-table-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.sw-div-table-row.sw-lap-best > .sw-div-table-cell:nth-child(2) {
    color: var(--accent);
}

.sw-div-table-row.sw-lap-worst > .sw-div-table-cell:nth-child(2) {
    color: var(--danger);
}

.sw-lap-new > .sw-div-table-cell {
    animation: sw-lap-in 0.3s ease-out;
}

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

/* ── Countdown Finished Effect ─────────────────── */

.sw-countdown-done .sw-ring-wrap {
    animation: sw-pulse-ring 0.8s ease-in-out infinite;
}

.sw-countdown-done .sw-ring-track {
    stroke: var(--success);
    stroke-width: 4;
    animation: sw-ring-glow 0.8s ease-in-out infinite;
}

.sw-countdown-done .sw-ring-progress {
    stroke: var(--success);
    stroke-dashoffset: 0 !important;
    stroke-width: 5;
    filter: drop-shadow(0 0 12px var(--success-glow));
    animation: sw-ring-stroke-pulse 0.8s ease-in-out infinite;
}

.sw-countdown-done .sw-display {
    animation: sw-flash-text 0.8s ease-in-out infinite;
    font-weight: 400;
}

.sw-countdown-done .sw-digit,
.sw-countdown-done .sw-sep,
.sw-countdown-done .sw-digit-ms,
.sw-countdown-done .sw-sep-ms {
    color: var(--success) !important;
}

.sw-finish-flag {
    display: none;
    position: absolute;
    bottom: 18%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--success);
    animation: sw-flag-in 0.4s ease-out both;
}

.sw-countdown-done .sw-finish-flag {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sw-finish-flag svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

@keyframes sw-pulse-ring {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes sw-ring-glow {
    0%, 100% { stroke-opacity: 0.3; }
    50% { stroke-opacity: 0.7; }
}

@keyframes sw-ring-stroke-pulse {
    0%, 100% { stroke-opacity: 1; }
    50% { stroke-opacity: 0.5; }
}

@keyframes sw-flash-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes sw-flag-in {
    from { opacity: 0; transform: translateX(-50%) translateY(6px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Page Background ───────────────────────────── */

.sw {
    background: var(--bg);
}

#home-container.base-layout-content-container {
    background: var(--bg);
}

/* ── Light Theme ──────────────────────────────── */

[data-theme="light"] .sw {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-glass: rgba(0, 0, 0, 0.03);
    --border: rgba(0, 0, 0, 0.08);
    --text: #1a1a2e;
    --text-dim: #4b5563;
    --accent: #0d9488;
    --accent-glow: rgba(13, 148, 136, 0.2);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.2);
    --blue: #3b82f6;
}

[data-theme="light"] #home-container.base-layout-content-container {
    background: #ffffff;
}

[data-theme="light"] .sw-ring-track {
    stroke: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .sw-ring-tick-60 {
    stroke: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .sw-div-table-row > .sw-div-table-cell {
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .sw-div-table-row > .sw-div-table-cell:first-child {
    color: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .sw-div-table-row:hover {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .sw-countdown-done .sw-ring-track {
    stroke: var(--success);
}

/* Änderungsprotokoll: 2026-08-19 | parent-agent | @skill-css-rules, @skill-change-provenance | Tastatur-Hinweis helles Theme kontrastreicher */
[data-theme="light"] .sw-kbd-hint {
    color: rgba(31, 41, 55, 0.95);
}

[data-theme="light"] .sw-preset-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text);
    border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .sw-btn-reset,
[data-theme="light"] .sw-btn-lap {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-dim);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .sw-btn-reset:hover:not(:disabled),
[data-theme="light"] .sw-btn-lap:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text);
}

[data-theme="light"] .sw-btn-start {
    background: linear-gradient(145deg, var(--accent) 0%, #0f766e 100%);
    color: #ffffff;
    border-color: rgba(13, 148, 136, 0.35);
    box-shadow: 0 4px 20px var(--accent-glow), 0 2px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .sw-btn-start svg {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

[data-theme="light"] .sw-btn-start:hover:not(:disabled) {
    background: linear-gradient(145deg, #14b8a6 0%, var(--accent) 100%);
    box-shadow: 0 6px 28px var(--accent-glow), 0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .sw-btn-start.sw-active {
    background: linear-gradient(145deg, var(--danger) 0%, #dc2626 100%);
    color: #ffffff;
    border-color: rgba(239, 68, 68, 0.35);
    box-shadow: 0 4px 20px var(--danger-glow), 0 2px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .sw-btn-start.sw-active svg {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

[data-theme="light"] .sw-btn-start.sw-active:hover {
    background: linear-gradient(145deg, #f87171 0%, var(--danger) 100%);
    box-shadow: 0 6px 28px var(--danger-glow), 0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .sw-mode-btn.sw-mode-active {
    color: #ffffff;
}

[data-theme="light"] .sw-preset-btn.sw-preset-active {
    color: #ffffff;
}

/* ── Responsive ────────────────────────────────── */

@media (min-width: 480px) {
    .sw-ring-wrap {
        width: 340px;
        height: 340px;
    }

    .sw-display {
        font-size: 4rem;
    }

    .sw-display-ms {
        font-size: 1.5rem;
    }
}

@media (min-width: 768px) {
    .sw-ring-wrap {
        width: 400px;
        height: 400px;
    }

    .sw-display {
        font-size: 4.5rem;
    }

    .sw-display-ms {
        font-size: 1.75rem;
    }

    .sw-btn-start {
        width: 80px;
        height: 80px;
    }

    .sw-btn-start svg {
        width: 32px;
        height: 32px;
    }

    .sw-btn-reset,
    .sw-btn-lap {
        width: 56px;
        height: 56px;
    }
}

.sw-tooltip-wrap {
    position: relative;
}

.sw-tooltip-wrap::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.35rem 0.6rem;
    background: rgba(15, 15, 15, 0.92);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    transform: translateX(-50%) translateY(4px);
    z-index: 100;
}

.sw-tooltip-wrap:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Aenderungsprotokoll: 2026-08-19 | parent-agent | @skill-css-rules, @skill-change-provenance | CSV-Export-Button */
.sw-btn-export {
    display: none;
    align-items: center;
    gap: 0.4rem;
    margin: 0.75rem auto 0;
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border, rgba(255,255,255,0.12));
    border-radius: 8px;
    background: transparent;
    color: var(--color-text-muted, #999);
    font-size: 0.8rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.sw-btn-export:hover {
    color: var(--accent, #6366f1);
    border-color: var(--accent, #6366f1);
}

.has-laps ~ .sw-btn-export,
.sw-div-table.has-laps ~ .sw-btn-export {
    display: inline-flex;
}
