/* macOS-style dock and app windows: Telegram (talk to us), Safari and iPhone (the live platform), Notes. */

.dock {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 24px;
  background: rgba(30,32,36,.58);
  box-shadow: inset 0 0 0 .5px rgba(255,255,255,.22),0 18px 48px #0009;
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
  transform: translate(-50%,calc(100% + 32px));
  opacity: 0;
  transition: transform 420ms cubic-bezier(.22,1,.36,1),opacity 300ms;
  pointer-events: none;
}

.dock.is-visible {
  transform: translate(-50%,0);
  opacity: 1;
  pointer-events: auto;
}

.dock.is-visible.is-tucked {
  transform: translate(-50%,calc(100% + 32px));
  opacity: 0;
  pointer-events: none;
}

.dock-app {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  transform: scale(var(--dock-scale,1));
  transform-origin: 50% 100%;
  transition: transform 160ms cubic-bezier(.22,1,.36,1);
  -webkit-tap-highlight-color: transparent;
}

.dock-app svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 8px #0006);
}

.dock-label {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 50%;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(30,32,36,.92);
  box-shadow: inset 0 0 0 .5px rgba(255,255,255,.18);
  color: #f4f7fb;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  transform: translate(-50%,4px) scale(calc(1 / var(--dock-scale,1)));
  transform-origin: 50% 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms,transform 120ms;
}

.dock-app:hover .dock-label,.dock-app:focus-visible .dock-label {
  opacity: 1;
  transform: translate(-50%,0) scale(calc(1 / var(--dock-scale,1)));
}

.dock-dot {
  position: absolute;
  bottom: -6px;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #f4f7fb;
  transform: translateX(-50%);
  opacity: 0;
}

.dock-app.is-running .dock-dot { opacity: .9; }

