/* ==========================================================================
   Mapleland Online Timer — 스타일시트

   구성
   1. 디자인 토큰 (테마)
   2. 기본 요소 리셋
   3. 공통 컴포넌트 (버튼 / 칩 / 배지)
   4. 상단 바
   5. 페이지 / 그룹 / 알림 배너
   6. 타이머 카드
   7. 푸터 범례
   8. 설정 모달
   9. 토스트
   10. 애니메이션 / 접근성
   ========================================================================== */

/* 1. 디자인 토큰 --------------------------------------------------------- */

:root {
	--font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Apple SD Gothic Neo',
		'Noto Sans KR', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
	--font-time: 'Clockicons', var(--font-ui);

	--r-sm: 8px;
	--r-md: 12px;
	--r-lg: 16px;
	--r-xl: 22px;
	--r-pill: 999px;

	--ease: cubic-bezier(0.2, 0.8, 0.3, 1);
	--t-fast: 0.12s;
	--t-mid: 0.22s;

	--page-max: 1320px;
}

@font-face {
	font-family: 'Clockicons';
	src: url('https://db.onlinewebfonts.com/t/84cb021d5f9af287ffff84b61beef6dc.woff') format('woff');
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

/* 라이트 테마 */
:root,
:root[data-theme='light'] {
	color-scheme: light;

	--bg: #eef1f7;
	--bg-glow-1: rgba(99, 102, 241, 0.10);
	--bg-glow-2: rgba(14, 165, 233, 0.08);

	--surface: #ffffff;
	--surface-2: #f5f7fb;
	--surface-3: #e9edf5;
	--surface-inset: rgba(15, 23, 42, 0.05);

	--line: #dde3ee;
	--line-strong: #c6cfdf;

	--text: #101828;
	--text-2: #4a5568;
	--text-3: #8794aa;

	--accent: #4f46e5;
	--accent-soft: rgba(79, 70, 229, 0.12);
	--accent-ink: #ffffff;

	--run: #0f9d58;
	--run-soft: rgba(15, 157, 88, 0.13);
	--warn: #d97706;
	--warn-soft: rgba(217, 119, 6, 0.15);
	--done: #dc2626;
	--done-soft: rgba(220, 38, 38, 0.12);

	--shadow-1: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px rgba(16, 24, 40, 0.06);
	--shadow-2: 0 2px 4px rgba(16, 24, 40, 0.06), 0 12px 28px rgba(16, 24, 40, 0.13);
	--shadow-modal: 0 24px 64px rgba(16, 24, 40, 0.25);

	--topbar-bg: rgba(255, 255, 255, 0.82);
	--scrim: rgba(16, 24, 40, 0.45);
}

/* 다크 테마 */
:root[data-theme='dark'] {
	color-scheme: dark;

	--bg: #0a0d14;
	--bg-glow-1: rgba(99, 102, 241, 0.16);
	--bg-glow-2: rgba(14, 165, 233, 0.10);

	--surface: #151a25;
	--surface-2: #1b2130;
	--surface-3: #232b3d;
	--surface-inset: rgba(255, 255, 255, 0.06);

	--line: #262e40;
	--line-strong: #36415a;

	--text: #e9eefb;
	--text-2: #9aa6bf;
	--text-3: #6b7791;

	--accent: #7c8cff;
	--accent-soft: rgba(124, 140, 255, 0.16);
	--accent-ink: #0a0d14;

	--run: #34d399;
	--run-soft: rgba(52, 211, 153, 0.14);
	--warn: #fbbf24;
	--warn-soft: rgba(251, 191, 36, 0.16);
	--done: #fb7185;
	--done-soft: rgba(251, 113, 133, 0.16);

	--shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.35);
	--shadow-2: 0 2px 6px rgba(0, 0, 0, 0.45), 0 16px 36px rgba(0, 0, 0, 0.55);
	--shadow-modal: 0 28px 72px rgba(0, 0, 0, 0.7);

	--topbar-bg: rgba(13, 17, 26, 0.8);
	--scrim: rgba(3, 6, 12, 0.66);
}

