/* Try Mike — the in-browser chat, dressed like Mike's desktop window. */

/* A fixed app window: the page itself never scrolls, bounces or pans --
   only the conversation does. */
html:has(.chat-body), .chat-body { height: 100%; overflow: hidden; overscroll-behavior: none; }

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 264px 1fr;
}

/* ── the rail (desktop) ── */
.rail {
  background: var(--sunk);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 18px;
  min-height: 0;
}
@media (prefers-color-scheme: light) { .rail { background: var(--raised); } }

.rail__brand { padding: 4px 10px 18px; }
.rail__new {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  background: transparent; border: 0; border-radius: 10px;
  padding: 9px 10px;
  font-size: 16px; text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}
.rail__new:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.rail__plus {
  width: 26px; height: 26px; border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  display: grid; place-items: center;
}
.rail__plus svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.rail__spacer { flex: 1; }

.getcard {
  background: var(--ground);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 16px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
}
.getcard h2 { margin: 6px 0 0; font-size: 17px; font-weight: 600; line-height: 1.3; }
.getcard p { margin: 0 0 6px; font-size: 14.5px; line-height: 1.5; color: var(--ink-soft); }
.getcard .tile { width: 38px; height: 38px; border-radius: 10px; }
.getcard .tile .nibmark { width: 26px; height: 26px; }
.rail__note { margin: 12px 10px 0; font-size: 13px; color: var(--ink-mute); }

/* ── the main column ── */
.main { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; min-height: 0; }

.bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px;
  padding-top: calc(14px + env(safe-area-inset-top));
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.app.is-scrolled .bar { border-bottom-color: var(--hairline); }
.bar__brand { display: none; }
.bar__title { font-size: 15.5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bar__tag {
  font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-mute);
  border: 1px solid var(--hairline); border-radius: 999px;
  padding: 2px 8px;
  flex: none;
}
.bar__actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.bar__actions .iconbtn, .bar__get { display: none; }

.iconbtn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 0; background: transparent;
  display: grid; place-items: center; cursor: pointer;
  transition: background 0.15s ease;
}
.iconbtn:hover { background: var(--raised); }
.iconbtn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}
.column {
  max-width: 800px;
  margin: 0 auto;
  padding: 8px 32px 28px;
  min-height: 100%;
  display: flex; flex-direction: column;
}

