:root {
  --bg-left: #0e0e0e;
  --bg-right: linear-gradient(135deg, #f05a28, #f0a202);
  --text: #f5f5f5;
  --muted: #c8c8c8;
  --accent: #ffffff;
  --btn-bg: #ffffff;
  --btn-text: #0e0e0e;
  --btn-hover: rgba(255, 255, 255, .85);
  --rail-width: 16rem;
  --gutter: 1rem;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .25);
  --maxw: 900px;
  --header-h: 64px;
  --footer-h: 30px;
}

/* global reset for safer sizing */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg-right);
  display: grid;
  /*grid-template-columns: 1fr var(--rail-width);*/
  min-height: 100%;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  grid-template-areas: "header header"
    "main nav"
    "footer footer";
  grid-template-rows: 1fr 3fr 1fr;
  grid-template-columns: 2fr 1fr;
  overflow: clip;
}

body>header {
  grid-area: header;
}

body>main {
  grid-area: main;
}

body>nav {
  grid-area: nav;
}

body>footer {
  grid-area: footer;
}

/* header */
.site-header {
  /*position: fixed;*/
  position: sticky;
  inset: 0 0 auto 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  background: rgba(14, 14, 14, .92);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  z-index: 100;
}

.brand {
  font-weight: 700;
  letter-spacing: .5px;
  font-size: clamp(1.3rem, 2vw + .5rem, 1.8rem);
  line-height: 1.2;
  display: flex;
  align-items: center;
}

.brand .name {
  padding-left: 5px;
}

.tagline {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: .4px;
  text-align: right;
}

/* left panel */
.live {
  background: var(--bg-left);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--header-h) + min(6vh, 4rem)) var(--gutter) min(6vh, 4rem);
  height: auto;
  overflow-y: auto;
  scrollbar-color: #1d1d1d99 chocolate;
}

.card {
  width: 100%;
  max-width: var(--maxw);
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  padding: clamp(1rem, 2vw + .5rem, 2rem);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
  backdrop-filter: blur(6px);
}

h1 {
  font-size: clamp(32px, 3.2vw + 14px, 52px);
  margin: 0 0 .5rem 0;
  letter-spacing: .1px;
}

.sub {
  color: var(--muted);
  margin: .25rem 0 1.25rem;
  font-size: 1.05rem;
  /*max-width:52ch;*/
}

/* actions */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin: 1rem 0 0;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: .7rem 1rem;
  cursor: pointer;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-weight: 600;
  letter-spacing: .2px;
  transition: transform .06s ease, background .2s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover {
  background: var(--btn-hover);
  transform: translateY(-1px);
}

.btn.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(255, 255, 255, .28);
  opacity: .95;
}

.btn.secondary:hover {
  opacity: 1;
}

/* prompts (final, conflict-free) */
.prompt-group {
  margin-top: 1rem;
}

.prompt-title {
  font-weight: 600;
  font-size: .95rem;
  color: var(--muted);
  letter-spacing: .2px;
  margin: .25rem 0 .4rem;
}

/* ——— chips as responsive grid: 2 cols desktop, 1 col mobile ——— */
.prompts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: .7rem;
  /* space between questions */
  max-width: 900px;
  /* keeps cluster neat under the subline */
}

.prompts .chip {
  display: block;
  width: 100%;
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .05);
  backdrop-filter: blur(4px);
  color: var(--accent);
  font-size: 0.95rem;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
  text-decoration: none;
  /* remove underline */
}

.prompts .chip:hover {
  background: rgba(255, 255, 255, .15);
}



/* right rail */
nav {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h) - var(--footer-h));
  /*height: auto;*/
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-right);
  /*border-left: 1px solid rgba(255, 255, 255, .2);*/
  padding-bottom: min(6vh, 4rem);
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-end;
  padding: 2rem var(--gutter);
}

.rail a {
  color: #fff;
  text-decoration: none;
  opacity: .92;
}

.rail a[aria-current="page"] {
  font-weight: 800;
  text-decoration: underline 2px;
  font-size: larger;
  color: #0d0d0d;
}

/* footer */
footer {
  /*position: fixed;*/
  position: sticky !important;
  left: var(--gutter);
  /*bottom: var(--gutter);*/
  bottom: 0;
  color: var(--muted);
  font-size: 14px;
  z-index: 1;
  padding: 5px 10px;
  background: var(--bg-right);
  height: var(--footer-h);
}

/* accessibility */
a:focus,
button:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* responsive */
@media (max-width:900px) {
  body {
    grid-template-columns: 1fr;
    grid-template-areas: "header"
                          "main"
                          "nav"
                          "footer";
    grid-template-rows: auto 1fr auto auto;
  }

  nav {
    /*position: static;*/
    bottom: var(--footer-h);
    height: auto;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, .2);
    /*margin-top: var(--header-h);*/
    padding-bottom: 0px;
  }

  .rail {
    flex-direction: row;
    justify-content: center;
    gap: 1.25rem;
  }

  footer {
    /*position: static;*/
    /*margin: 1rem auto 2rem;*/
    text-align: center;
    width: -webkit-fill-available;
    bottom: 0;
  }

  .live {
    display: block;
    padding: 0px var(--gutter);
  }

  .prompts {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }

  .site-header {
    padding-bottom: 5px;
    width: auto;
  }

  /*body>header,
  body>main,
  body>nav,
  body>footer {
    grid-area: initial;
  }*/
}

@media (max-width:900px) {
  .prompts {
    grid-template-columns: 1fr;
    gap: .55rem .6rem;
  }
}

/* Ask Grace input */
.ask {
  display: flex;
  gap: .6rem;
  align-items: center;
  margin: .75rem 0 1rem;
}

.ask-input {
  flex: 1 1 auto;
  padding: .75rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.25;
  outline: none;
}

.ask-input::placeholder {
  color: rgba(255, 255, 255, .6);
}

.ask-input:focus {
  border-color: rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .09);
}

.ask-btn {
  white-space: nowrap;
}

/* small screens: stack neatly */
@media (max-width: 560px) {
  .ask {
    flex-direction: column;
    align-items: stretch;
  }

  .ask-btn {
    width: 100%;
  }
}

/* visually-hidden utility for the label */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Chat layout */
.chat {
  display: block;
  margin-top: 1rem;
}

#chat[hidden] {
  display: none;
}

.chat-thread {
  height: clamp(40vh, 56vh, 68vh);
  overflow-y: auto;
  padding: .25rem .25rem 0;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
}

/* Message bubbles */
.msg {
  max-width: 72ch;
  padding: .6rem .8rem;
  margin: .6rem;
  border-radius: 12px;
  line-height: 1.35;
  word-wrap: break-word;
}

.msg.user {
  margin-left: auto;
  background: var(--bg-right);
  border: 1px solid rgba(255, 255, 255, .18);
}

.msg.assistant {
  margin-right: auto;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
}

.msg.loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.85;
  font-style: italic;
}

.msg .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: gm-spin 1s linear infinite;
}

@keyframes gm-spin {
  to {
    transform: rotate(360deg);
  }
}

/* When chat is open, hide the suggested questions */
.card.chat-open .prompt-group {
  display: none;
}