:root {
  color-scheme: dark;
  --bg: #1a1410;
  --card: #241c17;
  --line: #3a2e26;
  --text: #f6f1ea;
  --muted: #cbbbaa;
  --ai: #5460c9;
  --user: #3c2d24;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(900px 420px at 10% -10%, #3a241c 0%, transparent 55%),
    var(--bg);
  color: var(--text);
}

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

#app {
  min-height: 100vh;
  min-height: 100dvh;
}

.v1-screen {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.v1-top {
  margin-bottom: 12px;
}

.v1-mark {
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 8px;
}

.v1-screen-title {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 500;
  line-height: 1.1;
  margin: 0 0 8px;
}

.v1-lede {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
  margin: 0 0 16px;
}

.v1-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
}

.v1-panel h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  font-weight: 500;
}

.v1-empty,
.v1-status,
.v1-muted {
  margin: 8px 0 0;
  line-height: 1.45;
}

.v1-muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.v1-empty code,
.v1-status code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  color: var(--ai);
}

.v1-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.v1-primary,
.v1-ghost {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
}

.v1-primary {
  background: var(--text);
  color: var(--bg);
}

.v1-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.v1-ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.v1-companion-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  padding: 8px 0 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.v1-ai-label {
  margin: 4px 0 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ai);
}

.v1-back {
  margin-bottom: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.v1-synthetic {
  font-size: 0.85rem;
  color: var(--muted);
  margin: -4px 0 12px;
}

.v1-card-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.v1-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.v1-list {
  margin: 0;
  padding-left: 1.2rem;
  line-height: 1.5;
}

.v1-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40vh;
  margin-bottom: 12px;
}

.v1-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.v1-bubble--user {
  align-self: flex-end;
  background: var(--user);
}

.v1-bubble--assistant {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
}

.v1-bubble--system {
  align-self: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.v1-typing {
  opacity: 0.7;
}

.v1-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.v1-composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
}

.v1-dev-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.v1-dev-nav button {
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.v1-screen--tabbed {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.v1-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.v1-tabbar__btn {
  flex: 1;
  max-width: 120px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 8px;
  background: transparent;
  cursor: pointer;
  font-size: 0.78rem;
}

.v1-tabbar__btn--active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.v1-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.v1-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.v1-field span {
  font-size: 0.85rem;
  color: var(--muted);
}

.v1-field input,
.v1-field textarea {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
}

.v1-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  line-height: 1.45;
}

.v1-check input {
  margin-top: 4px;
}

.v1-banner {
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.45;
  margin: 8px 0;
}

.v1-banner--error {
  background: color-mix(in srgb, #8b2e2e 35%, var(--card));
  border: 1px solid #a44;
}

.v1-question {
  font-size: 1.05rem;
  margin: 0 0 12px;
}

.v1-deck-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.v1-deck-card__portrait,
.v1-profile-portrait {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--line);
}

.v1-deck-card__body {
  padding: 14px 16px 16px;
}

.v1-deck-card__name {
  margin: 0 0 4px;
  font-size: 1.35rem;
  font-weight: 500;
}

.v1-deck-card__meta,
.v1-profile-meta {
  color: var(--muted);
  margin: 0 0 8px;
}

.v1-deck-card__bio {
  margin: 8px 0;
  line-height: 1.5;
}

.v1-prompts {
  margin: 12px 0;
  padding-left: 1.1rem;
  color: var(--muted);
}

.v1-link-btn {
  padding: 8px 0;
}

.v1-deck-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 24px;
}

.v1-like-result__headline {
  font-size: 1.25rem;
  margin: 0 0 8px;
}

.v1-chat-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}

.v1-stage-pill {
  font-size: 0.8rem;
  color: var(--muted);
  margin-right: 4px;
}

