:root {
  --bg: #f6f8fc;
  --panel: #ffffff;
  --panel2: #f0f4ff;
  --border: rgba(15, 23, 42, 0.12);
  --text: rgba(15, 23, 42, 0.92);
  --muted: rgba(15, 23, 42, 0.62);
  --brand: #4f46e5;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

code {
  font-family: var(--mono);
  font-size: 0.95em;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel2);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-title {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.app-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.topbar__right {
  display: flex;
  gap: 10px;
  align-items: center;
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.04);
  font-size: 12px;
  color: var(--muted);
}

.pill--ok {
  border-color: rgba(22, 163, 74, 0.25);
  color: rgba(22, 163, 74, 0.95);
  background: rgba(22, 163, 74, 0.08);
}

.pill--warn {
  border-color: rgba(217, 119, 6, 0.25);
  color: rgba(217, 119, 6, 0.95);
  background: rgba(217, 119, 6, 0.08);
}

.pill--danger {
  border-color: rgba(220, 38, 38, 0.25);
  color: rgba(220, 38, 38, 0.95);
  background: rgba(220, 38, 38, 0.08);
}

.layout {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 360px;
  gap: 16px;
  padding: 16px;
  max-width: 1240px;
  margin: 0 auto;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.02);
}

.panel__title {
  font-weight: 700;
  font-size: 14px;
}

.panel__meta {
  color: var(--muted);
  font-size: 12px;
}

.panel--chat {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 84px - 32px);
}

.panel--side {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 84px - 32px);
}

.notice {
  margin: 12px 14px 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(217, 119, 6, 0.35);
  background: rgba(217, 119, 6, 0.08);
  color: rgba(15, 23, 42, 0.82);
  font-size: 13px;
}

.status-banner {
  margin: 12px 14px 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.03);
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(15, 23, 42, 0.85);
  font-size: 13px;
}

.status-banner--ok {
  border-color: rgba(22, 163, 74, 0.25);
  background: rgba(22, 163, 74, 0.08);
}

.status-banner--warn {
  border-color: rgba(217, 119, 6, 0.25);
  background: rgba(217, 119, 6, 0.08);
}

.status-banner--danger {
  border-color: rgba(220, 38, 38, 0.25);
  background: rgba(220, 38, 38, 0.08);
}

.status-banner__text {
  line-height: 1.35;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 42, 0.18);
  border-top-color: rgba(15, 23, 42, 0.75);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.chat {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  flex: 1;
}

.bubble {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.03);
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble__meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.bubble--narration {
  max-width: 100%;
  background: rgba(79, 70, 229, 0.09);
  border-color: rgba(79, 70, 229, 0.22);
}

.bubble--npc {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
}

.bubble--user {
  align-self: flex-end;
  background: rgba(22, 163, 74, 0.09);
  border-color: rgba(22, 163, 74, 0.22);
}

.bubble--system {
  max-width: 100%;
  align-self: center;
  background: rgba(15, 23, 42, 0.02);
  border-style: dashed;
  color: var(--muted);
}

.guidance {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.02);
}

.guidance__label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.guidance__text {
  font-size: 13px;
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.02);
}

.controls {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hr {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.btn {
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.04);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 650;
}

.btn:hover {
  background: rgba(15, 23, 42, 0.06);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn--primary {
  border-color: rgba(79, 70, 229, 0.45);
  background: rgba(79, 70, 229, 0.12);
}

.btn--primary:hover {
  background: rgba(79, 70, 229, 0.16);
}

.btn--ghost {
  background: rgba(15, 23, 42, 0.02);
}

.btn--danger {
  border-color: rgba(220, 38, 38, 0.35);
  background: rgba(220, 38, 38, 0.08);
}

.btn--danger:hover {
  background: rgba(220, 38, 38, 0.12);
}

.btn--mic {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.btn__icon {
  font-family: var(--mono);
  font-size: 13px;
  color: rgba(220, 38, 38, 0.95);
}

.btn--mic.btn--recording .btn__icon {
  color: rgba(217, 119, 6, 0.95);
}

.input,
.select {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.02);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}

.input:focus,
.select:focus {
  border-color: rgba(79, 70, 229, 0.55);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

.drawer {
  position: fixed;
  right: 12px;
  bottom: 12px;
  width: min(960px, calc(100vw - 24px));
  max-height: min(720px, calc(100vh - 24px));
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.95);
  overflow: hidden;
  z-index: 50;
}

.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.drawer__title {
  font-weight: 800;
}

.drawer__content {
  padding: 12px;
  overflow: auto;
  max-height: calc(720px - 56px);
}

.debug-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 980px) {
  .debug-grid {
    grid-template-columns: 1fr;
  }
}

.debug-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.02);
  overflow: hidden;
}

.debug-card__title {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
}

.pre {
  margin: 0;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.modal {
  border: none;
  padding: 0;
  background: transparent;
}

.modal__card {
  width: min(620px, calc(100vw - 24px));
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.97);
  overflow: hidden;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.modal__title {
  font-weight: 850;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.form {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form__row--grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form__row--inline {
  display: flex;
  align-items: center;
}

.label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.checkbox {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
