:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --ink: #172033;
  --muted: #687385;
  --line: #d9e1ea;
  --blue: #1768c9;
  --teal: #16826b;
  --amber: #a96700;
  --rose: #b43a58;
  --green: #26734d;
  --shadow: 0 12px 30px rgba(24, 36, 56, .08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button,
textarea,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  min-height: 36px;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

button:hover {
  border-color: #aeb9c8;
  background: #f8fafc;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: .5;
  transform: none;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid #c7d0dc;
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea:focus,
input:focus,
select:focus,
button:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 104, 201, .14);
}

.app {
  height: 100dvh;
  min-height: 720px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: #fff;
  background: #182438;
  font-size: 13px;
  font-weight: 850;
  flex: 0 0 auto;
}

.brand-copy {
  min-width: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 17px;
  line-height: 1.1;
  white-space: nowrap;
}

.status-line {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.top-link,
.action-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #263247;
  background: #fff;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.top-link:hover,
.action-button:hover {
  border-color: #aeb9c8;
  background: #f8fafc;
}

.primary-action {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.primary-action:hover {
  color: #fff;
  background: #0e58af;
  border-color: #0e58af;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
}

.primary-icon {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.send-button:hover,
.solid-button:hover {
  color: #fff;
  background: #0e58af;
  border-color: #0e58af;
}

.layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(540px, 1fr) minmax(320px, 360px);
}

.left-rail,
.right-rail {
  min-width: 0;
  min-height: 0;
  display: grid;
  background: #fbfcfe;
}

.left-rail {
  grid-template-rows: auto auto minmax(0, 1fr);
  border-right: 1px solid var(--line);
  overflow: auto;
}

.right-rail {
  grid-template-rows: auto auto auto minmax(240px, 1fr);
  border-left: 1px solid var(--line);
  overflow: auto;
}

.panel {
  min-width: 0;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.panel h2 {
  color: #263247;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.compact-button,
.solid-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.solid-button {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.memory-input {
  min-height: 104px;
  max-height: 180px;
  resize: vertical;
  padding: 10px 11px;
  font-size: 13px;
  line-height: 1.55;
}

.project-field {
  margin-bottom: 12px;
}

.memory-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: #263247;
  font-size: 12px;
  font-weight: 850;
}

.template-list,
.sessions-list,
.agent-list,
.providers-box {
  display: grid;
  gap: 8px;
}

.template-panel {
  min-height: 0;
  overflow: auto;
}

.template-button {
  width: 100%;
  min-height: 66px;
  padding: 10px;
  display: grid;
  gap: 5px;
  text-align: left;
  border-color: transparent;
  background: transparent;
}

.template-button:hover {
  border-color: var(--line);
  background: #fff;
}

.template-button.active {
  border-color: #afc5e6;
  background: #eef5ff;
}

.template-name,
.session-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-desc,
.session-meta,
.muted-text {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.history-panel {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.sessions-list {
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
  overscroll-behavior: contain;
}

.session-button {
  width: 100%;
  min-height: 56px;
  padding: 9px 10px;
  display: grid;
  align-content: center;
  gap: 4px;
  text-align: left;
  border-color: transparent;
  background: transparent;
}

.session-button:hover {
  border-color: var(--line);
  background: #fff;
}

.session-button.active {
  border-color: #bad0c2;
  background: #eef8f3;
}

.meeting {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--bg);
}

.meeting-context {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 20px 24px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.meeting-context > div:first-child {
  min-width: 0;
}

.template-kicker {
  margin-bottom: 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 850;
}

.meeting-context h2 {
  max-width: 920px;
  font-size: 24px;
  line-height: 1.22;
  word-break: normal;
}

.meeting-context p {
  margin-top: 6px;
  max-width: 760px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.agent-ribbon {
  max-width: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px;
}

.agent-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: #344056;
  background: #fff;
  font-size: 12px;
  white-space: nowrap;
}

.feed {
  min-height: 0;
  overflow: auto;
  padding: 22px;
}

.empty-state {
  min-height: 360px;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-title {
  color: var(--ink);
  font-size: 26px;
  font-weight: 850;
  line-height: 1.15;
}

.empty-copy {
  margin-top: 10px;
  font-size: 14px;
}

.round-divider {
  margin: 18px 0 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.message {
  max-width: 820px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin: 12px 0;
}

.message.user {
  margin-left: auto;
  grid-template-columns: minmax(0, 720px) 42px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
  font-weight: 850;
  user-select: none;
}

.message.user .avatar {
  grid-column: 2;
  background: #20283a;
}

.message.user .bubble {
  grid-column: 1;
  grid-row: 1;
  color: #fff;
  background: #20283a;
  border-color: #20283a;
}

.avatar.product,
.avatar.content_strategy,
.avatar.industry {
  background: var(--blue);
}

.avatar.growth,
.avatar.paid_growth,
.avatar.investment {
  background: var(--teal);
}

.avatar.finance,
.avatar.monetization {
  background: var(--amber);
}

.avatar.tech,
.avatar.fan_ops {
  background: #5a6f8d;
}

.avatar.opposition,
.avatar.risk,
.avatar.skeptic {
  background: var(--rose);
}

.avatar.chair {
  background: var(--green);
}

.bubble {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 13px;
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(20, 31, 48, .04);
  overflow-wrap: anywhere;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.speaker {
  color: var(--ink);
  font-weight: 850;
}

.message.user .speaker,
.message.user .message-meta {
  color: rgba(255, 255, 255, .8);
}

.message-text {
  font-size: 14px;
  line-height: 1.68;
  white-space: pre-wrap;
}

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

.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: .35; transform: scale(.82); }
  50% { opacity: 1; transform: scale(1); }
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 10px;
  align-items: end;
  padding: 14px 18px 18px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.composer textarea {
  min-height: 52px;
  max-height: 160px;
  resize: vertical;
  padding: 12px 13px;
  line-height: 1.48;
}

.composer-actions {
  display: grid;
}

.send-button {
  width: 46px;
  height: 52px;
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  font-size: 22px;
}

.agent-card {
  min-height: 84px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.agent-card-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.agent-card-body {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

select,
input {
  min-height: 36px;
  padding: 7px 9px;
}

.providers-box {
  margin-top: 14px;
}

.provider-row {
  min-height: 34px;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  color: #344056;
  font-size: 13px;
}

.provider-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #aab4c2;
}

.provider-dot.ready {
  background: var(--teal);
}

.provider-model {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
}

.billing-box {
  display: grid;
  gap: 10px;
}

.billing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric {
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

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

.metric-value {
  margin-top: 4px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 850;
  line-height: 1.2;
}

.billing-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.payment-settings {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.checkbox-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: #344056;
}

.checkbox-row input {
  width: 16px;
  min-height: 16px;
}

.usage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  color: #344056;
  font-size: 12px;
  line-height: 1.45;
}

.usage-row span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-panel {
  min-height: 0;
  overflow: auto;
}

.report-box {
  color: #243047;
  font-size: 14px;
  line-height: 1.65;
}

.report-box h3 {
  margin: 14px 0 6px;
  font-size: 14px;
}

.report-box p {
  margin: 0 0 8px;
}

.report-list {
  margin: 6px 0 12px;
  padding-left: 18px;
}

.decision-point {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.decision-question {
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.45;
}

.decision-options {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.decision-options button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.recommendation {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.modal-shell {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 20;
  overflow: auto;
  padding: 24px 14px;
}

.modal-shell.open {
  display: grid;
  align-items: start;
  justify-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, .36);
  z-index: 0;
}

.modal {
  position: relative;
  z-index: 1;
  width: min(640px, calc(100vw - 28px));
  max-height: calc(100dvh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

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

.modal-heading h2 {
  font-size: 16px;
}

.keys-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  overflow: auto;
}

.account-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  overflow: auto;
}

.topup-form {
  display: grid;
  gap: 16px;
  padding: 16px;
  overflow: auto;
}

.form-label {
  margin-bottom: 8px;
  color: #263247;
  font-size: 12px;
  font-weight: 850;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.payment-grid {
  grid-template-columns: 1fr;
}

.option-card {
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.option-card.active {
  border-color: #afc5e6;
  background: #eef5ff;
}

.option-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

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

.checkout-box {
  display: grid;
  gap: 8px;
}

.checkout-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfe;
}

.checkout-url {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.key-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.key-provider {
  display: grid;
  gap: 5px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.narrow-modal {
  width: min(480px, calc(100vw - 28px));
}

.modal-textarea {
  min-height: 110px;
  max-height: 220px;
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  min-width: 220px;
  max-width: min(520px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 10px 12px;
  border-radius: var(--radius);
  color: #fff;
  background: #20283a;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  font-size: 13px;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

.admin-app {
  min-height: 100dvh;
  background: var(--bg);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.admin-title {
  display: grid;
  gap: 4px;
}

.admin-title h1 {
  font-size: 22px;
}

.admin-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 24px 32px;
  display: grid;
  gap: 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.admin-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 8px 18px rgba(20, 31, 48, .04);
}

.admin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.admin-card-header h2 {
  font-size: 14px;
}

.admin-card-body {
  padding: 16px;
}

.admin-form {
  display: grid;
  gap: 14px;
}

.admin-form-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) minmax(0, 2fr);
  gap: 12px;
  align-items: end;
}

.model-key-rows {
  display: grid;
  gap: 10px;
}

.model-key-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1.3fr) minmax(0, 1fr) 110px;
  gap: 10px;
  align-items: end;
}

.model-key-label {
  display: grid;
  gap: 4px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.model-key-label span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.admin-metric {
  padding: 14px 16px;
}

.admin-metric-label {
  color: var(--muted);
  font-size: 12px;
}

.admin-metric-value {
  margin-top: 6px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 850;
  line-height: 1.1;
}

.admin-table-wrap {
  overflow: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.admin-table th {
  color: var(--muted);
  background: #fbfcfe;
  font-size: 12px;
  font-weight: 850;
}

.admin-table td.wrap {
  white-space: normal;
  overflow-wrap: anywhere;
}

.admin-token {
  max-width: 520px;
  margin: 80px auto;
}

.empty-admin {
  color: var(--muted);
  font-size: 13px;
  padding: 16px;
}

@media (max-width: 1280px) {
  .layout {
    grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  }

  .right-rail {
    display: none;
  }
}

@media (max-width: 760px) {
  .app {
    height: auto;
    min-height: 100vh;
  }

  .topbar {
    align-items: flex-start;
    padding: 12px;
    height: auto;
    flex-wrap: wrap;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .left-rail,
  .right-rail {
    display: grid;
    border: 0;
  }

  .left-rail {
    max-height: 82vh;
    grid-template-rows: auto minmax(220px, 1fr) minmax(160px, 240px);
    overflow: auto;
    border-bottom: 1px solid var(--line);
  }

  .template-panel {
    max-height: 320px;
  }

  .history-panel {
    min-height: 160px;
  }

  .meeting {
    min-height: 78vh;
  }

  .meeting-context {
    padding: 16px;
  }

  .feed {
    padding: 14px;
  }

  .message,
  .message.user {
    grid-template-columns: 36px minmax(0, 1fr);
    margin-left: 0;
  }

  .message.user .avatar {
    grid-column: 1;
  }

  .message.user .bubble {
    grid-column: 2;
  }

  .avatar {
    width: 36px;
    height: 36px;
  }

  .key-row {
    grid-template-columns: 1fr;
  }

  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-shell {
    padding: 16px;
  }

  .admin-grid {
    grid-template-columns: 1fr 1fr;
  }

  .admin-form-row {
    grid-template-columns: 1fr;
  }

  .model-key-row {
    grid-template-columns: 1fr;
  }
}

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