/* 루미AI — 다크 픽셀 테마 */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #141420;
    --surface: #1e1e2e;
    --surface2: #28283c;
    --border: #3a3a52;
    --text: #eceaf4;
    --text-dim: #9a97b0;
    --accent: #7de3a0;
    --accent-dark: #4db878;
    --danger: #ff7089;
    --warn: #ffd166;
}

html, body { height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', 'Malgun Gothic', system-ui, sans-serif;
    font-size: 15px;
    overscroll-behavior: none;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ── 펫 화면 ── */
.pet-area {
    padding: 10px 14px 8px;
    background: linear-gradient(180deg, #1a1a2c, var(--bg));
    flex-shrink: 0;
}
.pet-topbar {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 6px;
}
.pet-name { font-weight: 700; font-size: 17px; }
.stage-label {
    font-size: 12px; background: var(--surface2);
    padding: 2px 8px; border-radius: 10px; color: var(--text-dim);
}
.conn-badge { margin-left: auto; font-size: 13px; }
.conn-badge.on { color: var(--accent); }
.conn-badge.off { color: var(--danger); }

.screen-frame {
    position: relative;
    display: flex; justify-content: center;
}
#game-canvas {
    width: min(264px, 62vw);
    aspect-ratio: 1;
    image-rendering: pixelated;
    border-radius: 14px;
    border: 3px solid var(--border);
    cursor: pointer;
    background: #000;
}
.pet-bubble {
    position: absolute;
    top: 6px; left: 50%; transform: translateX(-50%);
    background: #fff; color: #222;
    font-size: 13px; padding: 6px 12px;
    border-radius: 12px;
    max-width: 85%;
    box-shadow: 0 2px 8px rgba(0,0,0,.4);
    z-index: 5;
}
.pet-bubble::after {
    content: ''; position: absolute;
    bottom: -6px; left: 50%; transform: translateX(-50%);
    border: 6px solid transparent; border-top-color: #fff; border-bottom: 0;
}

/* 컴팩트: 대화·작업·음성·입력 중 펫 그래픽 접기 (화면 넓게) */
.pet-area.compact .screen-frame,
.pet-area.compact .growth-bar-wrap { display: none; }
.pet-area.compact { padding: 6px 14px; }
.pet-area.compact .pet-topbar { margin-bottom: 0; }

.growth-bar-wrap { margin-top: 8px; }
.growth-hint { font-size: 11px; color: var(--text-dim); margin-bottom: 3px; text-align: center; }
.growth-bar {
    height: 8px; background: var(--surface2);
    border-radius: 4px; overflow: hidden;
}
.growth-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--accent-dark), var(--accent));
    border-radius: 4px;
    transition: width .5s;
}

/* ── 탭 콘텐츠 ── */
#tab-content { flex: 1; overflow: hidden; display: flex; }
.tab-page { display: none; flex: 1; flex-direction: column; overflow-y: auto; padding: 12px 14px; }
.tab-page.active { display: flex; }

/* ── 채팅 ── */
#tab-home { padding: 0; }
.chat-log {
    flex: 1; overflow-y: auto;
    padding: 12px 14px;
    display: flex; flex-direction: column; gap: 8px;
}
.msg { display: flex; gap: 6px; max-width: 85%; }
.msg.user { align-self: flex-end; }
.msg.pet { align-self: flex-start; }
.msg-icon { font-size: 18px; flex-shrink: 0; }
.msg-text {
    padding: 8px 12px; border-radius: 14px;
    line-height: 1.45; word-break: break-word; white-space: pre-wrap;
}
.msg.user .msg-text { background: var(--accent-dark); color: #fff; border-bottom-right-radius: 4px; }
.msg.pet .msg-text { background: var(--surface2); border-bottom-left-radius: 4px; }
.msg.typing .msg-text { color: var(--text-dim); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .4; } }

