:root {
  color-scheme: dark;
  --bg: #02050a;
  --panel: rgba(5, 13, 24, 0.88);
  --panel-soft: rgba(7, 17, 29, 0.72);
  --line: rgba(71, 234, 255, 0.15);
  --line-strong: rgba(71, 234, 255, 0.56);
  --text: #d9e7f5;
  --muted: #8ea9c5;
  --electric: #16a7ff;
  --cyan: #47eaff;
  --cobalt: #0b5cff;
  --green: #37d5a7;
  --gold: #d9b66d;
  --danger: #ff6f82;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: clip;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: clip;
  overflow-y: auto;
  color: var(--text);
  background:
    radial-gradient(circle at 52% 72%, rgba(71, 234, 255, 0.16), transparent 14rem),
    radial-gradient(circle at 86% 16%, rgba(11, 92, 255, 0.18), transparent 22rem),
    linear-gradient(180deg, rgba(7, 17, 29, 0.92), #02050a 62%),
    #02050a;
  font-family:
    "Be Vietnam Pro",
    "Inter",
    "Segoe UI Variable",
    "Segoe UI",
    Arial,
    sans-serif;
  font-size: 14px;
  font-weight: 300;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  font-synthesis-weight: none;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: fixed;
  inset: auto 0 0;
  height: 58vh;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(22, 167, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 167, 255, 0.08) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to top, black 0%, transparent 78%);
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: rgba(71, 234, 255, 0.28);
}

strong {
  font-weight: 400;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(calc(100% - 32px), 1240px);
  min-height: auto;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding: 22px 0 26px;
}

.page-header {
  grid-area: banner;
  position: relative;
  width: 100%;
  aspect-ratio: 2048 / 684;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #000;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.48);
}

.top-banner-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
}

.chat-actions {
  grid-column: 1 / -1;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  margin-left: 0;
}

.chat-provider-badge {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid rgba(245, 250, 255, 0.16);
  border-radius: 7px;
  color: rgba(232, 241, 250, 0.68);
  background: rgba(255, 255, 255, 0.035);
  font-size: 11px;
  font-weight: 450;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.chat-provider-badge[hidden] {
  display: none;
}

.chat-actions:has(.chat-provider-badge[hidden]) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.chat-actions > .ghost-button,
.chat-actions > .primary-small,
.chat-actions > .system-status {
  width: 100%;
  min-width: 0;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
}

.sidebar,
.main,
.insight-rail {
  min-width: 0;
}

.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.main {
  grid-area: main;
  display: flex;
}

.insight-rail {
  grid-area: rail;
  --rail-card-min: 180px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--rail-card-min)), 1fr));
  align-content: start;
  gap: 12px;
}

.sidebar-section,
.rail-section,
.chat-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 52px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(16px);
}

.sidebar-section,
.rail-section {
  min-width: 0;
  padding: 12px;
}

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

.language-option {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  font-weight: 400;
  transition: transform 0.16s ease, border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.language-option.active {
  border-color: rgba(71, 234, 255, 0.7);
  color: #021018;
  background: var(--cyan);
  box-shadow: 0 0 32px rgba(22, 167, 255, 0.22);
}

.section-title {
  margin-bottom: 9px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.new-chat,
.primary-small,
.composer button,
.babygpt-composer button[type="submit"] {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: #021018;
  background: var(--cyan);
  box-shadow: 0 0 32px rgba(22, 167, 255, 0.22);
  font-size: 13px;
  font-weight: 400;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.new-chat {
  width: 100%;
  padding: 0 12px;
}

.primary-small {
  padding: 0 12px;
  white-space: nowrap;
}

.ghost-button,
.mode,
.icon-button {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  font-size: 13px;
  transition: transform 0.16s ease, border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.ghost-button {
  padding: 0 11px;
  white-space: nowrap;
}

.full-width {
  width: 100%;
}

button:hover {
  border-color: rgba(71, 234, 255, 0.6);
  transform: translateY(-1px);
}

.mode {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 8px 10px;
  color: var(--muted);
  font-weight: 400;
  text-align: left;
}

.mode.active {
  color: var(--cyan);
  border-color: rgba(71, 234, 255, 0.42);
  background: rgba(71, 234, 255, 0.08);
}

.memory-list {
  display: grid;
  gap: 7px;
  margin-bottom: 10px;
}

.memory-item {
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
}

.memory-item strong {
  display: block;
  color: #edf7ff;
  font-size: 12px;
  font-weight: 350;
}

.memory-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.system-status,
.dialog-actions {
  display: flex;
  align-items: center;
}

.system-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(55, 213, 167, 0.24);
  border-radius: 7px;
  color: #c9d8e6;
  background: rgba(6, 20, 18, 0.62);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 16px rgba(55, 213, 167, 0.74);
}

.chat-panel {
  width: 100%;
  height: 820px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(5, 13, 24, 0.9);
}

body.babygpt-mode .chat-panel {
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.chat-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 14px;
  row-gap: 16px;
  padding: 16px 16px 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, rgba(7, 17, 29, 0.92), rgba(2, 6, 13, 0.28));
}

body.babygpt-mode .chat-header {
  display: none !important;
  border-bottom-color: rgba(71, 234, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(11, 24, 38, 0.96), rgba(3, 9, 18, 0.45));
}

body.babygpt-mode #messages,
body.babygpt-mode #chatForm {
  display: none !important;
}

.chat-header > div:first-child {
  text-align: left;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--cyan);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: 0.08em;
}

