/* ============================================================================
   TikTok 라이브 번역기 — 공용 테마 (Tikfinity 스타일: 다크 + 핑크/시안 그라데이션)
   사이드바 셸 + 카드/버튼/인풋 공통 컴포넌트. index/voice/login/register 공유.
   ========================================================================== */
:root {
  color-scheme: dark;

  --bg:        #0E0E12;
  --surface:   #16161C;
  --surface-2: #1E1E27;
  --surface-3: #262631;
  --border:    #2A2A37;
  --border-soft:#20202A;

  --text:    #ECECF1;
  --muted:   #9A9AAB;
  --muted-2: #6C6C7C;

  --pink: #FE2C55;
  --cyan: #25F4EE;
  --grad: linear-gradient(135deg, #FE2C55 0%, #FF5C8A 45%, #25F4EE 100%);
  --grad-soft: linear-gradient(135deg, rgba(254,44,85,.16), rgba(37,244,238,.16));

  --ok:   #2ED573;
  --warn: #FFA502;
  --bad:  #FF4757;

  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 10px 30px rgba(0,0,0,.40);
  --shadow-sm: 0 4px 14px rgba(0,0,0,.30);

  --font: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Malgun Gothic",
          "맑은 고딕", "Noto Sans KR", "Noto Sans JP", sans-serif;

  /* ── 모바일 토큰 (제거 없음, 추가만) ──────────────────────────────── */
  --nav-h: 60px;          /* 하단 탭바 높이 */
  --topbar-h: 52px;
  --tap: 44px;            /* 최소 탭 타깃 */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --sheet-radius: 20px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(254,44,85,.10), transparent 60%),
    radial-gradient(900px 600px at 0% 110%, rgba(37,244,238,.08), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2C2C39; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #3A3A4A; background-clip: padding-box; }

/* ── 브랜드 로고 ──────────────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto;
  background: var(--grad); display: grid; place-items: center;
  font-size: 16px; box-shadow: 0 4px 12px rgba(254,44,85,.35);
}
.brand .word {
  font-size: 18px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

/* ── 셸 레이아웃 ──────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }

.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: linear-gradient(180deg, #14141A, #101015);
  border-right: 1px solid var(--border-soft);
  padding: 18px 14px;
}
.sidebar .brand { padding: 6px 8px 18px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav .label { font-size: 11px; color: var(--muted-2); text-transform: uppercase;
  letter-spacing: .08em; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 11px; color: var(--muted);
  font-size: 14px; font-weight: 500; text-decoration: none;
  border: 1px solid transparent; transition: background .15s, color .15s;
}
.nav a .ico { width: 20px; text-align: center; font-size: 15px; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active {
  background: var(--grad-soft); color: var(--text);
  border-color: rgba(254,44,85,.30);
}
.nav a.active .ico { filter: drop-shadow(0 0 6px rgba(254,44,85,.5)); }

.sidebar .spacer { flex: 1; }

.account {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border-soft);
}
.account .avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  background: var(--grad); display: grid; place-items: center;
  font-weight: 800; font-size: 14px; color: #0E0E12;
}
.account .who { min-width: 0; flex: 1; }
.account .who .name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .who .sub { font-size: 11px; color: var(--muted-2); }
.account .logout {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 9px; padding: 6px 9px; font-size: 12px; cursor: pointer;
}
.account .logout:hover { color: var(--text); border-color: var(--bad); background: rgba(255,71,87,.10); }

/* ── 메인 / 상단바 ────────────────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 26px; border-bottom: 1px solid var(--border-soft);
  background: rgba(14,14,18,.55); backdrop-filter: blur(8px);
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.topbar .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.topbar .grow { flex: 1; }
.content { padding: 24px 26px; overflow: auto; min-height: 0; }

/* ── 카드 ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 18px; }
.card-title { font-size: 14px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.card-title .hint { font-weight: 400; }
.grid { display: grid; gap: 18px; }
@media (min-width: 1100px) { .grid.cols-2 { grid-template-columns: 1fr 360px; align-items: start; } }

/* ── 버튼 ─────────────────────────────────────────────────────────────────── */
button, .btn {
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 11px; padding: 10px 16px;
  transition: background .15s, border-color .15s, transform .05s, opacity .15s;
}
button:hover, .btn:hover { background: var(--surface-3); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn-primary, button.primary {
  background: var(--grad); border: none; color: #fff;
  box-shadow: 0 6px 18px rgba(254,44,85,.30);
}
.btn-primary:hover, button.primary:hover { filter: brightness(1.06); background: var(--grad); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; justify-content: center; display: flex; }

/* 토글 / 칩 / 세그먼트 */
.toggle { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; font-size: 13px; }
.toggle.on { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 4px 12px rgba(254,44,85,.28); }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 8px 14px; font-weight: 600; }
.seg button.on { background: var(--grad); color: #fff; }

/* ── 인풋 ─────────────────────────────────────────────────────────────────── */
input[type=text], input[type=password], input[type=email] {
  background: #101016; color: var(--text); border: 1px solid var(--border);
  border-radius: 11px; padding: 11px 13px; font-size: 14px; font-family: inherit; width: 100%;
}
input[type=text]:focus, input[type=password]:focus, input[type=email]:focus {
  outline: none; border-color: var(--pink); box-shadow: 0 0 0 3px rgba(254,44,85,.18);
}
input[type=range] { accent-color: var(--pink); }
.hint { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── 모달 ─────────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.62); display: none;
  align-items: center; justify-content: center; z-index: 50; backdrop-filter: blur(4px); }
.modal.show { display: flex; }
.modal .box { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; width: 440px; max-width: 92vw; box-shadow: var(--shadow); }
.modal h2 { font-size: 17px; margin: 0 0 18px; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ── 인증 페이지 (login/register) ─────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 400px; max-width: 94vw; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; padding: 34px 30px;
  box-shadow: var(--shadow);
}
.auth-card .brand { justify-content: center; margin-bottom: 6px; }
.auth-card .brand .word { font-size: 22px; }
.auth-card .tagline { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.auth-card h2 { font-size: 18px; margin: 0 0 18px; text-align: center; }
.auth-card .field label { font-weight: 600; }
.auth-card .btn-primary { margin-top: 6px; padding: 12px; font-size: 15px; }
.auth-error { display: none; background: rgba(255,71,87,.12); border: 1px solid rgba(255,71,87,.4);
  color: #FF9AA6; border-radius: 11px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.auth-error.show { display: block; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }

/* ── 제작사 표기 (nineagain 엔터테인먼트 자체 개발) — 공용 ─────────────────── */
.made-by { text-align: center; font-size: 11.5px; color: var(--muted-2); line-height: 1.5; }
.made-by .n { font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent; }
.sidebar .made-by { padding: 10px 8px 2px; }

/* ── 공용 모바일 컴포넌트 (모든 뷰포트에서 정의, 표시는 화면폭으로 제어) ─────── */

/* 전역 토스트 (복사 성공/실패 등) — 조용한 실패 제거 */
.toast { position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 80; opacity: 0; pointer-events: none;
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 18px; font-size: 13px; font-weight: 700;
  box-shadow: var(--shadow); transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok  { background: #0d3b22; border-color: #1F9D63; color: #8ef0b8; }
.toast.bad { background: #3a1620; border-color: var(--bad); color: #FF9AA6; }
@media (min-width: 861px) { .toast { bottom: 26px; } }

/* iOS 스타일 스위치 (44px 탭 영역 라벨로 감싸 사용) */
.switch { width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3);
  position: relative; flex: 0 0 44px; display: inline-block; cursor: pointer; border: 0; padding: 0; }
.switch.on { background: var(--grad); }
.switch .knob { width: 20px; height: 20px; border-radius: 50%; background: #fff;
  position: absolute; top: 3px; left: 3px; transition: transform .15s; }
.switch.on .knob { transform: translateX(18px); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--tap); width: 100%; }

/* 숫자 스테퍼 (범위 클램프는 JS) */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; }
.stepper button { width: var(--tap); height: var(--tap); border: 0; border-radius: 0;
  background: var(--surface-2); color: var(--text); font-size: 20px; font-weight: 800; }
.stepper input { width: 56px; text-align: center; min-height: var(--tap); border: 0; border-radius: 0;
  background: #101016; font-variant-numeric: tabular-nums; }

/* 하단 탭바 (기본 숨김 → 모바일에서 노출) */
.botnav { display: none; }

/* 바텀시트 */
.sheet { position: fixed; inset: 0; z-index: 60; display: none; }
.sheet.show { display: block; }
.sheet .backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.62); backdrop-filter: blur(4px); }
.sheet .panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow: auto;
  background: var(--surface); border-top: 1px solid var(--border);
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  padding: 20px 18px calc(20px + var(--safe-b)); box-shadow: var(--shadow);
  transform: translateY(100%); transition: transform .24s ease; }
.sheet.show .panel { transform: translateY(0); }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--surface-3); margin: 0 auto 14px; }