/* 2. 기본 요소 리셋 ------------------------------------------------------ */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	min-height: 100dvh;
	font-family: var(--font-ui);
	color: var(--text);
	background:
		radial-gradient(1100px 640px at 12% -12%, var(--bg-glow-1), transparent 62%),
		radial-gradient(900px 560px at 92% 0%, var(--bg-glow-2), transparent 60%),
		var(--bg);
	background-attachment: fixed;
	line-height: 1.45;
	display: flex;
	flex-direction: column;
}

h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }

button { font: inherit; color: inherit; }

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
	border-radius: var(--r-sm);
}

.skip-link {
	position: absolute;
	left: 12px;
	top: -60px;
	z-index: 100;
	padding: 10px 16px;
	background: var(--accent);
	color: var(--accent-ink);
	border-radius: var(--r-sm);
	font-weight: 600;
	text-decoration: none;
	transition: top var(--t-fast) var(--ease);
}
.skip-link:focus { top: 12px; }

[hidden] { display: none !important; }

/* 3. 공통 컴포넌트 ------------------------------------------------------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	padding: 9px 15px;
	border: 1px solid transparent;
	border-radius: var(--r-md);
	background: var(--surface-2);
	color: var(--text);
	font-weight: 600;
	font-size: 14px;
	white-space: nowrap;
	cursor: pointer;
	transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
		transform var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }

.btn-primary {
	background: var(--accent);
	color: var(--accent-ink);
	box-shadow: var(--shadow-1);
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }

.btn-ghost {
	background: transparent;
	border-color: var(--line);
	color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: var(--r-sm); }

.iconbtn {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 8px 13px;
	border: 1px solid var(--line);
	border-radius: var(--r-md);
	background: var(--surface);
	color: var(--text-2);
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
	white-space: nowrap;
	transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
		border-color var(--t-fast) var(--ease);
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); border-color: var(--line-strong); }
.iconbtn-glyph { font-size: 15px; line-height: 1; }
.iconbtn-square { padding: 8px 10px; }

/* 알람이 켜진 상태의 버튼은 초록 계열로 상태를 즉시 알림 */
.iconbtn[aria-pressed='true'] {
	background: var(--run-soft);
	border-color: color-mix(in srgb, var(--run) 40%, transparent);
	color: var(--run);
}
/* 사용자 제스처를 기다리는 중간 상태 */
.iconbtn[data-state='pending'] {
	background: var(--warn-soft);
	border-color: color-mix(in srgb, var(--warn) 40%, transparent);
	color: var(--warn);
}

.chip {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 6px 12px;
	border: 1px solid var(--line);
	border-radius: var(--r-pill);
	background: var(--surface);
	color: var(--text-2);
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
}

.chip-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--text-3);
	flex: none;
}
.chip-presence[data-status='online'] .chip-dot { background: var(--run); }
.chip-presence[data-status='connecting'] .chip-dot { background: var(--warn); animation: blip 1.2s ease-in-out infinite; }
.chip-presence[data-status='offline'] .chip-dot { background: var(--done); }
.chip-presence[data-status='offline'] {
	color: var(--done);
	border-color: color-mix(in srgb, var(--done) 40%, transparent);
	background: var(--done-soft);
}

.chip-running {
	background: var(--run-soft);
	border-color: color-mix(in srgb, var(--run) 35%, transparent);
	color: var(--run);
}
.chip-pulse {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
	flex: none;
	animation: blip 1.4s ease-in-out infinite;
}

/* 관전 배지. 경고가 아니라 상태 표시이므로 강조색이 아닌 중립 면을 쓴다.
   누르면 조작 키 입력으로 이어지므로 호버 신호는 남겨 둔다 */
.chip-role {
	background: var(--surface-inset);
	color: var(--text-2);
	border-style: dashed;
	cursor: pointer;
}
.chip-role:hover {
	background: var(--surface-2);
	color: var(--text);
	border-color: var(--line-strong);
}

/* 4. 상단 바 ------------------------------------------------------------- */