.meaning-line {
  margin-bottom: 6px;
  color: rgba(217, 231, 245, 0.62);
  font-size: 11px;
  font-weight: 300;
  line-height: 1.25;
  letter-spacing: 0.1em;
}

body.babygpt-mode .meaning-line {
  color: rgba(71, 234, 255, 0.78);
  font-weight: 450;
  letter-spacing: 0.14em;
}

.workspace-title {
  margin: 14px 0 0;
  color: #f4f9ff;
  font-size: 21px;
  font-weight: 450;
  line-height: 1.18;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

body.babygpt-mode .workspace-title {
  color: #ffffff;
  text-shadow: 0 0 18px rgba(71, 234, 255, 0.2);
}

.kernel-list span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid rgba(71, 234, 255, 0.18);
  border-radius: 999px;
  color: #ccefff;
  background: rgba(4, 17, 28, 0.72);
  font-size: 11px;
}

.messages {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 14px;
  scrollbar-color: rgba(22, 167, 255, 0.56) rgba(255, 255, 255, 0.04);
  scrollbar-width: thin;
}

.babygpt-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(245, 250, 255, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(9, 20, 32, 0.94), rgba(3, 8, 16, 0.96)),
    rgba(5, 13, 24, 0.94);
  box-shadow:
    0 18px 60px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(71, 234, 255, 0.06),
    0 0 34px rgba(22, 167, 255, 0.1);
}

.babygpt-card[hidden] {
  display: none;
}

.babygpt-card-header {
  position: relative;
  display: block;
  padding: 0;
  border-bottom: 1px solid rgba(71, 234, 255, 0.16);
  background: #000;
}

.babygpt-banner {
  display: block;
  width: 100%;
  aspect-ratio: 2048 / 885;
  object-fit: cover;
  object-position: center center;
}

.babygpt-status {
  position: absolute;
  right: 12px;
  bottom: 10px;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid rgba(255, 111, 130, 0.32);
  border-radius: 999px;
  color: #ffb5bf;
  background: rgba(255, 111, 130, 0.07);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: none;
  white-space: nowrap;
}

.babygpt-status::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #ff6f82;
  box-shadow: 0 0 12px rgba(255, 111, 130, 0.74);
}

.babygpt-status.live {
  border-color: rgba(55, 213, 167, 0.34);
  color: #bffbea;
  background: rgba(55, 213, 167, 0.08);
}

.babygpt-status.live::before {
  background: var(--green);
  box-shadow: 0 0 12px rgba(55, 213, 167, 0.74);
}

.babygpt-model-switch {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  width: min(360px, calc(100% - 24px));
  margin: 0 12px 12px auto;
  padding: 4px;
  border: 1px solid rgba(245, 250, 255, 0.12);
  border-radius: 999px;
  background: rgba(2, 8, 15, 0.82);
}

