@font-face {
  font-family: Rubik;
  src: url("./fonts/Rubik.ttf") format("truetype");
  font-display: swap;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #e7fbff;
  color: #142f40;
  font-family: Rubik, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

#app {
  max-width: 40rem;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 0;
  overflow: hidden;
}

header, #welcome, #starters, form, #disclaimer, #legal {
  flex: none;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #142f40;
  color: #e7fbff;
  padding: 0.7rem 0.85rem;
}

.who {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.who-text { min-width: 0; }

h1, h2, p { margin: 0; }

h1 {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

#status {
  margin-top: 0.1rem;
  font-size: 0.75rem;
  line-height: 1.3;
  font-weight: 400;
  color: #c8f0f7;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: none;
}

.avatar {
  position: relative;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 999px;
  background: #40b4c9;
  color: #142f40;
  font-weight: 700;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.avatar-sm {
  width: 26px;
  height: 26px;
  font-size: 0.8rem;
}

.dot {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 2px #fff;
}

button, textarea, a { font: inherit; }

button, .link-button {
  min-height: 2.75rem;
  border: 0;
  border-radius: 0.6rem;
  background: #009bb7;
  color: #fff;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:focus-visible, a:focus-visible, textarea:focus-visible {
  outline: 0.15rem solid #142f40;
  outline-offset: 0.1rem;
}

#new-chat, #close {
  min-height: 0;
  padding: 0.2rem 0.45rem;
  background: transparent;
  color: #e7fbff;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 0.45rem;
}

#new-chat:hover, #close:hover { background: rgba(255, 255, 255, 0.1); }

header button:focus-visible { outline-color: #e7fbff; }

#thread {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-inline: 0.75rem;
}

#log {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding-bottom: 0.15rem;
}

#log > * { flex: none; }

.msg-row {
  display: flex;
  width: fit-content;
  max-width: min(92%, 36rem);
  min-width: 0;
}

.msg-row-user { align-self: flex-start; max-width: min(85%, 32rem); }

.msg-row-assistant {
  align-self: flex-end;
  align-items: flex-end;
  gap: 0.4rem;
}

.msg {
  padding: 0.6rem 0.8rem;
  border-radius: 14px;
  overflow-wrap: anywhere;
  min-width: 0;
  max-width: 100%;
}

.msg-user {
  background: #142f40;
  color: #fff;
  border-end-start-radius: 4px;
}

.msg-assistant {
  background: #fff;
  color: #142f40;
  border: 1px solid #c8f0f7;
  border-end-end-radius: 4px;
}

.msg p, .msg ul, .msg ol { margin: 0.25rem 0; }

.cards, .actions, #starters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cards, .actions { gap: 0.35rem; margin-top: 0.4rem; }

.card, .video-chip {
  background: #e7fbff;
  color: #142f40;
  border-radius: 0.5rem;
  padding: 0.3rem 0.6rem;
  text-decoration: none;
  min-height: 0;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
}

.msg .link-button {
  min-height: 0;
  margin-top: 0.4rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  border-radius: 0.5rem;
}

#starters { padding-inline: 0.75rem; }

#starters:empty { display: none; }

#starters button, .actions button {
  background: #fff;
  color: #142f40;
  border: 1px solid #80cddb;
}

#starters button {
  min-height: 0;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 999px;
}

#starters button:hover { background: #f4feff; }

.actions button {
  min-height: 0;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 999px;
  color: #5b6d79;
}

form {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  margin-inline: 0.75rem;
  padding: 0.25rem;
  padding-inline-start: 0.95rem;
  background: #fff;
  border: 2px solid #40b4c9;
  border-radius: 999px;
}

form:focus-within {
  outline: 0.15rem solid #142f40;
  outline-offset: 0.12rem;
}

textarea {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #142f40;
  resize: none;
  overflow: hidden;
  padding: 0.4rem 0;
  line-height: 1.35;
  min-height: 0;
}

textarea:focus-visible { outline: none; }

textarea::placeholder { color: #5b6d79; }

#send {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
  background: #009bb7;
  flex: none;
}

#send:hover { background: #0088a1; }

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

#disclaimer, #legal {
  margin-inline: 0.75rem;
  font-size: 12px;
  line-height: 1.45;
  color: #5b6d79;
}

#disclaimer { margin-top: 0; }

#legal {
  display: block;
  margin-bottom: 0.7rem;
  font-size: 11px;
}

#legal a, #delete {
  color: inherit;
  background: none;
  border: 0;
  min-height: 0;
  padding: 0;
  font-size: inherit;
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 2px;
  border-radius: 0;
}

#shortno { display: none; }

#typing {
  margin: 0;
  color: #5b6d79;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  align-self: flex-end;
  font-size: 0.9rem;
}

#typing .dots span {
  display: inline-block;
  animation: roni-dot 1.2s infinite ease-in-out;
}

#typing .dots span:nth-child(2) { animation-delay: 0.2s; }
#typing .dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes roni-dot {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.path {
  background: #fff;
  border: 1px solid #c8f0f7;
  border-radius: 0.75rem;
  padding: 0.5rem 0.6rem;
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.path .link-button, .path button {
  width: auto;
  min-height: 0;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  text-align: start;
}

#welcome { display: none; }

html.is-welcome,
html.is-welcome body,
html.is-welcome #app {
  height: auto;
  overflow: visible;
}

html.is-welcome #app {
  justify-content: center;
  gap: 0.8rem;
  padding: 1.35rem 1rem 1.1rem;
}

html.is-welcome header,
html.is-welcome #thread,
html.is-welcome #legal { display: none; }

html.is-welcome #welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
}

html.is-welcome #form {
  width: min(100%, 30rem);
  align-self: center;
  margin-inline: 0;
}

html.is-welcome #starters {
  justify-content: center;
  width: min(100%, 30rem);
  margin-inline: auto;
  padding-inline: 0;
}

html.is-welcome #disclaimer {
  width: min(100%, 30rem);
  margin-inline: auto;
  text-align: center;
}

.welcome-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
}

.welcome-head h2 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
}

.welcome-sub {
  color: #007a91;
  font-size: 0.875rem;
}

@keyframes roni-msg-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .msg-enter { animation: roni-msg-in 320ms ease-out both; }
  .msg-row-assistant.msg-enter { animation-duration: 450ms; }
  #typing:not([hidden]) { animation: roni-msg-in 250ms ease-out both; }
}

@media (prefers-reduced-motion: reduce) {
  #typing .dots span { animation: none; opacity: 1; }
}

[hidden] { display: none !important; }

@media (max-width: 22rem) {
  header { align-items: flex-start; }
  .welcome-head { align-items: flex-start; }
  .welcome-head h2 { font-size: 1.2rem; }
}

.ltr { white-space: nowrap; unicode-bidi: isolate; }
