:root {
  --ink: #17285c;
  --muted-ink: #94a7bc;
  --soft-line: #d6ebe8;
  --lava-deep: #4b0b25;
  --lava-wine: #741335;
  --lava-rose: #a84062;
  --lava-light: #dfa0b0;
  --page-background: var(--lava-deep);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  position: relative;
  isolation: isolate;
  min-height: 100dvh;
  color: #1b1b1b;
  background: var(--page-background);
  font-family: Arial, Helvetica, sans-serif;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: -18%;
  content: "";
  background:
    radial-gradient(
      ellipse at 12% 14%,
      var(--lava-light) 0 9%,
      transparent 38%
    ),
    radial-gradient(
      ellipse at 86% 84%,
      var(--lava-rose) 0 11%,
      transparent 40%
    ),
    radial-gradient(
      ellipse at 48% 45%,
      var(--lava-wine) 0 20%,
      transparent 58%
    ),
    linear-gradient(125deg, var(--lava-light), var(--lava-wine) 48%, var(--lava-deep));
  background-size: 155% 155%, 145% 145%, 135% 135%, 100% 100%;
  background-position: 0% 0%, 100% 100%, 50% 50%, 50% 50%;
  filter: blur(32px);
  transform: scale(1.08);
  animation: lava-lamp 28s ease-in-out infinite alternate;
}

button,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.page {
  position: relative;
  z-index: 0;
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 0;
}

.chat-window {
  display: flex;
  flex-direction: column;
  width: min(100%, 1100px);
  min-height: min(800px, calc(100dvh - 48px));
  overflow: hidden;
  background: transparent;
}

.site-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 76px;
  padding-inline: 32px;
}

.menu-button,
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  color: #ffffff;
  background: transparent;
  cursor: pointer;
}

.menu-button {
  justify-self: start;
}

.menu-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.site-menu {
  position: absolute;
  z-index: 10;
  top: 68px;
  left: 24px;
  display: none;
  width: min(240px, calc(100% - 48px));
  padding: 9px;
  border: 1px solid rgb(255 255 255 / 38%);
  border-radius: 20px;
  background: rgb(255 255 255 / 96%);
  box-shadow: 0 14px 34px rgb(35 0 16 / 22%);
}

.site-menu.is-open {
  display: block;
}

.site-menu-list {
  display: grid;
  gap: 4px;
}

.site-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 9px;
  border-radius: 12px;
  color: #171717;
  text-decoration: none;
  font-size: 15px;
  font-weight: 400;
}

.site-menu-item:hover,
.site-menu-item:focus-visible {
  background: #f1e9ed;
}

