:root {
  color-scheme: light;
  --bg: #f6f8fc;
  --bg-alt: #eef2fb;
  --panel: #ffffff;
  --panel-2: #f2f4fb;
  --text: #0c1220;
  --muted: #5b6b85;
  --muted-2: #8893a7;
  --border: rgba(12, 18, 32, 0.08);
  --primary: #1a6fff;
  --primary-600: #1558cc;
  --primary-soft: rgba(26, 111, 255, 0.12);
  --radius: 18px;
  --shadow: 0 18px 45px rgba(12, 24, 50, 0.12);
  --shadow-soft: 0 10px 30px rgba(12, 24, 50, 0.08);
  --font: "Sora", sans-serif;
  --mono: "JetBrains Mono", monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0c10;
  --bg-alt: #111420;
  --panel: #121626;
  --panel-2: #171c30;
  --text: #f5f7ff;
  --muted: #98a3bf;
  --muted-2: #7a84a3;
  --border: rgba(255, 255, 255, 0.08);
  --primary: #1a6fff;
  --primary-600: #4d9fff;
  --primary-soft: rgba(26, 111, 255, 0.2);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.4);
  --shadow-soft: 0 14px 40px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.bg-blur {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 15%, rgba(26, 111, 255, 0.12), transparent 45%),
    radial-gradient(circle at 80% 5%, rgba(26, 111, 255, 0.1), transparent 40%),
    radial-gradient(circle at 80% 75%, rgba(26, 111, 255, 0.08), transparent 40%);
  pointer-events: none;
  z-index: 0;
}

#root {
  position: relative;
  z-index: 1;
}

.app {
  width: min(560px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

.btn-primary:hover {
  background: var(--primary-600);
}

.btn-ghost {
  background: transparent;
}

.btn-pill {
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
}

.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 111, 255, 0.15);
}

.auth {
  padding: 48px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border-radius: 22px;
  padding: 26px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  background: var(--panel-2);
  padding: 4px;
  border-radius: 12px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
}

.auth-tab.active {
  background: var(--primary);
  color: #fff;
}

.auth-uid {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  text-align: center;
}

.section {
  padding: 16px 16px 96px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--panel);
  border-radius: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.card-title {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 8px;
}

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

.pill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.pill {
  border: 1px solid var(--border);
  background: var(--panel-2);
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  text-align: left;
}

.pill:hover {
  background: var(--bg-alt);
  color: var(--text);
}

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

.message {
  max-width: 80%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message.user {
  align-self: flex-end;
  text-align: right;
}

.message.nieo {
  align-self: flex-start;
}

.bubble {
  padding: 12px 14px;
  border-radius: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message.user .bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.message.nieo .bubble {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 6px;
}

.message-meta {
  font-size: 11px;
  color: var(--muted-2);
}

.composer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 70px;
  width: min(560px, 100%);
  padding: 12px 16px 16px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 30;
}

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

.input-pill {
  flex: 1;
  border-radius: 999px;
  padding: 11px 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.action-button {
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.action-button.primary {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

.sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 150px;
  width: min(520px, calc(100% - 24px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  max-height: 55vh;
  overflow-y: auto;
  padding: 8px 0;
  z-index: 40;
}

.sheet-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  width: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s ease;
  text-align: left;
  font-weight: 600;
}

.sheet-item:hover {
  background: var(--bg-alt);
}

.badge-new {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 20, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 60;
}

.modal-card {
  width: min(440px, 100%);
  background: var(--panel);
  border-radius: 22px;
  padding: 22px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--panel-2);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(560px, 100%);
  padding: 10px 22px 20px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  z-index: 25;
  backdrop-filter: blur(18px);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted-2);
  font-weight: 600;
  background: transparent;
  border: none;
  cursor: pointer;
}

.nav-item.active {
  color: var(--primary);
}

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

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  transition: background 0.2s ease;
}

.list-item:hover {
  background: var(--bg-alt);
}

.list-sub {
  font-size: 12px;
  color: var(--muted-2);
}

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  font-size: 13px;
  z-index: 100;
}

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

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-2);
  animation: bounce 1.1s infinite ease-in-out;
}

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

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

.small-preview {
  position: fixed;
  right: 16px;
  bottom: 150px;
  width: 180px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  z-index: 70;
}

.small-preview video {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.small-preview .preview-actions {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

@media (max-width: 600px) {
  .app,
  .composer,
  .nav {
    width: 100%;
  }
}
