/* Document tools share the application's neutral surfaces and vivid action colour. */
.protocol-chat-page {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 150px);
  min-height: 520px;
  gap: 18px;
}
.protocol-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-height: 36px;
}
.protocol-allowance {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 14px;
  margin-right: 12px;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--action) 22%, var(--line));
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition:
    border-color 200ms ease,
    box-shadow 200ms ease;
}
.protocol-allowance:hover {
  border-color: color-mix(in srgb, var(--action) 60%, var(--line));
  box-shadow: 0 4px 22px #5555e515;
}
.protocol-allowance:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 3px;
}
.protocol-plus-mark {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(140deg, #087ef5, #7046e8);
  color: white;
}
.protocol-plus-mark svg {
  width: 22px;
  height: 22px;
}
.protocol-allowance-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.protocol-allowance-copy strong {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
.protocol-allowance-copy small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.protocol-plus-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 9px;
  margin-left: auto;
  padding: 11px 16px;
  border-radius: 999px;
  background: linear-gradient(110deg, #0868e8, #6841dc);
  color: white;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.protocol-plus-cta svg {
  width: 16px;
  height: 16px;
}
.protocol-inspiration {
  padding: 14px 20px 0;
}
.protocol-inspiration > span {
  display: flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
}
.protocol-inspiration > span svg {
  width: 14px;
  height: 14px;
}
.protocol-inspiration > span small {
  font-size: 10px;
  font-weight: 400;
  margin-left: auto;
}
.protocol-reference-fields {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}
.protocol-reference {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  transition: border-color 180ms ease;
}
.protocol-reference > svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
  flex-shrink: 0;
}
.protocol-reference input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 5px 0;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
  outline: 0 !important;
  font: inherit;
  font-size: 13px;
  color: var(--text);
}
.protocol-reference:focus-within {
  border-color: var(--action);
}
.protocol-reference.has-value > svg,
.protocol-reference.has-value input {
  color: var(--action);
}
.protocol-reference-options {
  position: absolute;
  z-index: 120;
  bottom: calc(100% + 8px);
  left: -10px;
  width: max(100%, 260px);
  max-width: calc(100vw - 52px);
  max-height: min(280px, 40dvh);
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 12px 40px #00000024;
}
.protocol-reference-options[hidden] {
  display: none;
}
.protocol-reference-options button {
  display: block;
  text-align: left;
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
}
.protocol-reference-options button:first-child {
  color: var(--muted);
  font-size: 12px;
}
.protocol-reference-options button:hover,
.protocol-reference-options button[aria-selected='true'] {
  background: var(--surface-alt);
  color: var(--action);
}
.protocol-reference-options p {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}
.protocol-history {
  position: relative;
}
.protocol-history > summary {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}
.protocol-history > summary::-webkit-details-marker {
  display: none;
}
.protocol-history > summary svg {
  width: 19px;
  height: 19px;
}
.protocol-history > summary:hover,
.protocol-history[open] > summary {
  color: var(--action);
  background: var(--surface);
}
.protocol-history-panel {
  position: absolute;
  z-index: 130;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-width: calc(100vw - 48px);
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 8px;
  background: var(--surface);
  box-shadow: 0 12px 40px #00000020;
}
.protocol-history-panel > strong {
  display: block;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
}
.protocol-history-panel button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 10px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  text-align: left;
  font-size: 13px;
}
.protocol-history-panel button svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--muted);
}
.protocol-history-panel button span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.protocol-history-panel button:hover,
.protocol-history-panel button[aria-current='true'] {
  background: var(--surface-alt);
}
.protocol-composer-dock {
  position: relative;
  isolation: isolate;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 8px 30px #00000008;
  transition: border-color 180ms ease;
}
/* Border-beam treatment inspired by libraries.dev/beam; native CSS, no React wrapper. */
@property --protocol-beam-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}
.protocol-composer-dock::before {
  content: '';
  position: absolute;
  inset: -1px;
  z-index: 2;
  border-radius: inherit;
  padding: 1.5px;
  pointer-events: none;
  opacity: 0;
  background: conic-gradient(
    from var(--protocol-beam-angle),
    transparent 0deg 245deg,
    #29d5ec 275deg,
    #3c7bff 305deg,
    #a15aff 330deg,
    #f27bbd 346deg,
    transparent 360deg
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
}
.protocol-composer-dock.is-processing::before {
  opacity: 1;
  animation: protocol-beam-orbit 3.8s linear infinite;
}
.protocol-composer-dock.is-processing {
  box-shadow:
    0 8px 30px #00000008,
    0 0 22px #4d70ff14;
}
@keyframes protocol-beam-orbit {
  to {
    --protocol-beam-angle: 360deg;
  }
}
@media (prefers-reduced-motion: reduce) {
  .protocol-composer-dock.is-processing::before {
    animation: none;
    --protocol-beam-angle: 45deg;
  }
}
@media (forced-colors: active) {
  .protocol-composer-dock.is-processing {
    border-color: Highlight;
  }
  .protocol-composer-dock::before {
    display: none;
  }
}
.protocol-composer-dock:focus-within {
  border-color: color-mix(in srgb, var(--action) 55%, var(--line));
}
.protocol-composer-dock .protocol-composer {
  border: 0;
  background: transparent;
  box-shadow: none;
}
.protocol-conversation {
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: 20px 20px 32px;
  scrollbar-gutter: stable;
}
.protocol-welcome {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
}
.protocol-welcome h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 36px);
  letter-spacing: -0.045em;
  font-weight: 600;
  line-height: 1.15;
}
.protocol-welcome-orb {
  width: 172px;
  height: 172px;
}
.protocol-welcome-orb .assistant-orb {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 6px 18px #7060ed25);
}
.protocol-message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 28px;
  animation: document-arrive 300ms var(--ease-response);
}
.protocol-message > div {
  max-width: 86%;
  min-width: 0;
}
.protocol-message p {
  white-space: pre-wrap;
  line-height: 1.7;
  margin: 0;
}
.protocol-message.user {
  justify-content: flex-end;
}
.protocol-message.user > div {
  background: var(--surface-alt);
  padding: 14px 20px;
  border-radius: 24px 24px 6px 24px;
}
.protocol-assistant-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--action);
  flex-shrink: 0;
}
.protocol-assistant-mark svg {
  width: 17px;
  height: 17px;
}
.protocol-sources {
  margin-top: 15px;
  font-size: 12px;
  color: var(--muted);
}
.protocol-sources summary {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  list-style: none;
  width: fit-content;
  padding: 6px 0;
}
.protocol-sources summary svg {
  width: 15px;
  height: 15px;
}
.protocol-sources summary svg:last-child {
  transition: transform 180ms;
}
.protocol-sources[open] summary svg:last-child {
  transform: rotate(180deg);
}
.protocol-sources p {
  margin: 4px 0 10px;
}
.protocol-sources button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 16px;
  text-align: left;
  width: 100%;
  padding: 12px;
  margin-top: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
}
.protocol-sources button strong {
  font-weight: 500;
}
.protocol-sources button small {
  color: var(--muted);
  grid-column: 1;
}
.protocol-sources button > svg {
  grid-column: 2;
  grid-row: 1/3;
  align-self: center;
  width: 17px;
}
.protocol-questions {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.protocol-questions section {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.protocol-questions strong {
  display: block;
  font-weight: 550;
  margin-bottom: 9px;
}
.protocol-questions button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 20px;
  padding: 7px 12px;
  margin: 3px 5px 0 0;
  transition:
    background 180ms,
    color 180ms;
}
.protocol-questions button:hover {
  background: var(--action);
  color: white;
  border-color: var(--action);
}
.protocol-written {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}
.protocol-written header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.protocol-written header > span {
  flex: 1;
}
.protocol-written pre {
  font: inherit;
  line-height: 1.8;
  white-space: pre-wrap;
  padding: 22px;
  margin: 0;
  word-break: break-word;
}
.protocol-composer {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  padding: 12px 14px 12px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 8px 30px #00000008;
  flex-shrink: 0;
}
.protocol-composer:focus-within {
  border-color: var(--action);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--action) 12%, transparent);
}
.protocol-composer textarea {
  flex: 1;
  resize: none;
  max-height: 160px;
  min-width: 0;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  background: transparent;
  color: var(--text);
  padding: 5px 0;
  line-height: 1.5;
  font: inherit;
}
.protocol-send {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: var(--action);
  color: white;
  transition: transform 160ms;
}
.protocol-send:hover {
  transform: translateY(-2px);
}
.protocol-send:disabled {
  opacity: 0.4;
  transform: none;
}
.protocol-error {
  padding: 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.protocol-thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}