.topbar {
	position: sticky;
	top: 0;
	z-index: 20;
	background: var(--topbar-bg);
	backdrop-filter: saturate(160%) blur(14px);
	-webkit-backdrop-filter: saturate(160%) blur(14px);
	border-bottom: 1px solid var(--line);
}

.topbar-inner {
	max-width: var(--page-max);
	margin: 0 auto;
	padding: 12px 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
}

.identity {
	display: flex;
	align-items: center;
	gap: 12px;
	/* 좁은 화면에서 방 이름이 사라지지 않도록 이쪽이 남은 공간을 가진다 */
	flex: 1 1 auto;
	min-width: 0;
}

.logo {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	flex: none;
	border-radius: var(--r-md);
	background: var(--accent-soft);
	color: var(--accent);
}
.logo svg { width: 21px; height: 21px; }

.identity-text { min-width: 0; }

.room-name {
	font-size: 18px;
	font-weight: 800;
	letter-spacing: -0.01em;
	line-height: 1.2;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* 방 이름 아래 한 줄. 브랜드 워터마크가 아니라 **"이 타이머는 공유된다"는 상시 신호**다 —
   링크만 받고 들어온 사람은 여기가 각자 누르는 개인 타이머인지 방 전체가 함께 보는
   타이머인지 모른 채 시작한다. 그래서 회색 소문자 워터마크가 아니라 강조색으로 둔다.
   (대문자 변환은 한글에 아무 효과가 없고 자간만 벌어지므로 걷어냈다) */
.brand {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.02em;
	color: var(--accent);
	white-space: nowrap;
}

.topbar-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 0 0 auto;
	flex-wrap: wrap;
	justify-content: flex-end;
}

/* 5. 페이지 / 그룹 / 알림 배너 ------------------------------------------- */

.page {
	flex: 1;
	width: 100%;
	max-width: var(--page-max);
	margin: 0 auto;
	padding: 24px 20px 8px;
}

.notice {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-bottom: 22px;
	padding: 14px 16px;
	border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
	border-radius: var(--r-lg);
	background: var(--accent-soft);
}
.notice-icon { font-size: 20px; line-height: 1; flex: none; }
.notice-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.notice-body strong { font-size: 14px; }
.notice-body span { font-size: 13px; color: var(--text-2); }

.groups {
	display: flex;
	flex-direction: column;
	gap: 30px;
}

.group-head {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 12px;
}
.group-title {
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--text-2);
	white-space: nowrap;
}
.group-count {
	display: grid;
	place-items: center;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	border-radius: var(--r-pill);
	background: var(--surface-inset);
	color: var(--text-3);
	font-size: 11px;
	font-weight: 700;
}
.group-rule {
	flex: 1;
	height: 1px;
	background: var(--line);
}

.group-grid {
	display: grid;
	gap: 14px;
	grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
}

/* 6. 타이머 카드 --------------------------------------------------------- */

.card {
	--state: var(--text-3);
	--state-soft: var(--surface-inset);

	--card-bg: var(--surface);

	position: relative;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px 16px 12px;
	border: 1px solid var(--line);
	border-radius: var(--r-lg);
	background: var(--card-bg);
	box-shadow: var(--shadow-1);
	cursor: pointer;
	overflow: hidden;
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
	touch-action: manipulation;
	transition: transform var(--t-fast) var(--ease), box-shadow var(--t-mid) var(--ease),
		border-color var(--t-mid) var(--ease), background var(--t-mid) var(--ease);
}

/* 왼쪽 상태 레일: 대기/실행/경고/완료를 색으로 즉시 구분 */
.card::before {
	content: '';
	position: absolute;
	inset: 0 auto 0 0;
	width: 3px;
	background: var(--state);
	opacity: 0.35;
	transition: opacity var(--t-mid) var(--ease);
}

.card:hover {
	transform: translateY(-2px);
	box-shadow: var(--shadow-2);
	border-color: var(--line-strong);
}
.card:active { transform: translateY(0); }

.card[data-state='running'],
.card[data-state='warn'],
.card[data-state='done'] {
	border-color: color-mix(in srgb, var(--state) 40%, var(--line));
	background: linear-gradient(180deg, var(--state-soft), transparent 78%), var(--card-bg);
}
.card[data-state='running']::before,
.card[data-state='warn']::before,
.card[data-state='done']::before { opacity: 1; }

