/* The interactive app replica. Colours come from the real app's dark theme. */

.demo {
  --d-bg: #0e0f13;
  --d-side: #121318;
  --d-surface: #17181e;
  --d-surface-2: #1c1e25;
  --d-surface-3: #242733;
  --d-view: #111216;
  --d-line: rgba(255, 255, 255, 0.06);
  --d-line-2: rgba(255, 255, 255, 0.11);
  --d-text: #e9eaef;
  --d-text-2: #a4a7b3;
  --d-text-3: #6d717e;
  --d-accent: #8190ff;
  --d-accent-soft: rgba(129, 144, 255, 0.14);
  --d-badge: #ff4d6d;

  position: relative;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: 40px minmax(0, 1fr);
  height: clamp(520px, 62vw, 640px);
  border-radius: 14px;
  overflow: hidden;
  background: var(--d-bg);
  color: var(--d-text);
  font-size: 13.5px;
  line-height: 1.4;
  box-shadow:
    0 0 0 1px rgba(22, 26, 51, 0.12),
    0 50px 100px -40px rgba(22, 26, 51, 0.55),
    0 24px 40px -24px rgba(22, 26, 51, 0.35);
  isolation: isolate;
}

.demo button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.demo :focus-visible {
  outline: 2px solid var(--d-accent);
  outline-offset: 1px;
}

/* window chrome */

.d-titlebar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: var(--d-side);
  border-bottom: 1px solid var(--d-line);
}

.d-lights {
  display: flex;
  gap: 8px;
}

.d-lights i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #3a3c45;
}

.d-lights i:nth-child(1) {
  background: #ff5f57;
}

.d-lights i:nth-child(2) {
  background: #febc2e;
}

.d-lights i:nth-child(3) {
  background: #28c840;
}

.d-title {
  flex: 1;
  text-align: center;
  color: var(--d-text-3);
  font-size: 12.5px;
  font-weight: 500;
  margin-right: 52px;
}

/* sidebar */

.d-side {
  background: var(--d-side);
  border-right: 1px solid var(--d-line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.d-search {
  margin: 12px 12px 6px;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--d-surface) !important;
  border: 1px solid var(--d-line) !important;
  color: var(--d-text-3) !important;
  text-align: left;
}

.d-search span {
  flex: 1;
}

.d-search kbd {
  font: inherit;
  font-size: 11px;
  padding: 0 5px;
  border-radius: 4px;
  border: 1px solid var(--d-line-2);
}

.d-search svg {
  width: 14px;
  height: 14px;
}

.d-accounts {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 8px;
  scrollbar-width: none;
}

.d-group {
  padding: 12px 10px 5px;
  color: var(--d-text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.d-acct {
  position: relative;
  width: 100%;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-radius: 8px;
  text-align: left;
  color: var(--d-text-2) !important;
}

.d-acct:hover {
  background: rgba(255, 255, 255, 0.035) !important;
  color: var(--d-text) !important;
}

.d-acct[aria-current='true'] {
  background: var(--d-surface-3) !important;
  color: var(--d-text) !important;
}

.d-acct[aria-current='true']::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--d-accent);
}

.d-acct span.n {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 18%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 30%, transparent);
}

.badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--d-badge);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.badge.pop {
  animation: pop 0.45s var(--ease);
}

@keyframes pop {
  0% {
    transform: scale(0.4);
  }
  60% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.d-side-foot {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--d-line);
}

.d-add {
  width: 100%;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--d-line-2) !important;
  color: var(--d-text-2) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.d-add:hover {
  color: var(--d-text) !important;
  border-color: var(--d-accent) !important;
}

.d-add svg {
  width: 14px;
  height: 14px;
}

/* main */

.d-main {
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.d-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--d-line);
  background: var(--d-bg);
  min-width: 0;
}

.d-toolbar strong {
  font-weight: 600;
  white-space: nowrap;
}

.d-pill {
  padding: 1px 8px;
  border-radius: 5px;
  background: var(--d-surface-2);
  color: var(--d-text-2);
  font-size: 11.5px;
  white-space: nowrap;
}

.d-sealed {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--d-text-3);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.d-sealed svg {
  width: 12px;
  height: 12px;
  flex: none;
}

.d-tools {
  margin-left: auto;
  display: flex;
  gap: 4px;
  color: var(--d-text-3);
}

.d-tools span {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.d-tools svg {
  width: 15px;
  height: 15px;
}

/* the "website" inside the account view */

.d-view {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 0;
  background: var(--d-view);
}

.d-chats {
  border-right: 1px solid var(--d-line);
  overflow-y: auto;
  scrollbar-width: none;
  padding: 8px;
}

.d-chats-head {
  padding: 6px 8px 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--d-text);
}

.d-chat {
  width: 100%;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: center;
  padding: 8px;
  border-radius: 9px;
  text-align: left;
}

.d-chat:hover {
  background: rgba(255, 255, 255, 0.03) !important;
}

.d-chat[aria-current='true'] {
  background: var(--d-surface-2) !important;
}

