:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background: #050a12;
  color: #f4f7fb;
  --bg: #050a12;
  --panel: rgba(13, 22, 36, .88);
  --panel-2: rgba(18, 31, 50, .9);
  --border: rgba(120, 160, 220, .18);
  --muted: #91a4bc;
  --text: #f4f7fb;
  --cyan: #5cc8ff;
  --blue: #4f7cff;
  --violet: #8c62ff;
  --success: #38e58c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 75% 10%, rgba(49, 92, 190, .18), transparent 35rem),
    radial-gradient(circle at 15% 80%, rgba(104, 65, 190, .14), transparent 30rem),
    var(--bg);
  color: var(--text);
}

button, textarea, a { font: inherit; }

[hidden] { display: none !important; }

/* LOGIN */
.login-view {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-atmosphere {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 30% 45%, rgba(63, 119, 255, .17), transparent 30rem),
    radial-gradient(circle at 82% 30%, rgba(141, 75, 255, .13), transparent 24rem);
}

.login-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  min-height: min(720px, calc(100vh - 56px));
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(6, 12, 22, .86);
  box-shadow: 0 40px 120px rgba(0,0,0,.5);
  backdrop-filter: blur(22px);
}

.login-hero {
  position: relative;
  padding: 34px 44px 42px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(16, 31, 58, .72), rgba(8, 15, 27, .25)),
    radial-gradient(circle at 55% 55%, rgba(76, 110, 255, .18), transparent 24rem);
}

.login-hero::after {
  content: "";
  position: absolute;
  width: 440px;
  height: 440px;
  border: 1px solid rgba(114, 155, 255, .12);
  border-radius: 50%;
  right: -120px;
  top: 80px;
  box-shadow:
    0 0 80px rgba(48, 131, 255, .12),
    inset 0 0 80px rgba(82, 63, 255, .08);
}

.brand-row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark, .rail-logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(145deg, #2b77ff, #8b53ff);
  box-shadow: 0 0 30px rgba(80, 112, 255, .32);
  font-weight: 900;
}

.eyebrow {
  font-size: .72rem;
  letter-spacing: .22em;
  color: #9ebff9;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: .78rem;
}

.hero-copy {
  position: relative;
  z-index: 2;
  display: grid;
  align-content: center;
  min-height: 590px;
  max-width: 650px;
}

.avatar-hero-wrap {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(135deg, rgba(93,198,255,.9), rgba(135,77,255,.9));
  box-shadow: 0 0 70px rgba(65, 120, 255, .25);
  overflow: hidden;
}

.avatar-hero {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 50%;
}

.hero-copy h1 {
  margin: 28px 0 12px;
  font-size: clamp(2.6rem, 6vw, 5rem);
  line-height: .95;
  letter-spacing: -.05em;
}

.hero-copy p {
  margin: 0;
  max-width: 600px;
  color: #acb9cb;
  font-size: 1.08rem;
  line-height: 1.7;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 26px;
}

.hero-badges span {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(20, 34, 54, .72);
  color: #bdd0e9;
  font-size: .8rem;
}

.signin-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 52px;
  background:
    linear-gradient(180deg, rgba(15, 26, 43, .96), rgba(8, 15, 27, .98));
  border-left: 1px solid var(--border);
}

.signin-label {
  color: #79b5ff;
  letter-spacing: .18em;
  font-size: .73rem;
  font-weight: 800;
}

.signin-card h2 {
  margin: 10px 0 10px;
  font-size: 2rem;
}

.signin-card p {
  margin: 0 0 26px;
  color: var(--muted);
  line-height: 1.6;
}

.microsoft-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  text-decoration: none;
  color: #fff;
  font-weight: 750;
  border: 1px solid rgba(120, 163, 255, .35);
  background: linear-gradient(135deg, #2468dc, #5c4ce6);
  box-shadow: 0 18px 45px rgba(58, 85, 230, .28);
}

.microsoft-button.disabled {
  pointer-events: none;
  opacity: .45;
  filter: grayscale(.35);
}

.ms-grid {
  width: 18px;
  height: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}

.ms-grid i:nth-child(1) { background: #f35325; }
.ms-grid i:nth-child(2) { background: #81bc06; }
.ms-grid i:nth-child(3) { background: #05a6f0; }
.ms-grid i:nth-child(4) { background: #ffba08; }

.auth-warning {
  margin-top: 18px;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 190, 86, .26);
  background: rgba(98, 66, 15, .18);
  color: #f1cb8f;
  line-height: 1.5;
  font-size: .86rem;
}

.signin-security {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  color: #7f93aa;
  font-size: .8rem;
}

.security-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 12px rgba(56,229,140,.7);
}

/* APP */
.app-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 78px 1fr;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 18px 12px;
  border-right: 1px solid var(--border);
  background: rgba(7, 13, 23, .92);
  backdrop-filter: blur(18px);
  z-index: 10;
}

.rail-logo {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
}

.rail-nav,
.rail-bottom {
  display: grid;
  gap: 9px;
}

.rail-nav { margin-top: 14px; }
.rail-bottom { margin-top: auto; }

.rail-button {
  width: 48px;
  height: 48px;
  border: 1px solid transparent;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #8195ad;
  background: transparent;
  cursor: pointer;
  transition: .18s ease;
  text-decoration: none;
}

.rail-button:hover,
.rail-button.active {
  color: white;
  border-color: rgba(111, 152, 255, .24);
  background: rgba(53, 85, 151, .2);
  box-shadow: inset 0 0 24px rgba(76, 106, 255, .08);
}

.rail-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace {
  width: min(1380px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0 22px;
}

.info-panel {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(480px, 1.3fr);
  gap: 24px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px 24px;
  background:
    linear-gradient(135deg, rgba(19, 34, 58, .92), rgba(10, 18, 31, .88)),
    radial-gradient(circle at 88% 10%, rgba(91, 84, 255, .17), transparent 18rem);
  box-shadow: 0 18px 55px rgba(0,0,0,.2);
}

.welcome-line {
  color: #83b6ff;
  font-size: .75rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 800;
}

.info-main h1 {
  margin: 5px 0 5px;
  font-size: 1.65rem;
}

.info-main p {
  margin: 0;
  color: var(--muted);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px,1fr));
  gap: 10px;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(128, 164, 219, .13);
  background: rgba(6, 13, 24, .48);
}

