/* 기본: 라이트 테마 */
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #eef1f7;
  --border: #e2e6f0;
  --text: #1a1d27;
  --muted: #6b7280;
  --accent: #4f6ef7;
  --accent-2: #4f6ef7;
  --green: #16a34a;
  --red: #ef4444;
  --amber: #d97706;
  --grad-top: #e9eefb;
  --btn-hover: #e4e8f2;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(20, 30, 60, 0.10);
}

/* 다크 테마 (토글) */
[data-theme="dark"] {
  --bg: #0f1117;
  --panel: #1a1d27;
  --panel-2: #232735;
  --border: #2d3242;
  --text: #e7e9ee;
  --muted: #8b90a0;
  --accent: #6c8cff;
  --accent-2: #4f6ef7;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --grad-top: #1b2030;
  --btn-hover: #2b3142;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 700px at 50% -10%, var(--grad-top) 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic",
    "Apple SD Gothic Neo", Roboto, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); }

.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 4px;
}
.brand .dot { font-size: 24px; }
.brand .spacer { flex: 1; }

.lang-switch { display: inline-flex; gap: 4px; }
.lang-switch button {
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 8px;
  background: transparent; color: var(--muted); border: 1px solid var(--border); cursor: pointer;
}
.lang-switch button.active { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }

.theme-toggle {
  font-size: 15px; line-height: 1; padding: 6px 9px; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--text); border: 1px solid var(--border);
}
.theme-toggle:hover { background: var(--btn-hover); }
.tagline {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 28px 34px;
  letter-spacing: .2px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 14px; }

/* 폼 */
.field { margin-bottom: 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="email"], input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
}
input:focus { border-color: var(--accent); }

/* 브라우저 자동완성 시 흰 배경/검은 글씨 덮어쓰기 방지 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--panel-2) inset;
  box-shadow: 0 0 0 1000px var(--panel-2) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s, background .15s, opacity .15s;
  user-select: none;
}
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); }
.btn.primary:hover { background: var(--accent); }
.btn.green { background: var(--green); border-color: var(--green); color: #06281d; }
.btn.red { background: var(--red); border-color: var(--red); color: #2c0b0b; }
.btn.ghost { background: transparent; }
.btn.lg { padding: 16px 26px; font-size: 17px; }
.btn.block { width: 100%; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.error {
  color: var(--red);
  font-size: 14px;
  margin-top: 8px;
  min-height: 18px;
}
.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tab {
  flex: 1; text-align: center; padding: 10px; border-radius: 10px;
  cursor: pointer; color: var(--muted); border: 1px solid transparent;
}
.tab.active { background: var(--panel-2); color: var(--text); border-color: var(--border); }

.hidden { display: none !important; }

/* 공개 방문자 카운터 (랜딩 하단) */
.visit-counter {
  text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 온보딩 슬라이드 (첫 슬라이드는 타이머 데모 링) */
.onboarding { max-width: 420px; margin: 0 auto 18px; }
.ob-viewport { position: relative; height: 190px; }

/* 소개 슬라이드 안의 타이머 데모 링 */
.ob-slide-timer { gap: 12px; }
.ht-ring { position: relative; width: 128px; height: 128px; }
.ht-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ht-track { fill: none; stroke: var(--border); stroke-width: 8; }
.ht-prog {
  fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 339.29; stroke-dashoffset: 0;
  transition: stroke-dashoffset .3s linear, stroke .3s;
}
.ht-ring.finish .ht-prog { stroke: var(--green, #22c55e); }
.ht-face {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
}
.ht-time { font-size: 30px; font-weight: 800; letter-spacing: 1px; color: var(--text); font-variant-numeric: tabular-nums; }
.ht-sub { font-size: 11px; color: var(--muted); }

.ob-slide {
  position: absolute; inset: 0; opacity: 0; transition: opacity .5s; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 6px; padding: 10px;
}
.ob-slide.active { opacity: 1; pointer-events: auto; }
.ob-emoji { font-size: 42px; line-height: 1; }
.ob-t { font-weight: 700; font-size: 18px; color: var(--text); }
.ob-d { color: var(--muted); font-size: 14px; max-width: 320px; }
.ob-dots { display: flex; gap: 7px; justify-content: center; margin-top: 4px; }
.ob-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); cursor: pointer; transition: background .2s; }
.ob-dot.active { background: var(--accent); }
.ob-more { color: var(--accent); font-size: 13px; text-decoration: none; }
.ob-more:hover { text-decoration: underline; }

/* 모달 오버레이 */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay .card { box-shadow: var(--shadow); }

/* 대시보드 타이머 목록 */
.timer-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.timer-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer;
}
.timer-item:hover { border-color: var(--accent); }
.timer-item .dot { flex: none; }
/* 이름(위) + 라벨·시간(아래) 2줄 스택. 가운데 영역만 늘어나고 삭제버튼은 고정 → 모바일 겹침/줄밀림 방지 */
.timer-item .ti-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.timer-item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-item .ti-time { font-family: monospace; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-item .btn { flex: none; }

/* ── 타이머 페이지 ── */
.topbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
}
.topbar .who { margin-left: auto; color: var(--muted); font-size: 14px; }
.logo-link {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 19px; color: var(--text); text-decoration: none;
  white-space: nowrap;
}
.logo-link .dot { font-size: 23px; }
.logo-link:hover { opacity: .85; }

