:root {
  --ink: #172d2a;
  --ink-soft: #5d6b66;
  --forest: #173f3b;
  --forest-deep: #0d2e2b;
  --paper: #f2ecdf;
  --paper-bright: #fbf7ed;
  --paper-shadow: #d9cdb9;
  --red: #a74032;
  --gold: #bd9250;
  --line: rgba(23, 63, 59, 0.16);
  --shadow: 0 28px 80px rgba(20, 43, 39, 0.13);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  margin: 0;
  background:
    radial-gradient(circle at 85% 8%, rgba(189, 146, 80, 0.16), transparent 26rem),
    linear-gradient(140deg, #ded4c4 0%, #f3eee5 50%, #d9d0c2 100%);
  color: var(--ink);
  font-family: "Vazirmatn", "Noto Naskh Arabic", "Geeza Pro", Tahoma, serif;
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.auth-gate {
  position: fixed;
  z-index: 10;
  display: grid;
  inset: 0;
  place-items: center;
  padding: 1.25rem;
  background:
    radial-gradient(circle at 50% 22%, rgba(189, 146, 80, 0.2), transparent 24rem),
    linear-gradient(145deg, #122f2c 0%, #0b2422 100%);
}

.auth-gate::before {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(30deg, transparent 48%, rgba(255, 255, 255, 0.035) 49%, transparent 51%),
    linear-gradient(-30deg, transparent 48%, rgba(255, 255, 255, 0.025) 49%, transparent 51%);
  background-size: 3.2rem 3.2rem;
  content: "";
}

.auth-card {
  position: relative;
  width: min(31rem, 100%);
  padding: clamp(2rem, 7vw, 4rem);
  border: 1px solid rgba(244, 213, 157, 0.25);
  border-radius: 1.25rem;
  color: #f8f0df;
  background: rgba(8, 31, 29, 0.72);
  box-shadow: 0 2rem 7rem rgba(0, 0, 0, 0.3);
  text-align: center;
  backdrop-filter: blur(16px);
  animation: reveal 550ms ease both;
}

.auth-seal {
  display: grid;
  width: 4.5rem;
  height: 4.5rem;
  margin: 0 auto 1.75rem;
  place-items: center;
  border: 1px solid rgba(244, 213, 157, 0.65);
  border-radius: 50%;
  color: #f3d497;
  font-size: 2rem;
  box-shadow: inset 0 0 0 0.45rem rgba(189, 146, 80, 0.07);
}

.auth-card .eyebrow {
  margin-bottom: 0.7rem;
}

.auth-card h1 {
  margin: 0;
  font-family: "Noto Naskh Arabic", "Geeza Pro", serif;
  font-size: clamp(2.5rem, 8vw, 4.2rem);
  font-weight: 500;
}

.auth-copy {
  margin: 1rem auto 1.75rem;
  color: rgba(248, 240, 223, 0.72);
  line-height: 2;
}

.auth-action {
  min-width: 12rem;
  padding: 0.85rem 1.35rem;
  border: 1px solid rgba(244, 213, 157, 0.35);
  border-radius: 999px;
  color: #173f3b;
  background: #efd49c;
  cursor: pointer;
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.2);
  transition: transform 180ms ease, filter 180ms ease;
}

.auth-action:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-2px);
}

.auth-action:disabled {
  cursor: wait;
  opacity: 0.6;
}

.auth-status {
  min-height: 1.5rem;
  margin: 1rem 0 0;
  color: #c9b98f;
  font-size: 0.78rem;
  line-height: 1.8;
}

.auth-status.error {
  color: #ef9e91;
}

.auth-note {
  margin: 2rem 0 0;
  color: rgba(248, 240, 223, 0.4);
  font-size: 0.68rem;
}

.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(15rem, 21rem) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  width: min(92rem, calc(100vw - 3rem));
  height: min(58rem, calc(100vh - 3rem));
  height: min(58rem, calc(100dvh - 3rem));
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
  animation: reveal 700ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.spine {
  position: relative;
  z-index: 2;
  display: flex;
  min-height: 0;
  flex-direction: column;
  justify-content: space-between;
  padding: 2.5rem 2.25rem 2rem;
  overflow: hidden;
  color: #f8f0df;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18), transparent 12%, transparent 88%, rgba(0, 0, 0, 0.18)),
    linear-gradient(160deg, var(--forest) 0%, var(--forest-deep) 100%);
  box-shadow: inset -1px 0 rgba(255, 255, 255, 0.08);
}

