/* 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 a neutral panel that sits well over any app. */

/* 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; }
[data-second-draft-note] { cursor: pointer; }
[data-second-draft-note] .sd-mark { display: block; 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;
}

.sd-note {
  --sd-ink: #1c1b1a;
  --sd-quiet: #5f5b57;
  --sd-card: #ffffff;
  --sd-line: #d9d5d0;
  --sd-field: #f6f5f3;
  --sd-act: #1c1b1a;
  --sd-on-act: #ffffff;
  --sd-focus: #2463d6;
  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: 18px;
  background: var(--sd-card);
  color: var(--sd-ink);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  overflow: auto;
  text-align: left;
}
@media (prefers-color-scheme: dark) {
  .sd-note {
    --sd-ink: #f2f0ed;
    --sd-quiet: #b3aea8;
    --sd-card: #242322;
    --sd-line: #45423f;
    --sd-field: #1b1a19;
    --sd-act: #f2f0ed;
    --sd-on-act: #1c1b1a;
    --sd-focus: #8db4ff;
    color-scheme: dark;
  }
}
.sd-note::backdrop { background: rgba(0, 0, 0, 0.42); }
.sd-note *, .sd-note *::before, .sd-note *::after { box-sizing: border-box; }
.sd-note-card { padding: 16px 18px 12px; display: grid; gap: 12px; }
.sd-note-head { display: flex; align-items: center; gap: 10px; }
.sd-note-head h2 { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 650; }
.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: 12px;
  font: 400 28px/1 system-ui, sans-serif; cursor: pointer;
}
.sd-note-form { display: grid; gap: 10px; margin: 0; }
.sd-note-kinds { display: flex; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.sd-note-kind {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 10px; border: 1px solid var(--sd-line); border-radius: 12px;
  font-size: 0.95rem; 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-act); box-shadow: inset 0 0 0 1px var(--sd-act); font-weight: 600; }
.sd-note-kind:has(input:focus-visible) { outline: 2px solid var(--sd-focus); outline-offset: 2px; }
.sd-note-label { font-weight: 600; font-size: 0.95rem; }
.sd-note textarea {
  width: 100%; min-height: 96px; resize: vertical; padding: 10px 12px;
  border: 1px solid var(--sd-line); border-radius: 12px; background: var(--sd-field); color: var(--sd-ink);
  font: inherit;
}
.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: 600; }
.sd-note-send {
  appearance: none; border: 0; border-radius: 12px; min-height: 44px; padding: 10px 18px;
  background: var(--sd-act); color: var(--sd-on-act); font: 600 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. */
.sd-note-choices { display: grid; gap: 8px; }
.sd-note-choices .sd-note-send { justify-self: stretch; }
.sd-note-others { display: flex; gap: 8px; }
.sd-note-other {
  appearance: none; flex: 1; display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 12px; border: 1px solid var(--sd-line); border-radius: 12px;
  background: transparent; color: var(--sd-ink); text-decoration: none; text-align: center;
  font: 500 0.95rem/1.2 system-ui, sans-serif; cursor: pointer;
}
.sd-note-other:hover { border-color: var(--sd-quiet); }
.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: 12px; background: var(--sd-field); font-size: 0.95rem;
}
.sd-note-waiting a { color: inherit; font-weight: 600; 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-ink);
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; border-radius: 10px;
  font: 500 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, .sd-note textarea: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;
}