/* 스티키 하단 액션바 */
.sticky-cta { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 14px;
  background: rgba(14,14,18,.9); backdrop-filter: blur(8px); border-top: 1px solid var(--border-soft); z-index: 35; }
@media (prefers-reduced-motion: reduce) { .toast, .sheet .panel { transition: none; } }

/* ── 모바일 레이아웃 (≤860px) ─────────────────────────────────────────────── */
@media (max-width: 860px) {
  /* 뷰포트 높이는 주소창 변화를 견디는 dvh 로 */
  .shell { grid-template-columns: 1fr; height: auto; min-height: 100dvh; }
  .auth-wrap { min-height: 100dvh; }

  /* 데스크톱 사이드바 제거 → 하단 탭바로 대체 */
  .sidebar { display: none; }

  /* 상단바 sticky, 콘텐츠는 하단 탭바에 가리지 않도록 여백 */
  .main { min-height: 100dvh; }
  .topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
    padding: 10px 14px; }
  .topbar h1 { font-size: 17px; }
  .topbar .sub { display: none; }
  .content { padding: 16px 14px calc(var(--nav-h) + var(--safe-b) + 16px); }

  /* 하단 탭바 노출 */
  .botnav { position: fixed; inset: auto 0 0 0; height: calc(var(--nav-h) + var(--safe-b));
    padding-bottom: var(--safe-b); display: flex;
    background: linear-gradient(180deg, #14141A, #101015);
    border-top: 1px solid var(--border-soft); z-index: 40; }
  .botnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; min-height: 56px; font-size: 11px; color: var(--muted); text-decoration: none; position: relative; }
  .botnav a .ico { font-size: 22px; line-height: 1; }
  .botnav a:hover { text-decoration: none; }
  .botnav a.active { color: var(--text); }
  .botnav a.active .ico { filter: drop-shadow(0 0 6px rgba(254,44,85,.55)); }
  .botnav a.active::before { content: ""; position: absolute; top: 0; width: 30px; height: 2px;
    border-radius: 2px; background: var(--grad); }

  /* iOS 포커스 줌 방지 + 44px 입력 (가장 값싼 큰 개선) */
  input[type=text], input[type=password], input[type=email], select, textarea {
    font-size: 16px; min-height: var(--tap); }

  /* 탭 타깃 최소 44px */
  button, .btn, .toggle, .chip, .seg button, .mini { min-height: var(--tap); }
  .seg { display: flex; width: 100%; }
  .seg button { flex: 1; }
  .mini { font-size: 13px; }

  /* 카드 제목 옆 인라인 힌트가 좁은 화면에서 제목을 단어 중간에 깨뜨리는 문제 →
     힌트를 다음 줄로 내려 제목이 온전한 폭을 갖도록 */
  .card-title { flex-wrap: wrap; }
  .card-title .hint { flex-basis: 100%; margin-top: 2px; }

  /* 스티키 하단바가 탭바 위에 오도록(탭바 있는 페이지) */
  .sticky-cta.above-nav { bottom: calc(var(--nav-h) + var(--safe-b)); }

  /* 설정 모달을 전체 화면에 가깝게 */
  .modal .box { width: 100%; max-width: 100%; border-radius: 18px 18px 0 0;
    position: fixed; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow: auto;
    padding: 20px 18px calc(20px + var(--safe-b)); }
  .modal { align-items: flex-end; }
}