/* Windows */
.mac-window {
  position: fixed;
  width: min(var(--window-width,720px),calc(100vw - 32px));
  height: min(var(--window-height,560px),calc(100dvh - 120px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  background: #fff;
  color: #1d1d1f;
  box-shadow: 0 0 0 .5px rgba(0,0,0,.4),0 0 0 1px rgba(255,255,255,.1),0 30px 80px #000a;
  font-family: -apple-system,BlinkMacSystemFont,'SF Pro Text','Helvetica Neue',Geist,Arial,sans-serif;
}

.mac-window[open] {
  display: flex;
  flex-direction: column;
  animation: window-in 260ms cubic-bezier(.22,1,.36,1);
}

.mac-window::backdrop {
  background: rgba(5,5,5,.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.mac-window.is-zoomed {
  width: calc(100vw - 32px);
  height: calc(100dvh - 32px);
  translate: none !important;
}

@keyframes window-in {
  from { opacity: 0; transform: translateY(24px) scale(.96); }
}

@keyframes sheet-in {
  from { transform: translateY(100%); }
}

.mac-titlebar {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  height: 40px;
  padding: 0 14px;
  border-bottom: 1px solid #dcdcdc;
  background: linear-gradient(#f6f6f6,#ececec);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.mac-titlebar:active { cursor: grabbing; }

.mac-lights {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 12px;
}

.mac-light {
  position: relative;
  width: 12px;
  height: 12px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 .5px rgba(0,0,0,.18);
  cursor: pointer;
}

/* 24px hit area around the 12px dot (WCAG 2.2 target size). */
.mac-light::after {
  content: '';
  position: absolute;
  inset: -6px;
}

.mac-window :is(button,a,input):focus-visible {
  outline: 2px solid #1f6fbf;
  outline-offset: 2px;
}

.mac-close { background: #ff5f57; }
.mac-min { background: #febc2e; }
.mac-zoom { background: #28c840; }

.mac-title {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: #4d4d4f;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  pointer-events: none;
}

.mac-body {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

/* Telegram */
.window-telegram { --window-width: 440px; --window-height: 720px; }

.tg-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #e7e7e7;
  background: #fff;
}

.tg-back {
  display: grid;
  place-items: center;
  width: 28px;
  height: 36px;
  padding: 0;
  border: 0;
  background: none;
  color: #1f6fbf;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.tg-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #3547ff;
}

.tg-avatar img { width: 26px; height: auto; }

.tg-name { margin: 0; color: #000; font-size: 16px; font-weight: 600; }
.tg-status { margin: 2px 0 0; color: #1f6fbf; font-size: 13px; }
.tg-status.is-typing::after { content: ' typing…'; }
.tg-status.is-typing span { display: none; }

.tg-chat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle,rgba(255,255,255,.35) 1.5px,transparent 1.6px) 0 0/36px 36px,
    linear-gradient(160deg,#c7dea1 0%,#a9cf98 45%,#8fc3a8 100%);
}

.tg-date {
  align-self: center;
  margin: 0 0 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(70,110,60,.35);
  color: #fff;
  font-size: 13px;
}

.tg-bubble {
  position: relative;
  max-width: 82%;
  margin: 0;
  padding: 7px 10px 7px 12px;
  border-radius: 14px;
  background: #fff;
  color: #000;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(0,0,0,.12);
  animation: bubble-in 200ms cubic-bezier(.22,1,.36,1);
}

.tg-bubble.is-out {
  align-self: flex-end;
  background: #effdde;
}


.tg-time {
  float: right;
  margin: 6px 0 -4px 10px;
  color: #6b776a;
  font-size: 11px;
}

.tg-bubble.is-out .tg-time { color: #3f7f35; }

.tg-typing {
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
}

.tg-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9aa59a;
  animation: typing 1s infinite ease-in-out;
}

.tg-typing i:nth-child(2) { animation-delay: .15s; }
.tg-typing i:nth-child(3) { animation-delay: .3s; }

@keyframes typing {
  0%,60%,100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-3px); opacity: 1; }
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px); }
}

.tg-system {
  align-self: center;
  margin: 4px 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(40,80,40,.4);
  color: #fff;
  font-size: 13px;
  text-align: center;
}

.tg-gate {
  display: grid;
  gap: 8px;
  padding: 12px 14px 4px;
  background: #fff;
  border-top: 1px solid #e7e7e7;
}

.tg-gate[hidden] { display: none; }

.tg-gate-title { margin: 0; color: #000; font-size: 14px; font-weight: 600; }
.tg-gate.is-attention .tg-gate-title { color: #e5484d; }

.tg-connect {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 10px;
  background: #1f6fbf;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

.tg-connect[hidden] { display: none; }
.tg-connect svg { width: 18px; height: 18px; }

.tg-contact {
  display: flex;
  gap: 8px;
  margin: 0;
}

.tg-contact input,.tg-compose input {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: #f1f1f4;
  color: #000;
  font: inherit;
  font-size: 15px;
}

.tg-contact button {
  min-width: 52px;
  border: 0;
  border-radius: 10px;
  background: #e5f2fd;
  color: #1f6fbf;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tg-linked {
  margin: 0;
  padding: 10px 14px;
  border-top: 1px solid #e7e7e7;
  background: #fff;
  color: #3a7d32;
  font-size: 13px;
}

.tg-linked[hidden] { display: none; }

.tg-chips {
  display: flex;
  gap: 8px;
  padding: 10px 14px 4px;
  overflow-x: auto;
  background: #fff;
  scrollbar-width: none;
}

.tg-chips::-webkit-scrollbar { display: none; }

.tg-chips button {
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1px solid #cfe5f8;
  border-radius: 999px;
  background: #f4faff;
  color: #1f6fbf;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.tg-compose {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 14px 12px;
  background: #fff;
}

.tg-send {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #1f6fbf;
  color: #fff;
  cursor: pointer;
}

.tg-send svg { width: 18px; height: 18px; }
.tg-send:disabled { opacity: .4; cursor: default; }

.tg-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* Safari: the live platform in a same-origin frame */
.window-safari { --window-width: 1240px; --window-height: 840px; }

.sf-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 8px 12px;
  border-bottom: 1px solid #dcdcdc;
  background: #f5f5f5;
}

.sf-toolbar button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: #6e6e73;
  font-size: 18px;
  cursor: pointer;
}

.sf-toolbar button:hover { background: #e6e6e6; }

.sf-address {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  margin: 0 8px;
  border-radius: 8px;
  background: #e8e8ea;
  color: #3a3a3c;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
}

.sf-address svg { flex: 0 0 auto; width: 11px; height: 11px; }

.sf-open {
  padding: 5px 10px;
  border-radius: 6px;
  color: #1f5fd6;
  font-size: 13px;
  text-decoration: none;
}

.sf-open:hover { background: #e6e6e6; }

.live-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0f1214;
}

.live-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #0f1214;
}

.live-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: #aeb8c3;
  font-size: 13px;
  pointer-events: none;
  transition: opacity 300ms;
}

.live-loading::before {
  content: '';
  width: 22px;
  height: 22px;
  border: 2px solid rgba(244,247,251,.2);
  border-top-color: #f4f7fb;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.is-loaded > .live-loading { opacity: 0; }

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

/* iPhone: the platform at phone width */
.window-iphone {
  --window-width: 470px;
  --window-height: 960px;
  background: #1b1d20;
}

.window-iphone .mac-titlebar {
  border-bottom-color: #2b2e33;
  background: linear-gradient(#2c2f34,#25282c);
}

.window-iphone .mac-title { color: #c9ced6; }

.iphone-stage {
  display: grid;
  place-items: center;
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px;
}

.iphone-frame {
  --phone-scale: 1;
  position: relative;
  width: calc(390px * var(--phone-scale) + 24px);
  height: calc(844px * var(--phone-scale) + 24px);
  padding: 12px;
  border-radius: calc(54px * var(--phone-scale) + 12px);
  background: #0b0c0e;
  box-shadow: inset 0 0 0 2px #3a3d42,0 20px 40px #0008;
}

.iphone-screen {
  position: relative;
  width: calc(390px * var(--phone-scale));
  height: calc(844px * var(--phone-scale));
  overflow: hidden;
  border-radius: calc(44px * var(--phone-scale));
  background: #0f1214;
}

.iphone-screen .live-frame {
  width: 390px;
  height: 844px;
  transform: scale(var(--phone-scale));
  transform-origin: 0 0;
}

.iphone-screen::after {
  content: '';
  position: absolute;
  top: calc(11px * var(--phone-scale));
  left: 50%;
  width: calc(122px * var(--phone-scale));
  height: calc(34px * var(--phone-scale));
  border-radius: 999px;
  background: #000;
  transform: translateX(-50%);
  pointer-events: none;
}

/* Notes */
.window-notes { --window-width: 820px; --window-height: 560px; }

.notes {
  display: grid;
  grid-template-columns: 240px minmax(0,1fr);
  flex: 1 1 auto;
  min-height: 0;
}

.notes-list {
  margin: 0;
  padding: 10px;
  overflow-y: auto;
  border-right: 1px solid #e3e3e3;
  background: #f7f6f2;
  list-style: none;
}

.notes-list button {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: #1d1d1f;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.notes-list button[aria-selected="true"] { background: #fde68a; }
.notes-list strong { font-size: 14px; }
.notes-list span { overflow: hidden; color: #6e6e73; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }

.notes-page {
  padding: 28px 36px;
  overflow-y: auto;
}

.notes-page[hidden] { display: none; }

.notes-page h2 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.notes-page .notes-sub { margin: 0 0 18px; color: #6e6e73; font-size: 13px; }

.notes-page ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.notes-page li {
  display: grid;
  grid-template-columns: 20px minmax(0,1fr);
  gap: 10px;
  font-size: 15px;
  line-height: 1.45;
}

.notes-page li::before {
  content: '';
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border: 1.5px solid #c7c7cc;
  border-radius: 50%;
}

.notes-page.is-done li::before {
  border-color: #e6a800;
  background: #e6a800 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4.5 8.2 2.3 2.3 4.7-4.9' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/14px no-repeat;
}

.notes-page b { font-weight: 600; }

@media(hover:none),(max-width:640px) {
  .dock-label { display: none; }
  /* iOS Safari zooms the page into any focused field under 16px. */
  .tg-contact input,.tg-compose input { font-size: 16px; }
}

@media(max-width:640px) {
  .dock { bottom: 10px; gap: 8px; padding: 6px 8px; border-radius: 20px; }
  .dock-app { width: 50px; height: 50px; }
  .dock-app[data-app="iphone"] { display: none; }
  /* Phones: windows rise as a bottom sheet; a strip of the dimmed page stays visible above (tap it to close). */
  .mac-window,.mac-window.is-zoomed {
    width: 100vw;
    height: calc(100dvh - 32px);
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
  }
  .mac-window[open] { animation: sheet-in 360ms cubic-bezier(.22,1,.36,1); }
  .mac-titlebar { height: 48px; cursor: default; }
  /* Sheet windows: minimize/zoom mean nothing, the close dot gets a 44px finger target. */
  .mac-min,.mac-zoom { display: none; }
  .mac-close { width: 14px; height: 14px; }
  .mac-close::after { inset: -15px; }
  .notes { grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr); }
  .notes-list { display: flex; gap: 6px; padding: 8px; overflow-x: auto; border-right: 0; border-bottom: 1px solid #e3e3e3; }
  .notes-list li { flex: 0 0 auto; }
  .notes-list span { display: none; }
  .notes-page { padding: 20px; }
}

@media(prefers-reduced-motion:reduce) {
  .dock,.dock-app,.mac-window[open],.tg-bubble { transition: none; animation: none; }
  .tg-typing i { animation: none; }
}