.chat-mode-bar {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 14px 0;
    background: var(--surface);
    flex-wrap: wrap;
}
.mode-toggle {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 14px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
}
.mode-toggle.active {
    background: var(--accent-dark);
    border-color: var(--accent);
    color: #fff;
}
.mode-hint { font-size: 11px; color: var(--accent); }
.mode-select {
    background: var(--surface2); color: var(--text);
    border: 1px solid var(--border); border-radius: 14px;
    padding: 4px 8px; font-size: 12px; width: auto;
}
.md-h { display: block; margin: 6px 0 2px; color: var(--accent); }
.md-li { margin: 2px 0; }
.md-pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px; overflow-x: auto; font-size: 12px; margin: 5px 0; white-space: pre-wrap; }
.md-table { border-collapse: collapse; margin: 6px 0; font-size: 12px; display: block; overflow-x: auto; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.md-table th { background: var(--surface2); }
.msg-text code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.voice-status {
    padding: 6px 14px 0;
    font-size: 12px;
    background: var(--surface);
    color: var(--accent);
}
.voice-status.listening { color: #7de3a0; }
.voice-status.thinking { color: var(--warn); }
.voice-status.speaking { color: #9ad7f7; }
#voice-toggle.active { background: #c0392b; border-color: #e2707f; color: #fff; }
.agent-actions {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-dim);
    border-top: 1px dashed var(--border);
    padding-top: 5px;
    line-height: 1.5;
}
.agent-files { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.file-dl {
    background: var(--accent-dark);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.file-dl:hover { filter: brightness(1.1); }
.file-dl:disabled { opacity: .7; }
.msg-pdf {
    display: inline-block; margin-top: 8px;
    background: transparent; border: 1px solid var(--accent-dark);
    color: var(--accent); border-radius: 10px;
    padding: 5px 10px; font-size: 12px; cursor: pointer;
}
.msg-pdf:hover { background: var(--surface2); }
.msg-pdf:disabled { opacity: .7; }

.chat-input-row {
    display: flex; gap: 8px; padding: 10px 14px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.chat-input-row input {
    flex: 1;
}

/* ── 공용 입력 ── */
input[type=text], input[type=password], textarea, select {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent-dark); }
label { display: block; font-size: 13px; margin: 12px 0 5px; color: var(--text); font-weight: 600; }
.label-sub { font-weight: 400; color: var(--text-dim); font-size: 11px; }

/* ── 버튼 ── */
.btn {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: filter .15s;
}
.btn:hover { filter: brightness(1.2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; font-weight: 600; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.wide { width: 100%; margin-top: 14px; }

/* ── 학습 탭 ── */
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.section-head h2 { font-size: 17px; }
h2 { font-size: 18px; margin-bottom: 8px; }
h3 { font-size: 14px; margin-bottom: 4px; color: var(--accent); }

.review-banner {
    background: #3a3320;
    border: 1px solid var(--warn);
    color: var(--warn);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 10px;
}

.knowledge-list { display: flex; flex-direction: column; gap: 10px; }
.k-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}
.k-card.learned { border-color: var(--accent-dark); }
.k-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; }
.k-status { color: var(--text-dim); }
.k-score { color: var(--accent); font-weight: 700; }
.k-title { font-weight: 700; margin-bottom: 3px; }
.k-preview { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; line-height: 1.4; }
.k-actions { display: flex; gap: 6px; }

.empty-text, .hint-text {
    color: var(--text-dim); font-size: 12.5px; line-height: 1.6;
    text-align: center; padding: 12px 4px;
}
.hint-text { text-align: left; }
.hint-text code {
    background: var(--surface2); padding: 1px 5px; border-radius: 4px;
    font-size: 11px;
}

/* ── 설정 ── */
.settings-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}
.settings-group label:first-of-type { margin-top: 8px; }
.row-inline { display: flex; gap: 8px; align-items: center; }
.row-inline select { flex: 1; }
.fix-list { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.fix-item { display: flex; justify-content: space-between; align-items: center; background: var(--surface2); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.fix-del { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 14px; }
#fix-from, #fix-to { flex: 1; min-width: 0; }
.conn-result { font-size: 12.5px; margin-top: 8px; color: var(--text-dim); line-height: 1.5; }
.version-text { text-align: center; color: var(--text-dim); font-size: 11px; margin: 14px 0 6px; }

/* ── 탭바 ── */
.tabbar {
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
    flex: 1;
    background: none; border: none;
    color: var(--text-dim);
    font-size: 20px;
    padding: 8px 0 6px;
    cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    position: relative;
}
.tab-badge {
    position: absolute;
    top: 4px; right: calc(50% - 22px);
    background: var(--danger);
    color: #fff;
    font-size: 10px; font-weight: 700;
    min-width: 16px; height: 16px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
}
.tab-btn span { font-size: 10px; }
.tab-btn.active { color: var(--accent); }
.tab-btn.quit-btn { color: var(--text-dim); }
.tab-btn.quit-btn:active { color: var(--danger); }

/* ── 모달 ── */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.65);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    padding: 16px;
}
.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%; max-width: 440px;
    max-height: 86dvh;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.modal-title { font-weight: 700; font-size: 16px; padding: 14px 16px 0; }
.modal-body { padding: 10px 16px; overflow-y: auto; flex: 1; }
.modal-actions { display: flex; gap: 8px; padding: 12px 16px 16px; justify-content: flex-end; }

/* ── 시험 ── */
.exam-progress { text-align: center; padding: 26px 0; color: var(--text-dim); line-height: 1.7; }
.spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--surface2);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.approve-card {
    background: var(--surface2);
    border-radius: 10px;
    padding: 10px;
    margin: 10px 0;
    font-size: 13px;
}
.approve-check { font-size: 13px; margin: 0 0 6px; color: var(--accent); }
.approve-check input { width: auto; margin-right: 4px; }
.qa-q { margin-bottom: 5px; line-height: 1.45; }
.qa-ans { color: var(--text-dim); font-size: 12.5px; line-height: 1.45; }
.qa-feedback { color: var(--warn); font-size: 12px; margin: 4px 0; }
.qa-model-label { font-size: 12px; margin: 6px 0 3px; }
.qa-model { font-size: 12.5px; }

.exam-result h3 { color: var(--text); text-align: center; margin: 6px 0 12px; }
.score-compare { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 10px; }
.score-box {
    background: var(--surface2); border-radius: 12px;
    padding: 10px 18px; text-align: center;
}
.score-box.good { border: 1px solid var(--accent); }
.score-label { display: block; font-size: 11px; color: var(--text-dim); }
.score-num { font-size: 22px; font-weight: 800; }
.score-box.good .score-num { color: var(--accent); }
.score-arrow { font-size: 20px; color: var(--text-dim); }
.score-diff { text-align: center; font-size: 13.5px; margin: 8px 0 12px; line-height: 1.5; }
.qa-review {
    background: var(--surface2); border-radius: 10px;
    padding: 10px; margin: 8px 0; font-size: 13px; line-height: 1.55;
}
.qa-score { color: var(--accent); font-size: 12.5px; }
.error-text { color: var(--danger); text-align: center; padding: 20px 0; line-height: 1.6; }

/* ── 토스트/배너 ── */
.toast {
    position: fixed;
    bottom: 76px; left: 50%; transform: translateX(-50%);
    background: #000c; color: #fff;
    padding: 10px 18px; border-radius: 12px;
    font-size: 13.5px;
    z-index: 200;
    max-width: 88vw;
    text-align: center;
}
.update-banner {
    position: fixed;
    top: 10px; left: 50%; transform: translateX(-50%);
    background: var(--surface); border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 8px 14px;
    display: flex; align-items: center; gap: 10px;
    font-size: 13px;
    z-index: 300;
}

/* ── 로그인/가입 화면 (P2) ── */
.auth-screen {
    position: fixed; inset: 0; z-index: 2000; overflow-y: auto;
    background: linear-gradient(180deg, #1a1a2c, var(--bg));
    padding: 32px 18px 40px;
    display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.auth-card {
    width: 100%; max-width: 360px; box-sizing: border-box;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 20px; padding: 26px 22px; text-align: center;
    box-shadow: 0 12px 40px rgba(0,0,0,.4);
}
.auth-logo { font-size: 26px; font-weight: 800; }
.auth-sub { color: var(--text-dim); font-size: 13px; margin: 6px 0 18px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tab {
    flex: 1; padding: 10px; border-radius: 12px; cursor: pointer;
    background: var(--surface2); color: var(--text-dim);
    border: 1px solid var(--border); font-size: 14px;
}
.auth-tab.active { background: var(--accent-dark); color: #fff; border-color: var(--accent-dark); }
#auth-form { display: flex; flex-direction: column; gap: 10px; }
#auth-form input {
    padding: 13px 14px; border-radius: 12px; font-size: 15px;
    background: var(--bg); color: var(--text); border: 1px solid var(--border);
}
#auth-form input:focus { outline: none; border-color: var(--accent); }
.auth-msg { min-height: 18px; font-size: 13px; color: var(--warn); margin-top: 2px; }
.auth-hint { color: var(--text-dim); font-size: 12px; margin-top: 14px; line-height: 1.6; }

/* 계정 버튼 (상단) */
.acct-btn {
    margin-left: auto; background: var(--surface2); color: var(--text);
    border: 1px solid var(--border); border-radius: 50%;
    width: 30px; height: 30px; cursor: pointer; font-size: 15px;
}

/* ── 관리자: 회원관리 ── */
.admin-users { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.urow {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 10px 12px; flex-wrap: wrap;
}
.uinfo { font-size: 14px; line-height: 1.5; }
.umeta { color: var(--text-dim); font-size: 12px; }
.uacts { display: flex; gap: 6px; flex-wrap: wrap; }
.ustat { font-size: 11px; padding: 2px 7px; border-radius: 8px; margin-left: 4px; }
.ustat.pend { background: rgba(255,209,102,.2); color: var(--warn); }
.ustat.ok { background: rgba(125,227,160,.18); color: var(--accent); }
.ustat.block { background: rgba(255,112,137,.18); color: var(--danger); }

/* 비밀번호 미리보기 토글 */
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { flex: 1; padding-right: 44px !important; }
.pw-toggle {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; font-size: 17px;
    padding: 4px 6px; line-height: 1;
}

/* ── 참고 판례 목록 + 전문 모달 (P: 판례 브라우저) ── */
.hits { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 6px; }
.hits summary { cursor: pointer; font-size: 12.5px; color: var(--accent); font-weight: 600; padding: 3px 0; }
.hit-item {
    display: block; width: 100%; text-align: left; margin: 4px 0;
    background: var(--surface2); border: 1px solid var(--border); border-radius: 9px;
    padding: 8px 10px; cursor: pointer; font-size: 12.5px; color: var(--text); line-height: 1.4;
}
.hit-item:hover { border-color: var(--accent); }
.hit-dom { display: inline-block; background: var(--accent-dark); color: #fff; font-size: 10.5px;
    padding: 1px 6px; border-radius: 7px; margin-right: 4px; }
.hit-meta { color: var(--text-dim); font-size: 11px; }
.doc-meta { color: var(--text-dim); font-size: 12.5px; margin-bottom: 6px; }
.doc-refs { background: var(--surface2); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; margin-bottom: 8px; }
.doc-body { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.7;
    max-height: 55vh; overflow-y: auto; background: var(--bg); border: 1px solid var(--border);
    border-radius: 10px; padding: 12px; }

/* 보고서 다듬기 버튼 */
.msg-polish {
    display: inline-block; margin: 6px 6px 0 0; padding: 5px 10px; font-size: 12px;
    background: linear-gradient(90deg, #7de3a0, #4db8e8); color: #10261a; font-weight: 700;
    border: none; border-radius: 8px; cursor: pointer;
}
.msg-polish:disabled { opacity: .6; cursor: default; }

/* 로그인 화면 상품안내 + 사업자정보 푸터 (전자상거래 고지) */
.auth-product { margin-top: 16px; text-align: left; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px; box-sizing: border-box; }
.auth-product h3 { margin: 0 0 5px; font-size: 12.5px; }
.auth-product > p { margin: 3px 0; font-size: 11.5px; }
.auth-product ul { margin: 5px 0; padding-left: 16px; }
.auth-product li { font-size: 11px; color: var(--text-dim); line-height: 1.55; margin: 1px 0; }
.auth-small { font-size: 10.5px; color: var(--text-dim); margin-top: 6px; line-height: 1.55; }
.auth-footer { width: 100%; max-width: 360px; box-sizing: border-box; text-align: center; padding-top: 4px; }
.af-links { font-size: 12.5px; margin-bottom: 10px; }
.af-links a { color: var(--accent); text-decoration: none; }
.af-biz { font-size: 11px; color: var(--text-dim); line-height: 1.7; }

/* 충전/구독 모달 */
.buy-list { display: flex; flex-direction: column; gap: 8px; }
.buy-item { text-align: left; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px; cursor: pointer; color: var(--text); }
.buy-item:hover { border-color: var(--accent); }
.buy-item.hot { border-color: var(--accent-dark); background: rgba(77,184,120,.12); }
.buy-item b { font-size: 14px; } .buy-item span { display: block; font-size: 11.5px; color: var(--text-dim); margin-top: 3px; }
.buy-note { font-size: 11px; color: var(--text-dim); margin-top: 10px; line-height: 1.6; }