.avatar {
  grid-row: span 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  background: var(--av, #3a3f58);
}

.d-chat b {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.d-chat time {
  color: var(--d-text-3);
  font-size: 11.5px;
}

.d-chat .pv {
  color: var(--d-text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
}

.d-chat .badge {
  justify-self: end;
  min-width: 18px;
  background: var(--c, var(--d-accent));
}

.d-thread {
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}

.d-thread-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--d-line);
}

.d-thread-head .avatar {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.d-thread-head small {
  display: block;
  color: var(--d-text-3);
  font-size: 11.5px;
}

.d-msgs {
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--d-surface-3) transparent;
}

.d-day {
  align-self: center;
  color: var(--d-text-3);
  font-size: 11.5px;
  margin-bottom: 6px;
}

.msg {
  max-width: min(76%, 420px);
  padding: 8px 12px 7px;
  border-radius: 14px;
  background: var(--d-surface-2);
  align-self: flex-start;
  border-bottom-left-radius: 5px;
}

.msg.me {
  align-self: flex-end;
  background: color-mix(in srgb, var(--c) 30%, #1c1e25);
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 5px;
}

.msg .who {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--c);
  margin-bottom: 1px;
}

.msg time {
  display: block;
  text-align: right;
  font-size: 10.5px;
  color: var(--d-text-3);
  margin-top: 2px;
}

.msg.me time {
  color: rgba(233, 234, 239, 0.55);
}

.msg.new {
  animation: rise 0.28s var(--ease);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.typing {
  align-self: flex-start;
  color: var(--d-text-3);
  font-size: 12px;
  padding: 4px 2px;
}

.d-compose {
  display: flex;
  gap: 8px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--d-line);
}

.d-compose input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 14px;
  border-radius: 19px;
  border: 1px solid var(--d-line-2);
  background: var(--d-surface);
  color: var(--d-text);
  font: inherit;
  outline: none;
}

.d-compose input:focus {
  border-color: var(--d-accent);
}

.d-compose input::placeholder {
  color: var(--d-text-3);
}

.d-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--c) !important;
  color: #fff !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.d-send svg {
  width: 16px;
  height: 16px;
}

/* notification toast (stands in for the macOS banner) */

.d-toast {
  position: absolute;
  z-index: 5;
  top: 52px;
  right: 14px;
  width: 320px;
  max-width: calc(100% - 28px);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 2px 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(46, 48, 58, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  text-align: left;
  transform: translateX(calc(100% + 30px));
  opacity: 0;
  transition:
    transform 0.5s var(--ease),
    opacity 0.3s;
  pointer-events: none;
}

.d-toast.show {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

.d-toast img {
  grid-row: span 3;
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.d-toast b {
  font-weight: 650;
  font-size: 13px;
}

.d-toast small {
  color: var(--d-text-2);
  font-size: 11.5px;
}

.d-toast span {
  color: var(--d-text);
  font-size: 13px;
}

/* overlays inside the window: quick switcher + add account */

.d-scrim {
  position: absolute;
  inset: 40px 0 0;
  z-index: 6;
  background: rgba(6, 7, 10, 0.58);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 64px;
}

.d-scrim[hidden] {
  display: none;
}

.d-sheet {
  width: min(440px, calc(100% - 32px));
  border-radius: 14px;
  background: var(--d-surface);
  border: 1px solid var(--d-line-2);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.d-sheet input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid var(--d-line);
  background: transparent;
  color: var(--d-text);
  font: inherit;
  font-size: 15px;
  outline: none;
}

.d-sheet input::placeholder {
  color: var(--d-text-3);
}

.d-results {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.d-results button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  text-align: left;
}

.d-results button[aria-selected='true'] {
  background: var(--d-accent-soft);
}

.d-results small {
  margin-left: auto;
  color: var(--d-text-3);
}

.d-empty {
  padding: 18px;
  color: var(--d-text-3);
  text-align: center;
}

.d-add-sheet {
  padding: 20px;
}

.d-add-sheet h4 {
  margin: 0 0 4px;
  font-size: 16px;
}

.d-add-sheet p {
  margin: 0 0 14px;
  color: var(--d-text-2);
}

.d-svc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 16px;
}

.d-svc-grid span {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: var(--d-surface-2);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
}

.d-add-sheet .d-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.d-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-weight: 600;
}

.d-btn.primary {
  background: var(--d-accent-strong, #6474f5);
  color: #fff;
}

.d-btn.plain {
  border: 1px solid var(--d-line-2) !important;
  color: var(--d-text-2) !important;
}

/* narrow screens: accounts become a strip, chat list hides */

@media (max-width: 860px) {
  .d-view {
    grid-template-columns: minmax(0, 1fr);
  }

  .d-chats {
    display: none;
  }
}

@media (max-width: 640px) {
  .demo {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 40px auto minmax(0, 1fr);
    height: 600px;
  }

  .d-side {
    border-right: 0;
    border-bottom: 1px solid var(--d-line);
  }

  .d-search,
  .d-side-foot,
  .d-group {
    display: none;
  }

  .d-accounts {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 10px;
  }

  .d-acct {
    width: auto;
    flex: none;
    height: 34px;
    background: var(--d-surface) !important;
  }

  .d-acct[aria-current='true']::before {
    display: none;
  }

  .d-acct[aria-current='true'] {
    box-shadow: inset 0 0 0 1px var(--d-accent);
  }

  .d-sealed,
  .d-tools {
    display: none;
  }

  .d-title {
    margin-right: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .demo *,
  .demo *::before {
    animation: none !important;
    transition: none !important;
  }
}
