/* ============================================================================
   짬 타이머 — 전용 스타일
   ----------------------------------------------------------------------------
   디자인 언어는 /qr/ 를 그대로 따른다(near-black void + 오로라 + 그리드 +
   바이올렛→시안 네온). 이 페이지는 lib/theme.php 의 제외 목록에 있으므로
   공용 다크 레이어가 덧씌워지지 않는다 — 여기 있는 것이 전부다.

   크기 체계: 다이얼 지름 --d 하나에서 글자·여백이 전부 파생된다.
   컨테이너 쿼리를 쓰지 않는 이유는 비용 때문이다(큰 글자에 컨테이너 쿼리를 걸면
   리플로가 눈에 띄게 비싸진다) — calc() 는 공짜다.
   ========================================================================= */

:root {
    --void: #0a0a12;
    --void-2: #12101f;
    --panel: #161425;
    --panel-2: #1c1930;
    --line: rgba(255, 255, 255, .08);
    --line-2: rgba(255, 255, 255, .16);
    --ink: #ece9ff;
    --ink-soft: #b9b3d8;
    --muted: #9995b5;
    --violet: #7c5cff;
    --violet-soft: #a894ff;
    --cyan: #22d3ee;
    --amber: #fbbf24;
    --red: #ff4d6d;
    --font: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 20px;
    --r-pill: 999px;
    --ease: cubic-bezier(.2, .8, .2, 1);

    /* 남은 시간대(zone)에 따라 JS 가 바꾸는 단 하나의 색. 모든 네온이 여기서 나온다. */
    --hot: #22d3ee;
    --hot-dim: rgba(34, 211, 238, .22);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

html {
    background: var(--void);
}

body {
    background: var(--void);
    color: var(--ink);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    min-height: 100dvh;
    overflow-x: hidden;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--panel);
    color: var(--ink);
    padding: 10px 16px;
    border-radius: var(--r-sm);
    z-index: 999;
}

.skip-link:focus {
    left: 12px;
    top: 12px;
}

/* ── 무대 ───────────────────────────────────────────────────────────────
   전체화면의 대상이자 유사 전체화면(iOS 폴백)의 대상. 두 경우 모두
   .tm-stage 하나에만 규칙을 걸면 되도록 구조를 여기로 모았다. */
.tm-stage {
    position: relative;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    /* 평소엔 투명 — 배경은 body 가 문서 끝까지 한 장으로 그린다(2026-11-19 배경 끊김 수정).
       전체화면에서만 무대가 배경을 든다(아래 「전체화면」 + index.php 의 공용 배경). */
    background: transparent;
    isolation: isolate;
}

/* ── 배경 ───────────────────────────────────────────────────────────────
   오로라·격자는 다른 도구(회식비 정산 등)와 같은 공용 배경을 쓴다 — index.php 가
   lib/theme_css.php jjam_theme_backdrop_style('html:root body', [전체화면 무대]) 로 낸다
   (2026-11-18 무대에 → 11-19 body 로: 무대가 끝나는 줄 아래에서 배경이 끊겼다).
   예전의 전용 오로라(blur 120px 원 3개 + 56px 격자)는 그때 걷어냈다.
   남은 시간 경고(가장자리 붉은 빛·종료 플래시)는 배경이 아니라 알림이라 그대로 둔다. */

/* 마지막 10초 — 화면 가장자리가 붉게 조여든다. */
.tm-vignette {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(ellipse 100% 100% at 50% 50%, transparent 52%, var(--hot) 160%);
    mix-blend-mode: screen;
    transition: opacity .35s var(--ease);
}

.tm-stage[data-zone="danger"] .tm-vignette {
    opacity: .3;
    animation: tmBreathe 1s ease-in-out infinite;
}

@keyframes tmBreathe {

    0%,
    100% {
        opacity: .16;
    }

    50% {
        opacity: .42;
    }
}

/* 종료 플래시 */
.tm-flash {
    position: absolute;
    inset: 0;
    z-index: 40;
    pointer-events: none;
    background: var(--hot);
    opacity: 0;
}

