:root {
  --bg: #0a0a0c;
  --surface: #141418;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #22d3ee;
  --accent-dim: #0891b2;
  --danger: #f43f5e;
  --nav-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body {
  -webkit-tap-highlight-color: transparent;
  text-size-adjust: 100%;
}

button, a, input, textarea {
  touch-action: manipulation;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.has-bottom-nav {
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #27272a;
  position: sticky;
  top: 0;
  background: rgba(10, 10, 12, 0.92);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.topbar__brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}

.topbar__brand span {
  color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
  min-height: 44px;
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #020617;
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid #3f3f46;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #3f3f46;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  min-height: 44px;
}

.field textarea {
  min-height: 100px;
  resize: vertical;
}

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert--error {
  background: rgba(244, 63, 94, 0.15);
  color: #fda4af;
}

.alert--ok {
  background: rgba(34, 211, 238, 0.12);
  color: #a5f3fc;
}

.auth-wrap {
  max-width: 400px;
  margin: 0 auto;
  padding: 32px 20px 100px;
}

.auth-wrap h1 {
  font-size: 1.5rem;
  margin: 0 0 8px;
}

.auth-wrap p.sub {
  color: var(--muted);
  margin: 0 0 24px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0));
  padding-bottom: env(safe-area-inset-bottom, 0);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  background: rgba(10, 10, 12, 0.96);
  border-top: 1px solid #27272a;
  z-index: 50;
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.65rem;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}

.bottom-nav__item:hover {
  color: var(--text);
  text-decoration: none;
}

.bottom-nav__item.is-active {
  color: var(--accent);
}

.bottom-nav__icon {
  font-size: 1.15rem;
  line-height: 1;
}

.bottom-nav__item--ai {
  color: #c4b5fd;
}

.bottom-nav__item--ai.is-active,
.bottom-nav__item--ai:hover {
  color: #ddd6fe;
}

.ai-panel[hidden] {
  display: none !important;
}

.ai-panel:not([hidden]) {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 100;
}

.ai-panel__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.ai-panel__sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 85vh;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  border: 1px solid #27272a;
  border-bottom: none;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-panel__header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.ai-panel__close {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.ai-panel__hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.ai-panel__log {
  flex: 1;
  overflow-y: auto;
  min-height: 180px;
  max-height: 45vh;
  padding: 10px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 0.9rem;
}

.ai-panel__log .msg {
  margin-bottom: 10px;
  white-space: pre-wrap;
}

.ai-panel__log .msg--user {
  color: var(--accent);
}

.ai-panel__log .msg--bot {
  color: var(--text);
}

.ai-panel__form {
  display: flex;
  gap: 8px;
}

.ai-panel__form input {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #3f3f46;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.ai-panel__form button {
  padding: 12px 16px;
  border-radius: 10px;
  border: 0;
  background: var(--accent);
  color: #020617;
  font-weight: 600;
  cursor: pointer;
}

.uploading {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 16px;
}

.uploading__card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid #27272a;
  border-radius: 16px;
  padding: 16px;
}

.uploading__sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.uploading__pct {
  margin-top: 10px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.uploading__ring {
  margin-top: 12px;
  display: grid;
  place-items: center;
}

.uploading__ring svg {
  width: 120px;
  height: 120px;
  transform: rotate(-90deg);
}

.uploading__ring circle {
  fill: none;
  stroke-width: 10;
}

.uploading__ring .track {
  stroke: rgba(255,255,255,0.14);
}

.uploading__ring .progress {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 120ms linear;
}

.uploading__ring-label {
  position: absolute;
  font-size: 1.35rem;
  font-weight: 800;
}

.uploading__hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.uploading__bar {
  margin-top: 12px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid #3f3f46;
  overflow: hidden;
  background: rgba(10, 10, 12, 0.7);
}

.uploading__bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #c4b5fd);
  transition: width 120ms linear;
}

.feed {
  height: 100vh;
  height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
}

.feed__item {
  height: 100vh;
  height: 100dvh;
  scroll-snap-align: start;
  position: relative;
  background: #000;
}

.feed__item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.feed__overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(transparent 55%, rgba(0, 0, 0, 0.75));
}

.feed__meta {
  position: absolute;
  left: 14px;
  right: 80px;
  bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom, 0));
  pointer-events: auto;
}

