/* ── Timer Modal ─────────────────────────────────────────────────────────────── */

.tm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 900;
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s;
}
.tm-backdrop.tm-visible {
    opacity: 1;
    visibility: visible;
}

.tm-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -48%) scale(.97);
    width: 480px;
    max-width: calc(100vw - 24px);
    max-height: 90vh;
    overflow-y: auto;
    z-index: 901;
    background: var(--card-bg);
    border: 3px solid var(--border-color);
    box-shadow: 0 24px 64px rgba(0, 0, 0, .4);
    opacity: 0;
    visibility: hidden;
    transition: transform .15s ease, opacity .15s;
}
.tm-window.tm-visible {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
}

/* Header */
.tm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: var(--border-w) solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 1;
}
.tm-header-title {
    font-family: var(--font-mono);
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-muted, var(--text-secondary));
}
.tm-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted, var(--text-secondary));
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .12s;
}
.tm-close-btn:hover { color: var(--text-primary, var(--text-color)); }
.tm-close-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* Body */
.tm-body {
    padding: 20px 24px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* Ring */
.tm-ring-wrap {
    position: relative;
    width: 220px;
    height: 220px;
}
.tm-ring-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.tm-ring-bg {
    fill: none;
    stroke: var(--ring-bg);
    stroke-width: 8;
}
.tm-ring-circle {
    fill: none;
    stroke: var(--theme-color);
    stroke-width: 8;
    stroke-linecap: square;
    transition: stroke-dashoffset .1s linear;
}
.tm-time-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40px;
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: -1px;
    color: var(--text-heading);
    white-space: nowrap;
}
.tm-ring-wrap.tm-finished .tm-ring-circle {
    stroke: var(--text-heading);
}
.tm-ring-wrap.tm-finished .tm-time-display {
    animation: tm-pulse 1s ease-in-out infinite;
}
@keyframes tm-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .4; }
}

/* Controls */
.tm-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}
.tm-btn {
    width: 48px;
    height: 48px;
    border: var(--border-w) solid var(--border-color);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .12s, border-color .12s, color .12s;
    color: var(--text-primary, var(--text-color));
}
.tm-btn svg { width: 22px; height: 22px; fill: currentColor; }
.tm-btn:hover { background: var(--theme-color); border-color: var(--theme-color); color: #fff; }
.tm-btn-play { width: 56px; height: 56px; }
.tm-btn-play svg { width: 26px; height: 26px; }

/* Presets */
.tm-presets {
    display: flex;
    gap: 6px;
}
.tm-preset {
    font-family: var(--font-mono);
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 5px 14px;
    border: var(--border-w) solid var(--border-color);
    background: transparent;
    cursor: pointer;
    color: var(--text-muted, var(--text-secondary));
    transition: background .12s, color .12s, border-color .12s;
}
.tm-preset:hover { border-color: var(--theme-color); color: var(--theme-color); }
.tm-preset.active { background: var(--theme-color); border-color: var(--theme-color); color: #fff; }
.tm-presets.disabled .tm-preset { opacity: .4; pointer-events: none; }

/* Input section */
.tm-input-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.tm-input-section.disabled { opacity: .45; pointer-events: none; }
.tm-input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}
.tm-label {
    font-family: var(--font-mono);
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted, var(--text-secondary));
}
.tm-input-section input[type="text"] {
    font-family: var(--font-mono);
    font-size: .9rem;
    background: var(--input-bg, var(--card-bg));
    color: var(--text-primary, var(--text-color));
    border: var(--border-w) solid var(--border-color);
    padding: 7px 10px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color .12s;
}
.tm-input-section input[type="text"]:focus {
    outline: none;
    border-color: var(--theme-color);
}

/* Log Time button */
.tm-log-open-btn {
    font-family: var(--font-mono);
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    border: var(--border-w) solid var(--border-color);
    background: transparent;
    color: var(--text-muted, var(--text-secondary));
    padding: 6px 16px;
    cursor: pointer;
    transition: border-color .12s, color .12s;
    align-self: center;
}
.tm-log-open-btn:hover { border-color: var(--theme-color); color: var(--theme-color); }

/* Log Time section */
.tm-log-section {
    width: 100%;
    border: var(--border-w) solid var(--border-color);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.tm-log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}
.tm-log-header span {
    font-family: var(--font-mono);
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted, var(--text-secondary));
}
.tm-log-cancel-btn {
    background: none;
    border: none;
    font-family: var(--font-mono);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted, var(--text-secondary));
    cursor: pointer;
    padding: 2px 6px;
}
.tm-log-cancel-btn:hover { color: var(--text-primary, var(--text-color)); }
.tm-log-section .tm-input-group input {
    font-family: var(--font-mono);
    font-size: .9rem;
    background: var(--input-bg, var(--card-bg));
    color: var(--text-primary, var(--text-color));
    border: var(--border-w) solid var(--border-color);
    padding: 7px 10px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color .12s;
}
.tm-log-section .tm-input-group input:focus {
    outline: none;
    border-color: var(--theme-color);
}
.tm-log-submit-btn {
    font-family: var(--font-mono);
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    border: var(--border-w) solid var(--border-color);
    background: var(--theme-color);
    border-color: var(--theme-color);
    color: #fff;
    padding: 8px 20px;
    cursor: pointer;
    align-self: flex-start;
    transition: opacity .12s;
}
.tm-log-submit-btn:hover { opacity: .88; }

/* Mobile: bottom sheet */
@media (max-width: 600px) {
    .tm-window {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: translateY(40px) scale(1);
        max-width: 100%;
        max-height: 92vh;
        border-bottom: none;
    }
    .tm-window.tm-visible {
        transform: translateY(0) scale(1);
    }
    .tm-time-display { font-size: 36px; }
    .tm-ring-wrap { width: 200px; height: 200px; }
}