.tm-flash.on {
    animation: tmFlash .66s ease-out 3;
}

@keyframes tmFlash {
    0% {
        opacity: 0;
    }

    12% {
        opacity: .5;
    }

    100% {
        opacity: 0;
    }
}

/* ── 레이아웃 ───────────────────────────────────────────────────────────── */
.tm-shell {
    position: relative;
    z-index: 2;
    flex: 1;
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    padding: 18px 16px 40px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.tm-head {
    text-align: center;
}

.tm-head h1 {
    margin: 0 0 6px;
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -.02em;
}

.tm-head h1 .grad {
    background: linear-gradient(135deg, var(--violet-soft), var(--cyan));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tm-head p {
    margin: 0;
    font-size: .86rem;
    color: var(--muted);
}

/* ── 모드 탭 ────────────────────────────────────────────────────────────── */
.tm-modes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: rgba(255, 255, 255, .035);
    border-radius: var(--r-pill);
    padding: 5px;
    max-width: 440px;
    width: 100%;
    margin: 0 auto;
}

.tm-mode {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--muted);
    font-family: inherit;
    font-size: .88rem;
    font-weight: 700;
    padding: 10px 6px;
    border-radius: var(--r-pill);
    cursor: pointer;
    transition: color .18s var(--ease), background .18s var(--ease);
    white-space: nowrap;
}

.tm-mode:hover {
    color: var(--ink-soft);
}

.tm-mode[aria-selected="true"] {
    color: var(--void);
    background: linear-gradient(135deg, var(--violet-soft), var(--cyan));
    box-shadow: 0 6px 18px rgba(124, 92, 255, .32);
}

/* ── 다이얼 ─────────────────────────────────────────────────────────────── */
.tm-dialwrap {
    display: flex;
    justify-content: center;
    align-items: center;
}

.tm-dial {
    /* 하한을 84vw 보다 크게 잡으면 좁은 화면에서 다이얼이 화면 밖으로 나간다. */
    --d: clamp(200px, min(58vh, 84vw), 520px);
    position: relative;
    width: var(--d);
    height: var(--d);
    flex: none;
}

.tm-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* 눈금 60개 — 멀리서 "대략 얼마나 남았나"를 숫자를 안 읽고도 보게 하는 층. */
.tm-tick {
    stroke: rgba(255, 255, 255, .10);
    stroke-width: 2.6;
    stroke-linecap: round;
    transition: stroke .3s var(--ease);
}

.tm-tick.lit {
    stroke: var(--hot);
}

/* 안쪽의 매끄러운 호 — 초 단위의 정밀한 층. */
.tm-arc-bg {
    fill: none;
    stroke: rgba(255, 255, 255, .07);
    stroke-width: 3;
}

.tm-arc {
    fill: none;
    stroke: var(--hot);
    stroke-width: 3.4;
    stroke-linecap: round;
    filter: drop-shadow(0 0 7px var(--hot));
}

/* 코어 — 숫자가 앉는 원판 */
.tm-core {
    position: absolute;
    inset: 11%;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 34%, rgba(255, 255, 255, .05), transparent 62%),
        linear-gradient(180deg, var(--panel), var(--void-2));
    box-shadow:
        inset 0 0 0 1px var(--line),
        inset 0 1px 0 rgba(255, 255, 255, .07),
        0 24px 60px rgba(0, 0, 0, .55);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: calc(var(--d) * .012);
    text-align: center;
    overflow: hidden;
}

.tm-core::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, var(--hot-dim), transparent 68%);
    opacity: .55;
    transition: opacity .4s var(--ease);
    pointer-events: none;
}

.tm-phase {
    font-size: calc(var(--d) * .055);
    font-weight: 700;
    letter-spacing: .14em;
    color: var(--hot);
    text-transform: none;
}

.tm-time {
    font-size: calc(var(--d) * .215);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
    color: var(--ink);
    text-shadow: 0 0 28px var(--hot-dim);
}

.tm-time.over {
    color: var(--red);
}

