.ctm-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;
}

/* Seletor de horário do modal de tarefas. O popover é movido para o body
   ao abrir para não ser recortado pelo scroll interno do modal. */
.ctm-time-picker-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10029;
    border: 0;
    background: rgba(15, 23, 42, 0.34);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    -webkit-tap-highlight-color: transparent;
}

.ctm-time-picker-backdrop[hidden] {
    display: none;
}

.ctm-time-picker-backdrop.is-mobile-layout.is-open {
    opacity: 1;
    pointer-events: auto;
}

.ctm-time-picker-popover {
    --ctp-accent: #ff5757;
    --ctp-accent-strong: #d93636;
    --ctp-solid: #d93636;
    --ctp-solid-hover: #c93434;
    --ctp-border: rgba(148, 163, 184, 0.26);
    --ctp-muted: #64748b;
    --ctp-soft: #f8fafc;
    --ctp-surface: #ffffff;
    --ctp-hover-surface: #fff1f1;
    --ctp-text: #172033;
    --ctp-safe-top: env(safe-area-inset-top, 0px);
    --ctp-safe-right: env(safe-area-inset-right, 0px);
    --ctp-safe-bottom: env(safe-area-inset-bottom, 0px);
    --ctp-safe-left: env(safe-area-inset-left, 0px);
    --ctp-face-size: 240px;
    box-sizing: border-box;
    position: fixed;
    z-index: 10030;
    width: min(360px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--ctp-border);
    border-radius: 12px;
    background: var(--ctp-surface);
    color: var(--ctp-text);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22), 0 4px 16px rgba(15, 23, 42, 0.08);
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px) scale(0.985);
    transform-origin: top right;
    transition: opacity 180ms ease, transform 180ms ease;
    scrollbar-width: thin;
}

.ctm-time-picker-popover[hidden] {
    display: none;
}

.ctm-time-picker-popover.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.ctm-time-picker-popover button {
    appearance: none;
    -webkit-appearance: none;
}

.ctm-time-picker__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 54px;
    padding: 11px 14px 10px 16px;
    border-bottom: 1px solid var(--ctp-border);
}