.spine::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.2;
  background-image:
    linear-gradient(30deg, transparent 48%, rgba(255, 255, 255, 0.09) 49%, transparent 51%),
    linear-gradient(-30deg, transparent 48%, rgba(255, 255, 255, 0.06) 49%, transparent 51%);
  background-size: 2.5rem 2.5rem;
}

.seal,
.spine-copy,
.privacy-mark {
  position: relative;
}

.seal {
  display: grid;
  width: 3.5rem;
  height: 3.5rem;
  place-items: center;
  border: 1px solid rgba(244, 213, 157, 0.6);
  border-radius: 50%;
  color: #f3d497;
  font-size: 1.65rem;
  box-shadow: inset 0 0 0 0.3rem rgba(189, 146, 80, 0.08);
}

.eyebrow {
  margin: 0 0 1rem;
  color: #d7b87a;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
}

.spine h1 {
  margin: 0;
  font-family: "Noto Naskh Arabic", "Geeza Pro", serif;
  font-size: clamp(2rem, 2.6vw, 2.6rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

/* ---- Conversation rail -------------------------------------------------- */

.spine-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.spine-head .seal {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.3rem;
}

.spine-head .eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.66rem;
}

.threads {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  margin: 1.75rem 0 1.25rem;
}

.threads-title {
  margin: 0 0 0.6rem;
  color: rgba(248, 240, 223, 0.45);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
}

.thread-list {
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  scrollbar-color: rgba(248, 240, 223, 0.25) transparent;
}

.threads-empty {
  margin: 0.4rem 0 0;
  color: rgba(248, 240, 223, 0.4);
  font-size: 0.78rem;
  line-height: 1.9;
}

.thread {
  display: flex;
  align-items: stretch;
  gap: 0.15rem;
  border-radius: 0.6rem;
}

.thread:hover,
.thread:focus-within {
  background: rgba(255, 255, 255, 0.07);
}

.thread.active {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(244, 213, 157, 0.25);
}

.thread-open {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 0.15rem;
  padding: 0.6rem 0.7rem;
  border: 0;
  border-radius: 0.6rem;
  background: transparent;
  cursor: pointer;
  text-align: start;
}

.thread-title {
  overflow: hidden;
  color: rgba(248, 240, 223, 0.92);
  font-size: 0.83rem;
  line-height: 1.6;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-when {
  color: rgba(248, 240, 223, 0.42);
  font-size: 0.67rem;
}

.thread-delete {
  flex-shrink: 0;
  align-self: center;
  padding: 0.3rem 0.5rem;
  border: 0;
  border-radius: 0.45rem;
  color: rgba(248, 240, 223, 0.45);
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 140ms ease, color 140ms ease;
}

.thread:hover .thread-delete,
.thread:focus-within .thread-delete,
.thread-delete:focus-visible {
  opacity: 1;
}

.thread-delete:hover {
  color: #f0a094;
  background: rgba(239, 158, 145, 0.12);
}

.scrim {
  position: absolute;
  z-index: 3;
  inset: 0;
  background: rgba(9, 26, 24, 0.5);
  backdrop-filter: blur(2px);
}

/* Collapsing the rail returns its width to the conversation, which matters most
   when the workbook is docked and three columns are competing. */
@media (min-width: 761px) {
  .shell.rail-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .shell.rail-collapsed .spine {
    display: none;
  }
}

/* ---- Project workbook ---------------------------------------------------
   Docked as a third column where there is room, so a glossary can be read
   beside the transcript; a slide-over below that, where it cannot be. */

.panel {
  position: absolute;
  z-index: 4;
  display: flex;
  inset-block: 0;
  inset-inline-end: 0;
  width: min(26rem, 88vw);
  flex-direction: column;
  padding: 1.5rem 1.5rem 1.25rem;
  border-inline-end: 1px solid var(--line);
  background: var(--paper-bright);
  box-shadow: 1rem 0 3rem rgba(20, 43, 39, 0.18);
}

.panel[hidden] {
  display: none !important;
}

.panel-scrim {
  position: absolute;
  z-index: 3;
  inset: 0;
  background: rgba(20, 43, 39, 0.28);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel-eyebrow {
  margin: 0;
  color: var(--red);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
}

.panel-tabs {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 1rem;
}

.panel-tab {
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 0.76rem;
  transition: background 140ms ease, border-color 140ms ease;
}

.panel-tab:hover {
  border-color: rgba(23, 63, 59, 0.4);
}

.panel-tab.active {
  border-color: transparent;
  color: #fffaf0;
  background: var(--forest);
}

.panel-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-shrink: 0;
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 500;
}

.panel-note {
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.panel-delete {
  padding: 0.2rem 0.45rem;
  font-size: 0.7rem;
}

.panel-delete:hover {
  color: var(--red);
}

.panel-body {
  min-height: 0;
  margin-top: 0.9rem;
  padding-inline-end: 0.4rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 0.92rem;
  scrollbar-color: rgba(23, 63, 59, 0.25) transparent;
}

.panel-empty {
  margin: 1rem 0 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 2;
}

/* Docked: the workbook takes its own column instead of covering the desk. */
@media (min-width: 1200px) {
  .shell.with-panel {
    grid-template-columns: minmax(15rem, 21rem) minmax(0, 1fr) minmax(20rem, 26rem);
  }

  .shell.with-panel.rail-collapsed {
    grid-template-columns: minmax(0, 1fr) minmax(20rem, 26rem);
  }

  .shell.with-panel .panel {
    position: relative;
    z-index: 1;
    width: auto;
    box-shadow: none;
  }

  .shell.with-panel .panel-scrim {
    display: none;
  }
}

.subtitle {
  max-width: 12rem;
  margin: 1.5rem 0 0;
  color: rgba(248, 240, 223, 0.68);
  font-size: 0.92rem;
  line-height: 1.9;
}

.privacy-mark {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: rgba(248, 240, 223, 0.65);
  font-size: 0.76rem;
}

.privacy-dot {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  background: #9cc5a9;
  box-shadow: 0 0 0 0.28rem rgba(156, 197, 169, 0.1);
}

.desk {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(23, 63, 59, 0.035) 1px, transparent 1px) 0 0 / 100% 2.35rem,
    var(--paper-bright);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem clamp(1.25rem, 4vw, 3.75rem);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 247, 237, 0.9);
  backdrop-filter: blur(16px);
}

.date-line,
.welcome {
  margin: 0;
}

.date-line {
  color: var(--red);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

/* Naskh is a display face. At interface sizes it costs legibility, so the
   greeting uses the body face at a heavier weight instead. */
.welcome {
  margin-top: 0.25rem;
  font-size: 1.18rem;
  font-weight: 500;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.quiet-action {
  padding: 0.55rem 0.7rem;
  border: 0;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  font-size: 0.74rem;
}

.quiet-action:hover {
  color: var(--red);
}

.new-chat:hover {
  border-color: rgba(23, 63, 59, 0.45);
  background: rgba(23, 63, 59, 0.05);
  transform: translateY(-1px);
}

.conversation {
  min-width: 0;
  min-height: 0;
  padding: 1rem clamp(1.25rem, 5vw, 5rem) 2rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-color: rgba(23, 63, 59, 0.25) transparent;
}

.opening {
  display: grid;
  width: 100%;
  min-width: 0;
  place-items: center;
  max-width: 50rem;
  min-height: 100%;
  margin: auto;
  padding: 2rem 0;
  text-align: center;
  animation: rise 700ms 180ms ease both;
}

.ornament {
  margin-bottom: 1rem;
  color: var(--gold);
  font-size: 1.1rem;
}

.opening h2 {
  margin: 0;
  font-family: "Noto Naskh Arabic", "Geeza Pro", serif;
  font-size: clamp(2rem, 4vw, 3.4rem);
  font-weight: 500;
  letter-spacing: -0.035em;
}

.opening > p {
  max-width: 35rem;
  margin: 0.9rem auto 2.2rem;
  color: var(--ink-soft);
  line-height: 2;
}

.prompts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
  gap: 0.8rem;
}

.prompts button {
  min-width: 0;
  min-height: 7rem;
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.42);
  text-align: right;
  cursor: pointer;
  box-shadow: 0 0.7rem 2rem rgba(46, 58, 52, 0.04);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.prompts button:hover {
  border-color: rgba(167, 64, 50, 0.4);
  box-shadow: 0 1rem 2.5rem rgba(46, 58, 52, 0.08);
  transform: translateY(-3px);
}

.prompts span,
.prompts small {
  display: block;
}

.prompts span {
  font-size: 1rem;
}

.prompts small {
  margin-top: 0.6rem;
  color: var(--ink-soft);
  font-size: 0.75rem;
  line-height: 1.6;
}

.message {
  display: grid;
  min-width: 0;
  max-width: 54rem;
  margin: 1.4rem auto;
  animation: rise 260ms ease both;
}

.message.user {
  justify-items: end;
}

.message.assistant {
  justify-items: start;
}

.message-label {
  margin-bottom: 0.45rem;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.bubble {
  /* A grid item defaults to min-width:auto and so refuses to shrink below its
     widest child. A glossary table or a citation block would then push the
     whole page sideways instead of scrolling inside its own box. */
  min-width: 0;
  max-width: min(90%, 45rem);
  padding: 1rem 1.25rem;
  border-radius: 1rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 2;
}

.bubble[dir="ltr"] {
  text-align: left;
}

.bubble[dir="rtl"] {
  text-align: right;
}

.user .bubble {
  border-bottom-left-radius: 0.25rem;
  color: #fffaf0;
  background: var(--forest);
  /* A pasted passage keeps each line's own direction instead of being forced
     into the direction of the line above it. */
  unicode-bidi: plaintext;
}

.assistant .bubble {
  border: 1px solid var(--line);
  border-bottom-right-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: 0 0.75rem 2rem rgba(31, 55, 49, 0.05);
}

/* ---- Rendered reply ----------------------------------------------------
   The companion answers with numbered variants, glossary tables, quoted
   passages and translator's notes. Each block below carries its own dir
   attribute, set when the block was built. */

.bubble.prose {
  white-space: normal;
}

.prose > :first-child {
  margin-top: 0;
}

.prose > :last-child {
  margin-bottom: 0;
}

.prose p {
  margin: 0 0 0.85em;
  line-height: 2;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  margin: 1.4em 0 0.6em;
  font-size: 1.05em;
  font-weight: 600;
  line-height: 1.7;
}

.prose h1 {
  font-size: 1.25em;
}

.prose h2 {
  font-size: 1.15em;
}

.prose ul,
.prose ol {
  margin: 0 0 0.9em;
  padding-inline-start: 1.5em;
}

.prose li {
  margin-bottom: 0.35em;
  line-height: 2;
}

.prose li::marker {
  color: var(--gold);
}

.prose li > ul,
.prose li > ol {
  margin-top: 0.35em;
}

.prose blockquote {
  margin: 0 0 0.9em;
  padding-inline-start: 1em;
  border-inline-start: 2px solid var(--gold);
  color: var(--ink-soft);
}

.prose a {
  color: var(--red);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.prose code {
  padding: 0.1em 0.35em;
  border-radius: 0.3em;
  background: rgba(23, 63, 59, 0.07);
  font-family: "SF Mono", "Cascadia Mono", "Roboto Mono", monospace;
  font-size: 0.88em;
}

.prose pre {
  margin: 0 0 0.9em;
  padding: 0.85em 1em;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: rgba(23, 63, 59, 0.05);
}

.prose pre code {
  padding: 0;
  background: none;
  line-height: 1.7;
}

.prose hr {
  margin: 1.4em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

/* Persian has no true italic; synthetic oblique distorts the letterforms.
   Emphasis in Persian is marked with a rule instead. */
.prose em:dir(rtl) {
  font-style: normal;
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 0.25em;
}

.table-scroll {
  max-width: 100%;
  margin: 0 0 0.9em;
  overflow-x: auto;
}

.prose table {
  border-collapse: collapse;
  min-width: 100%;
  font-size: 0.94em;
}

.prose th,
.prose td {
  padding: 0.5em 0.8em;
  border: 1px solid var(--line);
  line-height: 1.8;
  text-align: start;
  vertical-align: top;
}

.prose th {
  background: rgba(23, 63, 59, 0.06);
  font-weight: 600;
}

/* A message that never reached the companion, kept on screen so its text is
   still recoverable. */
.message.unsent .bubble {
  opacity: 0.55;
  box-shadow: none;
}

.message.unsent .message-label::after {
  color: var(--red);
  content: " · فرستاده نشد";
}

.message-actions {
  margin-top: 0.4rem;
  opacity: 0;
  transition: opacity 160ms ease;
}

.message:hover .message-actions,
.message:focus-within .message-actions {
  opacity: 1;
}

.copy-action {
  padding: 0.3rem 0.55rem;
  border-radius: 0.4rem;
  font-size: 0.7rem;
}

.copy-action:hover {
  background: rgba(23, 63, 59, 0.06);
}

@media (hover: none) {
  .message-actions {
    opacity: 1;
  }
}

.thinking .bubble {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 5.4rem;
  min-height: 3.3rem;
}

.thinking i {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1.1s infinite ease-in-out;
}

.thinking i:nth-child(2) {
  animation-delay: 120ms;
}

.thinking i:nth-child(3) {
  animation-delay: 240ms;
}

.composer-wrap {
  min-width: 0;
  padding: 1rem clamp(1.25rem, 5vw, 5rem) 1.25rem;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(251, 247, 237, 0.76), var(--paper-bright) 45%);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  max-width: 54rem;
  margin: auto;
  padding: 0.55rem 0.55rem 0.55rem 1rem;
  border: 1px solid rgba(23, 63, 59, 0.24);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0.8rem 2.6rem rgba(31, 55, 49, 0.08);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.composer:focus-within {
  border-color: rgba(23, 63, 59, 0.58);
  box-shadow: 0 1rem 3rem rgba(31, 55, 49, 0.12);
}

textarea {
  width: 100%;
  max-height: 13rem;
  padding: 0.65rem 0.75rem;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  line-height: 1.8;
}

textarea[dir="ltr"] {
  text-align: left;
}

textarea[dir="rtl"] {
  text-align: right;
}

textarea::placeholder {
  color: #89918d;
}

.send {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border: 0;
  border-radius: 0.75rem;
  color: #fff8e9;
  background: var(--red);
  cursor: pointer;
  box-shadow: 0 0.5rem 1rem rgba(167, 64, 50, 0.22);
  transition: transform 180ms ease, filter 180ms ease;
}

.send:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.send:disabled {
  cursor: wait;
  filter: grayscale(0.5);
  opacity: 0.55;
}

.send svg {
  width: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transform: scaleX(-1);
}

.composer-note {
  max-width: 54rem;
  margin: 0.55rem auto 0;
  color: #7b8580;
  font-size: 0.68rem;
  text-align: center;
}

.composer-note.error {
  color: var(--red);
}

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

@keyframes reveal {
  from {
    opacity: 0;
    transform: scale(0.985) translateY(0.6rem);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(0.65rem);
  }
}

@keyframes pulse {
  0%,
  70%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-0.25rem);
  }
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .shell {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  /* The rail becomes a drawer. It keeps the same markup so there is only ever
     one conversation list in the document. */
  .spine {
    position: absolute;
    z-index: 4;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(20rem, 84vw);
    padding: 1.5rem 1.25rem;
    transform: translateX(100%);
    transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: -1rem 0 3rem rgba(0, 0, 0, 0.35);
  }

  .spine.open {
    transform: none;
  }

  .panel {
    width: 100%;
    padding: 1.25rem 1rem 1rem;
  }

  .panel-toggle {
    padding: 0.55rem 0.5rem;
  }

  .thread-delete {
    opacity: 1;
  }

  .topbar {
    min-width: 0;
    padding: 1rem;
  }

  .topbar > div {
    min-width: 0;
  }

  .welcome {
    max-width: 48vw;
    overflow: hidden;
    font-size: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .new-chat {
    padding: 0.55rem 0.7rem;
    font-size: 0.78rem;
  }

  .conversation {
    min-width: 0;
    overflow-x: hidden;
    padding: 0.5rem 1rem 1.25rem;
  }

  .opening {
    align-content: center;
    padding: 1rem 0;
  }

  .opening h2 {
    font-size: 2rem;
  }

  .opening > p {
    margin-bottom: 1.25rem;
    font-size: 0.88rem;
  }

  .prompts {
    grid-template-columns: 1fr;
  }

  .prompts button {
    min-height: auto;
    padding: 0.9rem 1rem;
  }

  .prompts small {
    margin-top: 0.2rem;
  }

  .composer-wrap {
    min-width: 0;
    padding: 0.75rem 0.75rem max(0.75rem, env(safe-area-inset-bottom));
  }

  .composer {
    min-width: 0;
  }

  .bubble {
    max-width: 95%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