/* 1시간을 넘기면 글자가 'H:MM:SS' 일곱 자가 된다. 그대로 두면 코어 원판보다
   4% 넓어져(실측: 148px vs 142px) 원 바깥으로 잘려 나간다. 지름에서 파생되는
   값이라 화면 크기와 무관하게 늘 넘친다 — 글자만 줄인다. */
.tm-time.wide {
    font-size: calc(var(--d) * .15);
}

.tm-sub {
    font-size: calc(var(--d) * .044);
    color: var(--muted);
    font-weight: 600;
}

/* 코어 안의 글자는 카운트 팝업보다 위에 있어야 한다. */
.tm-phase,
.tm-time,
.tm-sub {
    position: relative;
    z-index: 2;
}

/* 마지막 5초 — 원판 뒤에서 큰 숫자가 터져 나온다(코어의 overflow:hidden 에 잘린다). */
.tm-pop {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--d) * .58);
    font-weight: 800;
    color: var(--hot);
    pointer-events: none;
    opacity: 0;
}

.tm-pop.go {
    animation: tmPop .9s var(--ease) 1;
}

@keyframes tmPop {
    0% {
        opacity: 0;
        transform: scale(.45);
    }

    18% {
        opacity: .5;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(1.6);
    }
}

/* 달리는 중에는 코어가 숨을 쉰다. */
.tm-stage[data-run="running"] .tm-core::after {
    animation: tmGlow 2.6s ease-in-out infinite;
}

.tm-stage[data-run="running"][data-zone="danger"] .tm-core::after {
    animation-duration: .95s;
}

@keyframes tmGlow {

    0%,
    100% {
        opacity: .34;
    }

    50% {
        opacity: .78;
    }
}

