:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-2: #eef1f2;
  --border: #dfe4e6;
  --text: #14211f;
  --muted: #64757a;
  --brand: #0d6a63;
  --brand-soft: #e3f1ef;
  --accent: #b45309;
  --accent-soft: #fdf2e0;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 32, 30, .06), 0 6px 18px rgba(16, 32, 30, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101615; --surface: #182220; --surface-2: #202c2a; --border: #2c3a38;
    --text: #e8efed; --muted: #93a5a2; --brand: #2fbcae; --brand-soft: #16302d;
    --accent: #f0b357; --accent-soft: #33261356; --danger: #f2776a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }

/* HTML 의 hidden 속성을 확실히 적용한다.
 * 브라우저 기본 스타일의 [hidden]{display:none} 은 우선순위가 가장 낮아서,
 * .login{display:grid} 같은 작성자 규칙 하나에 그대로 덮인다.
 * 그러면 el.login.hidden = true 를 해도 화면이 안 사라진다. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
        "Noto Sans KR", "Malgun Gothic", sans-serif;
  display: flex; flex-direction: column;
  height: 100dvh;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── 상단 바 ─────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 7px; flex: 0 0 auto; }
.brand strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand .sub { display: block; font-size: 11.5px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.clock { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }

.banner {
  padding: 9px 16px; font-size: 13px; line-height: 1.45;
  background: var(--accent-soft); color: var(--accent);
  border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.banner.error { background: #fdeceb; color: var(--danger); }
@media (prefers-color-scheme: dark) { .banner.error { background: #3a1d1b; } }

/* ── 탭 (모바일) ─────────────────────────────────────── */
.tabs {
  display: flex; flex: 0 0 auto;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1; padding: 11px 6px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.badge {
  display: inline-block; min-width: 17px; padding: 0 5px; margin-left: 3px;
  background: var(--accent); color: #fff; border-radius: 9px;
  font-size: 11px; line-height: 17px; font-weight: 700; vertical-align: 1px;
}

/* ── 패널 ────────────────────────────────────────────── */
.panels { flex: 1 1 auto; min-height: 0; display: flex; }
.panel { display: none; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.panel.is-active { display: flex; }
.panel-title { display: none; }
.scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 14px 14px 18px; -webkit-overflow-scrolling: touch;
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px;
}
.hint, .section-note { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 4px 2px 14px; }
.section-note b { color: var(--text); }

/* ── 일정 카드 ───────────────────────────────────────── */
.day-head { display: flex; align-items: baseline; gap: 8px; }
.day-label { font-size: 13px; font-weight: 700; color: var(--brand); }
.day-date { font-size: 12.5px; color: var(--muted); }
.big-time {
  font-size: 40px; font-weight: 700; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; margin: 2px 0 6px;
}
.big-time.unset { font-size: 20px; color: var(--muted); font-weight: 600; }
.status-row { margin-bottom: 10px; }
.pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
}
.pill.planned   { background: var(--brand-soft); color: var(--brand); }
.pill.draft     { background: var(--accent-soft); color: var(--accent); }
.pill.announced { background: var(--brand); color: #fff; }
.pill.warn      { background: #fdeceb; color: var(--danger); }
@media (prefers-color-scheme: dark) { .pill.warn { background: #3a1d1b; } }

.events { list-style: none; margin: 0; padding: 10px 0 0; border-top: 1px dashed var(--border); }
.events li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13.5px; }
.events .ev-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; min-width: 88px; }
.events .ev-type {
  font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px;
  background: var(--surface-2); color: var(--muted);
}
.events .empty { color: var(--muted); font-size: 13px; }

/* ── 대화 ────────────────────────────────────────────── */
#messages { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 84%; padding: 9px 13px; border-radius: 16px; font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg.err { align-self: flex-start; background: #fdeceb; color: var(--danger); border: 1px solid #f6c9c4; }
@media (prefers-color-scheme: dark) { .msg.err { background: #3a1d1b; border-color: #5a2d29; } }
.tools { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 5px; max-width: 92%; }
.tool-chip {
  font-size: 11.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.tool-chip.bad { background: #fdeceb; color: var(--danger); border-color: #f6c9c4; }
@media (prefers-color-scheme: dark) { .tool-chip.bad { background: #3a1d1b; border-color: #5a2d29; } }
.typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25 } 30% { opacity: 1 } }

.composer {
  flex: 0 0 auto; background: var(--surface); border-top: 1px solid var(--border);
  padding: 8px 12px calc(8px + var(--safe-b));
}
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 6px 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  font: inherit; font-size: 12.5px; white-space: nowrap;
}
.chip:active { background: var(--surface-2); }
.input-row { display: flex; align-items: center; gap: 8px; }
#chatInput {
  flex: 1 1 auto; min-width: 0; padding: 11px 14px; font: inherit; font-size: 16px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg); color: var(--text);
}
#chatInput:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.mic, .send {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; border: 1px solid var(--border);
  background: var(--bg); color: var(--muted);
}
.send { background: var(--brand); color: #fff; border-color: var(--brand); }
.mic.on { background: var(--danger); border-color: var(--danger); color: #fff; animation: pulse 1.4s infinite; }
.mic[disabled] { opacity: .4; cursor: not-allowed; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(180,35,24,.45) } 50% { box-shadow: 0 0 0 8px rgba(180,35,24,0) } }
.composer-foot { display: flex; gap: 14px; padding-top: 8px; }
.toggle { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--brand); }

/* ── 공지 ────────────────────────────────────────────── */
.notice { border-left: 3px solid var(--border); }
.notice.pending { border-left-color: var(--accent); }
.notice.sent { border-left-color: var(--brand); }
.notice.cancelled { opacity: .55; }
.notice-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.notice-meta { font-size: 12px; color: var(--muted); }
.notice-body {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; white-space: pre-wrap; font-size: 14.5px; line-height: 1.65;
}
.notice-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn {
  flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.quiet { color: var(--muted); }
.ghost-btn {
  padding: 7px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.ghost-btn.wide { display: block; width: 100%; }
details.payload { margin-top: 9px; }
details.payload summary { font-size: 12px; color: var(--muted); cursor: pointer; }
details.payload pre {
  margin: 8px 0 0; padding: 10px; overflow-x: auto; border-radius: 8px;
  background: var(--surface-2); font-size: 11.5px; line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.empty-state { text-align: center; color: var(--muted); font-size: 13.5px; padding: 34px 12px; }

/* ── 음성 인식 오버레이 ──────────────────────────────── */
.listening {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(128px + var(--safe-b)); z-index: 20;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 15px; border-radius: 999px; max-width: 88vw;
  background: rgba(20, 33, 31, .92); color: #fff; font-size: 13.5px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .25);
}
.listening span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wave { display: flex; align-items: flex-end; gap: 2px; height: 15px; flex: 0 0 auto; }
.wave i { width: 3px; background: #6ee7d8; border-radius: 2px; animation: bounce .9s infinite ease-in-out; }
.wave i:nth-child(1) { animation-delay: 0s }   .wave i:nth-child(2) { animation-delay: .15s }
.wave i:nth-child(3) { animation-delay: .3s }  .wave i:nth-child(4) { animation-delay: .45s }
@keyframes bounce { 0%,100% { height: 4px } 50% { height: 15px } }

/* ── 데스크톱: 3열 동시 표시 ─────────────────────────── */
@media (min-width: 1100px) {
  .tabs { display: none; }
  .panels { display: grid; grid-template-columns: 290px 310px minmax(0, 1fr) 380px; }
  .panel { display: flex !important; border-right: 1px solid var(--border); }
  .panel:last-child { border-right: 0; }
  .panel-title {
    display: block; margin: 0; padding: 12px 16px 10px;
    font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--muted); border-bottom: 1px solid var(--border); background: var(--surface);
  }
  .listening { bottom: 132px; left: auto; right: 404px; transform: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* ── 로그인 ──────────────────────────────────────────── */
.login {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 24px;
  background: var(--bg);
}
.login-box {
  width: 100%; max-width: 340px;
  display: flex; flex-direction: column; align-items: stretch; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow); padding: 28px 22px 22px;
}
.login-box img { align-self: center; border-radius: 13px; }
.login-box h1 { margin: 4px 0 0; font-size: 19px; text-align: center; letter-spacing: -.01em; }
.login-sub { margin: 0 0 6px; text-align: center; font-size: 13px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field input {
  padding: 11px 13px; font: inherit; font-size: 16px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text);
}
.field input:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.login-error {
  margin: 0; padding: 9px 11px; border-radius: 9px;
  background: #fdeceb; color: var(--danger); font-size: 13px; line-height: 1.45;
}
@media (prefers-color-scheme: dark) { .login-error { background: #3a1d1b; } }
#loginBtn { margin-top: 4px; padding: 12px; }
#loginBtn[disabled] { opacity: .6; }

/* ── 계정 · 감사 ─────────────────────────────────────── */
.account-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.account-label { font-size: 12.5px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.notice-audit { margin: 8px 0 0; font-size: 11.5px; color: var(--muted); }
.notice-audit:empty { display: none; }
.notice.superseded { border-left-color: var(--danger); opacity: .7; }

/* ── 주간 시간표 편집 ────────────────────────────────── */
.weekly-row { padding: 12px 14px; }
.weekly-row.is-off { opacity: .68; }
.weekly-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.weekly-day { font-size: 14.5px; font-weight: 700; }
.counts { display: flex; gap: 4px; }
.count {
  padding: 5px 9px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 600;
}
.count.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.time-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.time-field { display: flex; align-items: center; gap: 6px; }
.time-field span { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.time-field input {
  padding: 7px 9px; font: inherit; font-size: 15px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
.weekly-off { margin: 9px 0 0; font-size: 12.5px; color: var(--muted); }
.panel-foot {
  flex: 0 0 auto; display: flex; gap: 8px;
  padding: 10px 14px calc(10px + var(--safe-b));
  background: var(--surface); border-top: 1px solid var(--border);
}
.panel-foot .btn { flex: 1; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ── 일별 회차 ───────────────────────────────────────── */
.rounds { list-style: none; margin: 10px 0 0; padding: 0; }
.round { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 5px 0; }
.round-time { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 54px; }
.round-label { font-size: 12.5px; color: var(--muted); }
.round-by { font-size: 11.5px; color: var(--muted); flex-basis: 100%; }
.round-by:empty { display: none; }
.round.empty { color: var(--muted); font-size: 13.5px; }
.tiny-pill { font-size: 10.5px; padding: 2px 7px; }
.ghost-btn.tiny { margin-top: 10px; font-size: 12px; padding: 5px 9px; }
.day-card .events { margin-top: 10px; }

/* ── 푸시 카드 ───────────────────────────────────────── */
.push-card { border-left: 3px solid var(--brand); }
.push-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.push-card .hint { margin: 8px 0 12px; }
.btn.wide { width: 100%; }
