/* The note trigger's visibility and the web panel it opens. The platform's
   file, not the app's: keep it as it is. The trigger's own look is the app's,
   in styles.css; this file only hides it from anyone who may not leave a note,
   and draws the panel. The panel is neutral — white and near-black, or dark
   grey and white — so it sits in any app the way a chat does; Second Draft's
   plum and pink, and its house shape (the corner opened top-right), are only
   in its mark and in the one filled button that does the thing. Every other
   button is neutral. */

/* The phone's corner. A shell that knows the page declares its own trigger
   draws no button in the bottom-right corner, so the space every app keeps
   for it closes up: --shell-slot is 0. Only inside an older shell, which still
   draws its button whatever the page says, does second-draft-note.js mark the
   corner kept and the space come back. A browser never had a button there. */
:root:has(meta[name="second-draft-note-trigger"][content="app"]) { --shell-slot: 0px; }
html[data-second-draft-corner="kept"] {
  --shell-slot: calc(var(--shell-switcher-inset, 16px) + var(--shell-switcher-size, 48px) + var(--shell-switcher-gap, 16px)) !important;
}

/* Hidden until second-draft-note.js has asked who is here and been told yes. */
html:not([data-second-draft-notes="on"]) [data-second-draft-note] { display: none !important; }
/* A form that asks the agent shows only when the agent answers whoever is here. The Ask button the module puts
   beside the trigger shows then, and also while the conversation is theirs to turn on or will be here once this
   copy is live ("offer"): it is how they find it. */
html:not([data-second-draft-agent="on"]) [data-second-draft-ask]:not([data-second-draft-ask-auto]) { display: none !important; }
html:not([data-second-draft-agent="on"]):not([data-second-draft-agent="offer"]) [data-second-draft-ask-auto] { display: none !important; }
/* An app's way to its pinned charts shows only when there are some. */
html:not([data-second-draft-pins="some"]) [data-second-draft-pinned-link] { display: none !important; }
[data-second-draft-note] { cursor: pointer; }
/* The Ask button second-draft-note.js puts beside a trigger: the trigger's own look, with the spark in place of the mark. */
[data-second-draft-ask-auto] { cursor: pointer; }
[data-second-draft-ask-auto] .sd-spark { display: block; flex: none; }
[data-second-draft-ask-auto] .sd-mark-box { position: relative; display: inline-flex; flex: none; }
/* Second Draft's menu in a browser: the platform's few things, one under another. */
.sd-note-menu { display: grid; gap: 8px; }
.sd-note-menu[hidden] { display: none; }
.sd-note-form[hidden], .sd-note-more[hidden] { display: none; }
.sd-note-menu .sd-note-other { justify-content: flex-start; gap: 12px; min-height: 48px; padding-inline: 14px; }
.sd-note-menu .sd-note-icon { flex: none; color: var(--sd-quiet); }
.sd-note-menu .sd-note-other[hidden] { display: none; }
[data-second-draft-note] .sd-mark { display: block; flex: none; }
[data-second-draft-note] .sd-mark-box { position: relative; display: inline-flex; flex: none; }

/* Something waits for the person in the workspace: a small dot over the
   trigger's top-right corner, inside its box, so the trigger keeps its size
   and the mark stays whole. :where() leaves the app's own position standing,
   should it have one. The colour is the app's to set, if red clashes. */
:where([data-second-draft-note][data-second-draft-waiting]) { position: relative; }
[data-second-draft-note] .sd-waiting {
  position: absolute; top: 5px; right: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--second-draft-waiting, #d7401d);
  box-shadow: 0 0 0 2px var(--second-draft-waiting-ring, #fff);
  pointer-events: none;
}
/* On the mark itself when the module drew it: its top-right corner, just outside. */
[data-second-draft-note] .sd-mark-box > .sd-waiting { top: -3px; right: -6px; }

.sd-note {
  /* Neutral: the panel, its words, its lines, the bubbles and cards in it. */
  --sd-ink: #1c1c1e;
  --sd-quiet: #5f6368;
  --sd-card: #ffffff;
  --sd-line: #e5e5ea;
  --sd-line-strong: #c7c7cc;
  --sd-field: #ffffff;
  --sd-wash: #f2f2f7;
  /* Second Draft's own, for its mark and the filled button only. */
  --sd-plum: #4a2138;
  --sd-brand-wash: #fbeef2;
  --sd-act: #4a2138;
  --sd-on-act: #fff5f7;
  --sd-focus: #1c1c1e;
  /* Plain rounded corners for the panel and what is in it; the house shape, its corner opened, for buttons. */
  --sd-house-card: 16px;
  --sd-house-control: 3px 18px 3px 3px;
  --sd-house-field: 12px;
  color-scheme: light;
  box-sizing: border-box;
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--sd-house-card);
  background: var(--sd-card);
  color: var(--sd-ink);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  box-shadow: 0 0 0 1px var(--sd-line), 0 18px 48px rgba(42, 30, 37, 0.3);
  overflow: auto;
  text-align: left;
}
@media (prefers-color-scheme: dark) {
  .sd-note {
    --sd-ink: #f2f2f7;
    --sd-quiet: #a1a1aa;
    --sd-card: #1c1c1e;
    --sd-line: #2c2c2e;
    --sd-line-strong: #48484a;
    --sd-field: #242426;
    --sd-wash: #2c2c2e;
    --sd-plum: #edb9cf;
    --sd-brand-wash: #3d2c36;
    --sd-act: #f7d6de;
    --sd-on-act: #4a2138;
    --sd-focus: #f2f2f7;
    color-scheme: dark;
  }
}
/* Inside the Second Draft phone app the page is drawn behind the phone's own bars, and says where they are
   in --shell-safe-* (in a browser, env() does): the panel keeps clear of whichever is the larger. With only
   env(), the panel's top bar sat under the clock inside the phone app, and its × could not be pressed
   (23 November). */
