/* EIMS — 교육환경 지능화 관제 시스템 */
:root {
  --bg: #0b0d12; --bg2: #11141b; --card: #161a23; --card2: #1c212c; --line: #262c3a; --line2: #313849;
  --text: #e9ecf2; --dim: #9aa3b5; --mute: #6b7488;
  --accent: #ffb300; --accent2: #ff8a00; --teal: #2dd4bf; --blue: #60a5fa; --red: #f43f5e; --violet: #a78bfa; --green: #34d399;
  --grad: linear-gradient(135deg, #ffb300 0%, #ff7a00 55%, #ff4d6d 100%);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35); --r: 16px; --r2: 12px;
  --side: 232px; --top: 56px; --tab: 64px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f6f9; --bg2: #eceff4; --card: #ffffff; --card2: #f6f7fa; --line: #e3e6ee; --line2: #d4d9e3;
  --text: #141822; --dim: #586176; --mute: #8a93a6; --shadow: 0 8px 24px rgba(20, 24, 34, .08); color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f6f9; --bg2: #eceff4; --card: #ffffff; --card2: #f6f7fa; --line: #e3e6ee; --line2: #d4d9e3;
    --text: #141822; --dim: #586176; --mute: #8a93a6; --shadow: 0 8px 24px rgba(20, 24, 34, .08); color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, .tn { font-variant-numeric: tabular-nums; }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }

/* ── 셸 ── */
#app { min-height: 100%; }
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 18px 14px; border-right: 1px solid var(--line); background: var(--bg2); display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(255, 140, 0, .35); }
.brand .logo svg { width: 20px; height: 20px; }
.brand b { font-size: 17px; letter-spacing: .5px; }
.brand small { display: block; color: var(--dim); font-size: 11px; margin-top: -2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--dim); font-weight: 600; transition: background .15s, color .15s; }
.nav a svg { width: 19px; height: 19px; flex: none; }
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.on { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.side .foot { margin-top: auto; color: var(--mute); font-size: 11.5px; padding: 8px; line-height: 1.6; }
.main { min-width: 0; padding: 22px 26px 40px; }
.topbar { display: none; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 30; height: calc(var(--top) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 14px 0;
    align-items: center; gap: 10px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
  .topbar .brand { padding: 0; }
  .topbar .brand .logo { width: 28px; height: 28px; border-radius: 8px; }
  .topbar h1 { font-size: 16px; margin: 0; flex: 1; }
  .main { padding: 14px 14px calc(var(--tab) + 24px + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; height: calc(var(--tab) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--bg2) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--mute); font-size: 10.5px; font-weight: 600; }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--accent); }
}

