* {
  box-sizing: border-box;
}

[hidden] {
  display: none!important;
}

:root {
  color-scheme: dark;
  --bg: #19191b;
  --surface: #252528;
  --line: #38383d;
  --ink: #efedf1;
  --muted: #adabb4;
  --accent: #d5c5eb;
  font: 16px/1.45 -apple-system,BlinkMacSystemFont,"Helvetica Neue",Arial,sans-serif;
  color: var(--ink);
  background: #131315;
}

body {
  margin: 0;
}

button,input,textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  opacity: .45;
  cursor: default;
}

button:focus-visible,a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  touch-action: manipulation;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.symbols {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

#shell {
  position: relative;
  display: flex;
  flex-direction: column;
  margin: auto;
  max-width: 720px;
  background: var(--bg);
  height: 100vh;
  height: min(100dvh,var(--tg-viewport-height,100dvh));
  padding-top: max(env(safe-area-inset-top),var(--tg-content-safe-area-inset-top,0px));
  padding-bottom: max(env(safe-area-inset-bottom),var(--tg-content-safe-area-inset-bottom,0px));
  padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
}

.mast {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  min-height: 60px;
  padding: 6px 20px;
  border-bottom: 1px solid #ffffff0c;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 24px;
  letter-spacing: -.065em;
  font-weight: 730;
}

.brand svg {
  height: 26px;
  width: 26px;
  color: var(--accent);
}

.demo {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.screen {
  min-height: 0;
  flex: 1;
}

.reading {
  padding: 26px clamp(16px,5vw,36px);
  overflow: auto;
}

h1,h2,p {
  margin: 0;
}

h1 {
  font-size: clamp(30px,7vw,43px);
  letter-spacing: -.055em;
  font-weight: 620;
  line-height: 1.08;
  margin: 10px 0 26px;
}

h2 {
  font-size: 19px;
  letter-spacing: -.032em;
  font-weight: 610;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 36px;
}

.choice {
  border: 1px solid #ffffff12;
  position: relative;
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  text-align: left;
  min-width: 0;
  min-height: 158px;
  padding: 16px 12px;
  border-radius: 19px;
  background: linear-gradient(150deg,#373140,#29282e);
  transition: transform .16s,filter .16s;
}

.choice.own {
  background: linear-gradient(150deg,#2d3838,#272c2d);
}

.choice:active {
  transform: scale(.97);
}

.choice:hover {
  filter: brightness(1.09);
}

.emblem {
  display: grid;
  place-items: center;
  background: #d6b8f01c;
  color: #e4ccff;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  margin: 1px 0 24px;
}

.own .emblem {
  background: #b0e1d818;
  color: #c7eae4;
}

.choice strong {
  font-size: clamp(15px,3.6vw,19px);
  letter-spacing: -.035em;
}

.choice small,.muted,small {
  color: var(--muted);
  font-size: 13px;
}

.choice-arrow {
  position: absolute;
  right: 11px;
  top: 16px;
  width: 15px;
  color: #d3cdd577;
}

.reading>h2 {
  margin: 4px 0 13px;
}

.row {
  display: flex;
  align-items: center;
  gap: 13px;
  background: none;
  width: 100%;
  text-align: left;
  min-height: 68px;
  padding: 11px 4px;
  border-bottom: 1px solid #ffffff10;
}

.row>span:nth-child(2) {
  min-width: 0;
}

.row strong,.row small {
  display: block;
  overflow-wrap: anywhere;
}

.row>svg {
  margin-left: auto;
  width: 16px;
  color: var(--muted);
}

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 14px;
  background: linear-gradient(145deg,#413a4b,#2d2936);
  color: #dfd1eb;
  width: 40px;
  height: 40px;
  font-weight: 620;
}

.blank {
  color: var(--muted);
  font-size: 14px;
  padding: 18px 0;
}

.icon {
  width: 44px;
  height: 44px;
  background: none;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  border-radius: 12px;
}

.icon:hover {
  background: #ffffff09;
  color: var(--ink);
}

label {
  display: block;
  margin: 20px 0 8px;
  font-size: 14px;
  font-weight: 550;
}

input,textarea {
  border: 1px solid var(--line);
  width: 100%;
  background: var(--surface);
  border-radius: 13px;
  padding: 12px 14px;
  outline: 0;
}

input:focus,textarea:focus {
  border-color: #89808f;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input::placeholder,textarea::placeholder {
  color: #96939c;
}

.searchbox {
  display: flex;
  align-items: center;
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--line);
  padding-left: 12px;
  color: var(--muted);
}

.searchbox input {
  border: 0;
  background: none;
}

.muted {
  margin: 14px 0;
}

.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #201925;
  border-radius: 13px;
  padding: 13px 18px;
  width: 100%;
  font-weight: 620;
  margin-top: 14px;
}

.chat {
  display: flex;
  flex-direction: column;
}

.chat-head {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  gap: 12px;
  border-bottom: 1px solid #ffffff0a;
}

.chat-titles {
  min-width: 0;
}

.chat-head h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-head .icon {
  margin-left: auto;
}

.chat-head small {
  font-size: 12px;
}

#timeline {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  padding: 16px clamp(14px,4vw,30px);
  gap: 18px;
}