/* On a phone the panel sits at the top: centred, the keyboard came up over the
   words box and the buttons, since an app's page does not shrink for it. */
@media (max-width: 600px) {
  .sd-note { width: calc(100vw - 16px); max-width: none; margin: calc(12px + max(var(--shell-safe-top, 0px), env(safe-area-inset-top, 0px))) auto auto; max-height: calc(100dvh - 24px - max(var(--shell-safe-top, 0px), env(safe-area-inset-top, 0px)) - max(var(--shell-safe-bottom, 0px), env(safe-area-inset-bottom, 0px))); }
  .sd-note > .sd-note-card { padding-inline: 16px; }
}
.sd-note::backdrop { background: rgba(42, 30, 37, 0.45); }
.sd-note *, .sd-note *::before, .sd-note *::after { box-sizing: border-box; }
.sd-note-card { padding: 16px 18px 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.sd-note-head { display: flex; align-items: center; gap: 10px; color: var(--sd-plum); }
.sd-note-head h2 { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--sd-ink); }
.sd-note-close {
  appearance: none; border: 0; background: transparent; color: var(--sd-ink);
  min-width: 44px; min-height: 44px; margin: -8px -10px -8px 0; border-radius: var(--sd-house-control);
  font: 400 28px/1 system-ui, sans-serif; cursor: pointer;
}
.sd-note-form { display: grid; gap: 10px; margin: 0; }
/* Like the buttons below: one line each and the same height, two rows sooner than a taller button. */
.sd-note-kinds { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.sd-note-kind {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 8px; border: 1.5px solid var(--sd-line-strong); border-radius: var(--sd-house-control);
  white-space: nowrap; color: var(--sd-quiet); font-size: 0.9rem; font-weight: 600; cursor: pointer; text-align: center;
}
.sd-note-kind input { position: absolute; opacity: 0; pointer-events: none; }
.sd-note-kind:has(input:checked) { border-color: var(--sd-ink); background: var(--sd-wash); color: var(--sd-ink); font-weight: 700; }
.sd-note-kind:has(input:focus-visible) { outline: 2px solid var(--sd-focus); outline-offset: 2px; }
.sd-note-label { font-weight: 700; font-size: 0.95rem; }
.sd-note textarea {
  width: 100%; min-height: 96px; resize: vertical; padding: 10px 12px;
  border: 1.5px solid var(--sd-line-strong); border-radius: var(--sd-house-field); background: var(--sd-field); color: var(--sd-ink);
  font: inherit;
}
.sd-note textarea:focus { border-color: var(--sd-ink); outline: none; }
.sd-note-about { margin: 0; color: var(--sd-quiet); font-size: 0.85rem; overflow-wrap: anywhere; }
.sd-note-status { margin: 0; font-size: 0.95rem; }
.sd-note-status:empty { display: none; }
.sd-note-status a { color: inherit; font-weight: 700; }
.sd-note-send {
  appearance: none; border: 0; border-radius: var(--sd-house-control); min-height: 46px; padding: 10px 18px;
  background: var(--sd-act); color: var(--sd-on-act); font: 700 1rem/1 system-ui, sans-serif; cursor: pointer;
  justify-self: end;
}
.sd-note-send:disabled, .sd-note-other:disabled { opacity: 0.6; cursor: progress; }
.sd-note-send[hidden], .sd-note-choices[hidden], .sd-note-waiting[hidden] { display: none; }

/* A change: one thing to reach for, and two quieter ones beside it, in one row. */
.sd-note-choices { display: grid; gap: 8px; }
/* Each as wide as its words, the room left shared out; on the narrowest screens the row wraps rather than spill. */
.sd-note-row { display: flex; flex-wrap: wrap; gap: 8px; }
.sd-note-row > .sd-note-send, .sd-note-row > .sd-note-other { flex: 1 1 auto; min-height: 46px; padding-inline: 8px; white-space: nowrap; font-size: 0.9rem; }
.sd-note-other {
  appearance: none; display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 10px; border: 1.5px solid var(--sd-line-strong); border-radius: var(--sd-house-control);
  background: transparent; color: var(--sd-ink); text-decoration: none; text-align: center;
  font: 600 0.95rem/1.2 system-ui, sans-serif; cursor: pointer;
}
.sd-note-other:hover { background: var(--sd-wash); }
.sd-note-hint { margin: 0; color: var(--sd-quiet); font-size: 0.85rem; }

/* What waits for the person in the workspace, at the top of the panel. */
.sd-note-waiting {
  display: flex; align-items: center; gap: 8px; margin: 0;
  padding: 10px 12px; border-radius: var(--sd-house-field); background: var(--sd-wash); font-size: 0.95rem;
}
.sd-note-waiting a { color: inherit; font-weight: 700; text-underline-offset: 3px; }
.sd-note-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--second-draft-waiting, #d7401d); }
.sd-note-more { display: flex; gap: 8px; border-top: 1px solid var(--sd-line); padding-top: 8px; }
.sd-note-link {
  appearance: none; border: 0; background: transparent; color: var(--sd-quiet);
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; border-radius: var(--sd-house-control);
  font: 600 0.95rem/1 system-ui, sans-serif; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.sd-note-link:first-child { margin-left: -10px; }
.sd-note button:focus-visible, .sd-note a:focus-visible { outline: 2px solid var(--sd-focus); outline-offset: 2px; }
.sd-note-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