/* ── the greeting (the app's resting state) ── */
.hello {
  margin: auto 0;
  padding: 36px 0 20px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.tile--lg { width: 56px; height: 56px; border-radius: 16px; }
.tile--lg .nibmark { width: 38px; height: 38px; }
.hello h1 {
  font-family: var(--serif); font-weight: 500; letter-spacing: -0.02em;
  margin: 20px 0 8px;
  font-size: clamp(30px, 5vw, 40px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.hello p { margin: 0 0 30px; max-width: 470px; color: var(--ink-soft); font-size: 17px; line-height: 1.55; }

.starters { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.starter {
  text-align: left;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 3px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.starter:hover { border-color: var(--ink-faint); background: var(--sunk); }
.starter:active { transform: scale(0.99); }
.starter__kind { font-size: 12.5px; color: var(--ink-mute); letter-spacing: 0.02em; }
.starter__text { font-size: 16px; line-height: 1.35; }

.app.has-thread .hello { display: none; }

/* ── the conversation ── */
.thread { list-style: none; margin: 0; padding: 18px 0 0; display: flex; flex-direction: column; gap: 26px; }

.msg { animation: rise 0.3s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.msg--you { display: flex; justify-content: flex-end; }
.msg--you .bubble {
  max-width: min(78%, 560px);
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 11px 16px;
  font-size: 17px; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere;
}

.prose { font-size: 17px; line-height: 1.65; overflow-wrap: anywhere; }
.prose p { margin: 0 0 0.8em; }
.prose > :last-child { margin-bottom: 0; }
.prose ul, .prose ol { margin: 0 0 0.8em; padding-left: 1.35em; }
.prose li { margin: 0.25em 0; }
.prose li::marker { color: var(--ink-mute); }
.prose strong { font-weight: 600; }
.prose em { font-style: italic; }
.prose h3 { font-size: 17px; font-weight: 600; margin: 1em 0 0.4em; }
.prose code { background: var(--raised); border: 1px solid var(--hairline); border-radius: 6px; padding: 0.05em 0.35em; }
.prose pre {
  margin: 0 0 0.8em;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: 14px; line-height: 1.55; }

.msg__cut { margin: 8px 0 0; font-size: 14px; color: var(--ink-mute); font-style: italic; }
.msg__tools { display: flex; gap: 4px; margin-top: 8px; opacity: 0; transition: opacity 0.15s ease; }
.msg--mike:hover .msg__tools, .msg--mike:focus-within .msg__tools { opacity: 1; }
@media (hover: none) { .msg__tools { opacity: 1; } }
.tool {
  border: 0; background: transparent; cursor: pointer;
  font-size: 14px; color: var(--ink-mute);
  padding: 4px 8px; border-radius: 7px;
}
.tool:hover { background: var(--raised); color: var(--ink); }

/* thinking: the nib, writing */
.thinking { display: inline-flex; align-items: center; gap: 10px; color: var(--ink-mute); font-style: italic; font-size: 16px; }
.thinking--script { display: block; width: 360px; max-width: 100%; margin: -10px 0 -10px -4px; }
.thinking--script canvas { display: block; }
.thinking .nibmark { width: 22px; height: 22px; animation: write 1.3s ease-in-out infinite; transform-origin: 30% 20%; }
@keyframes write {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(3px, 1px) rotate(-4deg); }
  50% { transform: translate(6px, 0) rotate(0deg); }
  75% { transform: translate(3px, -1px) rotate(3deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

/* a notice: busy, resting, couldn't answer */
.notice {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 14px 16px;
  font-size: 16px; line-height: 1.5; color: var(--ink-soft);
}
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 3px; fill: none; stroke: var(--ink-mute); stroke-width: 1.6; stroke-linecap: round; }
.notice__actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* on your computer, Mike would… (the app's steps card) */
.steps {
  margin-top: 14px;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  overflow: hidden;
}
.steps__head { display: flex; align-items: center; gap: 12px; padding: 13px 16px 6px; font-weight: 600; font-size: 16px; }
.steps__head .nibmark { width: 20px; height: 20px; }
.steps__list { list-style: none; margin: 0; padding: 2px 16px 10px; }
.step { display: flex; gap: 12px; padding: 8px 0; align-items: flex-start; }
.step__dot {
  flex: none; width: 18px; height: 18px; border-radius: 50%; margin-top: 3px;
  background: color-mix(in srgb, var(--ink) 9%, transparent);
  display: grid; place-items: center;
  font: 500 10.5px/1 var(--mono); color: var(--ink-soft);
}
.step__title { font-size: 16px; line-height: 1.4; }
.step__detail { font: 13.5px/1.45 var(--mono); color: var(--ink-mute); overflow-wrap: anywhere; margin-top: 1px; }
.step__ask { display: inline-block; margin-top: 4px; font-size: 13px; color: var(--ink-mute); }
.steps__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--ground) 55%, transparent);
}
.steps__foot span { font-size: 15px; color: var(--ink-soft); }

/* ── the composer (as in the app) ── */
.dock { padding: 6px 32px calc(14px + env(safe-area-inset-bottom)); }
.composer {
  max-width: 736px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 12px 12px 10px 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.composer:focus-within { border-color: var(--ink-faint); box-shadow: var(--shadow); }
.composer textarea {
  display: block; width: 100%;
  min-height: 26px; max-height: 200px;
  resize: none; border: 0; outline: none; background: transparent;
  color: var(--ink);
  font: 400 17px/1.5 var(--serif);
  padding: 2px 0 6px;
}
.composer textarea::placeholder { color: var(--ink-mute); }
.composer__row { display: flex; align-items: center; gap: 10px; }
.composer__hint { font-size: 13px; color: var(--ink-mute); }
.composer__count { font: 12px var(--mono); color: var(--ink-mute); }
.send {
  margin-left: auto;
  width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: var(--ink); color: var(--ground);
  display: grid; place-items: center; cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.send:disabled { background: var(--ink-faint); color: var(--ground); cursor: default; }
.send:not(:disabled):active { transform: scale(0.94); }
.send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.send__stop { display: none; fill: currentColor !important; stroke: none !important; }
.app.is-busy .send__go { display: none; }
.app.is-busy .send__stop { display: block; }
.app.is-busy .send { background: var(--ink); }

.fine { max-width: 736px; margin: 9px auto 0; text-align: center; font-size: 13px; line-height: 1.5; color: var(--ink-mute); }
.fine a { color: var(--ink-soft); }
.fine__short { display: none; }

/* ── narrower windows keep the desktop layout, with a slimmer rail ── */
@media (max-width: 900px) and (min-width: 641px) {
  .app { grid-template-columns: 220px 1fr; }
  .getcard p { font-size: 13.5px; }
}

/* ── phones: no rail; the header carries the brand ── */
@media (max-width: 640px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .bar { padding-left: 16px; padding-right: 12px; }
  .bar__brand { display: inline-flex; }
  .bar__brand .brand__name { font-size: 19px; }
  .bar__title { display: none; }
  .bar__actions .iconbtn, .bar__get { display: inline-flex; }
}

@media (max-width: 560px) {
  .column { padding: 4px 16px 20px; }
  .dock { padding: 4px 10px calc(10px + env(safe-area-inset-bottom)); }
  .composer { display: flex; align-items: flex-end; gap: 8px; padding: 7px 7px 7px 16px; border-radius: 24px; }
  .composer textarea { font-size: 16px; padding: 7px 0; } /* 16px: no zoom-on-focus on iPhone */
  .composer__row { flex: none; }
  .composer__hint, .composer__count { display: none; }
  .hello { padding: 12px 0 8px; }
  .tile--lg { width: 46px; height: 46px; border-radius: 13px; }
  .tile--lg .nibmark { width: 31px; height: 31px; }
  .hello h1 { margin: 14px 0 6px; font-size: 30px; }
  .hello p { font-size: 15.5px; margin-bottom: 18px; }
  .starters { gap: 8px; }
  .starter { padding: 11px 12px; border-radius: 12px; }
  .starter__kind { font-size: 12px; }
  .starter__text { font-size: 14.5px; }
  .msg--you .bubble { max-width: 86%; font-size: 16px; }
  .prose { font-size: 16.5px; }
  .steps__foot { flex-direction: column; align-items: stretch; }
  .steps__foot .btn { justify-content: center; }
  .fine { font-size: 12px; }
  .fine__long { display: none; }
  .fine__short { display: inline; }
  .bar__tag { display: none; }
}

/* ── attaching files: the paperclip, the chips, dropping ── */
.attach {
  width: 34px; height: 34px; border-radius: 50%; border: 0; flex: none;
  background: transparent; color: var(--ink-soft);
  display: grid; place-items: center; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.attach:hover { background: var(--raised); color: var(--ink); }
.attach svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 10px; }
.tray[hidden] { display: none; }
.chip {
  display: flex; align-items: center; gap: 10px; max-width: 280px;
  padding: 6px 6px 6px 6px; border-radius: 12px;
  border: 1px solid var(--hairline); background: var(--raised);
  font-family: var(--sans);
}
.chip__kind {
  width: 36px; height: 36px; border-radius: 8px; flex: none; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em;
  background: var(--surface); border: 1px solid var(--hairline); color: var(--ink-soft);
}
.chip__thumb { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex: none; }
.chip__meta { display: flex; flex-direction: column; min-width: 0; }
.chip__name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip__note { font-size: 12px; color: var(--ink-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip--reading .chip__kind { animation: chip-pulse 1.2s ease-in-out infinite; }
.chip--error { border-color: color-mix(in srgb, var(--stop) 40%, var(--hairline)); }
.chip--error .chip__note { color: var(--stop); white-space: normal; }
.chip__x {
  width: 24px; height: 24px; border-radius: 50%; border: 0; flex: none; margin-left: 2px;
  background: transparent; color: var(--ink-mute); font-size: 17px; line-height: 1; cursor: pointer;
}
.chip__x:hover { background: var(--surface); color: var(--ink); }
@keyframes chip-pulse { 50% { opacity: 0.45; } }

.app.is-dropping .composer { border-color: var(--ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 8%, transparent); }

.sent-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-bottom: 6px; }
.sent-file {
  font: 500 12.5px/1 var(--sans); color: var(--ink-soft);
  padding: 6px 10px; border-radius: 999px; border: 1px solid var(--hairline); background: var(--surface);
  max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── connecting the visitor's Cloudflare ── */
.connect {
  border: 1px solid var(--hairline); border-radius: 16px; background: var(--surface);
  padding: 18px 20px; box-shadow: var(--shadow-sm); font-family: var(--sans); max-width: 560px;
}
.connect__head { display: flex; align-items: center; gap: 10px; font-size: 15.5px; }
.connect__head svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; }
.connect p { margin: 10px 0 0; color: var(--ink-soft); font-size: 14.5px; line-height: 1.55; }
.connect .sent-files { justify-content: flex-start; margin: 12px 0 0; }
.connect__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.connect .connect__fine { font-size: 12.5px; color: var(--ink-mute); margin-top: 12px; }
.connect .connect__err { color: var(--stop); font-size: 13.5px; }

.cfpill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--hairline);
  background: var(--surface); color: var(--ink); font: 500 13px/1 var(--sans); cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.cfpill[hidden] { display: none; }
.cfpill:hover { border-color: var(--ink-faint); }
.cfpill__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.cfpill.is-asking { color: var(--stop); border-color: color-mix(in srgb, var(--stop) 45%, var(--hairline)); }
.cfpill.is-asking .cfpill__dot { background: var(--stop); }

@media (max-width: 640px) {
  .composer { flex-wrap: wrap; }
  .composer textarea { flex: 1; min-width: 0; }
  .tray { flex-basis: 100%; padding-top: 4px; }
  .chip { max-width: 100%; }
  .cfpill span:last-child { display: none; }
  .cfpill { padding: 8px; }
}
