@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #f2f4f0;
    --surface: #fbfcfa;
    --surface-strong: #ffffff;
    --ink: #172228;
    --muted: #708087;
    --line: #dce4e1;
    --navy: #101820;
    --teal: #18a889;
    --teal-dark: #087860;
    --coral: #ef725a;
    --shadow: 0 18px 48px rgba(20, 45, 42, 0.08);
    --mono: 'DM Mono', 'SFMono-Regular', Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    font-family: 'Manrope', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--ink);
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 272px;
    flex: 0 0 272px;
    min-height: 100vh;
    padding: 30px 20px 24px;
    display: flex;
    flex-direction: column;
    background: var(--navy);
    color: #e9f3ee;
    transition: width 0.25s ease, flex-basis 0.25s ease, padding 0.25s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 38px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
    font-size: 23px;
    font-weight: 800;
    letter-spacing: 3px;
}

.brand-dot,
.status-light {
    display: inline-block;
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 50%;
    background: var(--teal);
    box-shadow: 0 0 0 4px rgba(24, 168, 137, 0.13);
}

.sidebar-toggle {
    width: 31px;
    height: 31px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    color: #d8e9e2;
    font-size: 23px;
    line-height: 1;
    transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
}

.sidebar-caption {
    margin: 7px 0 34px 17px;
    color: #79918c;
    font-size: 11px;
    letter-spacing: 1px;
}

