@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --text: #12335d;
  --title: #1f4f98;
  --muted: #6f7f98;
  --primary: #2558a8;
  --primary-soft: #e8effb;
  --warm: #fff4e6;
  --line: #d8e1ef;
  --danger: #b3202d;
  --body-radial-a: #d7e2f6;
  --body-radial-b: #f8ead7;
  --body-gradient-start: #f6f8fb;
  --body-gradient-end: #f1f4f8;
  --surface-soft: #fcfdff;
  --menu-bg: #ffffff;
  --menu-border: #d5dfef;
  --menu-shadow: 0 16px 30px rgba(19, 50, 95, 0.18);
  --hover-soft: #f6eade;
  --hover-warm-text: #e66f1f;
  --tile-border: #cdd8e8;
  --tile-text: #637b9d;
  --message-assistant-bg: #f5f7fb;
  --message-assistant-border: #ebf0f8;
  --message-user-bg: #e9f0fc;
  --message-user-border: #d9e6fb;
  --input-bg: #ffffff;
  --overlay: rgba(15, 36, 66, 0.3);
  --shadow: 0 14px 30px rgba(16, 48, 89, 0.08);
  --card-hover-border: #a9c2e6;
  --card-hover-bg-start: #ffffff;
  --card-hover-bg-end: #f6f9ff;
  --card-hover-shadow: 0 22px 34px rgba(24, 66, 122, 0.2);
  --muted-card-bg-start: #fbfcfe;
  --muted-card-bg-end: #f5f7fb;
  --muted-card-border: #dfe5ef;
  --muted-card-heading: #4a6287;
  --muted-card-text: #7487a4;
  --muted-card-tag-bg: #f1f4f9;
  --muted-card-tag-border: #dde4ef;
  --muted-card-button-bg: #f1efe6;
  --muted-card-button-text: #9ba6b7;
  --muted-card-button-border: #e5e2d6;
  --muted-card-hover-bg-start: #ffffff;
  --muted-card-hover-bg-end: #f8faff;
  --muted-card-hover-border: #bfd0e9;
}

body[data-theme='dark'] {
  --bg: #0f1622;
  --panel: #1a2535;
  --text: #dbe8fb;
  --title: #9ec4ff;
  --muted: #9fb3cf;
  --primary: #7fb0ff;
  --primary-soft: #2a3d5d;
  --warm: #2a2c30;
  --line: #34475f;
  --danger: #ff8b94;
  --body-radial-a: #24364f;
  --body-radial-b: #483528;
  --body-gradient-start: #111b2a;
  --body-gradient-end: #0d1521;
  --surface-soft: #1d2b3f;
  --menu-bg: #1a2738;
  --menu-border: #385070;
  --menu-shadow: 0 18px 36px rgba(0, 0, 0, 0.45);
  --hover-soft: #24364f;
  --hover-warm-text: #ffd09a;
  --tile-border: #3a4f6a;
  --tile-text: #b1c4df;
  --message-assistant-bg: #1f3046;
  --message-assistant-border: #304864;
  --message-user-bg: #233853;
  --message-user-border: #355578;
  --input-bg: #111b2a;
  --overlay: rgba(0, 0, 0, 0.56);
  --shadow: 0 16px 34px rgba(2, 8, 20, 0.44);
  --card-hover-border: #4a6486;
  --card-hover-bg-start: #213249;
  --card-hover-bg-end: #27405d;
  --card-hover-shadow: 0 20px 32px rgba(4, 10, 24, 0.5);
  --muted-card-bg-start: #141f2f;
  --muted-card-bg-end: #101a28;
  --muted-card-border: #2a3d57;
  --muted-card-heading: #8ea9ce;
  --muted-card-text: #7f99bb;
  --muted-card-tag-bg: #1b2b40;
  --muted-card-tag-border: #2f4768;
  --muted-card-button-bg: #223149;
  --muted-card-button-text: #92a8c6;
  --muted-card-button-border: #395171;
  --muted-card-hover-bg-start: #182538;
  --muted-card-hover-bg-end: #142135;
  --muted-card-hover-border: #355174;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Manrope, 'Avenir Next', 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -10%, var(--body-radial-a) 0, transparent 48%),
    radial-gradient(circle at 100% 14%, var(--body-radial-b) 0, transparent 44%),
    linear-gradient(180deg, var(--body-gradient-start) 0%, var(--body-gradient-end) 100%);
}

