:root {
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1f2430;
    --muted: #6b7280;
    --border: #e2e6ee;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --danger: #dc2626;
    --warn: #d97706;
    --ok: #059669;
    --shadow: 0 6px 20px rgba(0,0,0,.06);
}
[data-theme="dark"] {
    --bg: #0f1420;
    --card: #1a2130;
    --text: #e6e9f0;
    --muted: #9aa4b6;
    --border: #2a3346;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --shadow: 0 6px 20px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, "Malgun Gothic", sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background .25s, color .25s;
}

/* 상단바 */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.brand a { font-weight: 700; font-size: 18px; text-decoration: none; color: var(--text); }
.nav { display: flex; align-items: center; gap: 16px; }
.nav a { text-decoration: none; color: var(--muted); font-size: 14px; }
.nav a:hover { color: var(--primary); }
.nav .user { font-size: 14px; font-weight: 600; }
.nav .logout { color: var(--danger); }
.theme-toggle {
    border: 1px solid var(--border);
    background: transparent;
    border-radius: 50%;
    width: 36px; height: 36px;
    cursor: pointer; font-size: 16px;
    display: flex; align-items: center; justify-content: center;
}

/* 컨테이너 */
.container { max-width: 720px; margin: 32px auto; padding: 0 16px; }

/* 카드 */
.auth-card, .tts-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    box-shadow: var(--shadow);
}
.tts-card.wide, .container:has(.wide) { max-width: 100%; }
.wide { max-width: 960px; margin-left: auto; margin-right: auto; }

h1 { margin-top: 0; font-size: 22px; }

/* 폼 */
label { display: block; font-size: 14px; margin-bottom: 12px; color: var(--muted); }
input[type=text], input[type=password], select, textarea {
    width: 100%;
    padding: 10px 12px;
    margin-top: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}
textarea { resize: vertical; }
.field { margin-bottom: 18px; }
.textarea-wrap { position: relative; }
.play-btn { position: absolute; right: 10px; bottom: 10px; }

/* 목소리 선택 + 특징 표시 */
.voice-row { display: flex; align-items: center; gap: 12px; }
.voice-row select { width: auto; min-width: 160px; flex: 0 0 auto; }
.voice-desc {
    font-size: 14px;
    color: var(--primary);
    font-weight: 600;
    padding: 6px 12px;
    background: rgba(79,70,229,.08);
    border-radius: 8px;
    margin-top: 6px;
}

/* 버튼 */
.btn {
    border: none; border-radius: 8px; cursor: pointer;
    padding: 9px 16px; font-size: 14px; font-weight: 600;
    background: var(--border); color: var(--text);
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.full { width: 100%; margin-top: 8px; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.warn { background: var(--warn); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }

/* 플레이어 */
.player { margin-top: 16px; }
audio { width: 100%; margin-bottom: 12px; }
.speed-control label { color: var(--text); font-weight: 600; }
input[type=range] { width: 100%; }

/* 메시지 */
.msg { font-size: 14px; }
.msg.small { font-size: 13px; min-height: 18px; }
.msg.error { color: var(--danger); }
.msg.success { color: var(--ok); }
.msg.denied {
    color: var(--warn);
    background: rgba(217,119,6,.10);
    border: 1px solid rgba(217,119,6,.35);
    padding: 12px 14px;
    border-radius: 8px;
}
.hint { color: var(--muted); font-size: 13px; }
.hint.small { font-size: 12px; }
.auth-foot { margin-top: 16px; font-size: 14px; color: var(--muted); }
.auth-foot a { color: var(--primary); }

/* 이력 헤더 */
.history-head { display: flex; align-items: center; justify-content: space-between; }

/* 테이블 */
.tbl { width: 100%; border-collapse: collapse; margin-top: 12px; }
.tbl th, .tbl td { padding: 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.tbl th { color: var(--muted); font-weight: 600; }
.tbl .txt { max-width: 340px; }
.nowrap { white-space: nowrap; }
.inline { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.actions { white-space: nowrap; }
.history-audio { margin-bottom: 16px; }
.hspeed { width: auto; }

/* 배지 */
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.active { background: #d1fae5; color: #065f46; }
.badge.suspended { background: #fee2e2; color: #991b1b; }
