* {
  box-sizing: border-box;
}
:root {
  --bg: #1e1f22;
  --bg-deep: #222428;
  --surface: #2d2e32;
  --elevated: #3b3c40;
  --border: #4b4c52;
  --border-strong: #5b5c63;
  --text: #e1e2e5;
  --muted: #9ea3ac;
  --faint: #6e7278;
  --green: #04aa6d;
  --green-tint: rgba(4, 170, 109, 0.14);
  --scroll: #5b5c63;
  --scroll-hover: #6e6f76;
}
html {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll) var(--bg);
  scrollbar-gutter: stable;
  overflow-y: scroll;
  background: var(--bg);
}
body {
  background: var(--bg);
}
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--scroll);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-hover);
}
html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}
a {
  color: #93c5fd;
}
body {
  font-family: "Noto Serif", serif;
  font-size: 15px;
  line-height: 1.6;
}
header,
header nav,
header nav a,
h1,
h2,
h3,
h4,
h5,
h6,
.brand {
  font-family: Montserrat, sans-serif;
}
code,
kbd,
pre,
samp {
  font-family: "JetBrains Mono", monospace;
}
.topbar {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 68px;
  padding-top: env(safe-area-inset-top);
}
.topbar-row > :first-child {
  justify-self: start;
}
.topbar-row nav {
  justify-self: center;
}
.topbar-row .auth-area {
  justify-self: end;
  min-width: 0;
}
.layout,
.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  width: 100%;
}
.brand {
  font-weight: 700;
  letter-spacing: 0.3px;
  font-size: 1.05rem;
}
.brand img {
  width: 32px;
  height: 32px;
  border-radius: 0;
  object-fit: cover;
  display: block;
  flex: none;
}
.disclaimer {
  padding: 8px 16px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  text-align: center;
}
.disclaimer a {
  color: #93c5fd;
  text-decoration: none;
}
.disclaimer a:hover {
  text-decoration: underline;
}
.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 760px);
  gap: 16px;
  padding: 16px;
  justify-content: center;
  min-height: calc(100vh - 140px);
  min-height: calc(100dvh - 140px);
}
.selector {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 14px;
  align-self: start;
  position: sticky;
  top: 60px;
}
.select-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 10px;
  display: block;
}
.disciple-select {
  width: 100%;
  margin: 6px 0 4px;
  height: 44px;
  min-height: 44px;
  padding: 0 48px 0 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0;
  font-size: 12px;
  line-height: 44px;
  outline: none;
}
.disciple-select:focus {
  border-color: #3b82f6;
  outline: none;
}
.disciple-select:hover {
  border-color: var(--border-strong);
}
.history-box {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.history-list {
  max-height: 180px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
}
.history-item {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg);
  cursor: pointer;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.history-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-del {
  flex: none;
  min-width: 44px;
  min-height: 36px;
  padding: 2px 6px;
}
.chat-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  min-height: 560px;
  max-height: calc(100vh - 100px);
  max-height: calc(100dvh - 100px);
  overflow: hidden;
}
.voice-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--elevated), var(--surface));
}
.voice-header h3 {
  margin: 0;
  font-size: 1.05rem;
}
.voice-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}
.chat-log {
  flex: 1;
  overflow: auto;
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
}
.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 0;
  line-height: 1.5;
  font-size: 0.93rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble.user {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
  border-radius: 0;
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text);
}
.cite {
  font-size: 0.68em;
  color: var(--muted);
  cursor: default;
  margin-left: 1px;
}
.sources {
  margin-top: 8px;
  font-size: 0.68rem;
  line-height: 1.6;
  color: var(--faint);
}
.citation-bar {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  min-height: 28px;
  color: var(--muted);
  font-size: 0.78rem;
  background: var(--surface);
}
.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.resources {
  margin-top: 8px;
  padding: 8px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 0;
}
.chat-form {
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px;
  transition: border-color 0.15s;
}
.composer:focus-within {
  border-color: #3b82f6;
}
.composer textarea {
  flex: 1;
  min-height: 24px;
  max-height: 120px;
  padding: 6px 6px;
  border: none;
  background: transparent;
  color: var(--text);
  outline: none;
  resize: none;
  overflow-y: auto;
  line-height: 1.5;
  font-family: inherit;
  font-size: 16px;
}
.composer-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.composer .btn.icon {
  min-width: 44px;
  height: 44px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
}
.composer .btn.icon.send {
  min-width: 44px;
  font-size: 1rem;
  line-height: 1;
}
.chat-form textarea:disabled {
  opacity: 0.6;
}
.btn {
  padding: 8px 14px;
  min-height: 44px;
  border-radius: 0;
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--text);
  cursor: pointer;
  font-size: 0.86rem;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.12s ease,
    background-color 0.15s ease,
    opacity 0.15s ease;
}
.btn:not(:disabled):active {
  transform: scale(0.97);
}
.btn.primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.btn.primary:hover {
  background: #1d4ed8;
}
.btn.small {
  padding: 5px 10px;
  font-size: 0.82rem;
  min-height: 36px;
  min-width: 36px;
}
.btn.active {
  border-color: #3b82f6;
  background: #1e3a5f;
  color: #dbeafe;
}
.bubble.streaming {
  opacity: 0.95;
}
.bubble.streaming .bubble-text::after {
  content: " ▌";
  animation: blink 1s step-end infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn[hidden] {
  display: none !important;
}
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(480px, 90vw);
}
.toast {
  background: var(--elevated);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.5;
  padding: 10px 16px;
  text-align: center;
  opacity: 1;
  transition: opacity 0.3s;
}
.toast.hide {
  opacity: 0;
}
.auth-area {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 290px;
  min-height: 36px;
  flex: none;
}
#btnSignIn,
#btnSignOut {
  width: 150px;
  flex: none;
}
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 24px;
  padding: 0;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 12px;
  row-gap: 4px;
  margin-bottom: 0;
}
.footer-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 150ms;
}
.footer-links a:hover {
  color: var(--text);
}
.footer-links span {
  color: var(--faint);
}
.footer-note {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 24px;
  text-align: center;
  font-size: 11px;
  line-height: 20px;
  color: var(--faint);
}
.foot-tabs,
.foot-legal {
  display: none;
}
.muted {
  color: var(--muted);
}
@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    max-width: 760px;
  }
  .selector {
    position: static;
  }
  .bubble {
    max-width: 85%;
  }
  .chat-panel {
    min-height: 0;
    max-height: none;
  }
  .chat-log {
    overflow: visible;
  }
  .chat-form {
    position: sticky;
    bottom: 0;
    z-index: 5;
  }
}
@media (max-width: 560px) {
  .chat-log {
    padding: 12px;
  }
  .disclaimer {
    font-size: 0.74rem;
  }
}
@media (max-width: 640px) {
  .topbar-row {
    padding: 10px 12px;
    gap: 8px;
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .topbar-row nav {
    min-width: 0;
    overflow: hidden;
  }
  .nav-links {
    overflow-x: auto;
    max-width: 100%;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .nav-links::-webkit-scrollbar {
    display: none;
  }
  .brand {
    font-size: 0.95rem;
    white-space: nowrap;
  }
  .topbar-row nav {
    gap: 10px !important;
  }
  .topbar-row nav a {
    font-size: 12px;
  }
  .auth-area {
    min-width: 0;
    gap: 6px;
  }
  #btnSignIn,
  #btnSignOut {
    width: auto;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
  }
  .chip {
    min-height: 44px;
  }
  .footer-inner {
    flex-direction: column;
    gap: 8px;
  }
  .footer-links,
  .footer-inner > span {
    display: none;
  }
  .foot-tabs {
    display: flex;
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
    gap: 4px;
  }
  .foot-tabs a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 4px;
    min-height: 56px;
    color: var(--muted);
    text-decoration: none;
    font-size: 11px;
  }
  .foot-tabs a.active {
    color: #38bdf8;
  }
  .foot-legal {
    display: block;
    text-align: center;
    font-size: 11px;
    color: var(--faint);
  }
  .foot-legal a {
    color: var(--muted);
    text-decoration: none;
  }
  .foot-legal .dot {
    margin: 0 6px;
    color: var(--faint);
  }
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-family: Montserrat, sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
}
.nav-brand img {
  width: 32px;
  height: 32px;
  border-radius: 0;
  object-fit: cover;
  display: block;
}
.home-fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--muted);
  text-decoration: none;
  z-index: 40;
}
.home-fab:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.home-fab img {
  width: 28px;
  height: 28px;
  display: block;
  object-fit: contain;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  font-family: Montserrat, sans-serif;
  padding: 8px 16px;
  border-radius: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: var(--elevated);
}
@supports (text-wrap: pretty) {
  body {
    text-wrap: pretty;
  }
}
.topbar-row nav a {
  font-family: Montserrat, sans-serif;
}
html {
  overscroll-behavior: none;
}
body {
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
.topbar,
.foot-tabs,
.chat-form {
  user-select: none;
  -webkit-user-select: none;
}
.chat-log,
.bubble,
textarea,
input {
  user-select: text;
  -webkit-user-select: text;
}
@media (display-mode: standalone) {
  .topbar {
    padding-top: env(safe-area-inset-top);
  }
  .chat-form {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}
