:root {
  --bg: #05060d;
  --bg-2: #0b0d1a;
  --card: rgba(18, 21, 40, 0.72);
  --line: rgba(140, 160, 255, 0.14);
  --text: #eef0ff;
  --text-2: #a9aecb;
  --muted: #6f7596;
  --accent: #7c8cff;
  --accent-2: #4fe3c1;
  --warn: #ffb547;
  --bad: #ff6b81;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.4em; margin: 0; font-size: 13px; }

#stars { position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(1px 1px at 23px 41px, rgba(255, 255, 255, 0.55), transparent 60%) 0 0 / 173px 173px,
    radial-gradient(1px 1px at 97px 13px, rgba(200, 210, 255, 0.45), transparent 60%) 0 0 / 211px 211px,
    radial-gradient(1.5px 1.5px at 61px 127px, rgba(190, 255, 240, 0.4), transparent 60%) 0 0 / 307px 307px,
    radial-gradient(1px 1px at 151px 89px, rgba(255, 255, 255, 0.3), transparent 60%) 0 0 / 257px 257px,
    radial-gradient(1200px 700px at 75% -10%, rgba(92, 80, 255, 0.18), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(40, 200, 180, 0.12), transparent 60%),
    var(--bg); }

/* 로그인 */
.login { position: fixed; inset: 0; display: grid; place-items: center; z-index: 10; padding: 16px; }
.login-card { width: min(360px, 100%); padding: 36px 28px; text-align: center; background: var(--card);
  border: 1px solid var(--line); border-radius: 24px; backdrop-filter: blur(18px); }
.login-card h1 { margin: 18px 0 2px; letter-spacing: 0.04em; font-weight: 700; }
.login-card input { width: 100%; margin: 22px 0 10px; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35); color: var(--text); font-size: 16px; outline: none; }
.login-card input:focus { border-color: var(--accent); }
.login-card button { width: 100%; padding: 12px; border: 0; border-radius: 12px; font-weight: 600;
  background: linear-gradient(135deg, #6c7bff, #4fe3c1); color: #05060d; }
.orb, .hero-orb { width: 64px; height: 64px; margin: 0 auto; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #9aa6ff 25%, #5d4cff 55%, #1b1650 80%);
  box-shadow: 0 0 40px rgba(124, 140, 255, 0.7), 0 0 90px rgba(79, 227, 193, 0.25);
  animation: breathe 4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.06); box-shadow: 0 0 60px rgba(124, 140, 255, 0.9), 0 0 120px rgba(79, 227, 193, 0.35); } }

/* 위 막대 */
#app { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 14px; padding: 10px 18px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); background: rgba(5, 6, 13, 0.6); backdrop-filter: blur(14px); z-index: 5; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 18px; letter-spacing: 0.03em; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 12px var(--accent-2);
  animation: breathe 2.4s ease-in-out infinite; }
.stage-chip { padding: 3px 10px; border-radius: 999px; font-size: 13px; color: var(--text-2);
  border: 1px solid var(--line); background: rgba(124, 140, 255, 0.08); white-space: nowrap; }