.card[data-state='running'] { --state: var(--run); --state-soft: var(--run-soft); }
.card[data-state='warn'] { --state: var(--warn); --state-soft: var(--warn-soft); }
.card[data-state='done'] { --state: var(--done); --state-soft: var(--done-soft); }

/* 경고 구간에서는 카드가 은은하게 맥동해 시선을 끈다 */
.card[data-state='warn'] { animation: warnBreathe 1.1s var(--ease) infinite; }

/* 사용 안 함 상태.
   내가 조작하지 않을 뿐 시간은 여전히 봐야 하는 정보다. 그래서 카드를 흐리게 하지 않고
   '눌러서 쓰는 카드'라는 신호(솔리드 면 · 그림자 · 호버 리프트)만 걷어낸다.
   남는 구분 단서: 오려낸 듯한 면 + 파선 테두리 + OFF 배지 + 흐린 키 캡.
   상태 레일 / 진행 트랙 / 시간 색은 그대로 살려 둔다. */
.card[data-off] {
	--card-bg: var(--surface-inset);
	border-style: dashed;
	box-shadow: none;
}
.card[data-off]:hover {
	transform: none;
	box-shadow: none;
	border-color: var(--line-strong);
}

.card-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 10px;
	min-height: 22px;
}

.card-name {
	font-size: 15px;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--text);
	min-width: 0;
	overflow-wrap: anywhere;
}
.card-name[contenteditable='true'] {
	/* 편집 가능함을 알리되, 카드가 밑줄로 어수선해지지 않도록 약하게 */
	border-bottom: 1px dashed var(--line);
	outline: none;
	cursor: text;
}
.card:hover .card-name[contenteditable='true'] { border-bottom-color: var(--line-strong); }
.card-name[contenteditable='true']:hover { border-bottom-color: var(--accent); }
.card-name[contenteditable='true']:focus {
	border-bottom-color: var(--accent);
	background: var(--accent-soft);
	border-radius: 3px;
}

.card-key {
	flex: none;
	min-width: 24px;
	padding: 3px 7px;
	border: 1px solid var(--line);
	border-bottom-width: 2px;
	border-radius: 6px;
	background: var(--surface-2);
	color: var(--text-2);
	font-family: var(--font-ui);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-align: center;
	line-height: 1.35;
}
.card-key[data-muted] { opacity: 0.4; text-decoration: line-through; }

/* OFF 배지는 사용 안 함 상태에서만 (표시 여부를 JS가 아니라 CSS가 결정) */
.card-off-tag { display: none; }
.card[data-off] .card-off-tag {
	display: inline-block;
	flex: none;
	padding: 3px 8px;
	border-radius: var(--r-pill);
	background: var(--surface-inset);
	color: var(--text-3);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
}

.card-time {
	display: flex;
	align-items: baseline;
	gap: 8px;
	margin-top: 2px;
}

.card-time-value {
	font-family: var(--font-time);
	font-variant-numeric: tabular-nums;
	font-size: clamp(38px, 8.5vw, 46px);
	font-weight: 800;
	line-height: 1;
	letter-spacing: 0.02em;
	color: var(--text);
	transition: color var(--t-mid) var(--ease);
}
.card[data-state='warn'] .card-time-value { color: var(--warn); }
.card[data-state='done'] .card-time-value { color: var(--done); }

/* 진행 트랙: 남은 시간 비율을 한눈에 */
.card-track {
	height: 4px;
	border-radius: var(--r-pill);
	background: var(--surface-inset);
	overflow: hidden;
}
.card-track-fill {
	display: block;
	height: 100%;
	width: 0%;
	border-radius: inherit;
	background: var(--state);
	transition: background var(--t-mid) var(--ease);
}
.card[data-state='idle'] .card-track-fill { opacity: 0.28; }

.card-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	min-height: 22px;
}