.babygpt-model-option {
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  color: rgba(217, 231, 245, 0.72);
  background: transparent;
  box-shadow: none;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.babygpt-model-option.active {
  color: #021018;
  background: var(--cyan);
  box-shadow: 0 0 22px rgba(22, 167, 255, 0.18);
}

.babygpt-messages {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
  overflow-y: auto;
  padding: 14px;
  scrollbar-color: rgba(22, 167, 255, 0.56) rgba(255, 255, 255, 0.04);
  scrollbar-width: thin;
}

.babygpt-message {
  display: flex;
  max-width: 820px;
}

.babygpt-message.user {
  align-self: flex-end;
}

.babygpt-message-stack {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.babygpt-bubble {
  max-width: 100%;
  padding: 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #e3f0fb;
  background: rgba(255, 255, 255, 0.045);
  font-size: 13px;
  line-height: 1.58;
  white-space: pre-wrap;
}

.babygpt-message.user .babygpt-bubble {
  border-color: rgba(71, 234, 255, 0.25);
  background: rgba(22, 167, 255, 0.12);
}

.babygpt-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid rgba(71, 234, 255, 0.13);
  background: rgba(2, 7, 13, 0.7);
}

.babygpt-upload {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid rgba(245, 250, 255, 0.18);
  border-radius: 50%;
  color: #dff8ff;
  background: rgba(5, 14, 24, 0.96);
  box-shadow: inset 0 0 0 1px rgba(71, 234, 255, 0.06);
}

.babygpt-upload::before {
  content: "+";
  display: block;
  font-size: 24px;
  font-weight: 250;
  line-height: 40px;
}

.babygpt-upload.has-image {
  border-color: rgba(55, 213, 167, 0.72);
  color: #021018;
  background: var(--green);
}

.babygpt-image {
  max-width: min(260px, 72vw);
  overflow: hidden;
  border: 1px solid rgba(71, 234, 255, 0.22);
  border-radius: 8px;
  background: #02050a;
}

.babygpt-image img {
  display: block;
  width: 100%;
  height: auto;
}

.babygpt-composer textarea {
  min-height: 54px;
  max-height: 160px;
  flex: 1;
  resize: none;
  padding: 12px 13px;
  font-size: 13px;
  line-height: 1.5;
  border-color: rgba(245, 250, 255, 0.18);
  background: rgba(5, 14, 24, 0.96);
}

.babygpt-composer button[type="submit"] {
  min-width: 84px;
  padding: 0 16px;
}

.babygpt-composer button:disabled {
  cursor: progress;
  opacity: 0.62;
}

.message {
  display: flex;
  gap: 10px;
  max-width: 840px;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(245, 250, 255, 0.72);
  border-radius: 50%;
  color: #f5faff;
  background: #000;
  font-size: 12px;
  font-weight: 400;
}

.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  transform: scale(0.76);
}

body.babygpt-mode .message.assistant .avatar {
  border-color: rgba(245, 250, 255, 0.86);
  box-shadow: 0 0 18px rgba(71, 234, 255, 0.14);
}

.message.user .avatar {
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.bubble {
  max-width: 100%;
  padding: 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  color: #e3f0fb;
  background: rgba(255, 255, 255, 0.045);
  font-size: 13px;
  line-height: 1.58;
  white-space: pre-wrap;
}

.message.user .bubble {
  border-color: rgba(71, 234, 255, 0.24);
  background: rgba(22, 167, 255, 0.12);
}

.bubble p {
  margin: 7px 0 0;
}

.composer {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(2, 5, 10, 0.48);
}

body.babygpt-mode .composer {
  border-top-color: rgba(71, 234, 255, 0.16);
  background: rgba(2, 7, 13, 0.72);
}

textarea,
input {
  width: 100%;
  border: 1px solid rgba(71, 234, 255, 0.16);
  border-radius: 7px;
  color: var(--text);
  background: #07111d;
  outline: none;
  font-weight: 300;
}

body.babygpt-mode .composer textarea {
  border-color: rgba(245, 250, 255, 0.18);
  background: rgba(5, 14, 24, 0.96);
}

textarea::placeholder,
input::placeholder {
  color: rgba(142, 169, 197, 0.74);
  font-weight: 300;
}

textarea {
  min-height: 56px;
  max-height: 180px;
  flex: 1;
  resize: none;
  padding: 12px 13px;
  font-size: 13px;
  line-height: 1.5;
}

input {
  padding: 9px 11px;
}

textarea:focus,
input:focus {
  border-color: rgba(71, 234, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(71, 234, 255, 0.1);
}

.composer button {
  min-width: 84px;
  padding: 0 16px;
}

.rail-copy {
  margin: 0;
  color: #b8c9d9;
  font-size: 12px;
  line-height: 1.48;
}

.kernel-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.field-meter {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 1.5fr 0.7fr;
  gap: 5px;
  height: 7px;
  margin-bottom: 10px;
}

.field-meter span {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--electric), var(--cyan));
  box-shadow: 0 0 18px rgba(78, 219, 255, 0.24);
}

.field-meter span:nth-child(2) {
  background: linear-gradient(90deg, var(--green), var(--cyan));
}

.field-meter span:nth-child(4) {
  background: linear-gradient(90deg, var(--gold), var(--cyan));
}

.site-footer {
  grid-area: footer;
  padding: 0 0 8px;
  color: rgba(142, 169, 197, 0.54);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.28em;
  text-align: left;
  text-transform: uppercase;
}