.timer-display {
  text-align: center;
  padding: 40px 20px 30px;
}
.timer-name { font-size: 18px; color: var(--muted); margin-bottom: 10px; }
.clock {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-weight: 700;
  font-size: clamp(56px, 14vw, 120px);
  letter-spacing: 2px;
  line-height: 1;
}
.clock.finished { color: var(--amber); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }
.mode-badge {
  display: inline-block; margin-top: 14px; padding: 5px 12px;
  border-radius: 999px; font-size: 13px; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--muted);
}

.controls { display: flex; gap: 12px; justify-content: center; margin: 26px 0 8px; }

.phase-now {
  margin-top: 12px; font-size: 18px; font-weight: 700; color: var(--accent);
}
.phase-strip {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 6px 0 0;
}
.phase-chip {
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
}
.phase-chip.done { opacity: .45; }
.phase-chip.active { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }

.ai-box {
  margin-top: 22px; padding: 18px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(108,140,255,.08), rgba(79,110,247,.05));
  border: 1px solid var(--border);
}
.ai-box.locked { opacity: .5; pointer-events: none; }
/* 게스트: '만들기' 버튼만 비활성화 모양 (클릭은 가능 → 로그인 안내) */
.btn.locked-look { opacity: .5; }
.ai-box h2 { margin-bottom: 6px; }
.ai-preview {
  margin-top: 14px; padding: 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border);
}
.ai-preview .plan-name { font-weight: 700; margin-bottom: 4px; }
.ai-preview .plan-total { color: var(--muted); font-size: 13px; margin-bottom: 10px; }

.settings {
  margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--border);
}
.settings.locked { opacity: .5; pointer-events: none; }
.time-inputs { display: flex; align-items: flex-end; gap: 8px; }
.time-inputs .field { margin-bottom: 0; width: 90px; }
.time-inputs .colon { font-size: 22px; padding-bottom: 10px; color: var(--muted); }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button {
  padding: 10px 16px; background: var(--panel-2); color: var(--muted);
  border: none; cursor: pointer; font-size: 14px; font-weight: 600;
}
.seg button.active { background: var(--accent-2); color: #fff; }

/* 게스트(휘발성) 타이머 안내 배너 */
.ephem-note {
  text-align: center; font-size: 13px; color: var(--amber);
  background: rgba(217, 119, 6, .10); border: 1px solid rgba(217, 119, 6, .25);
  border-radius: 10px; padding: 8px 12px; margin: 0 auto 14px; max-width: 460px;
}

/* 접속자 목록 */
.presence { margin-top: 26px; }
.presence h2 { display: flex; align-items: center; gap: 8px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(52,211,153,.2); }
.people { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.person {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 10px;
}
.person .avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
}
.person .pname { font-weight: 600; }
.person .tag {
  font-size: 11px; padding: 3px 8px; border-radius: 999px; font-weight: 600;
}
.tag.owner { background: rgba(251,191,36,.15); color: var(--amber); border: 1px solid rgba(251,191,36,.3); }
.tag.ctrl { background: rgba(108,140,255,.15); color: var(--accent); border: 1px solid rgba(108,140,255,.3); }
.tag.me { background: rgba(52,211,153,.15); color: var(--green); border: 1px solid rgba(52,211,153,.3); }
.tag.guest { background: rgba(139,144,160,.15); color: var(--muted); border: 1px solid rgba(139,144,160,.3); }
.person .actions { margin-left: auto; display: flex; gap: 6px; }
.person .actions .btn { padding: 6px 12px; font-size: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