.page {
  display: none;
  min-height: 100vh;
}

.page.active {
  display: block;
}

#chat-view {
  min-height: 100dvh;
}

#chat-view.active {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

#chat-view .top-nav {
  flex: 0 0 auto;
}

#chat-view .chat-layout {
  flex: 1 1 auto;
  min-height: 0;
}

.reveal {
  animation: fade-in 0.42s ease both;
}

.stagger-1 {
  animation-delay: 0.08s;
}

.stagger-2 {
  animation-delay: 0.14s;
}

.stagger-3 {
  animation-delay: 0.2s;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.top-nav {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 96px;
  padding: 1.15rem 2.8rem;
  gap: 1rem;
  position: relative;
  z-index: 200;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-group-wide {
  gap: 1.1rem;
}

.logo-thornton {
  width: auto;
  height: 34px;
  object-fit: contain;
}

.logo-genie {
  width: auto;
  height: 75px;
  object-fit: contain;
}

.logo-thornton-nav {
  height: 38px;
}

.logo-genie-nav {
  height: 93px;
}

.logo-thornton-login {
  height: 48px;
}

.logo-genie-login {
  height: 93px;
}

.portal-heading {
  min-width: 0;
}

.portal-title {
  margin: 0;
  color: var(--title);
  font-size: 1.32rem;
  font-weight: 800;
  line-height: 1.15;
}

.portal-subtitle {
  margin: 0.22rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.nav-menu {
  display: flex;
}

#welcome-text {
  display: inline-flex;
  align-items: center;
  color: var(--title);
  font-weight: 700;
  margin-right: 0.2rem;
}

#chat-user-text {
  display: inline-flex;
  align-items: center;
  color: var(--title);
  font-weight: 700;
}

.menu-separator {
  width: 1px;
  height: 30px;
  background: var(--line);
}

.top-action-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.top-action-btn:hover {
  background: var(--hover-soft);
  color: var(--hover-warm-text);
}

.theme-toggle-btn {
  min-width: 98px;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--panel);
}

.theme-toggle-btn[data-target-theme='dark'] {
  background: #1b2d47;
  border-color: #2f4b73;
  color: #e8f1ff;
}

.theme-toggle-btn[data-target-theme='light'] {
  background: #f6f9ff;
  border-color: #a9bfdc;
  color: #21406c;
}

.theme-toggle-btn .action-icon {
  font-size: 1rem;
}

.action-icon {
  font-size: 0.86rem;
  line-height: 1;
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.logout-btn:hover {
  background: var(--hover-soft);
  border-color: var(--line);
  color: var(--hover-warm-text);
}

.content-wrap {
  max-width: 1280px;
  margin: 2rem auto;
  padding: 0 1.2rem 1.6rem;
}

.login-top-actions {
  justify-content: flex-end;
  margin-bottom: 0.55rem;
}

#theme-toggle-login {
  min-width: 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
}

#theme-toggle-login .theme-label {
  display: none;
}

#theme-toggle-login .action-icon {
  margin: 0;
}

h2 {
  margin: 0;
  color: var(--title);
  font-size: clamp(1.7rem, 2.1vw, 2.2rem);
}

h3 {
  margin: 0;
}