.media-panel {
  margin: 18px 0 24px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.media-panel header,
.media-panel header > span {
  display: flex;
  gap: 10px;
  align-items: center;
}
.media-panel header {
  justify-content: space-between;
}
.media-panel header strong {
  font-size: 14px;
  font-weight: 550;
}
.media-panel header small {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.media-panel header svg {
  width: 19px;
  height: 19px;
  color: var(--muted);
}
.media-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.media-gallery button {
  position: relative;
  border: 0;
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 1.25;
  background: var(--surface-alt);
  padding: 0;
  text-align: left;
  color: white;
  transition:
    transform 220ms var(--ease-response),
    box-shadow 220ms;
}
.media-gallery button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 22px #0002;
}
.media-gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-gallery button > span {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 10px 9px;
  background: linear-gradient(transparent, #0009);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.media-gallery button > span > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-gallery svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.media-upload-state {
  padding: 14px;
  background: var(--surface-alt);
  border-radius: 14px;
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-size: 13px;
}
.media-upload-state progress {
  width: 100%;
  height: 5px;
  accent-color: var(--action);
}
.media-view {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 150px);
  gap: 20px;
}
.media-view header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.media-view header strong {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #101012;
  border-radius: 24px;
  overflow: hidden;
  padding: 16px;
  color: #ccc;
}
.media-stage video,
.media-stage img {
  max-width: 100%;
  max-height: calc(100% - 42px);
  object-fit: contain;
  min-height: 0;
}
.media-stage p {
  font-size: 11px;
  margin: 12px 0 0;
}
.media-stage a {
  color: #b4d5ff;
}
.privacy-workspace {
  height: calc(100dvh - 150px);
  min-height: 500px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.privacy-workspace > header {
  display: flex;
  align-items: center;
  gap: 14px;
}
.privacy-workspace h2 {
  flex: 1;
  font-size: 20px;
  letter-spacing: -0.03em;
  margin: 0;
}
.privacy-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
  flex: 1;
  min-height: 0;
}
.privacy-tools {
  overflow: auto;
  font-size: 13px;
  line-height: 1.6;
}
.privacy-tools > p {
  color: var(--muted);
  margin: 0 0 18px;
}
.privacy-tools > .button {
  width: 100%;
  margin-top: 16px;
}
.privacy-mode {
  display: flex;
  gap: 3px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  padding: 3px;
  border-radius: 13px;
  margin-bottom: 18px;
}
.privacy-mode button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 4px;
  border-radius: 9px;
  font-size: 11px;
}
.privacy-mode button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 6px #0001;
}
.privacy-confirm {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.privacy-confirm input {
  accent-color: var(--action);
  margin-top: 5px;
  flex-shrink: 0;
}
.privacy-warning {
  border-left: 2px solid #f19322;
  padding-left: 10px;
}
.privacy-warning svg {
  width: 15px;
  height: 15px;
  vertical-align: middle;
}
.privacy-mask-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 16px 0;
}
.privacy-mask-actions > span {
  color: var(--muted);
  margin-right: auto;
}
.privacy-mask-actions .button {
  font-size: 12px;
  padding: 8px;
}
.privacy-pages {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--surface-alt);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  min-height: 0;
}
.privacy-page {
  min-width: 0;
  position: relative;
  margin: 0 auto 22px;
  max-width: 900px;
  line-height: 0;
  box-shadow: 0 2px 12px #0002;
  background: white;
}
.privacy-page img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}
.privacy-page > small {
  position: absolute;
  bottom: 4px;
  right: 6px;
  background: white;
  color: #444;
  padding: 3px 5px;
  line-height: 1;
  font-size: 10px;
}
.privacy-overlays {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.privacy-mask {
  position: absolute;
  background: #090909b3;
  border: 1px solid #fff9;
  display: block;
}
.privacy-mask.automatic {
  background: #0964cc3b;
  border-color: #0964cc8c;
}
.privacy-mask.drawing {
  background: #1119;
}
.privacy-page[data-draw-mask] {
  cursor: crosshair;
  touch-action: none;
}
.document-working {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  padding: 18px 0;
}
.document-working svg {
  animation: document-spin 2s linear infinite;
}
@keyframes document-arrive {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes document-pulse {
  from {
    opacity: 0.2;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(-2px);
  }
}
@keyframes document-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (max-width: 760px) {
  .protocol-chat-page {
    height: calc(100dvh - 140px);
    min-height: 450px;
    gap: 10px;
  }
  .protocol-controls {
    gap: 10px;
    flex-wrap: wrap;
  }
  .protocol-allowance {
    flex-basis: 100%;
    margin-right: 0;
    padding: 12px;
    gap: 10px;
    border-radius: 18px;
  }
  .protocol-plus-mark {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }
  .protocol-allowance-copy strong {
    font-size: 12px;
  }
  .protocol-allowance-copy small {
    font-size: 10px;
  }
  .protocol-plus-cta {
    padding: 10px 12px;
    font-size: 11px;
    gap: 5px;
  }
  .protocol-plus-cta svg {
    display: none;
  }
  .protocol-welcome {
    min-height: 220px;
    gap: 12px;
  }
  .protocol-welcome-orb {
    width: 140px;
    height: 140px;
  }
  .protocol-inspiration {
    padding: 12px 16px 0;
  }
  .protocol-inspiration > span {
    width: 100%;
    font-size: 11px;
  }
  .protocol-reference-fields {
    grid-template-columns: 1fr 1fr;
    gap: 3px 14px;
  }
  .protocol-reference:first-child {
    grid-column: 1 / -1;
  }
  .protocol-reference:last-child .protocol-reference-options {
    left: auto;
    right: 0;
  }
  .protocol-reference input {
    font-size: 12px;
  }
  .protocol-conversation {
    padding: 16px 0;
  }
  .protocol-message > div {
    max-width: 91%;
  }
  .protocol-message {
    gap: 8px;
  }
  .protocol-assistant-mark {
    display: none;
  }
  .protocol-written pre {
    padding: 15px;
    font-size: 13px;
  }
  .protocol-composer {
    border-radius: 20px;
    padding: 10px 12px;
  }
  .privacy-workspace {
    height: auto;
    min-height: 0;
  }
  .privacy-workspace > header {
    gap: 6px;
    flex-wrap: wrap;
  }
  .privacy-workspace h2 {
    font-size: 17px;
  }
  .privacy-layout {
    display: flex;
    flex-direction: column;
    gap: 15px;
  }
  .privacy-tools {
    overflow: visible;
  }
  .privacy-tools > p {
    margin-bottom: 12px;
  }
  .privacy-pages {
    width: 100%;
    max-height: 65dvh;
    padding: 10px;
  }
  .privacy-confirm {
    padding: 8px 0;
  }
  .privacy-tools > .button {
    margin-top: 4px;
  }
  .media-view {
    height: calc(100dvh - 150px);
  }
  .media-view header {
    gap: 6px;
    flex-wrap: wrap;
  }
  .media-view header strong {
    font-size: 13px;
  }
  .media-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .media-stage {
    padding: 8px;
    border-radius: 18px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .protocol-message,
  .document-working svg {
    animation: none;
  }
  .protocol-conversation {
    scroll-behavior: auto;
  }
  .media-gallery button,
  .protocol-send {
    transition: none;
  }
}
.privacy-optional {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.privacy-optional summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.privacy-optional[open] summary {
  margin-bottom: 16px;
  color: var(--text);
}