/* ── 조작 ───────────────────────────────────────────────────────────────── */
.tm-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.tm-btn {
    appearance: none;
    font-family: inherit;
    font-weight: 700;
    border: 0;
    cursor: pointer;
    border-radius: var(--r-pill);
    padding: 13px 22px;
    font-size: .95rem;
    color: var(--ink);
    background: rgba(255, 255, 255, .06);
    box-shadow: inset 0 0 0 1px var(--line-2);
    transition: background .18s var(--ease), transform .18s var(--ease), box-shadow .18s var(--ease);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.tm-btn:hover {
    background: rgba(255, 255, 255, .11);
}

.tm-btn:active {
    transform: translateY(1px);
}

.tm-btn:disabled {
    opacity: .38;
    cursor: not-allowed;
}

/* display:inline-flex 가 UA 의 [hidden]{display:none} 를 이긴다 —
   hidden 속성을 걸어도 버튼이 그대로 보인다. 여기서 되돌린다. */
.tm-btn[hidden] {
    display: none;
}

.tm-btn.primary {
    color: var(--void);
    background: linear-gradient(135deg, var(--violet-soft), var(--cyan));
    box-shadow: 0 10px 26px rgba(124, 92, 255, .34);
    padding: 14px 34px;
    font-size: 1.02rem;
}

.tm-btn.primary:hover {
    filter: brightness(1.07);
}

.tm-btn.icon {
    padding: 13px 15px;
}

/* ── 설정 패널 ──────────────────────────────────────────────────────────── */
.tm-panel {
    background: linear-gradient(180deg, var(--panel), var(--void-2));
    border-radius: var(--r-lg);
    box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 rgba(255, 255, 255, .06);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.tm-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.tm-panel h2 {
    margin: 0;
    font-size: .95rem;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 제목 앞 네온 막대 — 패널이 한 덩어리로 뭉개지지 않게 가른다. */
.tm-panel h2::before {
    content: "";
    width: 3px;
    height: 15px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--violet-soft), var(--cyan));
}

/* 설정을 만지는 동안 '전체 몇 분인지'가 늘 보이는 자리. */
.tm-total {
    font-size: .88rem;
    font-weight: 800;
    color: var(--cyan);
    background: rgba(34, 211, 238, .1);
    box-shadow: inset 0 0 0 1px rgba(34, 211, 238, .32);
    border-radius: var(--r-pill);
    padding: 5px 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* '빠른 선택'과 '직접 맞추기'를 각자 판 위에 올려 두 덩어리로 읽히게 한다. */
.tm-block {
    background: rgba(255, 255, 255, .028);
    border-radius: var(--r-md);
    box-shadow: inset 0 0 0 1px var(--line);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tm-sublabel {
    margin: 0;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .08em;
    color: var(--muted);
}

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

.tm-chip {
    appearance: none;
    font-family: inherit;
    border: 0;
    cursor: pointer;
    border-radius: var(--r-pill);
    padding: 11px 17px;
    font-size: .92rem;
    font-weight: 700;
    color: var(--ink-soft);
    background: rgba(255, 255, 255, .07);
    box-shadow: inset 0 0 0 1px var(--line-2);
    transition: background .16s var(--ease), color .16s var(--ease), box-shadow .16s var(--ease);
}

.tm-chip:hover {
    background: rgba(255, 255, 255, .13);
    color: var(--ink);
}

/* 고른 칩은 테두리가 아니라 '채움'이다 — 한눈에 보여야 한다.
   달리는 중 색(--hot)은 일부러 따르지 않는다: 설정 칩이 빨개질 이유가 없다. */
.tm-chip[aria-pressed="true"] {
    color: var(--void);
    background: linear-gradient(135deg, var(--violet-soft), var(--cyan));
    box-shadow: 0 6px 16px rgba(124, 92, 255, .3);
}

.tm-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tm-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 112px;
    flex: 1 1 112px;
}

.tm-field label {
    font-size: .78rem;
    color: var(--ink-soft);
    font-weight: 700;
}

.tm-step {
    display: flex;
    align-items: stretch;
    /* 손가락으로 누르는 높이 — 좁은 화면에서 글자를 줄여도 이 아래로 내려가지 않는다 */
    min-height: 44px;
    background: rgba(255, 255, 255, .07);
    border-radius: var(--r-md);
    box-shadow: inset 0 0 0 1px var(--line-2);
    overflow: hidden;
    transition: box-shadow .16s var(--ease);
}

.tm-step:focus-within {
    box-shadow: inset 0 0 0 1.5px var(--cyan);
}

.tm-step button {
    appearance: none;
    border: 0;
    background: rgba(255, 255, 255, .04);
    color: var(--ink-soft);
    font-family: inherit;
    font-size: 1.15rem;
    font-weight: 700;
    width: 40px;
    flex: none;
    cursor: pointer;
    transition: background .16s var(--ease), color .16s var(--ease);
}

.tm-step button:hover {
    background: rgba(255, 255, 255, .14);
    color: var(--ink);
}

.tm-step button:active {
    background: rgba(255, 255, 255, .22);
}

/* 숫자+단위 묶음. 칸이 넓어져도 이 쌍은 늘 가운데에 있다. */
.tm-val {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.tm-step input {
    width: 100%;
    flex: 0 1 auto;
    min-width: 0;
    appearance: none;
    -moz-appearance: textfield;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-family: inherit;
    font-size: 1.15rem;
    /* 16px 미만이면 iOS 가 입력 시 화면을 확대한다 — 1.15rem = 18.4px */
    font-weight: 800;
    text-align: center;
    padding: 11px 0;
    font-variant-numeric: tabular-nums;
}

/* 단위가 붙는 칸은 숫자 폭을 고정해 '60 초' 한 쌍이 가운데 오게 한다. */
.tm-step.has-unit input {
    text-align: right;
    width: auto;
    flex: 0 1 2.6em;
}

.tm-unit {
    display: flex;
    align-items: center;
    font-size: .84rem;
    font-weight: 700;
    color: var(--muted);
    flex: none;
}

.tm-step input::-webkit-outer-spin-button,
.tm-step input::-webkit-inner-spin-button {
    appearance: none;
    margin: 0;
}

/* ── 토글 ───────────────────────────────────────────────────────────────── */
.tm-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
}

.tm-toggle {
    appearance: none;
    font-family: inherit;
    border: 0;
    cursor: pointer;
    border-radius: var(--r-pill);
    padding: 9px 14px;
    font-size: .84rem;
    font-weight: 700;
    color: var(--muted);
    background: rgba(255, 255, 255, .05);
    box-shadow: inset 0 0 0 1px var(--line);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color .16s var(--ease), background .16s var(--ease), box-shadow .16s var(--ease);
}

.tm-toggle[aria-pressed="true"] {
    color: var(--cyan);
    background: rgba(34, 211, 238, .14);
    box-shadow: inset 0 0 0 1.5px rgba(34, 211, 238, .55);
}

.tm-toggle:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.tm-note {
    font-size: .76rem;
    color: var(--muted);
    margin: 0;
}

/* 달리는 중 설정 변경 안내. hidden 속성이 먹어야 하므로 display 를 따로 주지 않는다. */
.tm-pending {
    margin: 0;
    font-size: .78rem;
    font-weight: 600;
    color: var(--amber);
    background: rgba(251, 191, 36, .1);
    box-shadow: inset 0 0 0 1px rgba(251, 191, 36, .3);
    border-radius: var(--r-sm);
    padding: 8px 10px;
}

.tm-select {
    appearance: none;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink-soft);
    background: rgba(255, 255, 255, .05);
    box-shadow: inset 0 0 0 1px var(--line);
    border: 0;
    border-radius: var(--r-pill);
    padding: 9px 32px 9px 14px;
    cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.tm-select option {
    background: var(--panel);
    color: var(--ink);
}

/* ── 키보드 안내 ────────────────────────────────────────────────────────── */
.tm-keys {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    justify-content: center;
    font-size: .76rem;
    color: var(--muted);
}

.tm-keys kbd {
    font-family: inherit;
    font-size: .72rem;
    font-weight: 700;
    color: var(--ink-soft);
    background: rgba(255, 255, 255, .06);
    box-shadow: inset 0 0 0 1px var(--line);
    border-radius: 6px;
    padding: 2px 6px;
    margin-right: 3px;
}

/* ── 포커스 ─────────────────────────────────────────────────────────────── */
.tm-stage :focus-visible {
    outline: 3px solid var(--cyan);
    outline-offset: 2px;
}

/* ── 전체화면 ───────────────────────────────────────────────────────────── */
/* 진짜 전체화면(:fullscreen)과 iOS 폴백(.faux-full)이 같은 규칙을 쓴다. */
.tm-stage:fullscreen,
.tm-stage.faux-full {
    padding: 0;
    background-color: var(--void);
}

.tm-stage.faux-full {
    position: fixed;
    inset: 0;
    z-index: 9999;
    overflow: auto;
}

.tm-stage:fullscreen .tm-shell,
.tm-stage.faux-full .tm-shell {
    max-width: none;
    justify-content: center;
    gap: 22px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}

.tm-stage:fullscreen .tm-head,
.tm-stage:fullscreen .tm-panel,
.tm-stage:fullscreen .tm-keys,
.tm-stage:fullscreen .tm-modes,
.tm-stage.faux-full .tm-head,
.tm-stage.faux-full .tm-panel,
.tm-stage.faux-full .tm-keys,
.tm-stage.faux-full .tm-modes {
    display: none;
}

.tm-stage:fullscreen .tm-dial,
.tm-stage.faux-full .tm-dial {
    --d: clamp(260px, min(74vh, 92vw), 1080px);
}

/* 전체화면에서는 조작부가 떠 있다가 가만히 있으면 사라진다. */
.tm-stage:fullscreen .tm-controls,
.tm-stage.faux-full .tm-controls {
    position: fixed;
    left: 50%;
    bottom: calc(22px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    transition: opacity .4s var(--ease);
}

.tm-stage:fullscreen.idle .tm-controls,
.tm-stage.faux-full.idle .tm-controls {
    opacity: 0;
    pointer-events: none;
}

/* 떠 있는 홈 버튼(menu.php)은 전체화면에서 치운다. */
.tm-stage:fullscreen~.home-menu-btn,
body.tm-faux .home-menu-btn {
    display: none;
}

/* ── 반응형 ─────────────────────────────────────────────────────────────── */
@media (max-width: 420px) {
    .tm-shell {
        padding: 14px 12px 32px;
        gap: 14px;
    }

    /* 조작 버튼 4개가 390px 에서 한 줄에 들어가야 한다(실측: 좌우 여백을 줄이기
       전에는 전체화면 버튼만 둘째 줄로 떨어졌다). 세로 여백은 건드리지 않는다 —
       손가락으로 누르는 높이 44px 를 지켜야 한다. */
    .tm-controls {
        gap: 8px;
    }

    .tm-btn {
        padding: 14px 12px;
        /* 세로 14px — 손가락으로 누르는 높이 44px 를 지킨다 */
        font-size: .88rem;
        gap: 5px;
    }

    .tm-btn.primary {
        padding: 14px 18px;
        font-size: .95rem;
    }

    .tm-btn.icon {
        padding: 14px 11px;
    }
}

/* 아주 좁은 폰(구형 SE 등) — 여기서도 조작 4개가 한 줄에 들어가야 한다. */
@media (max-width: 345px) {
    .tm-controls {
        gap: 6px;
    }

    .tm-btn {
        padding: 14px 9px;
        font-size: .84rem;
    }

    .tm-btn.primary {
        padding: 14px 13px;
        font-size: .9rem;
    }

    .tm-btn.icon {
        padding: 14px 9px;
    }

    /* 아주 좁은 칸에서 ±버튼이 자리를 다 먹으면 숫자가 잘린다("60"이 "6|"로). */
    .tm-step button {
        width: 30px;
        font-size: 1rem;
    }

    .tm-step input {
        font-size: 1.02rem;
        /* 16px 밑으로 내리지 말 것 — iOS 가 입력 시 확대한다 */
    }

    .tm-unit {
        font-size: .76rem;
    }

    .tm-field {
        min-width: 94px;
        flex-basis: 94px;
    }

    .tm-mode {
        font-size: .82rem;
        padding: 9px 4px;
    }

    .tm-block {
        padding: 10px;
    }

    .tm-chip {
        padding: 10px 14px;
        font-size: .88rem;
    }

    .tm-field {
        min-width: 100px;
        flex-basis: 100px;
    }

    .tm-step button {
        width: 36px;
    }
}

/* 가로로 누운 폰·작은 태블릿 — 세로가 모자라니 다이얼과 조작부를 나란히. */
@media (orientation: landscape) and (max-height: 560px) {
    .tm-shell {
        display: grid;
        /* 1열 = 다이얼(내용만큼), 2열 = 나머지(0까지 줄어들 수 있어야 넘치지 않는다) */
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-rows: auto auto minmax(0, 1fr);
        align-items: center;
        gap: 12px 16px;
        padding: 10px 14px;
        /* 누운 폰은 세로가 390px 뿐이다. 높이를 화면에 묶어 두고 설정 패널만
           안에서 스크롤시킨다 — 그러지 않으면 다이얼까지 같이 밀려 올라간다. */
        max-height: 100dvh;
        overflow: hidden;
    }

    /* 자동 배치에 맡기면 다이얼이 2열로 밀려 가로가 넘친다 — 칸을 직접 지정한다. */
    .tm-dialwrap {
        grid-column: 1;
        grid-row: 1 / span 3;
    }

    .tm-modes {
        grid-column: 2;
        grid-row: 1;
        margin: 0;
    }

    .tm-controls {
        grid-column: 2;
        grid-row: 2;
        justify-content: flex-start;
    }

    .tm-panel {
        grid-column: 2;
        grid-row: 3;
        overflow: auto;
        padding: 12px;
    }

    .tm-head,
    .tm-keys {
        display: none;
    }

    .tm-dial {
        --d: clamp(150px, min(74vh, 42vw), 320px);
    }
}

@media (prefers-reduced-motion: reduce) {

    .tm-core::after,
    .tm-vignette,
    .tm-flash,
    .tm-pop {
        animation: none !important;
        transition: none !important;
    }

    .tm-pop.go {
        opacity: .9;
    }
}
