:root {
  --bg: #050505;
  --surface: #111821;
  --surface-raised: #151f2a;
  --surface-soft: #0d141c;
  --header: #111821;
  --header-dark: #0b1118;
  --accent: #72f1b8;
  --action: #004fff;
  --action-hover: #2f70ff;
  --text: #f5f7fa;
  --muted: #8c9bab;
  --panel: #111821;
  --incoming: #17212c;
  --outgoing: #132a27;
  --line: #263241;
  --danger: #ff7f87;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  background:
    linear-gradient(180deg, var(--header) 0 120px, transparent 120px),
    radial-gradient(circle at 20% 15%, rgba(37, 211, 102, 0.22), transparent 28%),
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 22px;
  overflow-x: hidden;
}

.phone {
  width: min(100%, 440px);
  max-width: 100vw;
  height: min(860px, calc(100vh - 44px));
  height: min(860px, calc(100dvh - 44px));
  min-height: 620px;
  overflow: hidden;
  background: #e7ddd3;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-screen,
.chat-screen {
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 0;
}

.auth-screen {
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--panel);
}

.auth-screen[hidden],
.chat-screen[hidden] {
  display: none;
}

.auth-card {
  width: min(100%, 320px);
}

.auth-avatar {
  width: 58px;
  height: 58px;
  margin-bottom: 18px;
  font-size: 17px;
  background: #d7fff0;
  border: 2px solid rgba(7, 94, 84, 0.16);
}

.auth-card h1 {
  margin: 0;
  color: var(--header);
  font-size: 25px;
}

.auth-card p {
  margin: 7px 0 22px;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 9px;
}

.login-form label {
  color: #40514c;
  font-size: 13px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: #ffffff;
}

.login-form button {
  height: 42px;
  margin-top: 8px;
  border: 0;
  border-radius: 7px;
  color: #ffffff;
  background: var(--header);
  cursor: pointer;
  font-weight: 700;
}

.login-error {
  min-height: 18px;
  margin: 2px 0 0 !important;
  color: #b42318 !important;
  font-size: 13px !important;
}

.chat-screen {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto auto auto auto auto auto auto;
  min-height: 0;
  overflow: hidden;
}

.chat-header {
  grid-row: 1;
}

.system-status-bar {
  grid-row: 2;
}

.abandonment-notice {
  grid-row: 3;
}

.messages {
  grid-row: 4;
}

.spotify-presence {
  grid-row: 5;
}

.preview {
  grid-row: 6;
}

.attach-panel {
  grid-row: 7;
}

.sticker-panel {
  grid-row: 8;
}

.reply-preview {
  grid-row: 9;
}

.post-notification {
  grid-row: 10;
}

.composer {
  grid-row: 11;
}

.chat-header {
  position: sticky;
  top: 0;
  z-index: 5;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 12px 14px;
  color: #ffffff;
  background: var(--header);
}

.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--header);
  background: #d7fff0;
  font-weight: 700;
  font-size: 14px;
}

.chat-title {
  min-width: 0;
  flex: 1;
}