.v1-chat-ctl {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.v1-crisis {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.v1-crisis li {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.v1-crisis a {
  color: var(--ai);
  word-break: break-all;
}

.v1-explore-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.v1-explore-item {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
}

.v1-explore-item img {
  border-radius: 12px;
  object-fit: cover;
}

.v1-explore-item small {
  display: block;
  color: var(--muted);
}

.td-app {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  min-height: 100dvh;
}

.td-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.td-logo {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #ff4458;
}

.td-status {
  margin: 24px 0;
  text-align: center;
  color: var(--muted);
}

.td-stack {
  position: relative;
  height: min(68dvh, 640px);
}

.td-card {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 18px;
  overflow: hidden;
  background: #2a211c;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.td-card--back {
  z-index: 1;
  transform: scale(0.96) translateY(10px);
  filter: brightness(0.72);
  pointer-events: none;
}

.td-card__photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.td-card__shade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 56px 16px 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0));
  color: #fff;
  pointer-events: none;
}

.td-card__name {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.td-card__name span {
  font-weight: 500;
}

.td-card__place,
.td-card__job,
.td-card__bio {
  margin: 4px 0 0;
  font-size: 0.95rem;
  line-height: 1.35;
}

.td-card__bio {
  color: rgba(255, 255, 255, 0.88);
}

.td-info {
  pointer-events: auto;
  position: absolute;
  right: 14px;
  bottom: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  background: transparent;
  color: #fff;
  font-family: Georgia, serif;
  font-style: italic;
  cursor: pointer;
}

.td-stamp {
  position: absolute;
  top: 28px;
  margin: 0;
  padding: 4px 10px;
  border: 4px solid;
  border-radius: 8px;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0;
}

.td-stamp--like {
  left: 16px;
  color: #2ee56b;
  border-color: #2ee56b;
  transform: rotate(-18deg);
}

.td-stamp--nope {
  right: 16px;
  color: #ff4458;
  border-color: #ff4458;
  transform: rotate(18deg);
}

.td-card.is-like .td-stamp--like,
.td-card.is-nope .td-stamp--nope {
  opacity: 1;
}

.td-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-top: 14px;
}

.td-round {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 1.6rem;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.td-round:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.td-round--rewind {
  width: 48px;
  height: 48px;
  font-size: 1.2rem;
  color: #f5c451;
}

.td-round--nope {
  color: #ff4458;
}

.td-round--like {
  color: #2ee56b;
}

.td-empty {
  min-height: 52dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 12px;
}

.td-empty h2 {
  margin: 0;
  font-size: 1.6rem;
}

.td-empty p {
  margin: 0 0 8px;
  color: var(--muted);
  max-width: 32ch;
}

.td-empty__actions,
.td-match__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(280px, 100%);
}

.td-btn {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: inherit;
  padding: 12px 16px;
  cursor: pointer;
  font: inherit;
}

.td-btn--solid {
  background: #ff4458;
  border-color: #ff4458;
  color: #fff;
  font-weight: 700;
}

.td-match {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 20px;
  text-align: center;
  color: #fff;
  background:
    radial-gradient(520px 280px at 50% 18%, rgba(255, 68, 88, 0.85), transparent 70%),
    #14080d;
}

.td-match__kicker {
  margin: 0;
  font-size: clamp(2.2rem, 8vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.td-match__photo {
  width: 168px;
  height: 168px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid #fff;
}

.td-match h2,
.td-match p {
  margin: 0;
}

.td-match__send,
.td-match__keep {
  width: 100%;
  border-radius: 999px;
  padding: 14px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.td-match__send {
  border: 0;
  background: #fff;
  color: #14080d;
}

.td-match__keep {
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: transparent;
  color: #fff;
}

.td-new h2 {
  margin: 8px 0;
  font-size: 1rem;
}

.td-new__row,
.td-threads,
.td-grid {
  list-style: none;
  margin: 0;
  padding: 0;
}

.td-new__row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.td-new__person,
.td-thread,
.td-grid__card {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.td-new__person {
  width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.td-new__person img {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ff4458;
}

.td-new__person span,
.td-thread small {
  font-size: 0.78rem;
  color: var(--muted);
}

.td-threads {
  display: flex;
  flex-direction: column;
}

.td-thread {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.td-thread img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
}

.td-thread strong,
.td-thread small {
  display: block;
}

.td-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.td-grid__card {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  padding: 0;
}

.td-grid__card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.td-grid__card span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 8px 8px;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
  font-size: 0.95rem;
}

.td-actions--profile {
  margin: 16px 0 8px;
}

@media (min-width: 520px) {
  .v1-screen {
    padding-left: 20px;
    padding-right: 20px;
  }
}
