/* Ember island — PORTED from upstream's design/prototype/notch-buddy.html
 * PROVENANCE-START
 * (upstream Louis-CFM/coucou, MIT). Geometry, colours and animation curves are upstream's
 * PROVENANCE-END
 * own numbers, not approximations: see docs/SPEC.md §2 (modes), §4 (animations), §5 (views).
 *
 * Every value below that carries a comment was copied from the prototype's stylesheet.
 * The class names and the `--ember-` custom properties are ours; the mechanism is theirs.
 *
 * Modes: hidden | peek | compact | expanded.  The console ships the island DOCKED, so the
 * default is `expanded` where there is room and `compact` under 720px; the notch states
 * exist so the same component can drive a native/notch surface later.
 */

@property --ember-island-w {
  syntax: '<length>';
  inherits: false;
  initial-value: 184px;
}

.ember-island {
  /* ---- ported tokens (prototype :12-14, :94-176) ---- */
  --spr: cubic-bezier(.32, 1.22, .42, 1);          /* open spring, prototype :13 */
  --out: cubic-bezier(.45, 0, .2, 1);              /* close curve, prototype :96 */
  --ink: #F5F6F8;
  --muted: #5F646D;                                 /* .ln, prototype :163 */
  --meta: #8E939C;                                  /* .who, prototype :146 */
  --sub: #9398A1;                                   /* .sub, prototype :150 */
  --sub-red: #FF8D97;                               /* .sub.red, prototype :151 */
  --card-bg: #141518;                               /* .card, prototype :130 */
  --card-line: rgba(255, 255, 255, .035);           /* .card border, prototype :130 */

  /* per-state wash; the rgba values are the prototype's own (:138-139) */
  --wash-neutral: rgba(255, 255, 255, .08);
  --wash-red: rgba(244, 80, 94, .55);
  --wash-green: rgba(52, 211, 153, .5);
  --wash-pink: rgba(244, 114, 182, .55);
  --wash-amber: rgba(245, 165, 36, .42);
  --wash-cyan: rgba(34, 211, 238, .38);
  --wash-indigo: rgba(99, 102, 241, .5);

  position: relative;
  display: block;
  background: #000;
  color: var(--ink);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', system-ui, sans-serif;
  border-radius: 0 0 30px 30px;                     /* expanded, prototype :100 */
  overflow: hidden;
  isolation: isolate;
}

/* ---- the concave "ears" that let the island flow into the screen edge (:97-99) ---- */
.ember-island::before,
.ember-island::after {
  content: '';
  position: absolute;
  top: 0;
  width: 14px;
  height: 14px;
  pointer-events: none;
  z-index: 1;
}
.ember-island::before {
  left: -14px;
  background: radial-gradient(circle at 0 100%, transparent 13.5px, #000 14px);
}
.ember-island::after {
  right: -14px;
  background: radial-gradient(circle at 100% 100%, transparent 13.5px, #000 14px);
}

/* ---- modes (SPEC §2 table) ---- */
.ember-island[data-mode='hidden']  { width: 184px; height: 32px; border-radius: 0 0 14px 14px; }
.ember-island[data-mode='peek']    { width: 248px; height: 32px; border-radius: 0 0 14px 14px; } /* wN+64 */
.ember-island[data-mode='compact'] { width: 288px; height: 32px; border-radius: 0 0 14px 14px; } /* wN+104 */
.ember-island[data-mode='expanded']{ width: 640px; border-radius: 0 0 30px 30px; }

/* SPEC §2/§3: only expanded shows a view body; peek and compact are the thin island
   (the character itself is the separate masthead mascot, not drawn twice here). */
.ember-island:not([data-mode='expanded']) .ember-island__view { display: none; }

/* Auto-fold countdown (SPEC §3.5): a 2 pt line, 160 pt -> 0 over the last 10 s,
   white 35 %, bottom centre. --ember-fold-left is 1..0, written by
   js/ember-island-state.js when the last 10 s open. */
.ember-island__countdown {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: calc(160px * var(--ember-fold-left, 1));
  height: 2px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, .35);
  border-radius: 1px;
  pointer-events: none;
  opacity: 0;
  z-index: 3;
}
.ember-island[data-fold='counting'] .ember-island__countdown { opacity: 1; }

/* open/close timing (prototype :95-96) */
.ember-island {
  transition:
    width .52s var(--spr),
    height .52s var(--spr),
    border-radius .5s var(--spr);
}
.ember-island.is-closing {
  transition:
    width .34s var(--out),
    height .34s var(--out),
    border-radius .3s ease;
}

/* ---- header (34pt, prototype :117-124) ---- */
.ember-island__hdr {
  position: absolute;
  inset: 0 0 auto 0;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.ember-island[data-mode='expanded'] .ember-island__hdr {
  opacity: 1;
  pointer-events: auto;
  transition: opacity .3s ease .3s;
}
.ember-island__tabs { display: flex; gap: 6px; }
.ember-island__tab {
  appearance: none;
  border: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  cursor: pointer;
  color: var(--meta);
}
.ember-island__tab[aria-selected='true'],
.ember-island__tab.is-on { background: #1D1F23; color: var(--ink); }
.ember-island__tab svg { width: 14px; height: 14px; }
.ember-island__hdr-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--fs-micro);
  color: #7B8089;
}

/* ---- views: shared container (prototype :127-129) ---- */
.ember-island__view {
  position: absolute;
  top: 36px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  opacity: 0;
  filter: blur(8px);
  transform: scale(.97);
  pointer-events: none;
  transition: opacity .16s ease, filter .16s ease, transform .16s ease;
  color: var(--ink);
  font-size: 13px;
}
.ember-island__view.is-on {
  opacity: 1;
  filter: blur(0);
  transform: none;
  pointer-events: auto;
  transition:
    opacity .3s ease .16s,
    filter .3s ease .16s,
    transform .4s var(--spr) .12s;
}

/* ---- cards (prototype :130-134) ---- */
.ember-island__card {
  position: absolute;
  background: var(--card-bg);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--card-line);
}
.ember-island__card--full { inset: 0 42px 0 0; }
.ember-island__card--wide { inset: 0; }
.ember-island__card--left { left: 0; top: 0; bottom: 0; width: 322px; }
.ember-island__card--right { left: 332px; right: 0; top: 0; bottom: 0; }