.feed__user {
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.feed__user a {
  color: inherit;
  text-decoration: none;
}

.feed__caption {
  margin-top: 6px;
  font-size: 0.9rem;
  color: #e4e4e7;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  max-height: 4.5em;
  overflow: hidden;
}

.feed__actions {
  position: absolute;
  right: 10px;
  bottom: calc(var(--nav-h) + 32px + env(safe-area-inset-bottom, 0));
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  pointer-events: auto;
}

.feed__action {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  width: 48px;
  height: 48px;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wizard__steps {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

.wizard__step {
  padding: 10px 8px;
  border: 1px solid #27272a;
  border-radius: 10px;
  text-align: center;
  background: rgba(20, 20, 24, 0.6);
}

.wizard__step.is-active {
  color: var(--text);
  border-color: rgba(34, 211, 238, 0.45);
}

.wizard__panel {
  border: 1px solid #27272a;
  border-radius: 12px;
  padding: 14px;
  background: rgba(20, 20, 24, 0.55);
  animation: wizardIn 220ms ease-out;
}

@keyframes wizardIn {
  from { transform: translateY(6px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.wizard__preview {
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.wizard__preview video {
  width: 100%;
  max-height: 55vh;
  display: block;
  object-fit: contain;
}

.wizard__row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.wizard__row .btn {
  flex: 1;
}

.wizard__small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.75rem;
}

.segmented {
  display: flex;
  gap: 8px;
}

.segmented__btn {
  flex: 1;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid #3f3f46;
  background: rgba(20, 20, 24, 0.65);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.segmented__btn.is-active {
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.14) inset;
}

.feed__action.is-liked {
  color: var(--danger);
  border-color: rgba(244, 63, 94, 0.4);
}

.feed__count {
  font-size: 0.7rem;
  color: #fff;
  margin-top: -10px;
  text-shadow: 0 1px 2px #000;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.sheet[hidden] {
  display: none !important;
}

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 70vh;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  border: 1px solid #27272a;
  display: flex;
  flex-direction: column;
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #27272a;
}

.sheet__head h3 {
  margin: 0;
  font-size: 1rem;
}

.sheet__close {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.sheet__body {
  padding: 12px 16px;
  overflow-y: auto;
  flex: 1;
}

.comment {
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.comment strong {
  color: var(--accent);
  margin-right: 6px;
}

.comment-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #27272a;
}

.comment-form input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #3f3f46;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.comment-form button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: #020617;
  font-weight: 600;
  cursor: pointer;
}

.profile-header {
  padding: 16px;
  display: flex;
  gap: 16px;
  align-items: center;
}

.profile-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  background: #27272a;
  border: 2px solid #3f3f46;
}

.profile-stats {
  display: flex;
  gap: 20px;
  flex: 1;
}

.profile-stats div {
  text-align: center;
}

.profile-stats span {
  display: block;
  font-weight: 700;
  font-size: 1.1rem;
}

.profile-stats small {
  color: var(--muted);
  font-size: 0.75rem;
}

.profile-bio {
  padding: 0 16px 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.profile-actions {
  padding: 0 16px 16px;
  display: flex;
  gap: 10px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}

.grid a {
  aspect-ratio: 9 / 16;
  background: #000;
  position: relative;
  overflow: hidden;
}

.grid video,
.grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-pad {
  padding: 16px 16px 100px;
}

.story-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 12px;
  overflow-x: auto;
  border-bottom: 1px solid #27272a;
  background: rgba(10, 10, 12, 0.96);
  position: sticky;
  top: 49px;
  z-index: 15;
}

.story-bar::-webkit-scrollbar { height: 0; }

.story-bar__add {
  min-width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px dashed rgba(34, 211, 238, 0.55);
  color: var(--accent);
  text-decoration: none;
  font-size: 1.35rem;
}

.story-bar__item {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  min-width: 74px;
  color: var(--text);
  text-decoration: none;
}

.story-bar__ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(196, 181, 253, 0.85);
  box-shadow: 0 0 0 2px rgba(10, 10, 12, 1) inset;
  display: grid;
  place-items: center;
}

.story-bar__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: #27272a;
}

.story-bar__avatar--empty {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #27272a;
  display: block;
}

.story-bar__name {
  font-size: 0.72rem;
  color: var(--muted);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-bar__empty {
  color: var(--muted);
  font-size: 0.85rem;
}

.story-view {
  background: #000;
  height: 100dvh;
  position: relative;
}

.story-progress {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  z-index: 5;
}

.story-progress__seg {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
  overflow: hidden;
}

.story-progress__fill {
  display: block;
  height: 100%;
  width: 0%;
  background: rgba(255,255,255,0.95);
}

.story-view__item {
  height: calc(100dvh - 56px - var(--nav-h));
  position: relative;
}

.story-view__media {
  width: 100%;
  height: calc(100dvh - 56px - var(--nav-h));
  object-fit: contain;
  display: block;
}

.story-view__top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
}

.story-view__who {
  display: flex;
  gap: 10px;
  align-items: center;
}

.story-view__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: #27272a;
  border: 1px solid rgba(255,255,255,0.25);
}

.story-view__avatar--empty {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #27272a;
  display: block;
  border: 1px solid rgba(255,255,255,0.25);
}

.story-like {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.25);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

.story-like.is-liked {
  color: var(--danger);
  border-color: rgba(244, 63, 94, 0.45);
}

.story-like-count {
  position: absolute;
  right: 16px;
  top: 64px;
  color: rgba(255,255,255,0.85);
  font-size: 0.85rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

.story-view__tap {
  position: absolute;
  inset: 0;
}

.thread-list a {
  display: block;
  padding: 14px 16px;
  border-bottom: 1px solid #27272a;
  color: var(--text);
  text-decoration: none;
}

.thread-list a:hover {
  background: var(--surface);
}

.thread-list small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
}

.chat {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 56px);
  max-height: 100%;
}

.chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  margin-bottom: 10px;
  font-size: 0.95rem;
  line-height: 1.35;
}

.bubble--me {
  margin-left: auto;
  background: var(--accent);
  color: #020617;
}

.bubble--them {
  margin-right: auto;
  background: #27272a;
  color: var(--text);
}

.bubble__meta {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
  font-size: 0.75rem;
  opacity: 0.85;
}

.bubble__ticks {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.bubble__ticks.is-sent {
  color: rgba(2, 6, 23, 0.6);
}

.bubble__ticks.is-delivered {
  color: rgba(2, 6, 23, 0.65);
}

.bubble__ticks.is-read {
  color: #2563eb; /* blue double-tick */
}

.chat__form {
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0));
  border-top: 1px solid #27272a;
  background: var(--bg);
}

.chat__form input {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #3f3f46;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.chat__form button {
  border: 0;
  border-radius: 12px;
  padding: 0 18px;
  background: var(--accent);
  color: #020617;
  font-weight: 600;
  cursor: pointer;
}
