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

:root {
  /* Yuty Surfaces */
  --bg: #121212;
  --surface: #181818;
  --surface-2: #1e1e1e;
  --surface-3: #2a2a2a;
  --surface-bright: #333333;

  /* Yuty Text */
  --text: #ffffff;
  --text-dim: #a0a0a0;
  --text-muted: #666666;

  /* Yuty Borders */
  --ghost-border: rgba(255, 255, 255, 0.05);
  --ghost-border-hover: rgba(255, 255, 255, 0.10);
  --border-focus: rgba(255, 255, 255, 0.15);

  /* Functional */
  --error: #cf6679;
  --success: #81c784;

  /* Radii */
  --radius: 0.5rem;
  --radius-sm: 0.375rem;
  --radius-lg: 1rem;

  /* Yuty Fonts */
  --font-headline: 'Manrope', sans-serif;
  --font-body: 'Inter', sans-serif;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  opacity: 0;
}

body.ready {
  opacity: 1;
}

/* ─── Screens ─── */
.screen {
  display: none;
  width: 100%;
  height: 100dvh;
}

.screen.active {
  display: flex;
}

/* ─── Landing ─── */
#landing {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.landing-glow {
  display: none;
}

.landing-tag {
  font-family: var(--font-body);
  font-size: 0.6875rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--ghost-border);
  padding: 6px 16px;
  border-radius: 9999px;
  margin-bottom: 28px;
}

.landing-title {
  font-family: var(--font-headline);
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 16px;
}

.landing-title em {
  font-style: normal;
  color: var(--text-dim);
}

.landing-sub {
  font-size: 1rem;
  color: var(--text-dim);
  max-width: 520px;
  line-height: 1.7;
  margin-bottom: 44px;
  font-weight: 300;
}

.landing-specs {
  display: flex;
  gap: 32px;
  margin-bottom: 48px;
}

.spec {
  text-align: center;
}

.spec-value {
  font-family: var(--font-headline);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.spec-label {
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Load button group */
.btn-load-group {
  display: inline-flex;
  align-items: stretch;
  border-radius: 9999px;
  position: relative;
  transition: transform 150ms ease;
}

.btn-load-group:hover {
  transform: translateY(-1px);
}

.btn-load-group:active {
  transform: translateY(0);
}

.btn-load {
  font-family: var(--font-headline);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--bg);
  background: var(--text);
  border: none;
  padding: 14px 12px 14px 32px;
  border-radius: 9999px 0 0 9999px;
  cursor: pointer;
  transition: opacity 150ms ease;
}

.btn-load:hover {
  opacity: 0.9;
}

.btn-load-arrow {
  color: var(--bg);
  background: var(--text);
  border: none;
  border-left: 1px solid rgba(0, 0, 0, 0.15);
  padding: 14px 18px 14px 12px;
  border-radius: 0 9999px 9999px 0;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: opacity 150ms ease;
}

.btn-load-arrow:hover {
  opacity: 0.9;
}

.model-select {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  pointer-events: none;
}

.model-select option {
  background: var(--surface-2);
  color: var(--text);
}

.landing-footer {
  position: absolute;
  bottom: 28px;
  font-size: 0.6875rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.landing-footer a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 300ms ease;
}

.landing-footer a:hover {
  color: var(--text);
}

/* ─── Loading ─── */
#loading {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 36px;
}

.loader-ring {
  width: 64px;
  height: 64px;
  border: 2px solid var(--ghost-border-hover);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loader-text {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  text-align: center;
}

.loader-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
  line-height: 1.5;
}

/* ─── Chat ─── */
#chat {
  flex-direction: column;
  height: 100dvh;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--ghost-border);
  background: var(--surface);
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-headline);
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 600;
}

.chat-header-title {
  font-family: var(--font-headline);
  font-size: 0.9375rem;
  font-weight: 600;
}

.chat-header-status {
  font-size: 0.6875rem;
  color: var(--success);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-header-status::before {
  content: "";
  width: 5px;
  height: 5px;
  background: var(--success);
  border-radius: 50%;
}

.chat-header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Reasoning toggle */
.toggle-reasoning {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle-reasoning input {
  display: none;
}

.toggle-slider {
  width: 30px;
  height: 16px;
  background: var(--surface-3);
  border-radius: 9999px;
  position: relative;
  transition: background 300ms ease;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  top: 2px;
  left: 2px;
  transition: all 300ms ease;
}

.toggle-reasoning input:checked + .toggle-slider {
  background: rgba(255, 255, 255, 0.15);
}

.toggle-reasoning input:checked + .toggle-slider::after {
  background: var(--text);
  left: 16px;
}

.toggle-label {
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color 300ms ease;
}

.toggle-reasoning input:checked ~ .toggle-label {
  color: var(--text);
}

.btn-reset {
  font-family: var(--font-body);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--ghost-border);
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
  transition: color 300ms ease, border-color 300ms ease;
}

.btn-reset:hover {
  color: var(--error);
  border-color: rgba(207, 102, 121, 0.3);
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
}

.msg {
  max-width: 72%;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--ghost-border);
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.65;
  animation: msgIn 0.3s ease;
  word-wrap: break-word;
  white-space: pre-wrap;
}

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