/* the per-state colour veil (prototype :137-139) */
.ember-island__card--wash::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 130%, var(--wash, transparent) 0%, transparent 70%);
  opacity: .9;
}
.ember-island__card--neutral { --wash: var(--wash-neutral); }
.ember-island__card--red     { --wash: var(--wash-red); }
.ember-island__card--green   { --wash: var(--wash-green); }
.ember-island__card--pink    { --wash: var(--wash-pink); }
.ember-island__card--amber   { --wash: var(--wash-amber); }
.ember-island__card--cyan    { --wash: var(--wash-cyan); }
.ember-island__card--indigo  { --wash: var(--wash-indigo); }

/* ---- copy block (prototype :140-145) ----
   --ember-pl is the left padding that keeps text clear of the character. */
.ember-island__copy {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 0 18px 0 var(--ember-pl, 102px);
}

/* ---- who line: dot + agent name + what it is doing (prototype :146-148) ---- */
.ember-island__who {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--meta);
}
.ember-island__who b { color: var(--ink); font-weight: 600; }
.ember-island__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c, #fff);
  display: inline-block;
  flex: none;
}
/* state colours, from the captures: red working-blocked, green ready, cyan question,
   amber approval, pink error-adjacent. Kept as data attributes so the engine sets one. */
.ember-island__dot[data-state='working'] { --c: #F4505E; }
.ember-island__dot[data-state='ready']   { --c: #34D399; }
.ember-island__dot[data-state='question']{ --c: #22D3EE; }
.ember-island__dot[data-state='approval']{ --c: #F5A524; }
.ember-island__dot[data-state='idle']    { --c: #5F646D; }

.ember-island__big {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--ink);
  line-height: 1.3;
}
.ember-island__sub { color: var(--sub); line-height: 1.35; }
.ember-island__sub--red { color: var(--sub-red); }

/* ---- the command block on an approval (prototype :152) ---- */
.ember-island code {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 12px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .06);
  padding: 8px 10px;
  border-radius: 10px;
  color: #E8E9EC;
  align-self: flex-start;
  max-width: 100%;
  overflow-x: auto;
  white-space: pre;
}

/* ---- buttons (prototype :154-161) ---- */
.ember-island__row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.ember-island__btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  white-space: nowrap;
  padding: 7px 13px;
  background: rgba(255, 255, 255, .09);
  color: #F1F2F4;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  transition: background .15s, transform .15s;
}
.ember-island__btn:hover { background: rgba(255, 255, 255, .15); }
.ember-island__btn:active { transform: scale(.96); }
.ember-island__btn--primary { background: var(--ink); color: #0B0C0E; }
.ember-island__btn--primary:hover { background: #fff; }
.ember-island__btn kbd {
  font-family: inherit;
  font-size: var(--fs-micro);
  opacity: .55;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0 4px;
}
.ember-island__btn.is-pressed { transform: scale(.94); background: rgba(255, 255, 255, .22); }

/* ---- the step feed (prototype :162-171) ----
   A 96pt window, gradient-masked top and bottom, four 30pt lines that roll upward. */
.ember-island__ticker {
  position: absolute;
  left: 112px;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  height: 96px;
  overflow: hidden;
  -webkit-mask: linear-gradient(transparent, #000 22%, #000 78%, transparent);
  mask: linear-gradient(transparent, #000 22%, #000 78%, transparent);
}
.ember-island__ticker-in {
  position: absolute;
  left: 0;
  right: 0;
  top: 4px;
}
.ember-island__ticker-in.is-rolling {
  transition: transform .45s cubic-bezier(.3, .9, .3, 1);
  transform: translateY(-30px);
}
.ember-island__line {
  height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}
.ember-island__line span { overflow: hidden; text-overflow: ellipsis; }
.ember-island__line svg { width: 14px; height: 14px; flex: none; opacity: .8; }
.ember-island__line.is-current { color: var(--ink); font-size: 14px; font-weight: 500; }

/* the current line shimmers: a grey→white→grey sweep, 2.2s (prototype :170-171) */
.ember-island__line.is-current .ember-island__txt {
  background: linear-gradient(90deg, #7c818a 0%, #ffffff 40%, #7c818a 70%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: ember-island-shim 2.2s linear infinite;
}
@keyframes ember-island-shim {
  from { background-position: 120% 0; }
  to   { background-position: -100% 0; }
}

.ember-island__agentline {
  position: absolute;
  left: 112px;
  top: 14px;
  right: 12px;
}

/* ---- pills: 132x34, radius 17, two columns (prototype :176, SPEC §5) ---- */
.ember-island__pills {
  position: absolute;
  inset: 0 18px 0 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-content: center;
}
.ember-island__pill {
  position: relative;
  display: flex;
  align-items: center;
  height: 34px;
  border-radius: 17px;
  padding-left: 17px;
  gap: 8px;
  font-size: 12px;
  background: var(--bg, rgba(255, 255, 255, .06));
  border: 1px solid var(--bd, rgba(255, 255, 255, .10));
  overflow: hidden;
}
.ember-island__pill-lbl {
  color: var(--fg, var(--ink));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity .3s ease calc(.22s + var(--d, 0s));
}
.ember-island[data-mode='expanded'] .ember-island__pill-lbl { opacity: 1; }
.ember-island__pill-mini {
  width: 24px;
  height: 24px;
  flex: none;
  display: grid;
  place-items: center;
}

/* ---- the multi-session card (the right card in overview) ----
   Ranked rows from js/ember-sessions.js. A 196px card insets 8px top/bottom and shows
   four ROW_PITCH(40) rows, then a MORE_ROW(20) "+N more" line. These three numbers are the
   contract with OVERVIEW_HEIGHT / CARD_PADDING / ROW_PITCH / MORE_ROW in that module. */
.ember-island__sessions {
  position: absolute;
  inset: 8px 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ember-island__srow {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  flex: none;
  min-width: 0;
  font-size: 12px;
  color: var(--meta);
  border-bottom: 1px solid rgba(255, 255, 255, .045);
}
.ember-island__srow:last-child { border-bottom: 0; }
.ember-island__srow-agent {
  flex: none;
  max-width: 92px;
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ember-island__srow-provider {
  flex: none;
  max-width: 84px;
  color: var(--sub);
  opacity: .8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ember-island__srow-step {
  flex: 1;
  min-width: 0;
  text-align: right;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ember-island__smore {
  height: 20px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-micro);
  color: var(--muted);
}

/* ---- the character, per view (SPEC §5: x and diameter per view) ---- */
.ember-island__bot {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  transition:
    left .52s var(--spr),
    top .52s var(--spr),
    width .52s var(--spr),
    height .52s var(--spr);
}
.ember-island__bot canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Per-view character placement, SPEC §5 table (x, diameter).
   The vertical CENTRE is fixed by SPEC §5: 36 + (height - 46) / 2. So `top` is that centre
   minus half the diameter -- not a constant 36px, which pins the character to the top of the
   card and was visibly wrong in the first render.
     overview 70 @ 196 -> 36 + 150/2 = 111 ; top = 111 - 35 = 76
     empty    62 @ 150 -> 36 + 104/2 =  88 ; top =  88 - 31 = 57
     approval 56 @ 206 -> 36 + 160/2 = 116 ; top = 116 - 28 = 88
     question 56 @ 196 -> 36 + 150/2 = 111 ; top = 111 - 28 = 83
     error    58 @ 190 -> 36 + 144/2 = 108 ; top = 108 - 29 = 79
     finished 58 @ 170 -> 36 + 124/2 =  98 ; top =  98 - 29 = 69   */
.ember-island__view[data-view='overview']  .ember-island__bot { left: 64px; top: 76px; width: 70px; height: 70px; }
.ember-island__view[data-view='empty']     .ember-island__bot { left: 70px; top: 57px; width: 62px; height: 62px; }
.ember-island__view[data-view='approval']  .ember-island__bot { left: 62px; top: 88px; width: 56px; height: 56px; }
.ember-island__view[data-view='question']  .ember-island__bot { left: 62px; top: 83px; width: 56px; height: 56px; }
.ember-island__view[data-view='error']     .ember-island__bot { left: 62px; top: 79px; width: 58px; height: 58px; }
.ember-island__view[data-view='finished']  .ember-island__bot { left: 62px; top: 69px; width: 58px; height: 58px; }

/* ---- view heights, SPEC §5 ---- */
.ember-island__view[data-view='overview'] { height: 196px; }
.ember-island__view[data-view='empty']    { height: 150px; }
.ember-island__view[data-view='approval'] { height: 206px; }
.ember-island__view[data-view='question'] { height: 196px; }
.ember-island__view[data-view='error']    { height: 190px; }
.ember-island__view[data-view='finished'] { height: 170px; }
.ember-island__view[data-view='chat']     { height: 320px; }

/* ---- chat view (PORTED from upstream PromptView/ChatBubble/TypingDotsView and the
   prototype .prompt/.ibtn at design/prototype/notch-buddy.html:178-183) ---- */

/* the the ported character sits bottom-left of the message card (capture) */
.ember-island__view[data-view='chat'] .ember-island__bot { left: 12px; top: 250px; width: 56px; height: 56px; }

.ember-island__chat {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 12px 14px;
}

/* agent pill: green dot + name (the "Claude" capsule in the capture) */
.ember-island__chatpill {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  font-size: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 999px;
  padding: 3px 10px 3px 8px;
}
.ember-island__chatpill b { font-weight: 600; }
/* The id that actually answered, not a model name guessed by the UI. It is real content, so
   it sits at the type ramp's floor (--fs-micro = 12px) and de-emphasises with opacity only. */
.ember-island__chatpill .ember-island__model { opacity: .55; font-size: var(--fs-micro); }

/* message list */
.ember-island__msgs {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}
.ember-island__msg { display: flex; }
.ember-island__msg--user { justify-content: flex-end; }
.ember-island__msg--assistant { justify-content: flex-start; }

/* user bubble: right, bg 13% white, radius 12 (ChatBubble .user, :1813-1818) */
.ember-island__msg--user .ember-island__bubble {
  max-width: 78%;
  background: rgba(255, 255, 255, .13);
  border-radius: 12px;
  padding: 6px 10px;
  color: #F1F2F4;
  font-size: 12.5px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

/* assistant bubble: left, bg 5% white, radius 8 (ChatBubble .assistant, :1848-1850) */
.ember-island__msg--assistant .ember-island__bubble {
  max-width: 82%;
  background: rgba(255, 255, 255, .05);
  border-radius: 8px;
  padding: 6px 8px;
  color: #B0B5BE;
  font-size: 12.5px;
  line-height: 1.45;
  word-break: break-word;
}

/* assistant markdown subset, coloured from ChatMarkdownView (:24-77) */
.ember-island__msg--assistant .ember-island__bubble strong { color: #F1F2F4; font-weight: 600; }
.ember-island__msg--assistant .ember-island__bubble em { font-style: italic; }
.ember-island__msg--assistant .ember-island__bubble code {
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: var(--fs-micro);
  background: rgba(255, 255, 255, .09);
  border-radius: 4px;
  padding: 1px 4px;
}
.ember-island__msg--assistant .ember-island__bubble a { color: #67B0FF; text-decoration: underline; }

/* tool action/result row: status dot + label + status word + short result, Retry on failure.
   Colour is a second signal only — the status is a visible word, so it survives greyscale. */
.ember-island__tool {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0 5px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  font-size: var(--fs-micro);
}
.ember-island__bubble > .ember-island__tool:last-of-type { margin-bottom: 6px; }
.ember-island__tool-dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: #34D399; }
.ember-island__tool-dot[data-status='running'] { background: #22D3EE; }
.ember-island__tool-dot[data-status='failed']  { background: #F4505E; }
.ember-island__tool-dot[data-status='denied']  { background: #5F646D; }
.ember-island__tool-label { color: #D7DAE0; font-weight: 600; }
.ember-island__tool-status { color: #6B7079; }
.ember-island__tool[data-status='failed'] .ember-island__tool-status { color: #F4505E; }
.ember-island__tool-sum { color: #9398A1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ember-island__tool-retry {
  margin-left: auto;
  background: none; border: 0; padding: 0 2px;
  color: #67B0FF; font: inherit; cursor: pointer; text-decoration: underline;
}

/* per-turn attribution: which model answered, and the request id it answered under.
   A compact, selectable line at the type-ramp floor (--fs-micro, 12px); the label is a real
   word, so this survives greyscale and a screen reader, and the id is monospace so it reads as
   an identifier. Only the request value truncates (it can be up to 200 chars); the full value
   stays in the DOM and in the title for a hover. */
.ember-island__msg-meta {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px;
  margin-top: 4px; padding-top: 3px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  font-size: var(--fs-micro); line-height: 1.3; color: #6B7079;
  font-variant-numeric: tabular-nums;
}
.ember-island__attr { display: inline-flex; align-items: baseline; gap: 4px; min-width: 0; }
.ember-island__attr-k { color: #5F646D; }
.ember-island__attr-v { color: #9398A1; font-family: 'SF Mono', ui-monospace, Menlo, monospace; }
.ember-island__attr--req .ember-island__attr-v {
  max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ember-island__attr-sep { color: #4A4E56; align-self: center; }

/* three-dot typing indicator (TypingDotsView, :1858: 5px dots, #6B7079, .45s, delay i*.14) */
.ember-island__typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, .05);
  border-radius: 8px;
  padding: 6px 8px;
}
.ember-island__typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6B7079;
  transform: scale(.6);
  animation: ember-island-dot .45s ease-in-out infinite;
}
.ember-island__typing i:nth-child(2) { animation-delay: .14s; }
.ember-island__typing i:nth-child(3) { animation-delay: .28s; }
@keyframes ember-island-dot {
  0%, 100% { transform: scale(.6); opacity: .7; }
  50%      { transform: scale(1.2); opacity: 1; }
}

/* input row (prototype .prompt, :178-180) */
.ember-island__prompt {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  /* clear the the ported character at the bottom-left so the input starts beside it (capture) */
  margin-left: 62px;
  background: rgba(255, 255, 255, .06);
  border-radius: 14px;
  padding: 6px 6px 6px 12px;
}
.ember-island__prompt-input {
  flex: 1;
  min-width: 0;
  max-height: 96px;
  background: transparent;
  border: 0;
  resize: none;
  color: #F5F6F8;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.4;
}
.ember-island__prompt-input::placeholder { color: #6E737C; }

/* circular icon button (prototype .ibtn / .ibtn.send, :181-183) */
.ember-island__ibtn {
  appearance: none;
  border: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  background: rgba(255, 255, 255, .08);
  color: #C9CCD2;
  cursor: pointer;
}
.ember-island__ibtn--send { background: #F5F6F8; color: #0B0C0E; }
/* While a reply is in flight the send is inert; it must LOOK inert instead of swallowing the
   press, and it must stay legible for a reader who needs the contrast. */
.ember-island__ibtn--send[disabled] { opacity: .45; cursor: progress; }
.ember-island__ibtn svg { width: 14px; height: 14px; }
.ember-island__ibtn:focus-visible { outline: 2px solid #2F6BFF; outline-offset: 2px; }

/* the island grows to fit whichever view is showing */
.ember-island[data-mode='expanded'] { height: var(--ember-island-h, 246px); }

/* ---- reduced motion: keep every state legible, drop the movement (prototype :226-228) ---- */
@media (prefers-reduced-motion: reduce) {
  .ember-island,
  .ember-island__bot,
  .ember-island__view,
  .ember-island__view.is-on,
  .ember-island__pill-lbl {
    transition-duration: .01s !important;
    transition-delay: 0s !important;
  }
  .ember-island__line.is-current .ember-island__txt {
    animation: none;
    background: none;
    -webkit-text-fill-color: var(--ink);
    color: var(--ink);
  }
  .ember-island__ticker-in.is-rolling { transition: none; }
  .ember-island__typing i { animation: none; opacity: .8; transform: scale(.9); }
}

/* ---- forced colours: the veil and shimmer are decoration, the controls are not ---- */
@media (forced-colors: active) {
  .ember-island__card--wash::before { display: none; }
  .ember-island__line.is-current .ember-island__txt {
    animation: none;
    background: none;
    color: CanvasText;
    -webkit-text-fill-color: CanvasText;
  }
  .ember-island__btn { border: 1px solid ButtonBorder; }
}

/* ---- focus: never removed, always visible ---- */
.ember-island__btn:focus-visible,
.ember-island__tab:focus-visible,
.ember-island__prompt-input:focus-visible {
  outline: 2px solid #2F6BFF;
  outline-offset: 2px;
}

/* ---- the host in index.html ----
   The island is a DOCKED companion, not a notch overlay: it sits bottom-right above the
   existing compact character and is hidden until opened. When hidden it must not capture
   clicks or show an empty black box over the page. */
.ember-island-host {
  position: fixed;
  right: 24px;
  bottom: 88px;
  z-index: 60;
  width: 640px;
  max-width: calc(100vw - 32px);
  display: none;
}
.ember-island-host[data-open='true'] { display: block; }
@media (max-width: 720px) {
  .ember-island-host { right: 8px; left: 8px; bottom: 76px; width: auto; }
  .ember-island[data-mode='expanded'] { width: 100%; }
}

}

/* ===========================================================================================
   Ember mail — the Mail surface, PORTED from upstream.
   PROVENANCE-START
   Louis-CFM/coucou, MIT. Every size, colour and indent below is lifted from
   MailViews.swift (MailCardView:50-168, MailRow:172-219, MailFilterChip:222-242,
   MailDetailView:269-398) with mailAccent #2F8CFF (MailViews.swift:8) and the open height
   MailLayout.readingHeight = 280 (IslandWindowController.swift:2238).
   PROVENANCE-END
   Everything is scoped under [data-ember-mail] so it cannot collide with the island
   selectors above: a mail card and an island can coexist on the same page.
   Left gutter 108 / right 12 are MailViews' own padding (the mascot sits in the gutter).
   =========================================================================================== */
[data-ember-mail] {
  --ember-mail-accent: #2F8CFF;
  --ember-mail-ink: #E8E9EC;
  --ember-mail-read-ink: #9398A1;
  --ember-mail-muted: #6B7079;
  --ember-mail-subject-read: #4D5159;
  --ember-mail-subject-unread: #8E939C;
  --ember-mail-flag: #F5A524;
  --ember-mail-panel: #1b2130;
  --ember-mail-hairline: #2b3343;
  --ember-mail-gutter: 108px;
  --ember-mail-reading: 280px;
  color: var(--ember-mail-ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-ember-mail] .ember-mail {
  box-sizing: border-box;
  width: 480px;
  max-width: 100%;
  padding-top: 4px;              /* MailCardView:167 */
  background: var(--ember-mail-panel);
  border-radius: 12px;
  overflow: hidden;
}
[data-ember-mail] .ember-mail[data-open-detail] { min-height: var(--ember-mail-reading); }

/* ---- header: dot(7) + Mail(12/600) + Inbox(11) + unread pill + search ---- */
[data-ember-mail] .ember-mail__hdr {
  display: flex;
  align-items: center;
  gap: 6px;                      /* MailViews:52 */
  padding: 6px 36px 0 var(--ember-mail-gutter);  /* top 6, trailing 36, leading 108 */
}
[data-ember-mail] .ember-mail__dot {
  width: 7px; height: 7px;       /* MailViews:55 */
  border-radius: 50%;
  background: var(--ember-mail-accent);
  flex: none;
}
[data-ember-mail] .ember-mail__title { font-size: 12px; font-weight: 600; color: #F5F6F8; }
[data-ember-mail] .ember-mail__inbox { font-size: var(--fs-micro); color: var(--ember-mail-subject-unread); }
[data-ember-mail] .ember-mail__unread {
  margin-left: auto;
  font-size: var(--fs-micro); font-weight: 600; color: var(--ember-mail-accent);
  padding: 1px 6px;              /* MailViews:90 */
  border-radius: 999px;
  background: color-mix(in srgb, var(--ember-mail-accent) 14%, transparent);
  font-variant-numeric: tabular-nums;
}
[data-ember-mail] .ember-mail__search-btn,
[data-ember-mail] .ember-mail__icon,
[data-ember-mail] .ember-mail__back {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--ember-mail-muted); cursor: pointer; padding: 0;
}
[data-ember-mail] .ember-mail__search-btn { width: 18px; height: 16px; flex: none; }
[data-ember-mail] .ember-mail__search-btn svg { width: 12px; height: 12px; }
[data-ember-mail] .ember-mail__search-btn:hover { color: var(--ember-mail-ink); }

/* ---- quick filters: All / Unread / Flagged / Today (one line, scrolls sideways) ---- */
[data-ember-mail] .ember-mail__filters {
  display: flex; gap: 3px;       /* MailViews:118 */
  padding: 4px 12px 0 var(--ember-mail-gutter);
  overflow-x: auto; scrollbar-width: none;
}
[data-ember-mail] .ember-mail__filters::-webkit-scrollbar { display: none; }
[data-ember-mail] .ember-mail__chip {
  font-size: var(--fs-micro); line-height: 1.4;  /* MailViews:231 */
  padding: 2px 6px;
  border-radius: 999px;
  border: 0; cursor: pointer; white-space: nowrap;
  background: transparent; color: var(--ember-mail-muted);
}
[data-ember-mail] .ember-mail__chip:hover { color: #B0B5BE; background: rgba(255,255,255,.06); }
[data-ember-mail] .ember-mail__chip.is-on {
  color: #E8E9EC; font-weight: 600;
  background: color-mix(in srgb, var(--ember-mail-accent) 22%, transparent);
}

/* ---- the message rows: sender(82 max) / flag / age / subject, three in view ---- */
[data-ember-mail] .ember-mail__list {
  display: flex; flex-direction: column; gap: 3px;  /* MailViews:141 */
  padding: 5px 12px 8px var(--ember-mail-gutter);
  max-height: 240px; overflow-y: auto;
}
[data-ember-mail] .ember-mail__row {
  display: flex; align-items: center; gap: 5px;     /* MailViews:180 */
  width: 100%; padding: 3px 8px;                    /* MailViews:206 */
  border: 0; border-radius: 5px;                    /* MailViews:209 */
  background: transparent; color: inherit; font: inherit;
  text-align: left; cursor: pointer;
}
[data-ember-mail] .ember-mail__row.is-unread {
  background: color-mix(in srgb, var(--ember-mail-accent) 8%, transparent);  /* MailViews:212 */
}
[data-ember-mail] .ember-mail__row.is-unread:hover {
  background: color-mix(in srgb, var(--ember-mail-accent) 14%, transparent);
}
[data-ember-mail] .ember-mail__row.is-read:hover { background: rgba(255,255,255,.05); }
[data-ember-mail] .ember-mail__rowdot {
  width: 5px; height: 5px; border-radius: 50%; flex: none;   /* MailViews:184 */
  background: var(--ember-mail-accent);
}
[data-ember-mail] .ember-mail__row.is-read .ember-mail__rowdot {
  background: transparent; box-shadow: inset 0 0 0 1px #4D5159;
}
[data-ember-mail] .ember-mail__sender {
  font-size: var(--fs-micro); color: var(--ember-mail-read-ink);
  max-width: 82px; flex: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
[data-ember-mail] .ember-mail__row.is-unread .ember-mail__sender { color: var(--ember-mail-ink); font-weight: 600; }
[data-ember-mail] .ember-mail__flag { color: var(--ember-mail-flag); flex: none; display: inline-flex; }
[data-ember-mail] .ember-mail__flag svg { width: 8px; height: 8px; }
[data-ember-mail] .ember-mail__time {
  font-size: var(--fs-micro); color: var(--ember-mail-muted); flex: none; font-variant-numeric: tabular-nums;
}
[data-ember-mail] .ember-mail__subject {
  font-size: var(--fs-micro); color: var(--ember-mail-subject-read);
  flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
[data-ember-mail] .ember-mail__row.is-unread .ember-mail__subject { color: var(--ember-mail-subject-unread); }
[data-ember-mail] .ember-mail__empty {
  font-size: var(--fs-micro); color: var(--ember-mail-muted);
  padding: 8px 12px 12px var(--ember-mail-gutter);
}

/* ---- the open message: back / sender / age, subject, text, actions ---- */
[data-ember-mail] .ember-mail__detail {
  display: flex; flex-direction: column; gap: 5px;   /* MailViews:276 */
  padding: 4px 12px 0 var(--ember-mail-gutter);
  min-height: var(--ember-mail-reading);
}
[data-ember-mail] .ember-mail__dhdr {
  display: flex; align-items: center; gap: 6px;
  padding-right: 24px;                              /* clear the card's top-right button */
}
[data-ember-mail] .ember-mail__back { width: 20px; height: 20px; flex: none; }
[data-ember-mail] .ember-mail__back svg { width: 11px; height: 11px; }
[data-ember-mail] .ember-mail__detail .ember-mail__dot { width: 6px; height: 6px; }
[data-ember-mail] .ember-mail__detail .ember-mail__dot[data-read='1'] { background: #4D5159; }
[data-ember-mail] .ember-mail__dsender {
  font-size: var(--fs-micro); font-weight: 600; color: #F5F6F8;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
[data-ember-mail] .ember-mail__dtime { margin-left: auto; font-size: var(--fs-micro); color: var(--ember-mail-muted); flex: none; }
[data-ember-mail] .ember-mail__dbody {
  display: flex; flex-direction: column; gap: 5px;
  flex: 1 1 auto; overflow-y: auto; max-height: 180px;
}
[data-ember-mail] .ember-mail__dsubject {
  font-size: var(--fs-micro); font-weight: 500; color: #C5C8CD; white-space: pre-wrap;
}
[data-ember-mail] .ember-mail__dtext {
  font-size: var(--fs-micro); color: var(--ember-mail-read-ink);
  line-height: 1.6;                                 /* lineSpacing 2 on 10.5 */
  white-space: pre-wrap;
}
[data-ember-mail] .ember-mail__actions {
  display: flex; align-items: center; gap: 4px; padding-bottom: 8px;
}
[data-ember-mail] .ember-mail__open {
  font-size: var(--fs-micro); font-weight: 600; color: var(--ember-mail-accent);
  padding: 3px 8px; border: 0; border-radius: 999px; cursor: pointer;
  background: color-mix(in srgb, var(--ember-mail-accent) 16%, transparent);
}
[data-ember-mail] .ember-mail__spacer { flex: 1 1 auto; }
[data-ember-mail] .ember-mail__icon { width: 24px; height: 20px; border-radius: 5px; }
[data-ember-mail] .ember-mail__icon:hover { background: rgba(255,255,255,.08); }
[data-ember-mail] .ember-mail__icon svg { width: 13px; height: 13px; }
[data-ember-mail] .ember-mail__icon--flag { color: var(--ember-mail-flag); }
[data-ember-mail] .ember-mail__icon--junk:hover { color: #FF6B6B; }

/* ---- the "More" menu: Make VIP / Ignore sender ---- */
[data-ember-mail] .ember-mail__more { position: relative; display: inline-flex; }
[data-ember-mail] .ember-mail__menu {
  position: absolute; right: 0; bottom: 24px; z-index: 5;
  display: none; flex-direction: column; min-width: 130px; padding: 4px;
  background: #232a3a; border: 1px solid var(--ember-mail-hairline);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
[data-ember-mail] .ember-mail__more.is-open .ember-mail__menu { display: flex; }
[data-ember-mail] .ember-mail__menu button {
  text-align: left; font-size: var(--fs-micro); color: var(--ember-mail-ink);
  padding: 5px 8px; border: 0; border-radius: 5px; background: none; cursor: pointer;
}
[data-ember-mail] .ember-mail__menu button:hover { background: rgba(255,255,255,.08); }

[data-ember-mail] :focus-visible { outline: 2px solid #2F6BFF; outline-offset: 2px; }