.ctm-time-picker__header > div {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ctm-time-picker__eyebrow {
    color: var(--ctp-accent-strong);
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.ctm-time-picker__header strong {
    color: var(--ctp-text);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
}

.ctm-time-picker__close {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ctp-muted);
    cursor: pointer;
    transition: color 160ms ease, background 160ms ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.ctm-time-picker__close:hover,
.ctm-time-picker__close:focus-visible {
    outline: none;
    color: var(--ctp-text);
    background: var(--ctp-soft);
}

.ctm-time-picker__digital {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 15px 16px 10px;
    font-variant-numeric: tabular-nums;
}

.ctm-time-picker__segment {
    min-width: 82px;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 6px 14px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--ctp-soft);
    color: var(--ctp-text);
    cursor: pointer;
    font: inherit;
    transition: color 180ms ease, background 180ms ease, border-color 180ms ease, transform 180ms ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.ctm-time-picker__segment > span {
    font-size: 30px;
    font-weight: 750;
    line-height: 1;
    letter-spacing: -0.035em;
}

.ctm-time-picker__segment small {
    color: var(--ctp-muted);
    font-size: 9px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ctm-time-picker__segment:hover {
    border-color: rgba(255, 87, 87, 0.24);
    transform: translateY(-1px);
}

.ctm-time-picker__segment.is-active,
.ctm-time-picker__segment[aria-pressed="true"] {
    border-color: rgba(255, 87, 87, 0.30);
    background: rgba(255, 87, 87, 0.10);
    color: var(--ctp-accent-strong);
}

.ctm-time-picker__segment:focus-visible {
    outline: none;
    border-color: var(--ctp-accent);
    box-shadow: 0 0 0 3px rgba(255, 87, 87, 0.13);
}

.ctm-time-picker__colon {
    color: var(--ctp-muted);
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    transform: translateY(-7px);
}

.ctm-time-picker__phase-row {
    min-height: 31px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 18px 5px;
}

.ctm-time-picker__phase {
    color: var(--ctp-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.015em;
}

.ctm-time-picker__range {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--ctp-border);
    border-radius: 8px;
    background: var(--ctp-soft);
}

.ctm-time-picker__range[hidden] {
    display: none;
}

.ctm-time-picker__range button {
    min-width: 52px;
    min-height: 25px;
    padding: 3px 7px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ctp-muted);
    cursor: pointer;
    font: inherit;
    font-size: 10px;
    font-weight: 750;
    transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.ctm-time-picker__range button:hover,
.ctm-time-picker__range button:focus-visible {
    outline: none;
    color: var(--ctp-text);
}

.ctm-time-picker__range button[aria-pressed="true"] {
    color: var(--ctp-text);
    background: var(--ctp-surface);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.10);
}

.ctm-time-picker__face {
    position: relative;
    width: var(--ctp-face-size);
    height: var(--ctp-face-size);
    margin: 2px auto 12px;
    border-radius: 50%;
    background:
        radial-gradient(circle at center, rgba(255, 87, 87, 0.045) 0 4px, transparent 5px),
        linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    transition: opacity 120ms ease, transform 120ms ease;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    cursor: crosshair;
}

.ctm-time-picker__face.is-dragging {
    cursor: grabbing;
}

.ctm-time-picker__face.is-transitioning {
    opacity: 0.38;
    transform: scale(0.985);
}

.ctm-time-picker__dial,
.ctm-time-picker__numbers {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.ctm-time-picker__dial {
    z-index: 1;
}

.ctm-time-picker__numbers {
    z-index: 2;
}

.ctm-time-picker__dial-ring {
    fill: none;
    stroke: var(--ctp-border);
    stroke-width: 1;
}

.ctm-time-picker__hand,
.ctm-time-picker__hand-tip {
    transform-box: view-box;
    transform-origin: 120px 120px;
    transition: transform 210ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ctm-time-picker__hand {
    stroke: var(--ctp-accent);
    stroke-width: 2.5;
    stroke-linecap: round;
}

.ctm-time-picker__hand-tip,
.ctm-time-picker__center {
    fill: var(--ctp-accent);
}

.ctm-time-picker__number {
    position: absolute;
    z-index: 1;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--ctp-text);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    transform: translate(-50%, -50%);
    transition: color 170ms ease, background 170ms ease, border-color 170ms ease, transform 170ms ease;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.ctm-time-picker__number:hover {
    z-index: 3;
    border-color: rgba(255, 87, 87, 0.34);
    background: var(--ctp-hover-surface);
    color: var(--ctp-accent-strong);
    box-shadow: 0 5px 14px rgba(15, 23, 42, 0.12);
    transform: translate(-50%, -50%) scale(1.04);
}

.ctm-time-picker__number:focus-visible {
    z-index: 3;
    outline: none;
    border-color: var(--ctp-accent);
    background: var(--ctp-hover-surface);
    box-shadow: 0 0 0 3px rgba(255, 87, 87, 0.14);
}

.ctm-time-picker__number.is-selected,
.ctm-time-picker__number[aria-selected="true"] {
    border-color: var(--ctp-solid);
    background: var(--ctp-solid);
    color: #fff;
    box-shadow: 0 5px 14px rgba(255, 87, 87, 0.28);
}

.ctm-time-picker__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 11px 14px;
    border-top: 1px solid var(--ctp-border);
    background: rgba(248, 250, 252, 0.72);
}

.ctm-time-picker__cancel,
.ctm-time-picker__confirm {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 750;
    transition: color 160ms ease, background 160ms ease, border-color 160ms ease, transform 160ms ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.ctm-time-picker__cancel {
    border: 1px solid var(--ctp-border);
    background: var(--ctp-surface);
    color: var(--ctp-muted);
}

.ctm-time-picker__confirm {
    border: 1px solid var(--ctp-solid);
    background: var(--ctp-solid);
    color: #fff;
}

.ctm-time-picker__cancel:hover,
.ctm-time-picker__cancel:focus-visible {
    outline: none;
    border-color: rgba(255, 87, 87, 0.35);
    color: var(--ctp-accent-strong);
    background: rgba(255, 87, 87, 0.06);
}

.ctm-time-picker__confirm:hover,
.ctm-time-picker__confirm:focus-visible {
    outline: none;
    border-color: var(--ctp-solid-hover);
    background: var(--ctp-solid-hover);
    box-shadow: 0 0 0 3px rgba(255, 87, 87, 0.13);
    transform: translateY(-1px);
}

[data-theme="dark"] .ctm-time-picker-popover,
html[data-theme="dark"] .ctm-time-picker-popover {
    --ctp-border: rgba(148, 163, 184, 0.22);
    --ctp-muted: #94a3b8;
    --ctp-accent-strong: #ff9696;
    --ctp-soft: rgba(255, 255, 255, 0.055);
    --ctp-surface: #252525;
    --ctp-hover-surface: #3b2929;
    --ctp-text: #f1f5f9;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.44), 0 4px 18px rgba(0, 0, 0, 0.28);
}

[data-theme="dark"] .ctm-time-picker__face,
html[data-theme="dark"] .ctm-time-picker__face {
    background:
        radial-gradient(circle at center, rgba(255, 87, 87, 0.09) 0 4px, transparent 5px),
        linear-gradient(145deg, #292929 0%, #202020 100%);
}

[data-theme="dark"] .ctm-time-picker__footer,
html[data-theme="dark"] .ctm-time-picker__footer {
    background: rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] .ctm-time-picker__segment:not(.is-active):not([aria-pressed="true"]),
html[data-theme="dark"] .ctm-time-picker__segment:not(.is-active):not([aria-pressed="true"]),
[data-theme="dark"] .ctm-time-picker__range,
html[data-theme="dark"] .ctm-time-picker__range,
[data-theme="dark"] .ctm-time-picker__cancel,
html[data-theme="dark"] .ctm-time-picker__cancel {
    background: #303030;
}

/* Viewer web: mantém a hierarquia premium em uma composição mais compacta. */
@media (min-width: 769px) {
    .ctm-time-picker-popover {
        --ctp-face-size: 210px;
        width: min(320px, calc(100vw - 24px));
        border-radius: 10px;
    }

    .ctm-time-picker__header {
        min-height: 48px;
        padding: 8px 11px 8px 13px;
    }

    .ctm-time-picker__eyebrow {
        font-size: 9px;
    }

    .ctm-time-picker__header strong {
        font-size: 13px;
    }

    .ctm-time-picker__close {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
    }

    .ctm-time-picker__digital {
        gap: 7px;
        padding: 10px 12px 7px;
    }

    .ctm-time-picker__segment {
        min-width: 72px;
        min-height: 54px;
        padding: 5px 11px;
        border-radius: 9px;
    }

    .ctm-time-picker__segment > span {
        font-size: 26px;
    }

    .ctm-time-picker__colon {
        font-size: 23px;
        transform: translateY(-6px);
    }

    .ctm-time-picker__phase-row {
        min-height: 28px;
        padding: 0 14px 4px;
    }

    .ctm-time-picker__phase {
        font-size: 10px;
    }

    .ctm-time-picker__range button {
        min-width: 46px;
        min-height: 24px;
        padding: 2px 6px;
        font-size: 9px;
    }

    .ctm-time-picker__face {
        margin: 0 auto 9px;
    }

    .ctm-time-picker__number {
        width: 36px;
        height: 36px;
        font-size: 11px;
    }

    .ctm-time-picker__footer {
        padding: 8px 11px;
    }

    .ctm-time-picker__cancel,
    .ctm-time-picker__confirm {
        min-height: 34px;
        padding: 6px 12px;
        font-size: 11px;
    }
}

@media (max-width: 768px) {
    body.ctm-time-picker-is-open-mobile #createTaskModal .rotina-modal-body {
        overflow: hidden;
        touch-action: none;
    }

    .ctm-time-picker-popover {
        width: min(480px, calc(100vw - 16px));
        max-height: calc(var(--mobile-viewport-height, 100dvh) - 16px);
        border-radius: 18px;
        box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28), 0 6px 20px rgba(15, 23, 42, 0.12);
        transform: translateY(14px) scale(0.99);
        scrollbar-gutter: stable;
    }

    .ctm-time-picker-popover.is-open {
        transform: translateY(0) scale(1);
    }

    .ctm-time-picker__header {
        position: sticky;
        top: 0;
        z-index: 3;
        min-height: 58px;
        padding: 10px 12px 9px 18px;
        background: color-mix(in srgb, var(--ctp-surface) 94%, transparent);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .ctm-time-picker__header strong {
        font-size: 15px;
    }

    .ctm-time-picker__close {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
        border-radius: 12px;
    }

    .ctm-time-picker__digital {
        gap: 7px;
        padding: 12px 18px 9px;
    }

    .ctm-time-picker__segment {
        flex: 1 1 0;
        min-width: 0;
        max-width: 132px;
        min-height: 68px;
        padding: 7px 12px;
        border-radius: 12px;
    }

    .ctm-time-picker__segment > span {
        font-size: clamp(30px, 9vw, 36px);
    }

    .ctm-time-picker__colon {
        font-size: 28px;
        transform: translateY(-8px);
    }

    .ctm-time-picker__phase-row {
        min-height: 48px;
        padding: 0 18px 6px;
    }

    .ctm-time-picker__phase {
        font-size: 12px;
    }

    .ctm-time-picker__range {
        padding: 3px;
        border-radius: 10px;
    }

    .ctm-time-picker__range button {
        min-width: 66px;
        min-height: 38px;
        border-radius: 8px;
        font-size: 11px;
    }

    .ctm-time-picker__face {
        --ctp-face-size: var(--ctp-mobile-face-size, clamp(248px, calc(100vw - 72px), 280px));
        margin: 2px auto 16px;
    }

    .ctm-time-picker__number {
        width: 44px;
        height: 44px;
        font-size: 12px;
    }

    /* No touch, minutos em grade oferecem alvos maiores e evitam a precisão
       excessiva do anel analógico. Horas continuam no relógio radial. */
    .ctm-time-picker-popover[data-phase="minute"] .ctm-time-picker__face {
        width: auto;
        height: auto;
        margin: 2px 16px 16px;
        border-radius: 14px;
        background: transparent;
        cursor: default;
        touch-action: manipulation;
    }

    .ctm-time-picker-popover[data-phase="minute"] .ctm-time-picker__dial {
        display: none;
    }

    .ctm-time-picker-popover[data-phase="minute"] .ctm-time-picker__numbers {
        position: relative;
        inset: auto;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
        height: auto;
    }

    .ctm-time-picker-popover[data-phase="minute"] .ctm-time-picker__number {
        position: relative;
        top: auto !important;
        left: auto !important;
        width: 100%;
        min-width: 0;
        height: 48px;
        border-color: var(--ctp-border);
        border-radius: 11px;
        background: var(--ctp-soft);
        transform: none;
    }

    .ctm-time-picker-popover[data-phase="minute"] .ctm-time-picker__number:hover {
        transform: none;
    }

    .ctm-time-picker-popover[data-phase="minute"] .ctm-time-picker__number.is-selected,
    .ctm-time-picker-popover[data-phase="minute"] .ctm-time-picker__number[aria-selected="true"] {
        border-color: var(--ctp-solid);
        background: var(--ctp-solid);
    }

    [data-theme="dark"] .ctm-time-picker-popover[data-phase="minute"] .ctm-time-picker__number:not(.is-selected):not([aria-selected="true"]),
    html[data-theme="dark"] .ctm-time-picker-popover[data-phase="minute"] .ctm-time-picker__number:not(.is-selected):not([aria-selected="true"]) {
        background: #303030;
    }

    .ctm-time-picker__footer {
        position: sticky;
        bottom: 0;
        z-index: 3;
        gap: 10px;
        padding: 12px 14px max(12px, env(safe-area-inset-bottom, 0px));
        background: color-mix(in srgb, var(--ctp-surface) 94%, transparent);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .ctm-time-picker__cancel,
    .ctm-time-picker__confirm {
        min-height: 48px;
        border-radius: 11px;
        font-size: 13px;
    }

    .ctm-time-picker__cancel {
        flex: 1 1 38%;
    }

    .ctm-time-picker__confirm {
        flex: 1 1 62%;
    }

    #createTaskModal .ctm-time-simple__input-wrap {
        min-height: 52px;
        padding-left: 8px;
    }

    #createTaskModal .ctm-time-simple__input-icon {
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
        border-radius: 10px;
    }
}

@media (max-width: 360px) {
    .ctm-time-picker-popover {
        width: calc(100vw - 12px);
        border-radius: 16px;
    }

    .ctm-time-picker__header {
        min-height: 54px;
        padding-left: 15px;
    }

    .ctm-time-picker__digital {
        padding-right: 14px;
        padding-left: 14px;
    }

    .ctm-time-picker__segment {
        min-height: 62px;
    }

    .ctm-time-picker__phase-row {
        padding-right: 14px;
        padding-left: 14px;
    }

    .ctm-time-picker__range button {
        min-width: 59px;
    }

    .ctm-time-picker__face {
        --ctp-face-size: var(--ctp-mobile-face-size, clamp(236px, calc(100vw - 64px), 272px));
    }

    .ctm-time-picker-popover[data-phase="minute"] .ctm-time-picker__face {
        margin-right: 12px;
        margin-left: 12px;
    }

    .ctm-time-picker-popover[data-phase="minute"] .ctm-time-picker__numbers {
        gap: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ctm-time-picker-backdrop,
    .ctm-time-picker-popover,
    .ctm-time-picker__face,
    .ctm-time-picker__hand,
    .ctm-time-picker__hand-tip,
    .ctm-time-picker__number,
    .ctm-time-picker__segment {
        transition-duration: 0.01ms !important;
    }
}