.site-footer span {
  display: inline;
}

.site-footer span + span::before {
  content: " ";
}

.boundary {
  border-color: rgba(255, 111, 130, 0.26);
}

.boundary .section-title {
  color: #ff9aa8;
}

.completion {
  border-color: rgba(217, 182, 109, 0.26);
}

.completion .section-title {
  color: var(--gold);
}

.packet-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 5;
  width: 440px;
  max-width: 92vw;
  height: 100vh;
  padding: 18px;
  border-left: 1px solid var(--line-strong);
  background: rgba(2, 8, 15, 0.98);
  box-shadow: -20px 0 44px rgba(0, 0, 0, 0.42);
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.packet-panel.open {
  transform: translateX(0);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h3,
.dialog h3 {
  margin: 0;
  color: #f5faff;
  font-size: 17px;
  font-weight: 350;
  letter-spacing: 0;
}

pre {
  overflow: auto;
  white-space: pre-wrap;
  color: #d4edff;
  background: rgba(10, 25, 40, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  font-size: 12px;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.dialog {
  width: min(560px, 92vw);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: #04101e;
  box-shadow: var(--shadow);
  padding: 18px;
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}

.dialog form {
  display: grid;
  gap: 13px;
}

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

.dialog textarea {
  min-height: 120px;
}

.dialog-actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.dialog.wide {
  width: min(760px, 92vw);
}

@media (min-width: 920px) {
  .app-shell {
    grid-template-columns: 230px minmax(380px, 1fr) 250px;
    grid-template-areas:
      "banner banner banner"
      "sidebar main main"
      "rail rail rail"
      "footer footer footer";
    column-gap: 14px;
    row-gap: 16px;
  }

  .insight-rail {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

}

@media (min-width: 1180px) {
  .app-shell {
    grid-template-columns: 250px minmax(520px, 1fr) 270px;
  }
}

@media (max-width: 919px) {
  .app-shell {
    grid-template-columns: 16px minmax(0, 1fr) 16px;
    grid-template-areas:
      "banner banner banner"
      ". main ."
      ". sidebar ."
      ". rail ."
      ". footer .";
  }

  .main {
    order: 1;
  }

  .sidebar {
    order: 2;
  }

  .insight-rail {
    order: 3;
  }
}

@media (min-width: 720px) and (max-width: 919px) {
  .app-shell {
    grid-template-columns: 16px 230px minmax(0, 1fr) 16px;
    grid-template-areas:
      "banner banner banner banner"
      ". sidebar main ."
      ". rail rail ."
      ". footer footer .";
    column-gap: 14px;
  }

  .insight-rail {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  html {
    min-width: 320px;
  }

  body {
    font-size: 13px;
  }

  .app-shell {
    width: 100%;
    grid-template-columns: 10px minmax(0, 1fr) 10px;
    grid-template-areas:
      ". banner ."
      ". main ."
      ". sidebar ."
      ". rail ."
      ". footer .";
    column-gap: 0;
    row-gap: 10px;
    padding: 0 0 18px;
  }

  .page-header {
    display: none;
  }

  .chat-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .chat-provider-badge {
    grid-column: 1 / -1;
  }

  .chat-actions:has(.chat-provider-badge[hidden]) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .insight-rail {
    --rail-card-min: 132px;
    gap: 8px;
  }

  .sidebar {
    gap: 8px;
  }

  .main,
  .sidebar,
  .site-footer {
    width: 100%;
  }

  .new-chat,
  .sidebar-section:not(.language-section),
  .insight-rail {
    display: none;
  }

  .sidebar-section,
  .rail-section {
    padding: 10px;
  }

  .sidebar-section:has(.mode) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .sidebar-section:has(.mode) .section-title {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .sidebar-section:not(.language-section) {
    display: none !important;
  }

  .mode {
    min-height: 38px;
    margin-top: 0;
    padding: 8px 9px;
    text-align: center;
  }

  .chat-provider-badge,
  .chat-actions > .ghost-button,
  .chat-actions > .primary-small,
  .chat-actions > .system-status {
    padding-left: 6px;
    padding-right: 6px;
    font-size: 11px;
  }

  .chat-panel {
    height: min(680px, calc(100svh - 128px));
    min-height: 520px;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    border-radius: 8px;
  }

  body.mobile-keyboard-active,
  body:has(#messageInput:focus),
  body:has(#babyGptInput:focus) {
    height: var(--mobile-vh, 100dvh);
    min-height: var(--mobile-vh, 100dvh);
    max-height: var(--mobile-vh, 100dvh);
    overflow: hidden;
  }

  body.mobile-keyboard-active .app-shell,
  body:has(#messageInput:focus) .app-shell,
  body:has(#babyGptInput:focus) .app-shell {
    position: fixed;
    inset: var(--mobile-vv-top, 0px) 0 auto;
    height: var(--mobile-vh, 100dvh);
    min-height: 0;
    max-height: var(--mobile-vh, 100dvh);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      ". main ."
      ". footer .";
    row-gap: 0;
    padding-bottom: 0;
    overflow: hidden;
  }

  body.mobile-keyboard-active .chat-panel,
  body:has(#messageInput:focus) .chat-panel,
  body:has(#babyGptInput:focus) .chat-panel {
    height: 100%;
    min-height: 0;
  }

  body.mobile-keyboard-active .sidebar,
  body:has(#messageInput:focus) .sidebar,
  body:has(#babyGptInput:focus) .sidebar {
    display: none;
  }

  body.mobile-keyboard-active .page-header,
  body:has(#messageInput:focus) .page-header,
  body:has(#babyGptInput:focus) .page-header {
    display: none;
  }

  .chat-header,
  .composer {
    flex-direction: column;
  }

  .workspace-title {
    font-size: 19px;
  }

  .composer button {
    width: 100%;
  }

  .babygpt-card {
    border-left: 0;
    border-right: 0;
    border-radius: 8px;
  }

  .babygpt-card-header {
    display: grid;
    gap: 8px;
    padding: 0 0 10px;
  }

  .babygpt-banner {
    max-height: 148px;
    object-fit: contain;
    background: #000;
    border: 0;
    border-radius: 8px 8px 0 0;
  }

  .babygpt-status {
    position: static;
    justify-self: end;
    margin-right: 10px;
    margin-bottom: 8px;
    min-height: 24px;
    font-size: 10px;
  }

  .babygpt-model-switch {
    width: calc(100% - 20px);
    margin: 0 10px 10px;
  }

  .babygpt-model-option {
    min-height: 30px;
    padding: 0 6px;
    font-size: 10px;
  }

  body.mobile-keyboard-active .babygpt-card-header,
  body:has(#babyGptInput:focus) .babygpt-card-header {
    padding: calc(env(safe-area-inset-top, 0px) + 42px) 10px 8px;
  }

  body.mobile-keyboard-active .babygpt-banner,
  body:has(#babyGptInput:focus) .babygpt-banner {
    display: none;
  }

  body.mobile-keyboard-active .babygpt-status,
  body:has(#babyGptInput:focus) .babygpt-status {
    width: 100%;
    justify-self: stretch;
    margin-right: 0;
    margin-bottom: 0;
    white-space: normal;
  }

  .babygpt-messages {
    gap: 9px;
    padding: 10px;
  }

  .babygpt-bubble {
    padding: 10px 11px;
    font-size: 12.5px;
    line-height: 1.54;
  }

  .babygpt-composer {
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
    padding: 10px;
  }

  .babygpt-upload {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .babygpt-composer textarea {
    min-height: 48px;
    padding: 10px 11px;
    font-size: 16px;
    line-height: 1.42;
  }

  .babygpt-composer button[type="submit"] {
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    min-height: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    font-size: 0;
    line-height: 1;
  }

  .babygpt-composer button[type="submit"]::before {
    content: "N";
    color: #021018;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0;
  }

  textarea,
  input {
    font-size: 16px;
  }

  .composer button,
  .babygpt-composer button,
  .new-chat,
  .mode,
  .language-option {
    min-height: 44px;
  }

  .site-footer {
    padding: 6px 8px max(6px, env(safe-area-inset-bottom, 0px));
    font-size: clamp(8.5px, 2.45vw, 10.5px);
    line-height: 1.3;
    letter-spacing: clamp(0.08em, 0.72vw, 0.16em);
    text-align: left;
    overflow-wrap: anywhere;
  }

  .site-footer span {
    display: block;
    white-space: nowrap;
  }

  .site-footer span + span::before {
    content: "";
  }

  body.mobile-keyboard-active .site-footer,
  body:has(#messageInput:focus) .site-footer,
  body:has(#babyGptInput:focus) .site-footer {
    padding: 3px 8px 2px;
    line-height: 1.18;
  }
}

@media (max-width: 390px) {
  .app-shell {
    width: 100%;
  }

  .babygpt-banner {
    max-height: 132px;
  }

  .chat-panel {
    height: min(640px, calc(100svh - 112px));
    min-height: 500px;
  }

  .section-title {
    font-size: 10px;
  }
}