.xp-mini { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.xp-mini-bar { width: 90px; height: 5px; border-radius: 9px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.xp-mini-bar i, .xp-bar i { display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, #6c7bff, #4fe3c1); transition: width 0.8s ease; }
.tabs { margin-left: auto; display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); }
.tabs button { border: 0; background: none; padding: 6px 14px; border-radius: 9px; color: var(--text-2); }
.tabs button.on { background: rgba(124, 140, 255, 0.18); color: var(--text); }
.live { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.live.on i { background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }

.tab { display: none; flex: 1; min-height: 0; position: relative; }
.tab.on { display: block; }
.tab.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 22px 16px 90px; display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
  backdrop-filter: blur(12px); min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--text-2); letter-spacing: 0.02em; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* 뉴런 */
#graph { position: absolute; inset: 0; }
.hud { position: absolute; top: 14px; left: 16px; display: grid; gap: 10px; z-index: 2; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-stats { display: flex; gap: 18px; }
.hud-stats div { display: flex; flex-direction: column; }
.hud-stats b { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hud-stats span { font-size: 12px; color: var(--muted); }
.search { width: 200px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(5, 6, 13, 0.6); color: var(--text); outline: none; font-size: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 10px; max-width: 260px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; }
.feed { position: absolute; left: 16px; bottom: 18px; display: grid; gap: 6px; z-index: 2; max-width: min(420px, calc(100% - 32px)); }
.feed div { padding: 7px 12px; border-radius: 10px; font-size: 13px; background: rgba(12, 14, 30, 0.78);
  border: 1px solid var(--line); animation: rise 0.4s ease; }
.feed b { color: var(--accent-2); font-weight: 600; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted);
  pointer-events: none; }
.panel { position: absolute; top: 12px; right: 12px; bottom: 12px; width: 360px; max-width: calc(100% - 24px); z-index: 3;
  background: rgba(12, 14, 30, 0.88); border: 1px solid var(--line); border-radius: 18px; backdrop-filter: blur(16px);
  padding: 20px; overflow-y: auto; transform: translateX(120%); visibility: hidden;
  transition: transform 0.3s ease, visibility 0s linear 0.3s; }
.panel.open { transform: none; visibility: visible; transition: transform 0.3s ease; }
.panel .close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 24px; color: var(--muted); }
.panel h2 { margin: 4px 0 2px; font-size: 22px; }
.kind { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.kind i { width: 9px; height: 9px; border-radius: 50%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.chip { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); border-radius: 999px; padding: 3px 10px;
  font-size: 13px; }
.chip small { color: var(--muted); margin-left: 4px; }
.mem { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.mem .meta { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.tag { display: inline-block; padding: 0 7px; border-radius: 6px; font-size: 11px; margin-right: 6px;
  background: rgba(124, 140, 255, 0.15); color: var(--text-2); }
.tag.teaching { background: rgba(255, 181, 71, 0.15); color: var(--warn); }

/* 성장 */
.hero-stage { display: flex; align-items: center; gap: 18px; }
.hero-orb { margin: 0; flex: none; }
.hero h2 { margin: 0; font-size: 28px; }
.hero p { margin: 2px 0 0; }
.xp-bar { height: 10px; margin: 18px 0 6px; border-radius: 9px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.xp-text { display: flex; justify-content: space-between; font-size: 13px; font-variant-numeric: tabular-nums; }
.ladder { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0 0; padding: 0; }
.ladder li { padding: 10px; border-radius: 12px; border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.ladder li b { display: block; font-size: 14px; color: var(--text-2); }
.ladder li.done { border-color: rgba(79, 227, 193, 0.35); }
.ladder li.now { border-color: var(--accent); background: rgba(124, 140, 255, 0.1); color: var(--text-2); }
.ladder li.now b { color: var(--text); }
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.tile span { font-size: 12px; color: var(--muted); }
.tile b { display: block; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.chart { position: relative; height: 220px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.list li:first-child { border-top: 0; }
.list .t { color: var(--muted); font-size: 12px; min-width: 88px; font-variant-numeric: tabular-nums; }
.list .grow { flex: 1; min-width: 0; word-break: break-word; }
.list .plus { color: var(--accent-2); font-variant-numeric: tabular-nums; }
.list .minus { color: var(--bad); font-variant-numeric: tabular-nums; }
.list .done { text-decoration: line-through; color: var(--muted); }
.list .empty-row { color: var(--muted); }

/* 일기 */
.diary-day { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.diary-day h3 { margin: 0; color: var(--text); font-size: 16px; }
.scores { display: flex; gap: 6px; flex-wrap: wrap; }
.score { font-size: 12px; padding: 2px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.05); color: var(--text-2); }
.score b { color: var(--text); }
.diary-text { white-space: pre-wrap; margin: 12px 0 0; line-height: 1.75; }
.teacher { margin-top: 12px; padding: 10px 12px; border-left: 2px solid var(--warn); background: rgba(255, 181, 71, 0.06);
  border-radius: 0 10px 10px 0; font-size: 14px; color: var(--text-2); }

.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 20; padding: 12px 18px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(108, 123, 255, 0.95), rgba(79, 227, 193, 0.95)); color: #05060d; font-weight: 600;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); max-width: calc(100% - 32px); }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; backdrop-filter: none; background: rgba(5, 6, 13, 0.92); }
  .xp-mini { display: none; }
  .live span { display: none; }
  .tabs { position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); margin: 0; z-index: 6;
    justify-content: space-around; background: rgba(12, 14, 30, 0.9); border: 1px solid var(--line); backdrop-filter: blur(14px);
    padding: 5px; border-radius: 16px; }
  .tabs button { flex: 1; padding: 9px 0; }
  .live { margin-left: auto; }
  .panel { top: auto; left: 8px; right: 8px; bottom: 76px; width: auto; max-width: none; max-height: 62%;
    transform: translateY(calc(100% + 120px)); }
  .feed { bottom: 80px; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .two { grid-template-columns: 1fr; }
  .ladder { grid-template-columns: repeat(2, 1fr); }
  .search { width: 150px; }
  .legend { max-width: 200px; }
}
.g-label { padding: 6px 10px; border-radius: 10px; background: rgba(12, 14, 30, 0.9); border: 1px solid var(--line);
  font: 13px/1.4 -apple-system, "Apple SD Gothic Neo", sans-serif; color: var(--text); }
.g-label small { color: var(--muted); }
.scene-tooltip { pointer-events: none; }
.g-names { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.g-names span { position: absolute; left: 0; top: 0; font-size: 12px; color: var(--text-2); white-space: nowrap;
  text-shadow: 0 0 6px #000, 0 0 2px #000; transition: color 0.3s; will-change: transform; }
.g-names span.lit { color: #fff; font-weight: 600; text-shadow: 0 0 10px rgba(79, 227, 193, 0.9), 0 0 2px #000; }
.g-names span.dim { opacity: 0.08 !important; }

/* 메일 */
.mail-status { font-size: 14px; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 6px 14px; }
.mail-status b { color: var(--text); }
.mail-status .bad { color: var(--bad); }
.mail-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.mail-head h3 { margin: 0; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button, .more, .btn { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); border-radius: 9px; padding: 4px 10px;
  font-size: 13px; color: var(--text-2); }
.seg button.on { background: rgba(124, 140, 255, 0.18); color: var(--text); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.mail-sum { white-space: pre-wrap; word-break: break-word; font: 14px/1.6 -apple-system, "Apple SD Gothic Neo", sans-serif; margin: 0;
  color: var(--text-2); }
.mail-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.mail-filters select { padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(5, 6, 13, 0.6);
  color: var(--text); font-size: 14px; max-width: 100%; }
.mail-filters .search { flex: 1; min-width: 160px; }
.mail-list li { cursor: pointer; align-items: flex-start; }
.mail-list li:hover { background: rgba(255, 255, 255, 0.02); }
.mail-list .from { font-weight: 600; }
.mail-list .sum { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; margin-right: 4px; vertical-align: 1px;
  background: rgba(124, 140, 255, 0.15); color: var(--text-2); white-space: nowrap; }
.badge.imp { background: rgba(255, 107, 129, 0.18); color: var(--bad); }
.badge.reply { background: rgba(255, 181, 71, 0.18); color: var(--warn); }
.badge.done { background: rgba(79, 227, 193, 0.14); color: var(--accent-2); }
.draft { border-top: 1px solid var(--line); padding: 12px 0; }
.draft:first-child { border-top: 0; }
.draft pre { white-space: pre-wrap; word-break: break-word; font: 14px/1.6 -apple-system, "Apple SD Gothic Neo", sans-serif;
  background: rgba(0, 0, 0, 0.25); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.draft .actions { display: flex; gap: 8px; }
.mail-body { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.6; max-height: 60vh; overflow: auto;
  background: rgba(0, 0, 0, 0.2); border-radius: 10px; padding: 12px; margin-top: 10px; }
.meta-grid { font-size: 13px; color: var(--text-2); display: grid; gap: 2px; }
.more { margin-top: 10px; width: 100%; }

/* 대화 (뉴런 화면): PC 오른쪽 패널, 휴대폰 아래 시트 */
.logout { border: 1px solid var(--line); background: none; border-radius: 9px; padding: 4px 10px; font-size: 12px; color: var(--muted); }
.chat { position: absolute; top: 12px; right: 12px; bottom: 12px; width: 380px; z-index: 3; display: none; flex-direction: column;
  background: rgba(12, 14, 30, 0.86); border: 1px solid var(--line); border-radius: 18px; backdrop-filter: blur(16px); overflow: hidden; }
.chat-open .chat { display: flex; }
.chat-open .chat-fab { display: none; }
.chat-open .panel { right: 404px; }
.chat-fab { position: absolute; right: 18px; bottom: 18px; z-index: 3; width: 52px; height: 52px; border-radius: 50%; font-size: 22px;
  border: 1px solid var(--line); background: linear-gradient(135deg, rgba(108, 123, 255, 0.9), rgba(79, 227, 193, 0.9));
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); }
.chat-head { display: flex; align-items: baseline; gap: 8px; padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
.chat-head span { font-size: 12px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-x { border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1; padding: 0 2px; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.chat-empty { color: var(--muted); font-size: 13px; text-align: center; margin: auto 8px; line-height: 1.7; }
.msg { display: flex; flex-direction: column; max-width: 88%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.ai { align-self: flex-start; }
.msg .b { padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.55; word-break: break-word; }
.msg.me .b { background: rgba(124, 140, 255, 0.28); border-bottom-right-radius: 4px; }
.msg.ai .b { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .fb { display: flex; gap: 2px; align-items: center; margin-top: 3px; }
.msg .fb .t { font-size: 11px; color: var(--muted); margin-right: 4px; }
.msg .fb button { border: 0; background: none; font-size: 13px; padding: 2px 5px; border-radius: 7px; opacity: 0.45; filter: grayscale(1); }
.msg .fb button:hover { opacity: 0.8; }
.msg .fb button.on { opacity: 1; filter: none; background: rgba(124, 140, 255, 0.18); }
.thinking { margin-bottom: 5px; font-size: 12px; color: var(--text-2); border-left: 2px solid rgba(79, 227, 193, 0.5); padding-left: 8px; }
.thinking summary { cursor: pointer; color: var(--accent-2); list-style: none; }
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary::before { content: '▸ '; }
.thinking[open] summary::before { content: '▾ '; }
.thinking ol, .live-steps { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 3px; }
.thinking li { display: flex; gap: 6px; line-height: 1.45; }
.thinking .si { flex: none; }
.srcs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.srcs a { font-size: 11px; color: var(--text-2); text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; }
.srcs a:hover { color: var(--text); border-color: var(--accent); }
.live-steps li { font-size: 12px; color: var(--text-2); margin-bottom: 2px; animation: rise 0.3s ease; }
.typing { display: flex; gap: 4px; align-items: center; height: 34px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-2); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; resize: none; max-height: 140px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35); color: var(--text); font: 15px/1.4 inherit; font-family: inherit; outline: none; overflow-y: hidden; }
.chat-form textarea:focus { border-color: var(--accent); }
.chat-form button { flex: none; width: 38px; height: 38px; border-radius: 50%; border: 0; font-size: 18px; font-weight: 700;
  background: linear-gradient(135deg, #6c7bff, #4fe3c1); color: #05060d; }
.chat-form button:disabled { opacity: 0.4; }
@media (max-width: 760px) {
  .chat { top: auto; left: 8px; right: 8px; bottom: 76px; width: auto; height: 58%; }
  .chat-open .panel { right: 8px; z-index: 4; }
  .chat-fab { bottom: 84px; right: 14px; }
  .chat-open .feed { display: none; }
  .chat-form textarea { font-size: 16px; } /* iOS 확대 막기 */
}