.card-state {
	font-size: 12px;
	font-weight: 700;
	color: var(--state);
	letter-spacing: 0.01em;
}
.card[data-state='idle'] .card-state { color: var(--text-3); }

.card-tags { display: flex; align-items: center; gap: 6px; }

.tag {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 3px 8px;
	border: 1px solid var(--line);
	border-radius: var(--r-pill);
	background: var(--surface-2);
	color: var(--text-3);
	font-size: 11px;
	font-weight: 600;
	line-height: 1.5;
	white-space: nowrap;
}

.tag-sound {
	cursor: pointer;
	color: var(--accent);
	border-color: color-mix(in srgb, var(--accent) 28%, transparent);
	background: var(--accent-soft);
	transition: opacity var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.tag-sound:hover { filter: brightness(1.08); }
.tag-sound[data-muted] {
	color: var(--text-3);
	background: var(--surface-2);
	border-color: var(--line);
}

/* 7. 푸터 범례 ----------------------------------------------------------- */

.app-footer {
	width: 100%;
	max-width: var(--page-max);
	margin: 0 auto;
	padding: 26px 20px 40px;
}
.legend {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 20px;
	font-size: 12px;
	color: var(--text-3);
}
.legend li { display: flex; align-items: center; gap: 7px; }
.legend-key {
	padding: 2px 7px;
	border: 1px solid var(--line);
	border-bottom-width: 2px;
	border-radius: 5px;
	background: var(--surface);
	color: var(--text-2);
	font-size: 11px;
	font-weight: 700;
}

/* 관전 모드에서 조작 범례를 대신하는 안내. 범례와 같은 무게로 읽히게 둔다 */
.legend-viewer {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	font-size: 12px;
	line-height: 1.6;
	color: var(--text-3);
}
.legend-viewer strong { color: var(--text-2); }

/* 조작 권한을 가진 상태의 태그. 카드 상태색과 같은 어휘를 쓴다 */
.tag[data-tone='ok'] {
	border-color: color-mix(in srgb, var(--run) 40%, transparent);
	background: var(--run-soft);
	color: var(--run);
}

/* 8. 설정 모달 ----------------------------------------------------------- */

.modal {
	position: fixed;
	inset: 0;
	z-index: 40;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}
.modal-backdrop {
	position: absolute;
	inset: 0;
	background: var(--scrim);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	animation: fadeIn var(--t-mid) var(--ease);
}
.modal-dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(620px, 100%);
	max-height: min(860px, calc(100dvh - 32px));
	border: 1px solid var(--line);
	border-radius: var(--r-xl);
	background: var(--surface);
	box-shadow: var(--shadow-modal);
	overflow: hidden;
	animation: popIn var(--t-mid) var(--ease);
}

.modal-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	padding: 18px 20px 14px;
	border-bottom: 1px solid var(--line);
}
.modal-header h2 { font-size: 17px; font-weight: 800; }
.modal-sub { margin-top: 3px; font-size: 12px; color: var(--text-3); }

.modal-body {
	display: flex;
	flex-direction: column;
	gap: 22px;
	padding: 18px 20px 22px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.panel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 10px;
	flex-wrap: wrap;
}
.panel-head h3 { font-size: 14px; font-weight: 700; }
.panel-tools { display: flex; gap: 6px; }

/* 타이머 설정 목록: [사용 + 이름] / [알람 소리] / [단축키] */
.tset-legend {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 172px 100px;
	gap: 8px;
	padding: 0 12px 6px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.05em;
	color: var(--text-3);
}
.tset-legend span:not(:first-child) { text-align: center; }

.tset-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	gap: 8px;
}
.tset-controls {
	display: grid;
	grid-template-columns: 172px 100px;
	gap: 8px;
	align-items: center;
}
.tset-sound,
.tset-hotkey { display: flex; align-items: center; gap: 4px; min-width: 0; }

.tset-list {
	display: flex;
	flex-direction: column;
	gap: 4px;
	max-height: min(46dvh, 380px);
	overflow-y: auto;
	overscroll-behavior: contain;
	border: 1px solid var(--line);
	border-radius: var(--r-md);
	padding: 6px;
	background: var(--surface-2);
}

