/* apps/web/src/styles/entry-collaboration.css */
.detail-collab-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -18px 0 30px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 17px;
}
.detail-revision-signature {
  min-width: 0;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.detail-collab-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
}
.detail-collab-actions button {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--glass-bg-soft);
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.detail-collab-actions button:hover,
.detail-collab-actions button:focus-visible {
  border-color: var(--accent);
  outline: none;
}
.entry-collab-dialog {
  width: min(1190px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 30px;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 28px 100px #0009;
  overflow: auto;
  overscroll-behavior: contain;
}
.entry-collab-dialog::backdrop {
  background: rgb(0 0 0 / .68);
  backdrop-filter: blur(6px);
}
.entry-collab-frame {
  min-width: 0;
  padding: clamp(18px, 3vw, 36px);
}
.entry-collab-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.entry-collab-head .v5-label {
  margin: 0 0 9px;
}
.entry-collab-head h2 {
  margin: 0;
  font-size: clamp(23px, 2.7vw, 34px);
  letter-spacing: -.04em;
}
.entry-collab-hint {
  max-width: 720px;
  margin: 9px 0 0;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.6;
}
.entry-collab-close {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--glass-bg-soft);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.entry-collab-body {
  display: grid;
  gap: 18px;
  padding-top: 24px;
}
.entry-collab-label {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
}
.entry-collab-input {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: var(--glass-bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
}
.entry-collab-input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
}
.entry-collab-input[type=checkbox] {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--accent);
}
.entry-collab-form {
  display: grid;
  gap: 19px;
}
.entry-collab-selectors,
.entry-collab-edit-grid,
.entry-collab-diff-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.entry-collab-field,
.entry-collab-timeline,
.entry-collab-history-detail,
.entry-collab-attribution,
.entry-collab-access,
.entry-collab-own-proposals {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
}
.entry-collab-field h3,
.entry-collab-history-grid h3,
.entry-collab-attribution h3,
.entry-collab-access h3,
.entry-collab-own-proposals h3 {
  margin: 0 0 12px;
  font-size: 16px;
}
.entry-collab-original {
  min-height: 170px;
  max-height: 320px;
  margin: 0;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--glass-bg-soft);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow: auto;
  overflow-wrap: anywhere;
}
.entry-collab-field textarea {
  min-height: 170px;
}
.entry-collab-form-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.entry-collab-button {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--glass-bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.entry-collab-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
}
.entry-collab-button:hover:not(:disabled),
.entry-collab-button:focus-visible {
  border-color: var(--accent);
  outline: none;
}
.entry-collab-button:disabled {
  opacity: .5;
  cursor: wait;
}
.entry-collab-status {
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.6;
}
.entry-collab-status[data-kind=error] {
  color: #f49d9d;
}
.entry-collab-status[data-kind=success] {
  color: var(--accent);
}
.entry-collab-preview {
  display: grid;
  gap: 10px;
}
.entry-collab-preview:empty {
  display: none;
}
.entry-collab-preview h3 {
  margin: 0;
  font-size: 14px;
}
.entry-collab-before,
.entry-collab-after {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text-2);
  background: var(--glass-bg-soft);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.entry-collab-after {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}