.scene-start {
  margin: auto;
  text-align: center;
  max-width: 260px;
  color: var(--muted);
  font-size: 15px;
}

.scene-start svg {
  display: block;
  margin: 0 auto 12px;
  color: #c4b1d9;
  width: 30px;
  height: 30px;
}

.bubble {
  max-width: 94%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.58;
}

.bubble.user {
  align-self: flex-end;
  padding: 9px 14px;
  background: #322e38;
  border-radius: 14px 14px 4px 14px;
}

.bubble.assistant {
  align-self: flex-start;
}

.bubble b {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}

.bubble img,.bubble .photo {
  display: block;
  max-width: min(230px,100%);
  max-height: 240px;
  border-radius: 10px;
}

.bubble .new {
  animation: appear .24s ease-out;
}

.bubble.pending {
  color: var(--muted);
}

#composer {
  margin: 5px clamp(10px,3vw,22px) 10px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
}

#message {
  resize: none;
  background: none;
  border: 0;
  padding: 5px 7px;
  max-height: 114px;
  min-height: 38px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.models {
  display: flex;
  border-radius: 13px;
  background: #1b1b1e;
  padding: 2px;
}

.models .icon {
  height: 40px;
}

.models .icon[aria-pressed=true] {
  background: #423b4b;
  color: #efdcff;
}

.send {
  margin-left: auto;
  background: var(--accent);
  color: #231d29;
}

.send:hover {
  background: #e5d6f6;
  color: #231d29;
}

#attachment {
  position: relative;
  width: max-content;
}

#thumb {
  width: 66px;
  height: 58px;
  object-fit: cover;
  border-radius: 9px;
}

#unpick,#close-card {
  border-radius: 20px;
  background: #3a373c;
  line-height: 1.1;
  color: white;
}

#unpick {
  position: absolute;
  right: -6px;
  top: -5px;
  width: 27px;
  height: 27px;
}

#close-card {
  width: 36px;
  height: 36px;
  font-size: 22px;
}

#notice {
  position: absolute;
  bottom: calc(12px + env(safe-area-inset-bottom));
  align-self: center;
  max-width: 92%;
  background: #42363b;
  color: #ffe7e7;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: 0 6px 24px #0005;
}

#shell:has(#chat:not([hidden])) #notice {
  bottom: calc(135px + env(safe-area-inset-bottom));
}

dialog {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  width: min(480px,92vw);
  max-height: 80dvh;
  padding: 19px;
}

dialog::backdrop {
  background: #0009;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}

#card-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

#source {
  display: inline-block;
  color: var(--accent);
  font-size: 14px;
  margin: 0 0 14px;
}

#source[hidden] {
  display: none;
}

@keyframes appear {
  from {
    opacity: 0;
    filter: blur(2px);
  }
  to {
    opacity: 1;
    filter: none;
  }
}

@media(prefers-reduced-motion:reduce) {
  *,*:before,*:after {
    animation: none!important;
    transition: none!important;
  }
}

@media(max-width:350px) {
  .reading {
    padding: 15px 12px;
  }
  .choices {
    gap: 6px;
  }
  .choice {
    padding: 12px 9px;
  }
}

@media(min-width:760px) {
  #shell {
    border-inline: 1px solid var(--line);
  }
  .reading {
    padding-top: 34px;
  }
  .choice {
    padding: 19px;
  }
  .choices {
    gap: 14px;
  }
}