.tset-row {
	padding: 7px 6px;
	border-radius: var(--r-sm);
	transition: background var(--t-fast) var(--ease);
}
.tset-row:hover { background: var(--surface); }
/* 꺼진 카드를 눌러 들어왔을 때 어떤 행을 켜야 하는지 잠시 강조 */
.tset-row.is-highlight { animation: rowHighlight 1.8s var(--ease); }
.tset-row[data-off] .tset-name { color: var(--text-2); }

.tset-main {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	cursor: pointer;
}
.tset-name {
	font-size: 14px;
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
/* 방 기본값과 다르게 설정된 행 표식 */
.tset-dot {
	flex: none;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--accent);
}

/* 작은 폼 컨트롤 (설정 목록 전용) */
.mini-select {
	flex: 1;
	min-width: 0;
	height: 30px;
	padding: 0 6px;
	border: 1px solid var(--line);
	border-radius: var(--r-sm);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
}
.mini-select:hover { border-color: var(--line-strong); }

.mini-btn {
	flex: none;
	display: grid;
	place-items: center;
	width: 26px;
	height: 30px;
	padding: 0;
	border: 1px solid var(--line);
	border-radius: var(--r-sm);
	background: var(--surface);
	color: var(--text-2);
	font-size: 11px;
	line-height: 1;
	cursor: pointer;
	transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.mini-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.mini-btn:disabled { opacity: 0.35; cursor: default; }

/* 단축키 지정 버튼 — 누르면 다음 키 입력을 기다린다 */
.keycap {
	flex: 1;
	min-width: 0;
	height: 30px;
	padding: 0 6px;
	border: 1px solid var(--line);
	border-bottom-width: 2px;
	border-radius: 6px;
	background: var(--surface);
	color: var(--text);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
	cursor: pointer;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.keycap:hover { border-color: var(--accent); }
.keycap[data-empty='true'] { color: var(--text-3); font-weight: 600; }
.keycap[data-capturing] {
	border-color: var(--accent);
	background: var(--accent-soft);
	color: var(--accent);
	animation: blip 1s ease-in-out infinite;
}

input[type='checkbox'] {
	appearance: none;
	-webkit-appearance: none;
	width: 18px;
	height: 18px;
	flex: none;
	margin: 0;
	border: 1.5px solid var(--line-strong);
	border-radius: 5px;
	background: var(--surface);
	cursor: pointer;
	display: grid;
	place-items: center;
	transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
input[type='checkbox']::after {
	content: '';
	width: 9px;
	height: 5px;
	border: 2px solid var(--accent-ink);
	border-top: 0;
	border-right: 0;
	transform: rotate(-45deg) translateY(-1px) scale(0);
	transition: transform var(--t-fast) var(--ease);
}
input[type='checkbox']:checked {
	background: var(--accent);
	border-color: var(--accent);
}
input[type='checkbox']:checked::after { transform: rotate(-45deg) translateY(-1px) scale(1); }
input[type='checkbox']:hover { border-color: var(--accent); }

.hint {
	margin-top: 10px;
	font-size: 12px;
	line-height: 1.6;
	color: var(--text-3);
}
.hint strong { color: var(--text-2); }
.hint-note { display: block; margin-top: 4px; }
.hint-key {
	padding: 1px 5px;
	border: 1px solid var(--line);
	border-bottom-width: 2px;
	border-radius: 4px;
	background: var(--surface);
	color: var(--text-2);
	font-family: var(--font-ui);
	font-size: 11px;
	font-weight: 700;
}
.hint-warn {
	padding: 9px 11px;
	border-radius: var(--r-sm);
	background: var(--warn-soft);
	color: var(--text-2);
}
.hint-warn strong { color: var(--warn); }

.volume-row {
	display: flex;
	align-items: center;
	gap: 12px;
}
.volume-icon { font-size: 16px; flex: none; }
#volumeLabel {
	flex: none;
	min-width: 48px;
	text-align: right;
	font-size: 14px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	color: var(--accent);
}

input[type='range'] {
	appearance: none;
	-webkit-appearance: none;
	flex: 1;
	height: 6px;
	border-radius: var(--r-pill);
	background:
		linear-gradient(var(--line-strong), var(--line-strong)) 33.1% / 2px 100% no-repeat,
		var(--surface-3);
	outline: none;
	cursor: pointer;
}
input[type='range']::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--accent);
	border: 3px solid var(--surface);
	box-shadow: var(--shadow-1);
	cursor: pointer;
}
input[type='range']::-moz-range-thumb {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--accent);
	border: 3px solid var(--surface);
	box-shadow: var(--shadow-1);
	cursor: pointer;
}

