/* 타이머 공용 UI — 1차 필기시험 타이머와 이후 타이머가 함께 쓴다.
   루트 요소에 class="tm"을 달고 칩·버튼·상태줄·디지털 숫자·원판·알림 배너·전체화면 규칙을 그대로 쓴다.
   도구 전용 규칙(1차 벽시계·시간표 등)은 각 도구 CSS에 둔다 */

/* 칩·버튼·필드에 display를 주므로 브라우저 기본 [hidden] 규칙이 밀린다 — 되돌려 둔다 */
.tm [hidden] {
    display: none !important;
}

.tm {
    --tm-break: #2E7D32; /* 흰 글자 대비 4.5:1 이상 */
    max-width: 880px;
    margin: 0 auto;
}

/* ── 설정 ── */
.tm-settings {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin-bottom: 12px;
}

.tm-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.tm-label {
    font-size: 13px;
    color: var(--text-muted-color);
}

.tm-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tm-chip {
    min-height: 36px;
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: var(--surface-color);
    color: var(--text-secondary-color);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.tm-chip:hover:not(:disabled) {
    border-color: var(--primary-light);
    background: var(--tint-orange-bg);
    color: var(--primary-dark);
}

.tm-chip.is-active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
    font-weight: 600;
}

/* 진행 중엔 잠긴 설정(모드·범위·연장 등) */
.tm-chip:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.tm-chip.is-active:disabled {
    opacity: 0.8;
}

.tm-note {
    margin: 8px 0;
    font-size: 13px;
    color: var(--text-muted-color);
}

.tm-sound {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--tint-amber-bg);
    color: var(--text-color);
    font-size: 14px;
}

/* 키보드 포커스 표시 */
.tm .tm-chip:focus-visible,
.tm .tm-btn:focus-visible,
.tm .tm-digital:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 알림 배너 — 전체화면에서도 보이도록 .tm 루트 안에 둔다 */
.tm-alert {
    margin: 12px 0;
    padding: 12px 16px;
    border-radius: 10px;
    background: var(--primary-color);
    color: #fff;
    font-size: 17px;
    font-weight: 600;
    text-align: center;
}

/* ── 상태 ── */
.tm-status {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    gap: 6px 12px;
    margin: 20px 0 12px;
    text-align: center;
}

.tm-phase {
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--surface-alt-color);
    color: var(--text-secondary-color);
    font-size: 13px;
    font-weight: 600;
}

.tm-phase[data-phase="exam"] { background: var(--primary-color); color: #fff; }
.tm-phase[data-phase="break"] { background: var(--tm-break); color: #fff; }
.tm-phase[data-phase="paused"] { background: var(--tint-amber-bg); color: var(--text-color); }

.tm-title {
    font-size: 20px;
}

.tm-range {
    font-size: 14px;
    color: var(--text-secondary-color);
    font-variant-numeric: tabular-nums;
}

/* ── 아날로그 ── */
.tm-clocks {
    display: flex;
    justify-content: center;
    gap: 32px;
}

.tm-clock {
    width: min(320px, 42vw);
    height: auto;
}

@media (max-width: 600px) {
    .tm-clocks {
        flex-direction: column;
        align-items: center;
        gap: 16px;
    }

    .tm-clock {
        width: min(280px, 80vw);
    }
}

.tm-face { fill: var(--surface-color); stroke: var(--border-color); stroke-width: 2; }
.tm-tick { stroke: var(--text-muted-color); stroke-width: 1; }
.tm-tick-major { stroke: var(--text-color); stroke-width: 2.5; }
.tm-pin { fill: var(--text-color); }
.tm-disc { fill: var(--primary-color); }
.tm-disc.is-break { fill: var(--tm-break); }
.tm-disc.is-waiting { fill: var(--text-muted-color); opacity: 0.35; }
/* 원판 위 어느 색에서도 읽히도록 바탕색 테두리를 깐다 */
.tm-disc-label { fill: var(--text-color); font-size: 12px; text-anchor: middle; paint-order: stroke; stroke: var(--surface-color); stroke-width: 3; }

.tm-caption {
    margin: 12px 0 0;
    text-align: center;
    font-size: 18px;
    font-variant-numeric: tabular-nums;
}

/* ── 디지털 ── */
.tm-digital {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 32px 16px;
    border: 0;
    background: none;
    color: var(--text-color);
    font: inherit;
    cursor: pointer;
}

.tm-digital-label { font-size: 15px; color: var(--text-secondary-color); }
.tm-digital-time { font-size: clamp(56px, 16vw, 128px); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.tm-digital-sub { font-size: 14px; color: var(--text-muted-color); font-variant-numeric: tabular-nums; }

/* ── 조작 ── */
.tm-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 24px 0 8px;
}

.tm-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--surface-color);
    color: var(--text-color);
    font: inherit;
    font-size: 15px;
    cursor: pointer;
}

.tm-btn-primary {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: #fff;
    font-weight: 600;
}

@media (max-width: 767px) {
    .tm-chip { min-height: 44px; }
}

/* ── 전체화면: 시계와 조작만 남긴다 ── */
.tm:fullscreen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: none;
    padding: 24px;
    overflow-y: auto;
    background: var(--bg-color);
}

.tm:fullscreen .tm-settings,
.tm:fullscreen .tm-note {
    display: none;
}

.tm:fullscreen .tm-clock {
    width: min(42vw, 70vh);
}