.chat-title h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.chat-status-line {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.chat-connection-indicator {
  width: 10px;
  height: 10px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.chat-connection-indicator svg {
  width: 10px;
  height: 10px;
  display: block;
  fill: #ef4444;
}

.chat-connection-indicator[data-state="connecting"] svg {
  fill: #fbbf24;
}

.chat-connection-indicator[data-state="connected"] svg {
  fill: #22c55e;
}

.chat-title p {
  min-width: 0;
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.send-button,
.attach-button,
.preview-close {
  border: 0;
  cursor: pointer;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
  font-size: 19px;
}

a.icon-button {
  text-decoration: none;
}

.posts-button {
  font-size: 21px;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.22);
}

.icon-button.notification-active {
  background: rgba(37, 211, 102, 0.32);
}

.icon-button.notification-off {
  background: rgba(255, 255, 255, 0.12);
}

.icon-button.spotify-button {
  color: #071b10;
  background: #1ed760;
  font-size: 23px;
  font-weight: 900;
}

.icon-button.spotify-button.is-connected {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.72);
}

.icon-button.export-button {
  font-size: 22px;
}

.icon-button.export-button:disabled {
  opacity: 0.58;
  cursor: wait;
}

.export-menu {
  position: absolute;
  top: 58px;
  right: 58px;
  z-index: 8;
  width: 210px;
  overflow: hidden;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(12, 22, 18, 0.24);
}

.export-menu[hidden] {
  display: none;
}

.export-menu button {
  width: 100%;
  min-height: 42px;
  padding: 0 13px;
  border: 0;
  color: var(--text);
  background: #ffffff;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
}

.export-menu button:hover,
.export-menu button:focus-visible {
  background: #f0f5f2;
}

.export-menu button:disabled {
  color: var(--muted);
  cursor: wait;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  padding: 18px 12px 16px;
  background-color: #e7ddd3;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.16) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.16) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.16) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.16) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.empty-state {
  margin: 28px auto 0;
  width: fit-content;
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 8px;
  color: #54615d;
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  text-align: center;
}

.date-separator {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 10px 0;
  pointer-events: none;
}

.date-separator time {
  padding: 5px 10px;
  border: 1px solid rgba(75, 108, 121, 0.12);
  border-radius: 7px;
  color: #4b626c;
  background: rgba(225, 241, 247, 0.96);
  box-shadow: 0 1px 3px rgba(31, 52, 59, 0.16);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  backdrop-filter: blur(5px);
}

.floating-date {
  position: absolute;
  top: 75px;
  left: 50%;
  z-index: 8;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -5px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.floating-date.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.floating-date time {
  display: block;
  padding: 5px 10px;
  border: 1px solid rgba(75, 108, 121, 0.12);
  border-radius: 7px;
  color: #4b626c;
  background: rgba(225, 241, 247, 0.96);
  box-shadow: 0 1px 3px rgba(31, 52, 59, 0.18);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  backdrop-filter: blur(5px);
}

.message-row {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: flex;
  margin: 7px 0;
  transition: background-color 0.2s ease;
}

.message-row.mine {
  justify-content: flex-end;
}

.message-row.message-highlight .bubble {
  outline: 2px solid var(--accent);
}

.bubble {
  position: relative;
  min-width: 0;
  max-width: min(78%, 320px);
  padding: 7px 30px 5px 8px;
  border-radius: 8px;
  background: var(--incoming);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
}

.mine .bubble {
  background: var(--outgoing);
}

.sender {
  margin-bottom: 4px;
  color: #11715f;
  font-size: 12px;
  font-weight: 700;
}

.message-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.35;
}

.message-link {
  color: #0277a8;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.message-link:hover,
.message-link:focus-visible {
  color: #005f87;
}

.message-media {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: 320px;
  margin-bottom: 6px;
  border-radius: 7px;
  object-fit: cover;
  background: #111;
  cursor: zoom-in;
}

.message-video {
  object-fit: contain;
}

.message-sticker {
  width: 104px;
  max-height: 104px;
  margin-bottom: 3px;
  object-fit: contain;
  background: transparent;
}

.reply-action {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  opacity: 0.58;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  font-size: 14px;
  transition: opacity 0.15s ease;
}

.bubble:hover .reply-action,
.reply-action:focus-visible {
  opacity: 1;
}

.reply-quote {
  width: 100%;
  display: grid;
  gap: 2px;
  margin: 0 0 6px;
  padding: 7px 9px;
  border: 0;
  border-left: 4px solid var(--header);
  border-radius: 7px;
  color: var(--text);
  background: rgba(7, 94, 84, 0.08);
  text-align: left;
  cursor: pointer;
}

.reply-quote strong {
  color: var(--header);
  font-size: 12px;
}

.reply-quote span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.meta {
  margin-top: 4px;
  color: #6d7773;
  font-size: 11px;
  text-align: right;
}

.status-ticks {
  display: inline-block;
  min-width: 18px;
  margin-left: 5px;
  color: #83908b;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.status-ticks.status-read {
  color: #34b7f1;
}

.preview {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  padding: 10px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.preview img,
.preview video {
  display: block;
  width: 86px;
  height: 86px;
  border-radius: 7px;
  object-fit: cover;
  background: #111;
}

.preview-close {
  position: absolute;
  top: 7px;
  left: 84px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.72);
  font-size: 20px;
  line-height: 1;
}

.attach-panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  overflow-x: hidden;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.attach-panel[hidden] {
  display: none;
}

.attach-panel button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--header);
  background: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.sticker-panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  overflow-x: hidden;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.sticker-title,
.sticker-create {
  grid-column: 1 / -1;
}

.sticker-title {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sticker-create {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--header);
  background: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.sticker-panel[hidden] {
  display: none;
}

.sticker-option {
  aspect-ratio: 1;
  min-width: 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.sticker-option:hover {
  border-color: var(--accent);
}

.sticker-option svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sticker-option img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.reply-preview {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.reply-preview[hidden] {
  display: none;
}

.reply-preview div {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding-left: 9px;
  border-left: 4px solid var(--header);
}

.reply-preview strong,
.reply-preview span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-preview strong {
  color: var(--header);
  font-size: 12px;
}

.reply-preview span {
  color: var(--muted);
  font-size: 12px;
}

.reply-preview button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 22px;
}

.spotify-presence {
  margin: 7px 10px 0;
  overflow: hidden;
  border-radius: 11px;
  color: #ffffff;
  background: linear-gradient(135deg, #17231b, #0d1510);
  box-shadow: 0 8px 20px rgba(8, 18, 11, 0.22);
  animation: post-notification-in 220ms ease-out;
}

.spotify-presence[hidden] {
  display: none;
}

.spotify-presence a {
  min-height: 72px;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 10px;
  padding: 8px 11px 8px 8px;
  color: inherit;
  text-decoration: none;
}

.spotify-presence a:hover,
.spotify-presence a:focus-visible {
  background: rgba(255, 255, 255, 0.05);
}

.spotify-presence img {
  width: 56px;
  height: 56px;
  display: block;
  border-radius: 7px;
  object-fit: cover;
  background: #26352b;
}

.spotify-presence-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.spotify-presence-copy strong,
.spotify-presence-copy > span:not(.spotify-progress) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spotify-presence-copy strong {
  font-size: 13px;
  line-height: 1.25;
}

.spotify-presence-copy > span:not(.spotify-progress) {
  color: #bdc8c0;
  font-size: 11px;
}

.spotify-presence-copy .spotify-presence-label {
  color: #1ed760;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.spotify-progress {
  height: 3px;
  margin-top: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.spotify-progress span {
  width: 0;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: #1ed760;
  transition: width 1s linear;
}

.spotify-mark {
  color: #1ed760;
  font-size: 28px;
  line-height: 1;
}

.post-notification {
  margin: 8px 10px 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 4px solid #5865f2;
  border-radius: 10px;
  color: #ffffff;
  background: #313338;
  box-shadow: 0 8px 22px rgba(25, 27, 31, 0.28);
  animation: post-notification-in 220ms ease-out;
}

.post-notification[hidden] {
  display: none;
}

.post-notification a {
  min-height: 58px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 10px;
  color: inherit;
  text-decoration: none;
}

.post-notification a:hover,
.post-notification a:focus-visible {
  background: rgba(255, 255, 255, 0.06);
}

.post-notification-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: #5865f2;
  font-size: 18px;
  font-weight: 800;
}

.post-notification-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.post-notification-copy strong,
.post-notification-copy > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-notification-copy strong {
  color: #f2f3f5;
  font-size: 13px;
}

.chat-title .foreground-timer {
  width: fit-content;
  max-width: 100%;
  margin-top: 3px;
  padding: 2px 7px;
  overflow: hidden;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-notification-copy > span {
  color: #b5bac1;
  font-size: 12px;
}

.post-notification-arrow {
  color: #dbdee1;
  font-size: 25px;
  line-height: 1;
}

@keyframes post-notification-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.composer {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 42px 42px minmax(0, 1fr) 42px;
  align-items: end;
  gap: 8px;
  overflow-x: hidden;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.attach-button,
.sticker-button,
.send-button {
  width: 42px;
  min-width: 0;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--header);
  font-size: 25px;
  line-height: 1;
  user-select: none;
}

.attach-button {
  color: var(--header);
  background: #ffffff;
  border: 1px solid var(--line);
}

.sticker-button {
  color: var(--header);
  background: #ffffff;
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 20px;
}

.send-button {
  background: var(--accent);
  font-size: 20px;
}

.composer textarea {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  max-height: 112px;
  min-height: 42px;
  padding: 11px 13px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #ffffff;
  line-height: 1.25;
  overflow-y: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  grid-template-rows: auto 1fr;
  background: rgba(8, 13, 12, 0.94);
}

.lightbox[hidden] {
  display: none;
}

.lightbox-topbar {
  min-height: 56px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.38);
}

.lightbox-topbar span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.lightbox-topbar a,
.lightbox-topbar button {
  height: 36px;
  border: 0;
  border-radius: 7px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
  cursor: pointer;
}

.lightbox-topbar a {
  display: grid;
  place-items: center;
  padding: 0 12px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.lightbox-topbar button {
  width: 36px;
  font-size: 25px;
  line-height: 1;
}

.lightbox-body {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 12px;
  touch-action: pinch-zoom;
}

.lightbox-media {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 82px);
  max-height: calc(100dvh - 82px);
  border-radius: 8px;
  object-fit: contain;
  background: #000000;
  touch-action: pinch-zoom;
}

@media (max-width: 520px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  body {
    background: #e7ddd3;
  }

  .app-shell {
    padding: 0;
  }

  .phone {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .sticker-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .composer {
    grid-template-columns: 40px 40px minmax(0, 1fr) 40px;
    gap: 6px;
    padding-right: 8px;
    padding-left: 8px;
  }

  .attach-button,
  .sticker-button,
  .send-button {
    width: 40px;
    height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .post-notification {
    animation: none;
  }
}

/* Technical dark interface */

html {
  color-scheme: dark;
}

body {
  min-width: 300px;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(0, 79, 255, 0.12), transparent 32rem),
    radial-gradient(circle at 88% 86%, rgba(114, 241, 184, 0.055), transparent 28rem),
    var(--bg);
}

[hidden] {
  display: none !important;
}

button,
a,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button,
a,
input,
textarea,
.bubble,
.spotify-presence,
.post-notification {
  transition:
    color 180ms ease,
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(114, 241, 184, 0.42);
  outline-offset: 3px;
}

.app-shell {
  padding: clamp(14px, 3vw, 34px);
}

.phone {
  width: min(100%, 1180px);
  height: min(900px, calc(100vh - 68px));
  height: min(900px, calc(100dvh - 68px));
  min-height: 640px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-soft);
  box-shadow: var(--shadow);
}

.auth-screen {
  padding: clamp(22px, 5vw, 48px);
  background:
    radial-gradient(circle at 50% 0%, rgba(0, 79, 255, 0.11), transparent 28rem),
    var(--surface-soft);
}

.auth-card {
  width: min(100%, 430px);
  padding: clamp(26px, 5vw, 42px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.38);
}

.auth-avatar,
.avatar {
  color: var(--accent);
  background: rgba(114, 241, 184, 0.08);
  border: 1px solid rgba(114, 241, 184, 0.22);
}

.auth-avatar {
  width: 64px;
  height: 64px;
  margin-bottom: 22px;
  border-radius: 18px;
  font-size: 15px;
  letter-spacing: 0.08em;
}

.auth-card .eyebrow,
.chat-eyebrow {
  display: block;
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1.2;
  text-transform: uppercase;
}

.auth-card h1 {
  color: var(--text);
  font-size: clamp(1.8rem, 6vw, 2.45rem);
  letter-spacing: -0.045em;
}

.auth-card > p:not(.eyebrow) {
  margin: 9px 0 26px;
  color: var(--muted);
  font-size: 0.92rem;
}

.login-form {
  gap: 8px;
}

.login-form label {
  margin: 8px 0 0;
  color: #b9c5d1;
  font-size: 0.76rem;
  letter-spacing: 0.025em;
}

.login-form input,
.composer textarea {
  color: var(--text);
  border: 1px solid var(--line);
  background: #0b1118;
  box-shadow: none;
}

.login-form input {
  height: 48px;
  border-radius: var(--radius-sm);
}

.login-form input:focus,
.composer textarea:focus {
  color: var(--text);
  border-color: var(--action);
  background: #0d141c;
  box-shadow: 0 0 0 4px rgba(0, 79, 255, 0.13);
}

.login-form button {
  height: 48px;
  margin-top: 15px;
  border-radius: var(--radius-sm);
  background: var(--action);
  box-shadow: 0 12px 28px rgba(0, 79, 255, 0.2);
}

.login-form button:hover:not(:disabled) {
  background: var(--action-hover);
  transform: translateY(-1px);
}

.login-form button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.login-error {
  color: var(--danger) !important;
}

.chat-screen {
  background: var(--surface-soft);
}

.chat-header {
  min-height: 88px;
  padding: 15px clamp(14px, 2vw, 22px);
  gap: 12px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  background: #0e151d;
}

.chat-title h1 {
  font-size: clamp(1.1rem, 3vw, 1.38rem);
  letter-spacing: -0.025em;
}

.chat-description,
.chat-title p.chat-description {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}

.chat-title .foreground-timer {
  color: var(--accent);
  background: rgba(114, 241, 184, 0.07);
  border: 1px solid rgba(114, 241, 184, 0.14);
}

.system-status-bar {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px clamp(14px, 2vw, 22px);
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: #0b1118;
}

.system-status-bar:has(.nina-counters:not([hidden])) {
  align-items: stretch;
  flex-direction: column;
}

.abandonment-notice {
  margin: 14px clamp(14px, 2vw, 22px);
  padding: clamp(18px, 3vw, 26px);
  color: #f5f7fa;
  border: 1px solid rgba(0, 79, 255, 0.48);
  border-radius: 18px;
  background:
    radial-gradient(circle at 100% 0, rgba(0, 79, 255, 0.2), transparent 58%),
    #101821;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}

.abandonment-notice > span {
  display: block;
  margin-bottom: 9px;
  color: #72f1b8;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.abandonment-notice p {
  margin: 0;
  color: #f5f7fa;
  font-size: clamp(1rem, 2.5vw, 1.28rem);
  font-weight: 650;
  line-height: 1.55;
  letter-spacing: -0.015em;
}

.chat-status-line {
  margin: 0;
}

.chat-status-line p {
  margin: 0;
  color: #c8d2dc;
  font-size: 0.76rem;
  font-weight: 650;
}

.status-protocol {
  color: #718193;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.67rem;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.nina-counters {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid #243141;
  border-radius: 14px;
  background: #0d141d;
}

.nina-counters[hidden] {
  display: none;
}

.nina-counter-copy {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #aab7c5;
  font-size: 0.75rem;
  line-height: 1.4;
}

.nina-counter-copy span {
  flex: 1;
}

.nina-counter-copy strong {
  color: #f5f7fa;
  font-size: 0.88rem;
  white-space: nowrap;
}

.nina-counter-action {
  padding-top: 10px;
  border-top: 1px solid #202c39;
}

.nina-counter-action .btn {
  min-width: 46px;
  min-height: 34px;
  padding: 4px 10px;
  border-radius: 9px;
  font-weight: 800;
}

.nina-milestone {
  margin: 0;
  padding: 10px 12px;
  color: #e9f0f8;
  border-left: 3px solid var(--action);
  border-radius: 4px 10px 10px 4px;
  background: rgba(0, 79, 255, 0.09);
  font-size: 0.8rem;
  line-height: 1.5;
}

.milestone-message {
  display: flex;
  gap: 8px;
}

.milestone-message .form-control {
  min-width: 0;
  min-height: 40px;
}

.milestone-message .btn {
  min-height: 40px;
}

.idle-poll-modal .modal-dialog {
  width: min(calc(100% - 28px), 430px);
  margin-inline: auto;
}

.idle-poll-modal .modal-content {
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #101720;
  box-shadow: var(--shadow-lg);
}

.idle-poll-modal .modal-header {
  min-height: 54px;
  padding: 14px 16px 0;
  border: 0;
}

.idle-poll-modal .btn-close {
  margin-left: auto;
  filter: invert(1) grayscale(1);
  opacity: 0.55;
}

.idle-poll-modal .modal-body {
  padding: 4px 28px 26px;
  text-align: center;
}

.idle-poll-modal h2 {
  margin: 0;
  font-size: clamp(1.25rem, 5vw, 1.6rem);
  letter-spacing: -0.025em;
}

.idle-poll-modal p {
  max-width: 330px;
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.idle-poll-modal .modal-footer {
  gap: 10px;
  padding: 16px 20px 20px;
  border-color: var(--line);
}

.idle-poll-modal .modal-footer .btn {
  min-height: 42px;
  flex: 1;
  border-radius: var(--radius-xs);
  font-weight: 700;
}

.poll-modal .modal-body {
  padding-top: 0;
  text-align: left;
}

.poll-modal .poll-kicker {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.poll-modal h2 {
  max-width: 360px;
  margin: 0 0 22px;
}

.poll-options {
  display: grid;
  gap: 10px;
}

.poll-option {
  position: relative;
  cursor: pointer;
}

.poll-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.poll-option span {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 12px 14px 12px 42px;
  color: #cbd5df;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: #121b25;
  font-size: 0.82rem;
  line-height: 1.4;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

.poll-option span::before {
  content: "";
  position: absolute;
  left: 15px;
  width: 15px;
  height: 15px;
  border: 1px solid #536375;
  border-radius: 50%;
}

.poll-option input:checked + span {
  color: #ffffff;
  border-color: var(--action);
  background: rgba(0, 79, 255, 0.12);
}

.poll-option input:checked + span::before {
  border: 4px solid var(--action);
  background: #ffffff;
}

.poll-option input:focus-visible + span {
  outline: 3px solid rgba(114, 241, 184, 0.25);
  outline-offset: 2px;
}

.idle-poll-modal [hidden] {
  display: none !important;
}

.modal-backdrop.show {
  opacity: 0.76;
}

.live-activity-toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 40;
  max-width: min(92vw, 420px);
  padding: 12px 18px;
  color: #ffffff;
  border: 1px solid rgba(114, 241, 184, 0.24);
  border-radius: var(--radius-sm);
  background: rgba(17, 31, 28, 0.96);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.live-activity-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.chat-connection-indicator svg {
  fill: #ff7f87;
  filter: drop-shadow(0 0 5px rgba(255, 127, 135, 0.2));
}

.chat-connection-indicator[data-state="connecting"] svg {
  fill: #ffd166;
}

.chat-connection-indicator[data-state="connected"] svg {
  fill: var(--accent);
  filter: drop-shadow(0 0 5px rgba(114, 241, 184, 0.32));
}

.icon-button {
  width: 40px;
  height: 40px;
  color: #c5d0db;
  border: 1px solid var(--line);
  background: #151e28;
}

.icon-button:hover,
.icon-button:focus-visible {
  color: #ffffff;
  border-color: #3d4f63;
  background: #1a2632;
  transform: translateY(-2px);
}

.icon-button.notification-active {
  color: var(--accent);
  border-color: rgba(114, 241, 184, 0.3);
  background: rgba(114, 241, 184, 0.1);
}

.icon-button.notification-off {
  background: #151e28;
}

.icon-button.spotify-button {
  color: #07150e;
  border-color: transparent;
  background: var(--accent);
}

.icon-button.spotify-button:hover {
  color: #07150e;
  background: #89f5c5;
}

.export-menu {
  top: 70px;
  right: 68px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.42);
}

.export-menu button {
  color: #d7dfe7;
  background: var(--surface-raised);
}

.export-menu button:hover,
.export-menu button:focus-visible {
  color: #ffffff;
  background: #1b2835;
}

.messages {
  padding: 22px clamp(12px, 2vw, 26px);
  background-color: #0a1016;
  background-image:
    linear-gradient(rgba(0, 79, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 79, 255, 0.025) 1px, transparent 1px),
    radial-gradient(circle at 78% 16%, rgba(0, 79, 255, 0.07), transparent 28rem);
  background-size: 32px 32px, 32px 32px, auto;
}

.messages::-webkit-scrollbar,
.sticker-panel::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-thumb,
.sticker-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #263241;
}

.empty-state {
  width: min(100%, 420px);
  margin: 56px auto 0;
  padding: 26px 24px;
  color: var(--muted);
  border: 1px dashed #334255;
  border-radius: var(--radius);
  background: rgba(17, 24, 33, 0.76);
  font-size: 0.83rem;
  line-height: 1.5;
}

.empty-state::before {
  content: "◇";
  display: block;
  margin-bottom: 9px;
  color: var(--accent);
  font-size: 2rem;
  line-height: 1;
}

.date-separator time,
.floating-date time {
  color: #a8b6c4;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(17, 24, 33, 0.94);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  backdrop-filter: none;
}

.floating-date {
  top: 140px;
}

.message-row {
  margin: 8px 0;
}

.bubble {
  max-width: min(70%, 640px);
  padding: 9px 34px 7px 11px;
  color: var(--text);
  border: 1px solid #253342;
  border-radius: 15px 15px 15px 5px;
  background: var(--incoming);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.mine .bubble {
  border-color: rgba(114, 241, 184, 0.2);
  border-radius: 15px 15px 5px 15px;
  background: var(--outgoing);
}

.message-row.message-highlight .bubble {
  outline-color: var(--action);
}

.sender,
.reply-quote strong {
  color: var(--accent);
}

.message-text {
  color: #edf2f7;
}

.message-link,
.post-notification a {
  color: #7ca0ff;
}

.message-link:hover,
.message-link:focus-visible {
  color: #9bb5ff;
}

.meta,
.status-ticks {
  color: #7e8c9a;
}

.status-ticks.status-read {
  color: var(--action-hover);
}

.reply-action {
  color: var(--muted);
  background: #202c38;
}

.reply-quote {
  color: var(--text);
  border-left-color: var(--action);
  background: rgba(0, 79, 255, 0.08);
}

.preview,
.attach-panel,
.sticker-panel,
.reply-preview,
.composer {
  border-top: 1px solid var(--line);
  background: #0e151d;
}

.preview img,
.preview video,
.message-media {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.attach-panel button,
.sticker-create,
.sticker-option {
  color: #cbd6df;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
}

.attach-panel button:hover,
.sticker-create:hover,
.sticker-option:hover {
  color: #ffffff;
  border-color: var(--action);
  background: #1a2632;
}

.reply-preview div {
  border-left-color: var(--action);
}

.reply-preview strong {
  color: #8eabff;
}

.spotify-presence {
  margin: 9px 12px 0;
  border: 1px solid rgba(114, 241, 184, 0.18);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #111c19, #101820);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

.spotify-presence:hover {
  border-color: rgba(114, 241, 184, 0.4);
  transform: translateY(-2px);
}

.spotify-presence-copy .spotify-presence-label,
.spotify-mark,
.spotify-progress span {
  color: var(--accent);
}

.spotify-progress span {
  background: var(--accent);
}

.post-notification {
  margin: 9px 12px 0;
  border: 1px solid rgba(0, 79, 255, 0.3);
  border-left: 4px solid var(--action);
  border-radius: var(--radius-sm);
  background: #111a26;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.26);
}

.post-notification-icon {
  background: var(--action);
}

.post-notification-copy strong {
  color: #eef3f8;
}

.post-notification-copy > span {
  color: var(--muted);
}

.composer {
  gap: 9px;
  padding: 11px 12px calc(11px + env(safe-area-inset-bottom));
}

.attach-button,
.sticker-button,
.send-button {
  color: #c7d2dc;
  border: 1px solid var(--line);
  background: var(--surface-raised);
}

.attach-button:hover,
.sticker-button:hover {
  color: #ffffff;
  border-color: #3d4f63;
  background: #1b2835;
  transform: translateY(-2px);
}

.send-button {
  color: #ffffff;
  border-color: transparent;
  background: var(--action);
  box-shadow: 0 8px 20px rgba(0, 79, 255, 0.2);
}

.send-button:hover {
  background: var(--action-hover);
  transform: translateY(-2px);
}

.composer textarea {
  border-radius: var(--radius-sm);
}

.composer textarea::placeholder,
.login-form input::placeholder {
  color: #657484;
}

.lightbox {
  background: rgba(5, 8, 12, 0.97);
}

.lightbox-topbar {
  border-bottom: 1px solid var(--line);
  background: #0d141c;
}

.lightbox-topbar a,
.lightbox-topbar button {
  color: #dce4eb;
  border: 1px solid var(--line);
  background: var(--surface-raised);
}

@media (max-width: 760px) {
  .chat-header {
    min-height: 78px;
    padding: 12px;
    gap: 8px;
  }

  .chat-header > .avatar {
    width: 38px;
    height: 38px;
  }

  .chat-description {
    display: none;
  }

  .icon-button {
    width: 37px;
    height: 37px;
  }

  .bubble {
    max-width: min(86%, 520px);
  }
}

@media (max-width: 520px) {
  body {
    background: var(--bg);
  }

  .app-shell {
    padding: 0;
  }

  .phone {
    border-radius: 0;
    background: var(--surface-soft);
  }

  .chat-header {
    gap: 6px;
  }

  .chat-eyebrow {
    font-size: 0.56rem;
    letter-spacing: 0.11em;
  }

  .chat-title h1 {
    font-size: 1rem;
  }

  .status-protocol {
    display: none;
  }

  .system-status-bar {
    gap: 8px;
    padding-inline: 10px;
  }

  .floating-date {
    top: 126px;
  }

  .messages {
    padding-top: 16px;
  }

  .empty-state {
    margin-top: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