.sidebar-nav {
    display: grid;
    gap: 7px;
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 0 13px;
    border: 1px solid transparent;
    color: #94aaa5;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.sidebar-link:hover,
.sidebar-link.is-active {
    color: #f4fbf7;
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-link.is-active {
    box-shadow: inset 3px 0 var(--teal);
}

.nav-icon {
    width: 22px;
    color: #77a89a;
    font-size: 20px;
    text-align: center;
}

.nav-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.nav-copy strong {
    color: inherit;
    font-size: 13px;
    font-weight: 700;
}

.nav-copy small {
    color: #718b84;
    font-size: 10px;
    white-space: nowrap;
}

.sidebar-link:hover .nav-copy small,
.sidebar-link.is-active .nav-copy small {
    color: #a4beb5;
}

.nav-badge {
    margin-left: auto;
    padding: 4px 7px;
    color: #84d7be;
    border: 1px solid rgba(132, 215, 190, 0.25);
    font-size: 10px;
}

.sidebar-bottom {
    margin-top: auto;
    color: #78918a;
    font-size: 11px;
}

.mini-status {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 25px;
}

.contact-link {
    display: flex;
    justify-content: space-between;
    color: #d7e5df;
    text-decoration: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 19px;
}

.sidebar.is-collapsed {
    width: 82px;
    flex-basis: 82px;
    padding-inline: 12px;
    align-items: center;
}

.sidebar.is-collapsed .sidebar-header {
    width: 100%;
    justify-content: center;
}

.sidebar.is-collapsed .brand-name,
.sidebar.is-collapsed .sidebar-caption,
.sidebar.is-collapsed .nav-copy,
.sidebar.is-collapsed .nav-badge,
.sidebar.is-collapsed .sidebar-bottom {
    display: none;
}

.sidebar.is-collapsed .sidebar-toggle {
    position: absolute;
    left: 56px;
    top: 31px;
    z-index: 2;
}

.sidebar.is-collapsed .sidebar-nav {
    width: 100%;
    margin-top: 40px;
}

.sidebar.is-collapsed .sidebar-link {
    justify-content: center;
    padding: 0;
}

.sidebar.is-collapsed .sidebar-link.is-active {
    box-shadow: inset 0 -3px var(--teal);
}

.main-content {
    width: min(1180px, calc(100% - 272px));
    margin: 0 auto;
    padding: 52px clamp(28px, 5vw, 78px) 25px;
    transition: width 0.25s ease;
}

.sidebar.is-collapsed + .main-content {
    width: min(1180px, calc(100% - 82px));
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 39px;
}

.eyebrow,
.section-kicker {
    margin: 0 0 7px;
    color: var(--teal-dark);
    font: 500 10px var(--mono);
    letter-spacing: 1.7px;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(28px, 4vw, 40px);
    letter-spacing: -0.8px;
}

h2 {
    margin: 0;
    font-size: 20px;
    letter-spacing: -0.3px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.live-pill {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-size: 11px;
}

.live-pill strong {
    color: var(--ink);
    font: 500 12px var(--mono);
}

.icon-button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font-size: 20px;
    transition: 0.2s ease;
}

.icon-button:hover {
    color: var(--teal-dark);
    border-color: var(--teal);
    transform: translateY(-2px);
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 7px 20px rgba(20, 45, 42, 0.05);
    transition: 0.2s ease;
}

.back-button:hover {
    border-color: var(--teal);
    color: var(--teal-dark);
    transform: translateX(-3px);
}

.back-button strong {
    font-size: 18px;
    font-weight: 400;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.9fr);
    gap: 18px;
}

.panel-surface {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.timer-panel {
    min-height: 540px;
    padding: 29px 35px 23px;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.timer-state {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 11px;
}

.status-light.is-active {
    background: var(--coral);
    box-shadow: 0 0 0 4px rgba(239, 114, 90, 0.14);
    animation: pulse 1.8s ease-in-out infinite;
}

.timer-stage {
    min-height: 350px;
    display: grid;
    place-items: center;
}

.timer-ring {
    --progress: 0%;
    width: min(310px, 67vw);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--teal) var(--progress), #e5ece9 var(--progress));
    position: relative;
    transition: background 0.2s ease;
}

.timer-ring::before {
    content: '';
    position: absolute;
    inset: 9px;
    border-radius: 50%;
    background: var(--surface);
}

.timer-ring::after {
    content: '';
    position: absolute;
    inset: -13px;
    border: 1px solid transparent;
    border-top-color: rgba(24, 168, 137, 0.3);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s;
}

.timer-ring.is-running::after {
    opacity: 1;
    animation: spin 4s linear infinite;
}

.timer-core {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#stopwatchDisplay {
    color: var(--ink);
    font: 500 clamp(29px, 5vw, 44px) var(--mono);
    letter-spacing: -2px;
}

.timer-core small {
    color: var(--muted);
    font-size: 11px;
}

.timer-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.primary-button,
.secondary-button {
    min-height: 44px;
    border: 0;
    padding: 0 21px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    font-weight: 700;
    font-size: 12px;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.primary-button {
    min-width: 152px;
    background: var(--navy);
    color: #ffffff;
}

.primary-button:hover {
    background: #20313a;
    transform: translateY(-2px);
}

.secondary-button {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink);
}

.secondary-button:not(:disabled):hover {
    border-color: var(--teal);
    color: var(--teal-dark);
    transform: translateY(-2px);
}

.primary-button:disabled,
.secondary-button:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.keyboard-hint {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 10px;
    text-align: center;
}

kbd {
    display: inline-block;
    min-width: 22px;
    padding: 3px 5px;
    margin-right: 4px;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: var(--ink);
    font: 10px var(--mono);
    text-align: center;
}

.keyboard-hint span {
    padding: 0 8px;
    color: #b5c1bd;
}

.session-panel {
    min-height: 540px;
    padding: 29px 25px 24px;
    display: flex;
    flex-direction: column;
}

.compact-heading {
    align-items: center;
    padding-bottom: 21px;
    border-bottom: 1px solid var(--line);
}

.count-label {
    color: var(--muted);
    font: 11px var(--mono);
}

.lap-list {
    flex: 1;
    padding-top: 3px;
    overflow: auto;
}

.empty-state {
    height: 360px;
    display: grid;
    place-content: center;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.8;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin: 0 auto 14px;
    border: 1px dashed #b9cac4;
    color: var(--teal-dark);
    font-size: 19px;
}

.lap-row {
    display: grid;
    grid-template-columns: 26px 1fr auto;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    border-bottom: 1px solid #edf1ef;
}

.lap-number {
    color: var(--muted);
    font: 10px var(--mono);
}

.lap-bar {
    height: 5px;
    background: #e6eeea;
    overflow: hidden;
}

.lap-bar i {
    display: block;
    height: 100%;
    background: var(--teal);
}

.lap-row strong {
    color: var(--ink);
    font: 11px var(--mono);
}

.text-button {
    align-self: flex-start;
    padding: 17px 0 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
}

.text-button:not(:disabled):hover {
    color: var(--coral);
}

.text-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.insight-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin-top: 18px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.insight-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 82px;
    padding: 0 21px;
    border-right: 1px solid var(--line);
}

.insight-item:last-child {
    border-right: 0;
}

.insight-icon {
    color: var(--teal-dark);
    font-size: 19px;
}

.insight-item div {
    display: grid;
    gap: 6px;
}

.insight-item span:not(.insight-icon) {
    color: var(--muted);
    font-size: 10px;
}

.insight-item strong {
    font: 500 15px var(--mono);
}

.page-footer {
    display: flex;
    justify-content: space-between;
    padding-top: 21px;
    color: #8a9898;
    font-size: 10px;
}

.light-theme {
    --bg: #e9eeeb;
    --surface: #ffffff;
    --surface-strong: #ffffff;
    --ink: #172228;
    --line: #d3dfda;
}

@keyframes pulse {
    50% {
        opacity: 0.45;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 860px) {
    .sidebar {
        width: 82px;
        flex-basis: 82px;
        padding-inline: 12px;
        align-items: center;
    }

    .sidebar-header {
        width: 100%;
        justify-content: center;
    }

    .brand-name,
    .sidebar-caption,
    .nav-copy,
    .nav-badge,
    .sidebar-bottom {
        display: none;
    }

    .sidebar-toggle {
        position: absolute;
        left: 56px;
        top: 31px;
        z-index: 2;
    }

    .sidebar-nav {
        width: 100%;
        margin-top: 40px;
    }

    .sidebar-link {
        justify-content: center;
        padding: 0;
    }

    .sidebar-link.is-active {
        box-shadow: inset 0 -3px var(--teal);
    }

    .sidebar:not(.is-collapsed) {
        width: 272px;
        flex-basis: 272px;
        padding-inline: 20px;
        align-items: initial;
    }

    .sidebar:not(.is-collapsed) .sidebar-header {
        width: auto;
        justify-content: space-between;
    }

    .sidebar:not(.is-collapsed) .brand-name,
    .sidebar:not(.is-collapsed) .nav-copy,
    .sidebar:not(.is-collapsed) .nav-badge,
    .sidebar:not(.is-collapsed) .sidebar-bottom {
        display: initial;
    }

    .sidebar:not(.is-collapsed) .brand-name {
        display: inline;
    }

    .sidebar:not(.is-collapsed) .nav-copy {
        display: grid;
    }

    .sidebar:not(.is-collapsed) .sidebar-bottom {
        display: block;
    }

    .sidebar:not(.is-collapsed) .sidebar-toggle {
        position: static;
    }

    .sidebar:not(.is-collapsed) .sidebar-nav {
        width: auto;
        margin-top: 0;
    }

    .sidebar:not(.is-collapsed) .sidebar-link {
        justify-content: flex-start;
        padding: 0 13px;
    }

    .sidebar:not(.is-collapsed) .sidebar-link.is-active {
        box-shadow: inset 3px 0 var(--teal);
    }

    .main-content,
    .sidebar.is-collapsed + .main-content {
        width: calc(100% - 82px);
        padding-inline: 24px;
    }

    .sidebar:not(.is-collapsed) + .main-content {
        width: calc(100% - 272px);
    }
}

@media (max-width: 620px) {
    .main-content,
    .sidebar.is-collapsed + .main-content {
        padding: 30px 16px 20px;
    }

    .topbar {
        margin-bottom: 26px;
    }

    .topbar-actions {
        gap: 10px;
    }

    .live-pill {
        gap: 8px;
        font-size: 0;
    }

    .live-pill strong {
        font-size: 11px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .timer-panel,
    .session-panel {
        min-height: auto;
        padding: 23px 18px 20px;
    }

    .timer-stage {
        min-height: 280px;
    }

    .timer-ring {
        width: min(280px, 72vw);
    }

    .timer-controls {
        flex-wrap: wrap;
    }

    .primary-button {
        min-width: 140px;
    }

    .empty-state {
        height: 180px;
    }

    .insight-strip {
        grid-template-columns: 1fr;
    }

    .insight-item {
        min-height: 65px;
        padding: 0 15px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .insight-item:last-child {
        border-bottom: 0;
    }
}
