/* vand.ai — ink on paper, one cinnabar accent. Mobile first, 480 max. */

:root {
  --paper: #faf9f7;
  --surface: #ffffff;
  --raised: #f2f0ec;
  --ink: #191817;
  --muted: #8a867e;
  --hairline: #e7e4df;
  --seal: #ce3a16;
  --seal-tint: #fbede8;
  --danger: #b4331a;

  --r-bubble: 20px;
  --r-control: 14px;
  --r-sheet: 28px;

  --bar: 52px;
  --page: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);

  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--raised);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

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

button {
  cursor: pointer;
  border: 0;
  background: none;
}

:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 2px;
  border-radius: 6px;
}

[hidden] {
  display: none !important;
}

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

/* ---------- Sign in ---------- */

.gate {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--paper);
  display: grid;
  place-items: center;
  padding: var(--page);
  padding-bottom: calc(var(--page) + var(--safe-b));
}

.gate-inner {
  width: 100%;
  max-width: 320px;
  animation: rise 220ms ease-out both;
}

/* The one bold element: a cinnabar seal. */
.seal {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--seal);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 27px;
  font-weight: 600;
  line-height: 1;
  padding-bottom: 2px;
  box-shadow: 0 6px 20px rgba(206, 58, 22, 0.24);
}

.gate-title {
  margin: 26px 0 6px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.024em;
}

.gate-sub {
  margin: 0 0 30px;
  color: var(--muted);
  font-size: 14.5px;
  max-width: 30ch;
}

.field {
  display: block;
}

.field-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 7px;
}

#phone {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-control);
  background: var(--surface);
  letter-spacing: 0.02em;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

#phone::placeholder {
  color: #bdb9b2;
  letter-spacing: 0;
}

#phone:focus {
  outline: none;
  border-color: var(--seal);
  box-shadow: 0 0 0 3px var(--seal-tint);
}

.btn-primary {
  width: 100%;
  height: 50px;
  margin-top: 14px;
  border-radius: var(--r-control);
  background: var(--ink);
  color: var(--paper);
  font-size: 15.5px;
  font-weight: 500;
  transition: opacity 140ms ease, transform 140ms ease;
}

.btn-primary:active {
  transform: scale(0.99);
}

.btn-primary[disabled] {
  opacity: 0.45;
  cursor: default;
}

.form-error {
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13.5px;
}

/* ---------- Shell ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--paper);
  position: relative;
}

.topbar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--bar);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px;
  background: rgba(250, 249, 247, 0.78);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--hairline);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--ink);
  flex: none;
  transition: background 140ms ease;
}

.icon-btn:active {
  background: var(--raised);
}

.model-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
  max-width: 62%;
  overflow: hidden;
  white-space: nowrap;
}

.model-trigger .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--seal);
  flex: none;
}

.model-trigger .chev {
  width: 15px;
  height: 15px;
  color: var(--muted);
  flex: none;
}

/* ---------- Thread ---------- */

.thread {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--bar) + 14px) var(--page) 8px;
}

.thread-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: rise 220ms ease-out both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.row {
  display: flex;
  flex-direction: column;
  max-width: 84%;
}

.row.user {
  align-self: flex-end;
  align-items: flex-end;
}

.row.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble {
  padding: 10px 14px;
  border-radius: var(--r-bubble);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.user .bubble {
  background: var(--seal-tint);
  border: 1px solid #f6ddd4;
  border-bottom-right-radius: 7px;
}

.assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-bottom-left-radius: 7px;
}

.assistant .bubble.failed {
  background: #fdf3f1;
  border-color: #f2d6cf;
  color: var(--danger);
}

/* Required disclosure on every assistant message. */
.tag {
  margin-top: 5px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 1px;
  background: var(--seal);
  vertical-align: -0.16em;
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

.thinking {
  display: inline-flex;
  gap: 4px;
  padding: 3px 0;
}

.thinking i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c8c4bc;
  animation: pulse 1.1s ease-in-out infinite;
}