.msg.user {
  align-self: flex-end;
  background: var(--surface-3);
  border-bottom-right-radius: 2px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--surface);
  border-bottom-left-radius: 2px;
}

.msg.assistant.generating {
  border-color: rgba(255, 255, 255, 0.15);
}

.msg-image {
  max-width: 220px;
  max-height: 180px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  display: block;
  object-fit: cover;
  border: 1px solid var(--ghost-border);
}

.msg-role {
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.msg.assistant .msg-role {
  color: var(--text-dim);
}

.thinking-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-dim);
  margin-right: 4px;
  animation: dot 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dot {
  0%,
  80%,
  100% {
    opacity: 0.2;
    transform: scale(0.8);
  }
  40% {
    opacity: 0.8;
    transform: scale(1);
  }
}

/* Generation stats */
.msg-stats {
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--ghost-border);
}

/* Thinking block (collapsible) */
.msg-thinking-label {
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 4px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 300ms ease;
}

.msg-thinking-label:hover {
  color: var(--text);
}

.msg-thinking-chevron {
  font-size: 0.55rem;
  transition: transform 200ms ease;
}

.msg-thinking {
  font-size: 0.8125rem;
  color: var(--text-muted);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  padding-left: 10px;
  margin-bottom: 8px;
  max-height: none;
  overflow-y: auto;
}

.msg-thinking.collapsing {
  overflow: hidden;
  transition:
    max-height 0.3s ease,
    opacity 0.2s ease,
    margin-bottom 0.2s ease;
}

.msg-thinking.collapsed {
  max-height: 0 !important;
  opacity: 0;
  margin-bottom: 0;
  overflow: hidden;
}

/* Input area */
.chat-input-area {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--ghost-border);
  background: var(--surface);
  flex-shrink: 0;
}

.image-preview-bar {
  display: none;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--ghost-border);
  border-radius: var(--radius-sm);
}

.image-preview-bar.visible {
  display: flex;
}

.image-preview-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--ghost-border);
}

.image-preview-name {
  font-size: 0.8125rem;
  color: var(--text-dim);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-remove-image {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  transition: color 300ms ease;
}

.btn-remove-image:hover {
  color: var(--error);
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.btn-attach,
.btn-send {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 150ms ease;
}

.btn-attach {
  background: var(--surface-2);
  border: 1px solid var(--ghost-border);
  color: var(--text-dim);
}

.btn-attach:hover:not(:disabled) {
  border-color: var(--ghost-border-hover);
  color: var(--text);
  background: var(--surface-3);
}

.btn-attach:disabled,
.btn-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.input-wrap {
  flex: 1;
  position: relative;
}

.input-wrap textarea {
  width: 100%;
  min-height: 40px;
  max-height: 140px;
  padding: 10px 16px;
  background: var(--surface-2);
  border: 1px solid var(--ghost-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  transition: border-color 300ms ease, background 300ms ease;
}

.input-wrap textarea::placeholder {
  color: var(--text-muted);
}

.input-wrap textarea:focus {
  border-color: var(--border-focus);
  background: var(--bg);
}

.btn-send {
  background: var(--text);
  border: none;
  color: var(--bg);
}

.btn-send .icon-stop {
  display: none;
}

.btn-send.stopping {
  background: var(--error);
}

.btn-send.stopping .icon-send {
  display: none;
}

.btn-send.stopping .icon-stop {
  display: block;
}

.btn-send:not(:disabled):hover {
  opacity: 0.9;
}

.btn-send.stopping:not(:disabled):hover {
  opacity: 0.9;
}

.chat-footer-note {
  font-size: 0.625rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 10px;
  letter-spacing: 0.02em;
}

/* ─── Error banner ─── */
.error-banner {
  display: none;
  padding: 12px 18px;
  background: rgba(207, 102, 121, 0.08);
  border: 1px solid rgba(207, 102, 121, 0.2);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 0.875rem;
  margin: 12px 24px 0;
}

.error-banner.visible {
  display: block;
}

/* ─── Welcome msg ─── */
.welcome-msg {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.welcome-msg h3 {
  font-family: var(--font-headline);
  font-size: 1.25rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 600;
}

.welcome-msg p {
  font-size: 0.875rem;
  line-height: 1.6;
}