.site-menu-item-icon {
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.site-menu-divider {
  height: 1px;
  margin: 4px 8px;
  background: #d9d9d9;
}

.brand {
  display: grid;
  justify-items: center;
  color: #ffffff;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: clamp(225px, 30vw, 345px);
  height: auto;
  max-height: 87px;
  object-fit: contain;
}

.login-button {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  min-width: 96px;
  min-height: 44px;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  background: var(--ink);
  font-size: 15px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
}

.account-controls {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 10px;
  min-width: 0;
}

.sessions-button {
  display: grid;
  width: 47px;
  height: 47px;
  padding: 6px;
  place-items: center;
  border-radius: 999px;
  color: var(--accent, #701b3d);
  background: transparent;
  cursor: pointer;
}

.sessions-button svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.sessions-button:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.chat-home {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-start;
  gap: 24px;
  min-height: 0;
  padding: clamp(60px, 10vh, 128px) clamp(24px, 7vw, 96px) 28px;
  background: transparent;
}

.home-crown-doodle {
  position: absolute;
  z-index: 0;
  top: 0;
  left: clamp(18px, 5vw, 56px);
  width: clamp(75px, 12.5vw, 125px);
  height: auto;
  opacity: 0.2;
  mix-blend-mode: multiply;
  pointer-events: none;
  transform: rotate(-4deg);
}

.home-doodle {
  position: absolute;
  z-index: 0;
  height: auto;
  opacity: 0.14;
  mix-blend-mode: multiply;
  pointer-events: none;
  user-select: none;
}

.home-doodle-aplus {
  top: -24px;
  right: 4%;
  width: clamp(110px, 15vw, 154px);
  transform: rotate(5deg);
}

.home-doodle-ruler {
  top: 54%;
  left: 16%;
  width: clamp(170px, 24vw, 250px);
  transform: rotate(-7deg);
}

.home-doodle-star {
  top: 78%;
  left: 4%;
  width: 78px;
  transform: rotate(-9deg);
}

.home-doodle-formula {
  top: 70%;
  right: 0;
  width: clamp(150px, 20vw, 220px);
  transform: rotate(-5deg);
}

.welcome-section {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 34px;
}

.welcome-section h1 {
  max-width: 100%;
  margin: 0;
  color: #ffffff;
  font-size: clamp(28px, 4vw, 52px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 1px 8px rgb(35 0 16 / 24%);
}

.quick-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(100%, 760px);
  overflow-x: auto;
  overflow-y: hidden;
  padding: 3px 2px 8px;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.quick-actions::-webkit-scrollbar {
  display: none;
}

.quick-actions:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

.quick-action {
  display: inline-flex;
  flex: 0 0 140px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 140px;
  min-height: 41px;
  padding: 5px 10px;
  border: 0;
  border-radius: 999px;
  color: #161616;
  background: #ffffff;
  box-shadow: 0 2px 10px rgb(20 60 70 / 3%);
  cursor: pointer;
  font-size: 16px;
  line-height: 1.1;
  scroll-snap-align: start;
}

.subject-emoji {
  font-size: 14px;
  line-height: 1;
}

.chat-composer {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 6px;
  padding: 10px 14px;
  border: 2px solid var(--soft-line);
  border-radius: 28px;
  background: #ffffff;
}

.chat-submit-status {
  min-height: 0;
  margin: 0;
  color: #ffffff;
  font-size: 14px;
  text-align: center;
}

.chat-submit-status:empty {
  display: none;
}

.page.is-chat-transitioning .site-header,
.page.is-chat-transitioning .site-menu,
.chat-home.is-chat-transitioning .welcome-section,
.page.is-chat-transitioning .legal-text {
  opacity: 0;
  transition: opacity 420ms ease;
}

.chat-home.is-chat-transitioning {
  gap: 0;
}

.chat-composer.is-chat-transitioning {
  box-shadow: 0 18px 48px rgb(35 0 16 / 20%);
}

.composer-main textarea.is-chat-transitioning {
  color: transparent;
  caret-color: transparent;
}

.composer-main textarea.is-chat-transitioning::placeholder {
  color: transparent;
}

.chat-transition-message {
  position: fixed;
  z-index: 1001;
  overflow: hidden;
  padding: 5px 0;
  border-radius: 20px;
  color: #24121a;
  background: #ffffff;
  font-size: clamp(16px, 2.4vw, 26px);
  line-height: 1.3;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  transition:
    top 560ms cubic-bezier(.2, 0, 0, 1),
    left 560ms cubic-bezier(.2, 0, 0, 1),
    width 560ms cubic-bezier(.2, 0, 0, 1),
    height 560ms cubic-bezier(.2, 0, 0, 1),
    padding 560ms cubic-bezier(.2, 0, 0, 1),
    font-size 560ms cubic-bezier(.2, 0, 0, 1),
    line-height 560ms cubic-bezier(.2, 0, 0, 1),
    border-radius 560ms cubic-bezier(.2, 0, 0, 1);
}

.chat-transition-message.is-moving {
  border-end-end-radius: 6px;
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.composer-main,
.composer-footer {
  display: flex;
  align-items: center;
}

.composer-main {
  align-items: flex-end;
  gap: 0;
}

.composer-main .icon-button {
  flex: 0 0 auto;
  color: #737373;
}

.composer-main .attachment-button {
  display: inline-grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  color: #4f4f4f;
  border-radius: 50%;
}

.composer-main .attachment-button svg {
  width: 26px;
  height: 26px;
  stroke-width: 2.2;
}

.composer-main textarea {
  flex: 1;
  min-width: 0;
  margin-inline-start: -4px;
  min-height: 38px;
  padding: 5px 0;
  resize: none;
  border: 0;
  outline: 0;
  color: #1b1b1b;
  background: transparent;
  font-size: clamp(16px, 2.4vw, 26px);
  line-height: 1.3;
  overflow-x: hidden;
  overflow-y: hidden;
}

.composer-main textarea::placeholder {
  color: #bcbcbc;
  opacity: 1;
}

.composer-main textarea:focus-visible {
  outline: none;
}

.icon-button svg,
.model-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.composer-footer {
  justify-content: space-between;
  gap: 10px;
}

.model-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 10px;
  border: 0;
  border-radius: 999px;
  color: #171717;
  background: #f2f2f2;
  cursor: pointer;
}

.model-button svg {
  width: 14px;
  height: 14px;
  color: #777777;
}

.model-icon {
  color: #151515;
  font-size: 14px;
}

.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 8px;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  background: var(--ink);
  cursor: pointer;
}

.send-button svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.legal-text {
  margin: 0;
  padding: 18px 24px 22px;
  color: rgb(255 255 255 / 82%);
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
}

.legal-text a {
  color: inherit;
  text-decoration: underline;
}

.menu-button:focus-visible,
.login-button:focus-visible,
.sessions-button:focus-visible,
.quick-action:focus-visible,
.icon-button:focus-visible,
.model-button:focus-visible,
.send-button:focus-visible,
.brand:focus-visible {
  outline: 3px solid #6374c8;
  outline-offset: 3px;
}

.login-button:active,
.quick-action:active,
.model-button:active,
.send-button:active {
  scale: 0.96;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes lava-lamp {
  0% {
    background-position: 0% 0%, 100% 100%, 50% 50%, 50% 50%;
    transform: scale(1.08) translate3d(-2%, -1%, 0);
  }

  50% {
    background-position: 34% 24%, 64% 76%, 38% 58%, 50% 50%;
    transform: scale(1.1) translate3d(1%, 2%, 0);
  }

  100% {
    background-position: 72% 54%, 18% 28%, 62% 40%, 50% 50%;
    transform: scale(1.08) translate3d(-1%, 1%, 0);
  }
}

@media (max-width: 600px) {
  .page {
    min-height: 100dvh;
    padding: 0;
  }

  .chat-window {
    width: 100%;
    min-height: 100dvh;
    border-radius: 0;
  }

  .site-header {
    min-height: 96px;
    padding: max(10px, env(safe-area-inset-top)) 20px 10px;
  }

  .site-menu {
    top: 82px;
    left: 16px;
    width: min(240px, calc(100% - 32px));
  }

  .brand-logo {
    width: 255px;
    max-height: 72px;
  }

  .login-button {
    min-width: 84px;
    min-height: 42px;
    padding-inline: 14px;
    font-size: 16px;
  }

  .account-controls {
    gap: 6px;
  }

  .sessions-button {
    width: 43px;
    height: 43px;
    padding: 5px;
  }

  .chat-home {
    position: relative;
    min-height: 0;
    gap: 24px;
    padding: 64px 22px 24px;
  }

  .welcome-section {
    gap: 28px;
  }

  .home-crown-doodle {
    top: -12px;
    left: 10px;
    width: 72px;
    opacity: 0.18;
  }

  .home-doodle-aplus {
    top: -18px;
    right: 2%;
    width: 92px;
    opacity: 0.13;
  }

  .home-doodle-ruler {
    top: 58%;
    left: 16%;
    width: 155px;
  }

  .home-doodle-star {
    top: 81%;
    left: 3%;
    width: 68px;
  }

  .home-doodle-formula {
    top: 73%;
    right: 0;
    width: 145px;
  }

  .welcome-section h1 {
    width: max-content;
    max-width: none;
    font-size: clamp(20px, 7vw, 38px);
    white-space: nowrap;
  }

  .quick-actions {
    width: calc(100% + 44px);
    max-width: none;
    margin-inline: -22px;
    padding-inline-start: 30px;
    scroll-padding-inline-start: 30px;
    gap: 12px;
  }

  .quick-action {
    flex-basis: 140px;
    min-width: 140px;
    min-height: 41px;
    padding-inline: 10px;
    font-size: clamp(12px, 3.36vw, 16px);
  }

  .subject-emoji {
    font-size: 13px;
  }

  .chat-composer {
    gap: 5px;
    padding: 9px 10px;
    border-radius: 23px;
  }

  .composer-main {
    gap: 8px;
  }

  .composer-main textarea {
    min-height: 38px;
    font-size: 17px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .icon-button svg {
    width: 24px;
    height: 24px;
  }

  .model-button {
    min-height: 32px;
    gap: 5px;
    padding: 4px 8px;
    font-size: 12px;
  }

  .send-button {
    width: 44px;
    height: 44px;
  }

  .legal-text {
    padding: 14px 18px max(18px, env(safe-area-inset-bottom));
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .site-header {
    padding-inline: 14px;
  }

  .chat-home {
    padding-inline: 14px;
  }

  .quick-actions {
    width: calc(100% + 28px);
    margin-inline: -14px;
    padding-inline-start: 22px;
    scroll-padding-inline-start: 22px;
  }

  .brand-logo {
    width: 217px;
    max-height: 62px;
  }

  .login-button {
    min-width: 78px;
    padding-inline: 10px;
  }

  .quick-action {
    flex-basis: 130px;
    min-width: 130px;
    padding-inline: 8px;
    font-size: 12px;
  }

  .subject-emoji {
    font-size: 12px;
  }

}

@media (prefers-reduced-motion: reduce) {
  body::before {
    animation: none;
  }

  .page.is-chat-transitioning .site-header,
  .page.is-chat-transitioning .site-menu,
  .chat-home.is-chat-transitioning .welcome-section,
  .page.is-chat-transitioning .legal-text {
    transition: none;
  }

  .chat-transition-message {
    transition: none;
  }

  .login-button:active,
  .quick-action:active,
  .model-button:active,
  .send-button:active {
    scale: 1;
  }
}

/* Paper notebook theme */
:root {
  --paper: #f2f5fa;
  --grid: #dce5f2;
  --accent: #701b3d;
  --text: #29252a;
  --surface: #ffffff;
  --text-secondary: #99949a;
  --soft-line: #dce5f2;
  --ink: #701b3d;
}

body {
  color: var(--text);
  background: var(--paper);
}

body::before {
  z-index: -2;
  inset: 0;
  background-image:
    linear-gradient(to right, rgb(220 229 242 / 58%) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(220 229 242 / 58%) 1px, transparent 1px),
    radial-gradient(circle, rgb(112 27 61 / 4%) 0.6px, transparent 0.8px);
  background-size: 28px 28px, 28px 28px, 7px 7px;
  filter: none;
  opacity: 0.9;
  transform: none;
  animation: none;
}

.menu-button,
.icon-button {
  color: var(--accent);
}

.site-menu {
  border-color: var(--grid);
  background: rgb(255 255 255 / 96%);
  box-shadow: 0 14px 34px rgb(41 37 42 / 12%);
}

.site-menu-item {
  color: var(--text);
}

.site-menu-item:hover,
.site-menu-item:focus-visible {
  background: #f1f5fb;
}

.brand {
  color: var(--accent);
}

.login-button,
.send-button {
  background: var(--accent);
}

.welcome-section h1 {
  color: var(--accent);
  text-shadow: none;
}

.quick-action {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 6px 18px rgb(41 37 42 / 8%);
}

.chat-composer {
  border-color: var(--grid);
  background: var(--surface);
  box-shadow: 0 10px 28px rgb(41 37 42 / 9%);
}

.chat-submit-status {
  color: var(--text-secondary);
}

.legal-text {
  color: var(--text-secondary);
}

.chat-transition-message {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 10px 28px rgb(41 37 42 / 9%);
}