/* 조작 권한 패널. 타이머·볼륨 설정과 성격이 다르므로(개인 설정이 아니라 권한)
   테두리로 한 덩어리로 묶어 구분한다 */
#controlPanel {
	padding: 14px 16px;
	border: 1px solid var(--line);
	border-radius: var(--r-md);
	background: var(--surface-2);
}
/* 관전 배지로 들어왔을 때 어디에 입력해야 하는지 잠시 강조.
   배경이 아니라 테두리만 건드려 패널의 면색을 지운 채로 끝나지 않게 한다 */
#controlPanel.is-highlight { animation: panelHighlight 1.8s var(--ease); }

.control-row {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}
.control-input {
	flex: 1;
	min-width: 140px;
	height: 34px;
	padding: 0 10px;
	border: 1px solid var(--line);
	border-radius: var(--r-sm);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.02em;
}
.control-input:hover { border-color: var(--line-strong); }
.control-input::placeholder { color: var(--text-3); font-weight: 500; letter-spacing: 0; }

/* 9. 관전 모드 ----------------------------------------------------------- */

/* 관전자에게는 '누를 수 있다'는 신호만 걷어낸다. 카드를 흐리게 하지 않는 것은
   data-off와 같은 이유다 — 남이 돌리는 타이머의 시간·상태는 여전히 봐야 하는 정보다.
   대신 커서 · 호버 리프트 · 편집 밑줄처럼 조작을 약속하는 것만 없앤다. */
:root[data-role='viewer'] .card {
	cursor: default;
}
:root[data-role='viewer'] .card:hover {
	transform: none;
	box-shadow: var(--shadow-1);
	border-color: var(--line);
}
/* 상태 색을 가진 카드는 자기 테두리색을 지켜야 한다 (위 규칙이 덮지 않도록) */
:root[data-role='viewer'] .card[data-state='running']:hover,
:root[data-role='viewer'] .card[data-state='warn']:hover,
:root[data-role='viewer'] .card[data-state='done']:hover {
	border-color: color-mix(in srgb, var(--state) 40%, var(--line));
}

/* 설정 목록에서 조작 전용 두 축(사용 여부 · 단축키)을 접는다.
   관전자에게 남는 것은 '어떤 타이머에서 어떤 소리를 낼지'뿐이다. */
:root[data-role='viewer'] .tset-legend { grid-template-columns: minmax(0, 1fr) 172px; }
:root[data-role='viewer'] .tset-controls { grid-template-columns: 172px; }
:root[data-role='viewer'] .tset-hotkey,
:root[data-role='viewer'] #tsetLegendHotkey,
:root[data-role='viewer'] .tset-main input[type='checkbox'] { display: none; }
:root[data-role='viewer'] .tset-main { cursor: default; }

/* 10. 토스트 ------------------------------------------------------------- */

.toast-host {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%);
	z-index: 60;
	display: flex;
	flex-direction: column;
	gap: 8px;
	align-items: center;
	pointer-events: none;
	width: min(440px, calc(100% - 32px));
}
.toast {
	width: 100%;
	padding: 11px 16px;
	border: 1px solid var(--line);
	border-radius: var(--r-md);
	background: var(--surface);
	box-shadow: var(--shadow-2);
	font-size: 14px;
	font-weight: 600;
	text-align: center;
	animation: toastIn var(--t-mid) var(--ease);
}
/* 톤 틴트는 반드시 불투명한 면 위에 얹는다. `--*-soft`는 알파가 0.15 정도인 틴트여서
   그것만 배경으로 쓰면 페이지 위에 떠 있는 토스트의 글씨와 뒤의 본문이 겹쳐 보인다.
   (카드가 상태 틴트를 `--card-bg` 위에 얹는 것과 같은 방식) */