.muted {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.card-grid {
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 1rem;
}

.agent-card {
  display: grid;
  gap: 0.6rem;
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1rem 0.95rem;
  box-shadow: var(--shadow);
  overflow: hidden;
  transform: translateY(0);
  will-change: transform;
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.agent-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: transparent;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}

.agent-card:hover {
  transform: translateY(-5px);
  border-color: var(--card-hover-border);
  background: linear-gradient(180deg, var(--card-hover-bg-start), var(--card-hover-bg-end));
  box-shadow: var(--card-hover-shadow);
}

.agent-card:hover::before {
  background: #ff9a36;
  box-shadow: 0 0 14px rgba(255, 149, 52, 0.55);
}

.active-agent {
  border-color: #f0c18f;
  box-shadow: 0 14px 24px rgba(242, 164, 81, 0.22);
}

.active-agent:hover {
  border-color: #f1b778;
  box-shadow: 0 24px 35px rgba(231, 152, 59, 0.33);
}

.agent-card h3 {
  color: var(--title);
  font-size: 1.14rem;
}

.agent-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.pill,
.chip {
  display: inline-block;
  margin-left: 0.4rem;
  vertical-align: middle;
  font-size: 0.69rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
}

.pill {
  color: #fff;
  background: linear-gradient(90deg, #ff9b3f, #ff7c1f);
}

.chip {
  color: #887448;
  background: #f7efe2;
}

.card-subhead {
  color: #355b91;
  font-size: 0.82rem;
  font-weight: 800;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
}

.tag-list span {
  font-size: 0.73rem;
  color: #2d598f;
  background: #eef3fc;
  border: 1px solid #dbe5f7;
  border-radius: 999px;
  padding: 0.22rem 0.52rem;
}

.muted-card {
  background: linear-gradient(180deg, var(--muted-card-bg-start) 0%, var(--muted-card-bg-end) 100%);
  border-color: var(--muted-card-border);
}

.muted-card:hover {
  border-color: var(--muted-card-hover-border);
  background: linear-gradient(180deg, var(--muted-card-hover-bg-start) 0%, var(--muted-card-hover-bg-end) 100%);
}

.muted-card::before {
  background: transparent;
  box-shadow: none;
}

.muted-card h3,
.muted-card .card-subhead {
  color: var(--muted-card-heading);
}

.muted-card p,
.muted-card .tag-list span,
.muted-card .chip {
  color: var(--muted-card-text);
}

.muted-card .tag-list span {
  background: var(--muted-card-tag-bg);
  border-color: var(--muted-card-tag-border);
}

.muted-card .secondary-button {
  background: var(--muted-card-button-bg);
  color: var(--muted-card-button-text);
  border-color: var(--muted-card-button-border);
}

.muted-card .secondary-button {
  opacity: 0.96;
}

.metrics-grid {
  margin-top: 1.4rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 1rem;
}

.stats-section {
  margin-top: 1.5rem;
}

.stats-section h3 {
  color: var(--title);
}

.stats-section p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.metric-card {
  background: var(--surface-soft);
  border: 1px solid var(--tile-border);
  border-radius: 12px;
  padding: 0.78rem 0.72rem;
  text-align: center;
  min-height: 81px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.metric-card strong {
  display: block;
  font-size: 1.14rem;
  line-height: 1;
  letter-spacing: -0.01em;
}

.metric-card span {
  display: block;
  margin-top: 0.22rem;
  color: var(--tile-text);
  font-size: 0.73rem;
  font-weight: 600;
}

.metric-blue {
  color: #1f4f98;
}

.metric-orange {
  color: #f0781c;
}

.metric-card:hover {
  transform: translateY(-1px);
  border-color: var(--line);
  box-shadow: 0 6px 12px rgba(34, 61, 106, 0.08);
}

.primary-button,
.secondary-button,
.ghost-button {
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.primary-button {
  background: linear-gradient(180deg, #2f66b8, #2357a8);
  color: white;
}

.primary-button:hover {
  background: linear-gradient(180deg, #2f6ec8, #1f4f9c);
}

.secondary-button {
  background: var(--warm);
  color: #8f7f55;
  border-color: #f5e7d3;
}

.ghost-button {
  color: var(--primary);
  border-color: var(--line);
  background: var(--panel);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.66;
}

.full {
  width: 100%;
}

.text-link {
  border: none;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.soft-link {
  color: #6e84a6;
  font-size: 0.92rem;
}

.divider {
  width: 1px;
  height: 32px;
  background: var(--line);
}

.login-divider {
  height: 42px;
}

#login-view {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

#login-view.active {
  display: flex;
}

.login-shell {
  width: min(448px, 94vw);
  display: block;
}

.login-brand,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.7rem;
  box-shadow: var(--shadow);
}

.single-card {
  padding: 1.15rem 1rem 1rem;
}

.login-logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin-bottom: 0.65rem;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.72rem;
  font-weight: 800;
}

.login-card h2 {
  margin-top: 0.3rem;
  text-align: center;
  font-size: 2rem;
}

.login-portal-title {
  color: var(--title);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0;
}

.login-subtitle {
  margin: 0.15rem 0 0.85rem;
  text-align: center;
  font-size: 0.92rem;
}

.provider-row {
  display: grid;
  gap: 0.35rem;
}

/* ── Auth loading & signed-out states ─────────────────────────── */

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

.auth-spinner {
  display: block;
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: #2f66b8;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto 0.9rem;
}

.auth-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.4rem 0 0.8rem;
}

.auth-loading-msg {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.signed-out-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 0 0.4rem;
}

.signed-out-msg {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
  text-align: center;
}

label {
  font-weight: 700;
  margin-top: 0.35rem;
  font-size: 0.92rem;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.72rem 0.8rem;
  font: inherit;
  background: var(--input-bg);
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid #b8cdf2;
  border-color: #7fa3da;
}

.password-row {
  display: flex;
  gap: 0.5rem;
}

.login-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0.38rem 0 0.5rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  font-weight: 500;
  margin: 0;
}

.checkbox-row input {
  width: auto;
}

.helper {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.error {
  min-height: 1.15rem;
  color: var(--danger);
  margin: 0;
  text-align: center;
}

.chat-layout {
  max-width: 1280px;
  margin: 1rem auto;
  padding: 0 1.2rem 1.2rem;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1rem;
  overflow: hidden;
}

.chat-window,
.side-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem;
  box-shadow: var(--shadow);
}

.chat-window,
.side-panel {
  transition: box-shadow 0.22s ease, transform 0.22s ease;
}

.chat-window:hover,
.side-panel:hover {
  box-shadow: 0 16px 30px rgba(20, 55, 102, 0.14);
}

.chat-window {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}


.token-estimate-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 0.55rem 0.62rem;
  display: grid;
  gap: 0.34rem;
}

.token-estimate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.token-estimate-row strong {
  color: var(--title);
  font-size: 0.82rem;
}

.chat-window h2 {
  font-size: 1.44rem;
}

.chat-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.chat-window-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.memory-overflow-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d8212d;
  box-shadow: 0 0 0 2px rgba(216, 33, 45, 0.22);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.memory-overflow-indicator.active {
  opacity: 1;
  transform: scale(1);
}

.new-chat-button {
  padding: 0.4rem 0.62rem;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

body[data-theme='dark'] .memory-overflow-indicator {
  background: #ff5d6b;
  box-shadow: 0 0 0 2px rgba(255, 93, 107, 0.24);
}

.messages {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.82rem;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.45rem;
}

.side-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: auto;
}

.token-estimate-section {
  margin-top: auto;
  padding-top: 0.8rem;
}

.system-prompt-controls {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.system-prompt-checkbox {
  margin-top: 0;
  font-size: 0.86rem;
}

#edit-system-prompt-button {
  width: 100%;
}

.token-estimate-title {
  margin-top: 0;
}

.message {
  max-width: 86%;
  padding: 0.75rem 0.82rem;
  border-radius: 10px;
  line-height: 1.42;
  border: 1px solid transparent;
}

.message.assistant {
  background: var(--message-assistant-bg);
  border-color: var(--message-assistant-border);
}

.message.user {
  margin-left: auto;
  background: var(--message-user-bg);
  border-color: var(--message-user-border);
}

.message.out-of-memory-scope {
  background: #ffe5e7;
  border-color: #f2a8b0;
}

body[data-theme='dark'] .message.out-of-memory-scope {
  background: #4a2027;
  border-color: #9f505e;
}

.message time {
  display: block;
  margin-top: 0.34rem;
  font-size: 0.73rem;
  color: var(--muted);
}

.message-form {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

#chat-input {
  flex: 1;
}

.send-button {
  min-width: 52px;
}

.side-title {
  color: var(--title);
  font-weight: 800;
  margin: 1rem 0 0.55rem;
  font-size: 0.92rem;
}

.quick-panel-toggle {
  display: none;
}

.quick-panel-backdrop {
  display: none;
}

.side-panel-header {
  display: block;
}

.close-panel-btn {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 2500;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: min(920px, 96vw);
  max-height: min(86vh, 780px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 22px 38px rgba(18, 47, 89, 0.25);
  padding: 1rem;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 0.7rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.modal-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.modal-close-btn {
  display: inline-flex;
}

.system-prompt-editor {
  width: 100%;
  min-height: 280px;
  height: 52vh;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  padding: 0.78rem;
  font: 500 0.86rem/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

.system-prompt-editor:focus {
  outline: 2px solid #b8cdf2;
  border-color: #7fa3da;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.suggestions {
  display: grid;
  gap: 0.5rem;
}

.suggestion {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 0.62rem;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.suggestion:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.source-list {
  padding-left: 1rem;
  margin: 0;
  color: var(--muted);
  display: grid;
  gap: 0.38rem;
}

.top-space {
  margin-top: 1.3rem;
}

.debug-panel {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.38;
  white-space: pre-wrap;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem;
  color: #2e558b;
  max-height: 210px;
  overflow: auto;
}

@media (max-width: 1180px) {
  .card-grid {
    grid-template-columns: repeat(2, minmax(250px, 1fr));
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 980px) {
  #chat-view .chat-layout {
    min-height: 0;
    padding-bottom: 0.8rem;
  }

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

  .top-nav {
    min-height: 88px;
    padding: 0.8rem 1rem;
    flex-wrap: nowrap;
  }

  .portal-title {
    font-size: 1.08rem;
  }

  .portal-subtitle {
    font-size: 0.75rem;
  }

  .brand-group {
    flex: 1;
    min-width: 0;
    gap: 0.52rem;
  }

  .brand-group .divider {
    display: none;
  }

  .logo-thornton-nav {
    height: 30px;
  }

  .logo-genie-nav {
    height: 56px;
  }

  .top-actions.nav-menu {
    display: flex;
    position: static;
    flex-direction: row;
    align-items: center;
    width: auto;
    gap: 0.35rem;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    z-index: auto;
  }

  .chat-window {
    min-height: 0;
    height: 100%;
  }

  .quick-panel-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 0;
    top: 146px;
    transform: none;
    z-index: 1900;
    border: 1px solid var(--line);
    border-right: none;
    border-radius: 10px 0 0 10px;
    background: var(--panel);
    color: var(--primary);
    font: inherit;
    font-weight: 700;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.04em;
    padding: 0.7rem 0.38rem;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(18, 47, 89, 0.15);
  }

  .quick-panel-toggle:hover {
    background: var(--primary-soft);
  }

  .quick-panel-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    opacity: 0;
    pointer-events: none;
    z-index: 2000;
    transition: opacity 0.2s ease;
  }

  .quick-panel-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  .side-panel {
    position: fixed;
    right: 0;
    top: 86px;
    bottom: 0;
    width: min(330px, 88vw);
    max-height: none;
    border-radius: 14px 0 0 0;
    z-index: 2105;
    transform: translateX(104%);
    transition: transform 0.24s ease;
    overflow: auto;
  }

  .side-panel.open {
    transform: translateX(0);
    box-shadow: -10px 0 28px rgba(18, 47, 89, 0.2);
  }

  .side-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
  }

  .close-panel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--title);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
  }

  .modal-card {
    width: min(760px, 96vw);
    max-height: 88vh;
  }

  .system-prompt-editor {
    height: 48vh;
  }
}