.status-card small {
  display: block;
  color: #7890aa;
  font-size: .7rem;
  margin-bottom: 2px;
}

.status-card strong {
  display: block;
  font-size: .82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-icon {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.status-icon.online { background: var(--success); box-shadow: 0 0 11px rgba(56,229,140,.7); }
.status-icon.connected { background: #4f91ff; box-shadow: 0 0 11px rgba(79,145,255,.65); }
.status-icon.search { background: #64d2ff; box-shadow: 0 0 11px rgba(100,210,255,.65); }
.status-icon.memory { background: #9b72ff; box-shadow: 0 0 11px rgba(155,114,255,.65); }

.conversation-shell {
  margin-top: 16px;
  min-height: calc(100vh - 180px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(9, 17, 29, .88), rgba(5, 11, 19, .94));
  box-shadow: 0 22px 70px rgba(0,0,0,.24);
}

.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 26, 43, .72);
}

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

.kyle-mini img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(109, 160, 255, .4);
}

.kyle-mini strong, .kyle-mini span {
  display: block;
}
.kyle-mini strong { font-size: .95rem; }
.kyle-mini span { margin-top: 2px; color: var(--muted); font-size: .74rem; }

.model-tag {
  color: #8fa6c1;
  font-size: .74rem;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.chat {
  overflow-y: auto;
  min-height: 400px;
  padding: 24px clamp(16px, 4vw, 54px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.message-row {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  max-width: min(880px, 92%);
}

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

.message-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid rgba(106, 150, 255, .22);
  background:
    linear-gradient(145deg, rgba(63, 112, 255, .5), rgba(119, 72, 230, .5));
  background-position: center;
  background-size: cover;
}

.message-row.kyle .message-avatar {
  background-image: url('/assets/kyle-avatar.png');
}

.message-row.user .message-avatar::after {
  content: "U";
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: white;
  font-weight: 800;
  font-size: .75rem;
}

.message-body {
  min-width: 0;
}

.message-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 0 6px 2px;
  color: #6f8299;
  font-size: .69rem;
}

.message-row.user .message-meta {
  justify-content: flex-end;
}

.role {
  color: #9bb9dd;
  font-weight: 700;
}

.message-bubble {
  padding: 13px 15px;
  border-radius: 6px 16px 16px 16px;
  border: 1px solid rgba(119, 154, 205, .15);
  background: linear-gradient(145deg, rgba(23, 38, 60, .94), rgba(18, 29, 46, .94));
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-row.user .message-bubble {
  border-radius: 16px 6px 16px 16px;
  background: linear-gradient(135deg, rgba(42, 87, 202, .92), rgba(76, 63, 190, .92));
  border-color: rgba(109, 150, 255, .32);
}

.composer {
  position: sticky;
  bottom: 0;
  padding: 12px 16px 15px;
  border-top: 1px solid var(--border);
  background: rgba(8, 15, 26, .94);
  backdrop-filter: blur(18px);
}

.auto-research-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #7e93ad;
  font-size: .74rem;
  margin: 0 0 9px 3px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5dcaff;
  box-shadow: 0 0 12px rgba(93,202,255,.75);
}

.compose-row {
  display: grid;
  grid-template-columns: 1fr 46px;
  gap: 9px;
  align-items: end;
}

textarea {
  width: 100%;
  min-height: 48px;
  max-height: 180px;
  resize: none;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid rgba(118, 155, 210, .2);
  outline: none;
  color: var(--text);
  background: rgba(4, 10, 18, .72);
  transition: .18s ease;
}

textarea:focus {
  border-color: rgba(88, 148, 255, .52);
  box-shadow: 0 0 0 3px rgba(57, 111, 230, .09);
}

.send-button {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: white;
  cursor: pointer;
  background: linear-gradient(135deg, #347fff, #754df2);
  box-shadow: 0 12px 28px rgba(65, 89, 220, .28);
}

.send-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 920px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .signin-card { border-left: none; min-height: 520px; }

  .info-panel { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 650px) {
  .app-view { grid-template-columns: 62px 1fr; }
  .rail { padding-left: 7px; padding-right: 7px; }
  .rail-button, .rail-logo { width: 44px; height: 44px; }
  .workspace { width: min(100% - 18px, 1380px); padding-top: 9px; }
  .info-panel { padding: 15px; border-radius: 17px; }
  .status-grid { gap: 7px; }
  .conversation-shell { border-radius: 17px; }
  .chat { padding: 18px 12px; }
  .message-row { max-width: 98%; }
  .model-tag { display: none; }
}