.entry-collab-attribution,
.entry-collab-access {
  display: grid;
  justify-items: start;
  gap: 12px;
}
.entry-collab-attribution p,
.entry-collab-access p {
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.6;
}
.entry-collab-attribution .entry-collab-label,
.entry-collab-access .entry-collab-label {
  width: 100%;
}
.entry-collab-check {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
}
.entry-collab-own-proposals {
  display: grid;
  gap: 10px;
}
.entry-collab-own-proposal-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.entry-collab-own-proposal {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--glass-bg-soft);
}
.entry-collab-own-proposal strong {
  display: block;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.entry-collab-own-proposal p {
  margin: 5px 0 0;
}
.entry-collab-inline-action {
  display: inline-flex;
  min-height: 30px;
  padding: 4px 10px;
  margin: 0;
  border-color: var(--accent);
  font-size: 12px;
  vertical-align: middle;
}
.entry-collab-review-feedback {
  padding: 8px 10px;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.entry-collab-source-list {
  display: grid;
  gap: 10px;
}
.entry-collab-source-list[hidden] {
  display: none;
}
.entry-collab-source-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(160px, 1.3fr);
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.entry-collab-source-row input:nth-child(3) {
  grid-column: 1/-1;
}
.entry-collab-source-row button {
  justify-self: start;
}
.entry-collab-history-grid {
  display: grid;
  grid-template-columns: minmax(235px, .7fr) minmax(0, 1.3fr);
  gap: 14px;
  align-items: start;
}
.entry-collab-revisions {
  margin: 0;
  padding: 0 0 0 20px;
  list-style: none;
  border-left: 1px solid var(--border-strong);
}
.entry-collab-revisions li {
  position: relative;
  display: grid;
  gap: 5px;
  padding: 0 0 18px 16px;
}
.entry-collab-revisions li::before {
  content: "";
  position: absolute;
  top: 10px;
  left: -26px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--bg);
}
.entry-collab-revisions li:last-child {
  padding-bottom: 0;
}
.entry-collab-revisions button {
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.entry-collab-revisions button:hover,
.entry-collab-revisions button:focus-visible {
  color: var(--accent);
  outline: none;
}
.entry-collab-revisions small,
.entry-collab-muted {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.6;
}
.entry-collab-history-result {
  display: grid;
  gap: 13px;
  margin-top: 20px;
}
.entry-collab-revision-summary {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}
.entry-collab-diff-item {
  border-top: 1px solid var(--border);
  padding-top: 15px;
}
.entry-collab-diff-item h4 {
  margin: 0 0 9px;
  font-size: 13px;
}
@media (max-width: 720px) {
  .detail-collab-bar {
    align-items: stretch;
    flex-direction: column;
    margin: 20px 0 28px;
  }
  .detail-collab-actions {
    width: 100%;
  }
  .detail-collab-actions button {
    flex: 1;
  }
  .entry-collab-dialog {
    width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .entry-collab-frame {
    padding: 20px 16px max(26px, env(safe-area-inset-bottom, 0px));
  }
  .entry-collab-head {
    gap: 12px;
  }
  .entry-collab-hint {
    font-size: 12px;
  }
  .entry-collab-selectors,
  .entry-collab-edit-grid,
  .entry-collab-history-grid,
  .entry-collab-diff-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .entry-collab-original,
  .entry-collab-field textarea {
    min-height: 90px;
  }
  .entry-collab-source-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .entry-collab-source-row input:nth-child(3) {
    grid-column: auto;
  }
  .entry-collab-form-footer .entry-collab-button {
    flex: 1 1 140px;
  }
}

/* apps/web/src/styles/diagram.css */
.diagram-editor {
  max-width: 1180px;
  margin: 32px auto;
  display: grid;
  gap: 14px;
}
.diagram-editor > header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.diagram-editor > header button,
.diagram-editor > .diagram-conflict-action {
  min-height: 40px;
  margin-left: 8px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--glass-bg);
  color: var(--text);
  cursor: pointer;
}
.diagram-editor > header .accent {
  border-color: var(--accent);
  background: var(--accent);
  color: #07120e;
}
.diagram-editor > label {
  display: grid;
  gap: 6px;
  color: var(--text-2);
  font-size: 13px;
}
.diagram-editor > label > input:not([type=checkbox]),
.diagram-editor > label > textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--glass-bg-soft);
  color: var(--text);
  font: inherit;
}
.diagram-editor > label > textarea {
  min-height: 100px;
}
.diagram-editor > .diagram-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
}
.diagram-editor > .diagram-confirm input {
  width: auto;
}
.diagram-canvas {
  height: min(67vh, 680px);
  min-height: 460px;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
@media (max-width: 700px) {
  .diagram-editor {
    margin: 16px 0;
  }
  .diagram-editor > header {
    align-items: flex-start;
    flex-direction: column;
  }
  .diagram-editor > header button {
    margin: 0 6px 0 0;
  }
  .diagram-canvas {
    height: 48vh;
    min-height: 330px;
  }
  .diagram-editor > label:nth-last-of-type(1) {
    order: 2;
  }
  .diagram-canvas {
    order: 3;
  }
}
.ask-diagram-preview {
  display: grid;
  gap: 10px;
  width: 100%;
  margin: 10px 0 18px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--glass-bg-soft);
  color: var(--text);
}
.ask-diagram-preview svg {
  width: 100%;
  max-height: 330px;
  color: var(--text);
}
.diagram-preview-card {
  fill: var(--glass-bg);
  stroke: var(--border);
  stroke-width: 1.5;
}
.diagram-preview-card.is-answer {
  stroke: var(--accent);
  fill: color-mix(in srgb, var(--accent) 10%, var(--glass-bg));
}
.diagram-preview-kind,
.diagram-preview-edge-label {
  fill: var(--text-3);
  font: 11px system-ui, sans-serif;
  letter-spacing: .08em;
}
.diagram-preview-label {
  fill: var(--text);
  font: 14px system-ui, sans-serif;
}
.diagram-preview-edge {
  stroke: var(--text-3);
  stroke-width: 1.4;
  marker-end: url(#arrow);
}
.diagram-preview-arrow {
  fill: var(--text-3);
}
.ask-diagram-explanation,
.ask-diagram-boundary {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-line;
}
.ask-diagram-boundary {
  color: var(--text-2);
}
.detail-entry-diagram .ask-replay {
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--glass-bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.detail-entry-diagram .ask-replay:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.diagram-editor {
  margin-top: 100px;
}
.diagram-canvas {
  display: flex;
  flex-direction: column;
  background: #121212;
  position: relative;
}
.diagram-canvas-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 12px;
  flex: none;
  background: var(--glass-bg-solid,#171717);
  border-bottom: 1px solid var(--border);
}
.diagram-canvas-actions button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--glass-bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.diagram-canvas-actions button:disabled {
  opacity: .5;
  cursor: wait;
}
.diagram-canvas-surface {
  position: relative;
  flex: 1;
  min-height: 0;
}
.diagram-canvas:fullscreen,
.diagram-canvas.is-fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-height: none;
  min-height: 0;
  border: 0;
  border-radius: 0;
  z-index: 2147483000;
}
.diagram-canvas:fullscreen::backdrop {
  background: #121212;
}
.diagram-canvas .default-sidebar-trigger,
.diagram-canvas .App-toolbar__extra-tools-trigger,
.diagram-canvas .help-icon,
.diagram-canvas .excalidraw-hyperlinkContainer,
.diagram-canvas .App-toolbar__divider,
.diagram-canvas .excalidraw a[href] {
  display: none !important;
}
@media (max-width: 700px) {
  .diagram-editor {
    margin-top: 90px;
  }
  .diagram-canvas-actions {
    padding: 6px 8px;
  }
  .diagram-canvas:fullscreen,
  .diagram-canvas.is-fullscreen {
    height: 100dvh;
    order: initial;
  }
}
.diagram-canvas .sidebar-trigger__label-element:has(.default-sidebar-trigger) {
  display: none !important;
}
.diagram-canvas .HintViewer {
  display: none;
}
.diagram-canvas .excalidraw .HintViewer {
  display: none !important;
}
.ask-diagram-preview {
  position: relative;
  display: block;
  padding: 0;
  overflow: hidden;
  margin: 24px 0 0;
}
.ask-diagram-scene {
  min-height: 180px;
  padding: 44px 16px 12px;
  background: #fff;
}
.ask-diagram-scene svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
  margin: auto;
}
html:not(.light) .ask-diagram-scene {
  background: #111;
}
html:not(.light) .ask-diagram-scene svg {
  filter: invert(.93) hue-rotate(180deg);
}
.ask-diagram-fullscreen {
  position: absolute;
  right: 12px;
  top: 12px;
  display: grid;
  place-items: center;
  width: 36px !important;
  height: 36px;
  padding: 0 !important;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--glass-bg);
  color: var(--text);
  cursor: pointer;
}
.ask-diagram-fullscreen:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.ask-diagram-fullscreen:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.ask-answer-actions {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px !important;
  margin-top: 18px;
  padding: 16px 0 8px;
  border-top: 1px solid var(--border);
}
.ask-answer-actions .ask-replay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: auto !important;
  margin: 0 !important;
  padding: 9px 12px !important;
  border-radius: 10px !important;
  font-size: 13px;
}
.ask-answer-actions .ask-replay::before {
  content: "";
  display: block;
  width: 17px;
  height: 17px;
  flex: none;
  background: currentColor;
  mask: var(--action-icon) center/contain no-repeat;
}
.ask-action-copy {
  --action-icon:url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"%3E%3Crect x="8" y="8" width="12" height="12" rx="2"/%3E%3Cpath d="M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"/%3E%3C/svg%3E');
}
.ask-action-revise {
  --action-icon:url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"%3E%3Cpath d="M4 20h4l11-11a2.2 2.2 0 0 0-4-4L4 16zM13.5 6.5l4 4M4 20h16"/%3E%3C/svg%3E');
}
.ask-action-next {
  --action-icon:url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"%3E%3Cpath d="M5 12h13M13 7l5 5-5 5"/%3E%3C/svg%3E');
}
.ask-action-save {
  --action-icon:url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.7"%3E%3Cpath d="M4 3h13l3 3v15H4zM8 3v6h8V3M8 21v-8h8v8"/%3E%3C/svg%3E');
}
.ask-action-share {
  --action-icon:url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.7"%3E%3Cpath d="M12 16V3m-4 4 4-4 4 4M5 11v10h14V11"/%3E%3C/svg%3E');
}
.ask-action-speech {
  --action-icon:url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.7"%3E%3Cpath d="M3 9v6h4l5 4V5L7 9zM16 8q4 4 0 8m3-11q7 7 0 14"/%3E%3C/svg%3E');
}
.ask-workshop-save {
  --action-icon:url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="1.7"%3E%3Cpath d="M3 7h18v14H3zM8 7V3h8v4M3 12h18M10 12v3h4v-3"/%3E%3C/svg%3E');
}
@media (max-width: 600px) {
  .ask-answer-actions .ask-replay {
    flex: 1 1 40%;
  }
  .ask-diagram-scene {
    padding: 48px 6px 8px;
  }
}
.ask-diagram-preview {
  border-radius: 24px;
  box-shadow: 0 12px 36px #00000012;
}
.ask-diagram-scene {
  background:
    radial-gradient(
      ellipse at 50% 48%,
      #d3f9ee88,
      transparent 68%),
    #fafcfb;
}
html:not(.light) .ask-diagram-scene {
  background:
    radial-gradient(
      ellipse at 50% 48%,
      #0c493b35,
      transparent 68%),
    #111514;
}
.diagram-canvas {
  border-radius: 24px;
  box-shadow: 0 12px 36px #00000018;
}
.diagram-canvas-actions {
  background:
    linear-gradient(
      110deg,
      var(--glass-bg-soft),
      transparent);
  padding: 12px 16px;
  gap: 10px;
}
.diagram-canvas-actions button {
  border-radius: 999px;
  padding: 8px 14px;
}
.diagram-canvas .excalidraw {
  --color-primary:#21b88b;
  --color-primary-darker:#087f5b;
  --color-primary-light:#d3f9ee;
}
.diagram-canvas .excalidraw.theme--dark {
  --color-primary:#34d3a2;
  --color-primary-darker:#22b98a;
  --color-primary-light:#16493c;
}
.diagram-canvas.is-fullscreen {
  border-radius: 0;
}
.diagram-canvas-surface {
  min-width: 0;
  overscroll-behavior: none;
  touch-action: none;
}
.diagram-canvas-surface .excalidraw {
  overscroll-behavior: none;
}
@media (max-width: 600px) {
  .diagram-canvas-actions {
    gap: 6px;
    padding: 8px;
  }
  .diagram-canvas-actions button {
    padding: 8px 10px;
    font-size: 13px;
  }
  .diagram-canvas.is-fullscreen {
    height: 100svh;
    height: 100dvh;
  }
}
.diagram-canvas-actions {
  flex-wrap: wrap;
  flex-shrink: 0;
}
.diagram-review {
  flex-shrink: 0;
  padding: 8px 16px;
  max-height: 30vh;
  overflow: auto;
  font-size: 13px;
}
.diagram-review summary {
  cursor: pointer;
}
.diagram-live-status {
  flex-shrink: 0;
  margin: 0;
  padding: 4px 12px;
  font-size: 12px;
}
.diagram-live-status:empty {
  padding: 0;
}
.ask-diagram-preview {
  margin: 0 0 var(--ask-module-gap,22px);
  background: var(--glass-bg-soft);
  border-color: var(--border);
  --diagram-complement:#1971c2;
  --diagram-challenge:#b36b00;
}
html:not(.light) .ask-diagram-preview {
  --diagram-complement:#74b9ff;
  --diagram-challenge:#f6c16c;
}
.ask-diagram-scene,
html:not(.light) .ask-diagram-scene {
  background:
    radial-gradient(
      ellipse at 50% 48%,
      var(--accent-soft),
      transparent 68%),
    var(--bg);
}
html:not(.light) .ask-diagram-scene svg {
  filter: none;
}
.ask-diagram-title {
  margin-bottom: 8px;
}
.diagram-canvas {
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
}
.diagram-canvas-actions {
  justify-content: flex-start;
  align-items: center;
  padding: 12px 20px;
  gap: 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.diagram-workspace-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  font-size: 15px;
  font-weight: 600;
}
.diagram-workspace-label > svg {
  color: var(--accent);
}
.diagram-workspace-label small {
  display: block;
  margin-top: 3px;
  color: var(--text-3);
  font-size: 9px;
  letter-spacing: .12em;
  font-weight: 500;
}
.diagram-action-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 12px;
  border-right: 1px solid var(--border);
}
.diagram-canvas-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--glass-bg-soft);
}
.diagram-canvas-actions svg,
.diagram-review svg {
  flex-shrink: 0;
}
.diagram-canvas-actions button:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.diagram-canvas-actions .diagram-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink,#07120e);
}
.diagram-canvas :is(button, textarea, input, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.diagram-live-status {
  padding: 9px 20px;
  background: var(--accent-soft);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}
.diagram-live-status:empty {
  display: none;
}
.diagram-review {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 0 20px 12px;
  max-height: 32dvh;
  scrollbar-width: thin;
}
.diagram-review summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  font-size: 13px;
  font-weight: 600;
  list-style: none;
}
.diagram-review summary::-webkit-details-marker {
  display: none;
}
.diagram-review-hint {
  margin-left: auto;
  color: var(--accent);
  font-size: 12px;
  font-weight: 400;
}
.diagram-review > label {
  display: grid;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.diagram-review-check {
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.55;
}
.diagram-review > .diagram-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  min-height: 32px;
}
.diagram-confirm input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.diagram-canvas .excalidraw,
.diagram-canvas .excalidraw.theme--dark {
  --color-primary:var(--accent);
  --color-primary-darker:var(--accent);
  --color-primary-light:var(--accent-soft);
}
@media (max-width: 900px) {
  .diagram-workspace-label {
    width: 100%;
    margin: 0;
  }
  .diagram-canvas-actions {
    gap: 8px;
    padding: 10px 12px;
  }
  .diagram-action-group {
    padding-right: 8px;
  }
}
@media (max-width: 600px) {
  .diagram-workspace-label small {
    display: none;
  }
  .diagram-canvas-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
  }
  .diagram-workspace-label {
    width: auto;
  }
  .diagram-action-group {
    grid-column: 1/-1;
    border: 0;
    padding: 0;
    flex-wrap: wrap;
  }
  .diagram-action-group button {
    flex: 1;
  }
  .diagram-canvas-actions > button {
    grid-column: 2;
    grid-row: 1;
  }
  .diagram-canvas-actions button {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 12px;
  }
  .diagram-review {
    padding: 0 12px 10px;
    max-height: 30dvh;
  }
  .diagram-live-status {
    padding: 8px 12px;
    font-size: 12px;
  }
}
.diagram-list {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 24px;
}
.diagram-list li {
  min-width: 0;
}
.diagram-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--glass-bg);
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
.diagram-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px var(--accent-soft);
}
.diagram-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.diagram-thumbnail {
  aspect-ratio: 16/10;
  display: grid;
  place-items: center;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 16px;
  box-sizing: border-box;
  overflow: hidden;
}
.diagram-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}
.diagram-thumbnail > span {
  font-size: 13px;
  color: #555;
}
.diagram-card-info {
  padding: 20px;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 16px;
}
.diagram-card-info h2 {
  font-size: 18px;
  line-height: 1.5;
  font-weight: 600;
  margin: 0;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.diagram-card-info > span {
  margin-top: auto;
  color: var(--text-3);
  font-size: 13px;
}
@media (max-width: 600px) {
  .diagram-list {
    gap: 16px;
    margin-top: 20px;
  }
  .diagram-card-info {
    padding: 16px;
  }
}
.diagram-library-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 20px 0;
}
.diagram-library-tools input,
.diagram-library-tools select,
.diagram-library-tools button,
.diagram-item-menu button,
.diagram-item-menu select {
  font: inherit;
  color: var(--text);
  background: var(--glass-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 44px;
  padding: 8px 12px;
  max-width: 100%;
}
.diagram-library-tools input {
  flex: 1;
  min-width: 180px;
}
.diagram-library-item {
  position: relative;
}
.diagram-item-menu {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 2;
  color: var(--text);
}
.diagram-item-menu summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-weight: bold;
}
.diagram-item-menu > div {
  position: absolute;
  right: 0;
  top: 50px;
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  min-width: 180px;
  box-shadow: 0 8px 24px #0004;
}
.diagram-select {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 2;
  background: var(--bg);
  padding: 8px;
  border-radius: 8px;
}
.diagram-select input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}
.diagram-library-tools button:disabled,
.diagram-item-menu button:disabled {
  opacity: .5;
}
@media (max-width: 700px) {
  .diagram-canvas:not(.is-fullscreen):not(:fullscreen) {
    height: auto;
    min-height: 0;
    max-height: none;
  }
  .diagram-canvas:not(.is-fullscreen):not(:fullscreen) .diagram-canvas-surface {
    flex: none;
    height: clamp(380px, 65svh, 640px);
    min-height: 380px;
    width: 100%;
  }
  .diagram-canvas.is-fullscreen,
  .diagram-canvas:fullscreen {
    height: 100dvh;
    display: flex;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-sizing: border-box;
  }
  .diagram-canvas.is-fullscreen .diagram-canvas-surface,
  .diagram-canvas:fullscreen .diagram-canvas-surface {
    flex: 1 1 0;
    min-height: 160px;
    width: 100%;
  }
  .diagram-canvas.is-fullscreen .diagram-canvas-actions,
  .diagram-canvas:fullscreen .diagram-canvas-actions {
    max-height: 34dvh;
    overflow-y: auto;
  }
  .diagram-canvas.is-fullscreen .diagram-live-status,
  .diagram-canvas:fullscreen .diagram-live-status {
    max-height: 48px;
    overflow: auto;
  }
  .diagram-canvas.is-fullscreen .diagram-review,
  .diagram-canvas:fullscreen .diagram-review {
    max-height: 24dvh;
  }
  .diagram-canvas-surface > .excalidraw {
    height: 100%;
    width: 100%;
  }
}
@media (max-width: 700px) and (max-height: 450px) {
  .diagram-canvas.is-fullscreen .diagram-canvas-actions,
  .diagram-canvas:fullscreen .diagram-canvas-actions {
    max-height: 25dvh;
  }
  .diagram-canvas.is-fullscreen .diagram-review,
  .diagram-canvas:fullscreen .diagram-review {
    max-height: 48px;
  }
}
.ask-diagram-preview .ask-diagram-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 0;
  flex-wrap: wrap;
}
.ask-diagram-header .ask-diagram-title {
  margin: 0;
  min-width: 0;
}
.ask-diagram-open-editor {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
}
.ask-diagram-open-editor:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.ask-diagram-open-editor:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.ask-diagram-preview .ask-diagram-scene {
  padding: 12px 20px;
  min-height: 0;
}
.ask-diagram-scene svg {
  display: block;
  width: 100%;
  max-width: 540px;
  margin: auto;
}
.diagram-preview-card {
  fill: var(--bg,#080808);
  stroke: var(--border,#444);
  stroke-width: 1.2;
}
.diagram-preview-card.is-answer {
  stroke: var(--accent);
  stroke-width: 1.5;
}
.diagram-preview-label {
  fill: var(--text,#eee);
  font: 12px sans-serif;
}
.diagram-preview-edge {
  fill: none;
  stroke: var(--border,#555);
  stroke-width: 2;
}
.diagram-preview-edge-label {
  fill: var(--text-3,#999);
  font: 10px sans-serif;
}
.ask-diagram-preview > .ask-diagram-boundary {
  padding: 0 20px 14px;
}
.diagram-editor {
  max-width: 1480px;
}
.diagram-editor .diagram-canvas {
  height: auto;
  min-height: 0;
}
.diagram-editor-grid {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 280px;
  gap: 16px;
  padding: 16px;
  min-height: 610px;
  flex: 1;
  min-width: 0;
}
.diagram-options,
.diagram-editor-grid > .diagram-review {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  min-width: 0;
  background: var(--glass-bg-soft);
  max-height: none;
  overflow: auto;
}
.diagram-options label {
  display: grid;
  gap: 8px;
}
.diagram-options input {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  min-height: 44px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}
.diagram-options p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
}
.diagram-options .diagram-action-group {
  display: grid;
  border: 0;
  padding: 0;
  margin: 16px 0;
}
.diagram-options button {
  min-height: 44px;
}
.diagram-editor-grid > .diagram-canvas-surface {
  min-height: 580px;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.diagram-editor-grid > .diagram-review summary {
  flex-wrap: wrap;
  line-height: 1.5;
  padding: 0 0 12px;
}
.diagram-editor .diagram-canvas.is-fullscreen {
  height: 100dvh;
}
.diagram-canvas.is-fullscreen .diagram-editor-grid {
  min-height: 0;
  overflow: auto;
}
.diagram-canvas.is-fullscreen .diagram-canvas-surface {
  min-height: 320px;
}
@media (max-width: 1000px) {
  .diagram-editor-grid {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 12px;
    gap: 12px;
  }
  .diagram-editor-grid > .diagram-review {
    order: 0;
    max-height: 320px;
  }
  .diagram-editor-grid > .diagram-canvas-surface {
    order: 1;
    min-height: 440px;
    height: 60svh;
  }
  .diagram-editor-grid > .diagram-options {
    order: 2;
  }
  .diagram-editor .diagram-canvas:not(.is-fullscreen) .diagram-canvas-surface {
    height: 60svh;
    min-height: 440px;
  }
  .diagram-options .diagram-action-group {
    display: flex;
    flex-wrap: wrap;
  }
  .diagram-canvas.is-fullscreen .diagram-editor-grid > .diagram-review,
  .diagram-canvas.is-fullscreen .diagram-options {
    display: none;
  }
  .diagram-canvas.is-fullscreen .diagram-editor-grid > .diagram-canvas-surface {
    height: 100%;
    min-height: 0;
  }
  .ask-diagram-preview .ask-diagram-header {
    padding: 14px 14px 0;
    gap: 4px;
  }
  .ask-diagram-preview .ask-diagram-scene {
    padding: 10px 14px;
  }
}
.diagram-reference-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  display: grid;
  gap: 8px;
}
.diagram-reference-list li {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.diagram-options button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--glass-bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.diagram-options button svg {
  width: 18px;
  height: 18px;
  flex: none;
}
.diagram-options button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: var(--accent);
}
.diagram-options button:focus-visible,
.diagram-options input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.diagram-options button:disabled {
  opacity: .5;
  cursor: default;
}
body.diagram-page .diagram-editor {
  margin: 16px auto 24px;
}
body.diagram-page main.site-main {
  padding-bottom: 24px;
}
body.diagram-page footer.site {
  margin-bottom: 12px;
  padding: 12px 24px;
}
.diagram-editor > header {
  justify-content: flex-start;
  align-items: flex-start;
}
.diagram-editor > header h1 {
  font-size: clamp(18px, 2vw, 26px);
  line-height: 1.45;
  margin: 4px 0;
  overflow-wrap: anywhere;
  min-width: 0;
  flex: 1;
}
.diagram-editor > header button {
  flex-shrink: 0;
  margin: 0;
  min-height: 44px;
}
.diagram-editor-grid {
  grid-template-rows: minmax(0, 1fr);
  height: clamp(580px, 72dvh, 820px);
  min-height: 0;
  box-sizing: border-box;
}
.diagram-editor-grid > .diagram-canvas-surface {
  min-height: 0;
  height: 100%;
  position: relative;
}
.diagram-editor-grid > .diagram-review,
.diagram-editor-grid > .diagram-options {
  max-height: 100%;
  box-sizing: border-box;
}
.diagram-canvas.is-fullscreen .diagram-editor-grid {
  height: auto;
  flex: 1;
  min-height: 0;
}
@media (max-width: 1100px) {
  .diagram-editor-grid {
    grid-template-columns: 1fr;
    height: auto;
    grid-template-rows: auto;
  }
  .diagram-editor-grid > .diagram-review {
    order: 0;
    max-height: 300px;
  }
  .diagram-editor-grid > .diagram-canvas-surface {
    order: 1;
    height: clamp(440px, 65svh, 640px);
    min-height: 440px;
  }
  .diagram-editor-grid > .diagram-options {
    order: 2;
    max-height: none;
  }
  .diagram-editor > header {
    flex-direction: column;
    gap: 8px;
  }
  .diagram-canvas.is-fullscreen .diagram-editor-grid {
    display: flex;
    flex-direction: column;
  }
  .diagram-canvas.is-fullscreen .diagram-editor-grid > .diagram-review,
  .diagram-canvas.is-fullscreen .diagram-options {
    display: none;
  }
  .diagram-canvas.is-fullscreen .diagram-editor-grid > .diagram-canvas-surface {
    height: auto;
    flex: 1;
    min-height: 0;
  }
}
@media (max-width: 720px) {
  body.diagram-page main.site-main {
    padding-top: 160px;
  }
}
.diagram-reference-list li:has(a) {
  padding: 0;
}
.diagram-reference-list a {
  display: block;
  padding: 12px;
  min-height: 44px;
  box-sizing: border-box;
  color: var(--text);
  text-decoration: none;
  border-radius: 12px;
  overflow-wrap: anywhere;
}
.diagram-reference-list a span {
  color: var(--accent);
  white-space: nowrap;
}
.diagram-reference-list a:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}
.diagram-reference-list a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.diagram-canvas-actions .diagram-action-group {
  gap: 8px;
  flex-wrap: wrap;
}
.ask-diagram-preview .ask-diagram-scene > svg {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: none;
  display: block;
}
.ask-diagram-module {
  margin: var(--ask-module-gap,24px) 0;
  min-width: 0;
}
.ask-diagram-module > .ask-diagram-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 0;
  margin: 0 0 12px;
}
.ask-diagram-module > .ask-diagram-header .ask-label {
  margin: 0;
}
.ask-diagram-module > .ask-diagram-preview {
  margin: 0;
}
.ask-decision-unavailable {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--glass-bg-soft);
  padding: 16px 20px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.6;
}
.ask-decision-unavailable p {
  margin: 0;
}
.ask-decision-unavailable .ask-diagram-open-editor {
  margin-top: 8px;
  padding-left: 0;
}
.ask-decision-preview {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.ask-decision-preview .ask-diagram-scene {
  min-width: 0;
}
.ask-decision-preview .ask-diagram-scene > svg {
  width: 100%;
  max-width: none;
}
html:not(.light) .ask-decision-preview .ask-diagram-scene > svg {
  filter: invert(.93) hue-rotate(180deg);
}
.ask-decision-caption {
  display: block;
  min-width: 0;
  margin: 0;
  padding: 8px 2px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}
@media (max-width: 700px) {
  .ask-decision-preview .ask-diagram-scene {
    min-width: 760px;
  }
}
@media (min-width: 701px) {
  .ask-decision-preview .ask-diagram-scene {
    min-width: 0 !important;
  }
}
@media (max-width: 600px) {
  .ask-diagram-module > .ask-diagram-header {
    gap: 4px 12px;
  }
}
@media (min-width: 721px) {
  body.diagram-page main.site-main {
    padding-top: 80px;
  }
  body.diagram-page .diagram-editor {
    margin-top: 0;
  }
}
@media (max-width: 1100px) {
  .diagram-editor-grid > .diagram-review:not([open]) {
    max-height: none;
    overflow: visible;
    padding: 12px 16px;
  }
  .diagram-editor-grid > .diagram-review:not([open]) summary {
    padding: 0;
  }
  .diagram-review summary::after {
    content: "\2304";
    margin-left: 8px;
  }
  .diagram-review[open] summary::after {
    content: "\2303";
  }
}
.diagram-reference-role {
  display: block;
  margin: 0 12px 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}
.diagram-reference-list .diagram-reference-detail {
  margin: 0;
  padding: 0 12px 12px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-2);
  overflow-wrap: anywhere;
}