@media (max-width: 720px) {
  .card-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .logo-thornton,
  .logo-thornton-nav,
  .logo-thornton-login {
    height: 26px;
  }

  .logo-genie,
  .logo-genie-nav,
  .logo-genie-login {
    height: 44px;
  }

  .portal-title {
    font-size: 0.94rem;
  }

  .portal-subtitle {
    display: none;
  }

  .content-wrap,
  .chat-layout {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }

  .login-card h2 {
    font-size: 1.34rem;
  }

  .login-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-window {
    min-height: 0;
    height: 100%;
  }

  .message {
    max-width: 93%;
  }

  .message-form {
    flex-direction: column;
  }

  .send-button {
    width: 100%;
  }

  .top-nav {
    padding: 0.7rem 0.8rem;
  }

  .modal-card {
    width: 100%;
    max-height: 90vh;
    padding: 0.8rem;
    gap: 0.55rem;
  }

  .modal-actions {
    justify-content: stretch;
  }

  .modal-actions .ghost-button,
  .modal-actions .secondary-button,
  .modal-actions .primary-button {
    flex: 1 1 calc(50% - 0.25rem);
  }

  .system-prompt-editor {
    height: 44vh;
    min-height: 240px;
  }

  .brand-group {
    gap: 0.4rem;
  }

  #welcome-text,
  #chat-user-text,
  .menu-separator,
  .theme-label,
  .logout-label {
    display: none;
  }

  .top-action-btn,
  .logout-btn,
  .theme-toggle-btn {
    min-width: 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    border-radius: 10px;
  }

  .top-action-btn .action-icon,
  .logout-btn .action-icon {
    margin: 0;
    font-size: 1rem;
  }

  .side-panel {
    top: 76px;
    width: min(310px, 90vw);
  }

  .quick-panel-toggle {
    top: 132px;
    transform: none;
    right: 0;
    border-right: none;
    border-radius: 10px 0 0 10px;
    padding: 0.6rem 0.34rem;
  }
}

@keyframes menu-drop {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