.toast[data-tone='error'] {
	border-color: color-mix(in srgb, var(--done) 45%, transparent);
	background: linear-gradient(var(--done-soft), var(--done-soft)), var(--surface);
	color: var(--done);
}
.toast[data-tone='warn'] {
	border-color: color-mix(in srgb, var(--warn) 45%, transparent);
	background: linear-gradient(var(--warn-soft), var(--warn-soft)), var(--surface);
	color: var(--warn);
}
.toast.is-leaving { animation: toastOut var(--t-mid) var(--ease) forwards; }

/* 11. 애니메이션 / 반응형 / 접근성 --------------------------------------- */

@keyframes blip {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.3; }
}
@keyframes warnBreathe {
	0%, 100% { box-shadow: var(--shadow-1); }
	50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent), var(--shadow-2); }
}
@keyframes beepFlash {
	0%, 100% { background-color: transparent; }
	45% { background-color: var(--state-soft); }
}
@keyframes rowHighlight {
	0%, 60% { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
	100% { background: transparent; box-shadow: none; }
}
@keyframes panelHighlight {
	0%, 60% { box-shadow: inset 0 0 0 2px var(--accent); }
	100% { box-shadow: none; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
	from { opacity: 0; transform: translateY(10px) scale(0.985); }
	to { opacity: 1; transform: none; }
}
@keyframes toastIn {
	from { opacity: 0; transform: translateY(12px); }
	to { opacity: 1; transform: none; }
}
@keyframes toastOut {
	to { opacity: 0; transform: translateY(8px); }
}

/* 알람이 울리는 순간의 시각 신호 */
.card.blink { animation: beepFlash 0.28s ease-in-out 2; }

@media (max-width: 900px) {
	.topbar-inner { padding: 10px 14px; }
	.page { padding: 18px 14px 4px; }
	.app-footer { padding: 20px 14px 32px; }
	.group-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
}

@media (max-width: 620px) {
	.topbar-inner {
		flex-wrap: nowrap;
		gap: 10px;
	}
	.brand { display: none; }
	.room-name { font-size: 16px; }
	.logo { width: 34px; height: 34px; }

	.topbar-actions { flex-wrap: nowrap; gap: 6px; }
	.identity { gap: 8px; }
	/* 좁은 화면에서는 아이콘만 남겨 한 줄을 유지 */
	.iconbtn-label,
	.btn-label { display: none; }
	.iconbtn { padding: 8px 10px; }
	.btn-primary { padding: 9px 12px; }
	.chip-running,
	#presenceText,
	#roleChipText { display: none; }
	.chip-presence,
	.chip-role { padding: 6px 8px; }

	.notice { flex-direction: column; align-items: flex-start; }
	.notice .btn { align-self: stretch; }

	.group-grid { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
	.card { padding: 11px 12px 10px; gap: 8px; }
	.card-time-value { font-size: clamp(32px, 11vw, 42px); }
	.card-name { font-size: 14px; }

	.modal { padding: 0; align-items: flex-end; }
	.modal-dialog {
		width: 100%;
		max-height: 92dvh;
		border-radius: var(--r-xl) var(--r-xl) 0 0;
		border-bottom: 0;
	}
	.tset-legend { display: none; }
	.tset-row { grid-template-columns: 1fr; gap: 6px; }
	.tset-controls {
		grid-template-columns: minmax(0, 1fr) 96px;
		padding-left: 28px;
	}
	/* 체크박스를 감춘 관전 모드에서는 그 자리만큼의 들여쓰기도 필요 없다 */
	:root[data-role='viewer'] .tset-controls {
		grid-template-columns: minmax(0, 1fr);
		padding-left: 0;
	}
	.legend { gap: 6px 14px; }
}

@media (max-width: 430px) {
	.logo { display: none; }
	.room-name { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}
	.card:hover { transform: none; }
}