.thinking i:nth-child(2) {
  animation-delay: 0.14s;
}
.thinking i:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* Empty and loading states */

.empty {
  margin: max(12vh, 60px) auto 0;
  text-align: center;
  max-width: 28ch;
  animation: rise 220ms ease-out both;
}

.empty .seal {
  margin: 0 auto 18px;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  font-size: 22px;
}

.empty h2 {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.empty p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.loading-note {
  margin: 40px auto;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.banner {
  margin: 0 0 4px;
  padding: 10px 14px;
  border-radius: var(--r-control);
  background: #fdf3f1;
  border: 1px solid #f2d6cf;
  color: var(--danger);
  font-size: 13.5px;
}

/* ---------- Composer ---------- */

.composer {
  position: sticky;
  bottom: 0;
  z-index: 15;
  padding: 8px var(--page) calc(10px + var(--safe-b));
  background: rgba(250, 249, 247, 0.9);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--hairline);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

#input {
  flex: 1;
  min-height: 42px;
  max-height: 148px;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-control);
  background: var(--surface);
  resize: none;
  overflow-y: auto;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

#input:focus {
  outline: none;
  border-color: var(--seal);
  box-shadow: 0 0 0 3px var(--seal-tint);
}

.send {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 12px;
  background: var(--seal);
  color: #fff;
  display: grid;
  place-items: center;
  transition: transform 140ms ease, opacity 140ms ease;
}

.send:active {
  transform: scale(0.95);
}

.send[disabled] {
  opacity: 0.4;
  cursor: default;
}

.send.stop {
  background: var(--ink);
}

.stop-square {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: currentColor;
}

/* ---------- Sheets ---------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(24, 22, 20, 0.32);
  opacity: 0;
  transition: opacity 240ms ease;
}

.scrim.in {
  opacity: 1;
}

.sheet {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  transform: translate(-50%, 100%);
  background: var(--paper);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  border-top: 1px solid var(--hairline);
  box-shadow: 0 -12px 40px rgba(24, 22, 20, 0.14);
  padding: 8px var(--page) calc(16px + var(--safe-b));
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
  transition: transform 240ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

.sheet.in {
  transform: translate(-50%, 0);
}

.sheet-grip {
  width: 34px;
  height: 4px;
  border-radius: 2px;
  background: #ddd9d2;
  margin: 2px auto 12px;
  flex: none;
}

.sheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.sheet-title {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.012em;
}

.text-btn {
  color: var(--seal);
  font-size: 14.5px;
  font-weight: 500;
  padding: 4px 2px;
}

.text-btn.danger {
  color: var(--danger);
}

.model-list,
.conv-list {
  list-style: none;
  margin: 0;
  padding: 0 0 4px;
  overflow-y: auto;
  flex: 1;
}

.model-list li + li,
.conv-list li + li {
  border-top: 1px solid var(--hairline);
}

.model-row,
.conv-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 2px;
  text-align: left;
}

.model-row .meta,
.conv-row .meta {
  flex: 1;
  min-width: 0;
}

.model-row .name,
.conv-row .name {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-row .note,
.conv-row .note {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.check {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--seal);
  opacity: 0;
}

.model-row[aria-selected='true'] .check,
.conv-row[aria-current='true'] .check {
  opacity: 1;
}

.conv-wrap {
  display: flex;
  align-items: center;
}

.del {
  flex: none;
  color: var(--muted);
  padding: 6px;
  border-radius: 9px;
}

.del svg {
  width: 17px;
  height: 17px;
}

.sheet-foot {
  flex: none;
  border-top: 1px solid var(--hairline);
  padding-top: 12px;
  margin-top: 4px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.meter {
  flex: 1;
  min-width: 0;
}

.meter-line {
  height: 3px;
  border-radius: 2px;
  background: var(--hairline);
  overflow: hidden;
}

.meter-line span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--seal);
  border-radius: 2px;
  transition: width 240ms ease;
}

.meter-text {
  margin: 7px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.list-empty {
  padding: 26px 2px;
  color: var(--muted);
  font-size: 14px;
}

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