/* ── 공용 ── */
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 2px 0 18px; flex-wrap: wrap; }
.page-h h2 { margin: 0; font-size: 22px; letter-spacing: -.3px; }
.page-h p { margin: 2px 0 0; color: var(--dim); font-size: 13px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 1180px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .g3, .g2 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } .page-h h2 { font-size: 19px; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--dim); font-weight: 700; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.card h3 .sub { font-weight: 500; font-size: 12px; color: var(--mute); }
.muted { color: var(--dim); } .mute { color: var(--mute); } .small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; } .wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; } .end { justify-content: flex-end; }
.sep { height: 1px; background: var(--line); margin: 12px 0; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line2); background: var(--card2); cursor: pointer; font-weight: 600; font-size: 13px; text-decoration: none; transition: border-color .15s, background .15s, transform .05s; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.pri { background: var(--grad); border: 0; color: #1a1205; }
.btn.ghost { background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn svg { width: 16px; height: 16px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.input, select.input, textarea.input { height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line2); background: var(--bg2); outline: none; min-width: 0; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
select.input { padding-right: 28px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line2); background: transparent; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--dim); white-space: nowrap; }
.chip.on { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: color-mix(in srgb, var(--accent) 60%, transparent); color: var(--accent); }
.chip .n { font-size: 11px; opacity: .8; }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 6px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.b-new { background: color-mix(in srgb, var(--teal) 18%, transparent); color: var(--teal); }
.b-closed { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }
.b-changed { background: color-mix(in srgb, var(--violet) 18%, transparent); color: var(--violet); }
.b-planned { background: color-mix(in srgb, var(--blue) 18%, transparent); color: var(--blue); }
.b-recoded, .b-code_assigned, .b-reopened { background: color-mix(in srgb, var(--mute) 22%, transparent); color: var(--dim); }
.b-school { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
.b-aca { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.b-tut { background: color-mix(in srgb, var(--accent2) 14%, transparent); color: #ffa24d; }

/* ── 히어로 ── */
.hero { position: relative; overflow: hidden; border-radius: 20px; padding: 22px 22px 20px; margin-bottom: 14px; border: 1px solid var(--line);
  background: radial-gradient(1200px 300px at 0% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
              radial-gradient(800px 300px at 100% 0%, color-mix(in srgb, #ff4d6d 16%, transparent), transparent 60%), var(--card); }
.hero .k { color: var(--dim); font-size: 12.5px; font-weight: 600; }
.hero h2 { margin: 4px 0 6px; font-size: 24px; letter-spacing: -.4px; line-height: 1.3; }
.hero h2 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .brief { color: var(--text); opacity: .92; max-width: 960px; line-height: 1.7; }
/* 마크다운 본문(브리핑·AI 대화) */
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: .45em 0; } .md ul, .md ol { margin: .4em 0; padding-left: 1.3em; } .md li { margin: .15em 0; }
.md h2, .md h3, .md h4, .md h5 { margin: .9em 0 .35em; line-height: 1.35; } .md h2 { font-size: 1.15em; } .md h3 { font-size: 1.05em; } .md h4, .md h5 { font-size: 1em; }
.md strong { color: var(--text); } .md em { color: var(--dim); }
.md code { padding: 1px 6px; border-radius: 6px; background: color-mix(in srgb, var(--text) 9%, transparent); font-size: .92em; }
.md pre { padding: 10px 12px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); overflow: auto; } .md pre code { padding: 0; background: none; }
.md blockquote { margin: .5em 0; padding: 6px 12px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); border-radius: 0 8px 8px 0; color: var(--dim); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: .8em 0; }
.md table { border-collapse: collapse; margin: .5em 0; font-size: .93em; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; white-space: nowrap; } .md th { background: color-mix(in srgb, var(--text) 5%, transparent); }
.md a { color: var(--accent); }
.md .ltnc-mermaid { margin: 10px 0; overflow-x: auto; text-align: center; padding: 8px; border-radius: 12px; background: color-mix(in srgb, var(--text) 3%, transparent); }
.md .ltnc-mermaid svg { max-width: min(100%, 680px) !important; max-height: 380px; height: auto; }
.md .ltnc-mermaid[data-state="pending"] .ltnc-mermaid-out::after, .md .ltnc-mermaid[data-state="running"] .ltnc-mermaid-out::after { content: "다이어그램 그리는 중…"; color: var(--mute); font-size: 12px; }
.hero .meta { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--dim); font-size: 12px; font-weight: 600; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }
.pill.warn .dot { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

/* ── KPI ── */
.kpi { position: relative; overflow: hidden; }
.kpi .l { color: var(--dim); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 28px; font-weight: 800; letter-spacing: -.8px; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 14px; font-weight: 700; color: var(--dim); margin-left: 3px; }
.kpi .d { font-size: 12px; font-weight: 700; display: flex; gap: 8px; flex-wrap: wrap; }
.up { color: var(--teal); } .down { color: var(--red); } .flat { color: var(--dim); }
.kpi svg.spark { position: absolute; right: 12px; top: 14px; width: 38%; height: 34px; opacity: .9; }
@media (max-width: 860px) { .kpi svg.spark { width: 34%; height: 26px; opacity: .7; } .kpi .v { font-size: 24px; } }

/* ── 차트 ── */
.chart { width: 100%; display: block; }
.chart text { fill: var(--mute); font-size: 10.5px; font-family: var(--font); }
.chart .grid line { stroke: var(--line); }
.chart text.ax-minor { font-size: 9px; fill: var(--mute); }
.chart text.ax-major { font-size: 10px; font-weight: 800; fill: var(--dim); }
.chart line.ax-sep { stroke: var(--line2); stroke-dasharray: 2 3; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--dim); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hbars { display: grid; gap: 7px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 38%) 1fr auto; align-items: center; gap: 10px; font-size: 12.5px; cursor: default; }
.hbar.lk { cursor: pointer; }
.hbar.lk:hover .lbl { color: var(--accent); }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .bar { height: 8px; border-radius: 4px; background: var(--bg2); overflow: hidden; }
.hbar .bar i { display: block; height: 100%; border-radius: 4px; background: var(--grad); }
.hbar .bar.neg i { background: linear-gradient(90deg, #f43f5e, #fb7185); }
.hbar .val { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

/* ── 목록 ── */
.list { display: grid; gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--r2); background: var(--card); border: 1px solid var(--line); cursor: pointer; transition: border-color .15s, transform .15s; min-width: 0; }
.item:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.item .t { font-weight: 700; display: flex; align-items: center; gap: 8px; min-width: 0; }
.item .t span.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { color: var(--dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .r { margin-left: auto; text-align: right; flex: none; }
.day-h { position: sticky; top: calc(var(--top) * 0); z-index: 5; display: flex; align-items: center; gap: 10px; margin: 16px 0 8px; font-weight: 800; font-size: 13px; color: var(--dim); }
@media (max-width: 860px) { .day-h { top: calc(var(--top) + env(safe-area-inset-top)); } }
.day-h::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.day-h span { padding: 3px 10px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); }

.score { --p: 50; width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; font-size: 13px;
  background: radial-gradient(closest-side, var(--card) 76%, transparent 78% 100%), conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line) 0); }
.score.hi { background: radial-gradient(closest-side, var(--card) 76%, transparent 78% 100%), conic-gradient(#ff5e3a calc(var(--p) * 1%), var(--line) 0); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: right; color: var(--mute); font-weight: 700; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--card); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td { text-align: right; padding: 8px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.lk { cursor: pointer; }
.tbl tr.lk:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.tbl th.on { color: var(--accent); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl-wrap { max-height: 560px; overflow: auto; }

/* ── 필터 바 ── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input { height: 34px; }
@media (max-width: 860px) { .filters .input { flex: 1 1 140px; } }

/* ── 드로어 ── */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 60; opacity: 0; transition: opacity .2s; pointer-events: none; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); z-index: 61; background: var(--bg2); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  transform: translateX(105%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column; }
.drawer.on { transform: none; }
.drawer .dh { display: flex; align-items: center; gap: 10px; padding: calc(14px + env(safe-area-inset-top)) 16px 12px; border-bottom: 1px solid var(--line); }
.drawer .db { padding: 16px; overflow: auto; flex: 1; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
@media (max-width: 860px) {
  .drawer { top: auto; left: 0; width: 100vw; height: 88vh; border-radius: 20px 20px 0 0; border-left: 0; border-top: 1px solid var(--line); transform: translateY(105%); }
  .drawer .dh { padding-top: 14px; }
  .drawer .dh::before { content: ""; position: absolute; left: 50%; top: 6px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line2); }
}
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--mute); } .kv dd { margin: 0; word-break: break-all; }
.timeline { display: grid; gap: 10px; border-left: 2px solid var(--line); padding-left: 14px; margin-left: 4px; }
.timeline .e { position: relative; font-size: 12.5px; }
.timeline .e::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg2); }
.parts { display: grid; gap: 6px; }
.parts .p { display: grid; grid-template-columns: 80px 1fr 40px; gap: 8px; align-items: center; font-size: 12px; }
.parts .p .bar { height: 6px; background: var(--card2); border-radius: 3px; overflow: hidden; }
.parts .p .bar i { display: block; height: 100%; background: var(--grad); }
.status-seg { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.status-seg button { height: 32px; border-radius: 8px; border: 1px solid var(--line2); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--dim); }
.status-seg button.on { background: var(--grad); color: #1a1205; border-color: transparent; }

/* ── 지도 ── */
.mapwrap { position: relative; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); background: var(--bg2); }
.kmap { position: relative; width: 100%; height: min(72vh, 760px); touch-action: none; cursor: grab; }
.kmap:active { cursor: grabbing; }
.kmap svg { width: 100%; height: 100%; display: block; }
.kmap path.f { stroke: color-mix(in srgb, var(--bg) 70%, transparent); stroke-width: .6; vector-effect: non-scaling-stroke; transition: filter .12s; cursor: pointer; }
.kmap path.f:hover, .kmap path.f.hl { filter: brightness(1.35); stroke: var(--accent); stroke-width: 1.8; }
.kmap path.mesh { fill: none; stroke: color-mix(in srgb, var(--text) 45%, transparent); stroke-width: 1.1; vector-effect: non-scaling-stroke; pointer-events: none; }
.kmap .lab { position: absolute; transform: translate(-50%, -50%); pointer-events: none; text-align: center; line-height: 1.1; white-space: nowrap; text-shadow: 0 1px 3px var(--bg), 0 0 6px var(--bg); }
.kmap .lab b { display: block; font-size: 11px; }
.kmap .lab span { font-size: 10.5px; color: var(--accent); font-weight: 800; font-variant-numeric: tabular-nums; }
.map-ui { position: absolute; z-index: 5; display: flex; gap: 6px; flex-wrap: wrap; }
.map-ui.tl { top: 12px; left: 12px; right: 12px; }
.map-ui.br { right: 12px; bottom: 12px; flex-direction: column; align-items: flex-end; }
.glass { background: color-mix(in srgb, var(--bg2) 78%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 12px; }
.lgd { padding: 10px 12px; font-size: 11.5px; min-width: 180px; }
.lgd .ramp { height: 10px; border-radius: 5px; margin: 6px 0 4px; }
.tip { position: absolute; z-index: 8; pointer-events: none; padding: 10px 12px; font-size: 12px; min-width: 160px; transform: translate(12px, 12px); }
.tip b { font-size: 13px; }
.crumb { display: flex; align-items: center; gap: 6px; padding: 4px; }
.crumb button { height: 28px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-weight: 700; color: var(--dim); }
.crumb button.on { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); }
.navermap { width: 100%; height: min(72vh, 760px); }
.zoomctl { display: flex; flex-direction: column; overflow: hidden; }
.zoomctl button { width: 36px; height: 34px; border: 0; background: transparent; cursor: pointer; font-size: 18px; font-weight: 700; }
.zoomctl button + button { border-top: 1px solid var(--line); }

/* ── 채팅 ── */
.chat { display: flex; flex-direction: column; height: calc(100vh - 140px); min-height: 420px; }
@media (max-width: 860px) { .chat { height: calc(100vh - var(--top) - var(--tab) - 60px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); } }
.msgs { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px 12px; }
.msg { max-width: min(820px, 92%); padding: 12px 14px; border-radius: 14px; line-height: 1.65; word-break: break-word; }
.msg.me { white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--grad); color: #1a1205; border-bottom-right-radius: 4px; font-weight: 600; }
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.ai .tools { font-size: 11.5px; color: var(--mute); margin-bottom: 6px; }
.msg.ai table { border-collapse: collapse; margin: 6px 0; font-size: 12.5px; white-space: normal; }
.msg.ai th, .msg.ai td { border: 1px solid var(--line); padding: 4px 8px; }
.compose { display: flex; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.compose textarea { flex: 1; height: 46px; max-height: 160px; }
.sugg { display: flex; gap: 8px; flex-wrap: wrap; }
.typing::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

/* ── 로그인 ── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(900px 500px at 10% 0%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%), radial-gradient(700px 400px at 100% 100%, color-mix(in srgb, #ff4d6d 14%, transparent), transparent 60%), var(--bg); }
.login .box { width: min(400px, 100%); }
.login .brand { justify-content: center; padding-bottom: 22px; }
.login .brand .logo { width: 46px; height: 46px; border-radius: 14px; }
.login .brand b { font-size: 24px; }
.login form { display: grid; gap: 10px; }
.login .input { height: 46px; font-size: 15px; }
.login .btn { height: 46px; justify-content: center; font-size: 15px; }
.notice { padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.6; background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.notice.err { background: color-mix(in srgb, var(--red) 10%, transparent); border-color: color-mix(in srgb, var(--red) 40%, transparent); }

/* ── 기타 ── */
.skel { background: linear-gradient(90deg, var(--card) 0%, var(--card2) 50%, var(--card) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 10px; min-height: 80px; }
@keyframes sk { to { background-position: -200% 0; } }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--tab) + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); z-index: 90; padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 700; font-size: 13px; opacity: 0; transition: .25s; pointer-events: none; }
.toast.on { opacity: 1; transform: translateX(-50%); }
@media (min-width: 861px) { .toast { bottom: 28px; } }
.empty { padding: 30px 10px; text-align: center; color: var(--mute); }
.fade-in { animation: fi .25s ease-out; }
@keyframes fi { from { opacity: 0; transform: translateY(6px); } }
.src { color: var(--mute); font-size: 11px; margin-top: 18px; text-align: center; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); gap: 2px; }
.seg button { height: 28px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-weight: 700; font-size: 12.5px; color: var(--dim); white-space: nowrap; }
.seg button.on { background: var(--card2); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: var(--line2); transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
