.block {
  position: relative;
  min-height: 80px;
  --sb--markdown-bg: var(--color-background, #ffffff);
  --sb--markdown-fg: var(--color-foreground, #1f2328);
  --sb--markdown-muted: var(--color-foreground-muted, #656d76);
  --sb--markdown-accent: var(--color-background-accent-emphasis, #2f81f7);
  background: var(--sb--markdown-bg);
  color: var(--sb--markdown-fg);
  font-family: var(--tc-font-stack, system-ui, -apple-system, sans-serif);
}

.blockCollapsed {
  max-height: 360px;
  overflow: hidden;
}

.blockCollapsed .preview {
  mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
}

.preview {
  padding: 16px 20px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--sb--markdown-fg);
  cursor: text;
  min-height: 60px;
}

.preview :global(*) {
  color: inherit;
  pointer-events: none;
}

.preview a {
  color: var(--sb--markdown-accent);
  text-decoration: none;
  pointer-events: auto;
  cursor: pointer;
}

.preview a:hover {
  text-decoration: underline;
}

.preview img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--color-border, #d0d7de);
  margin: 8px 0;
  display: block;
  pointer-events: auto;
}

.preview video {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--color-border, #d0d7de);
  margin: 8px 0;
  display: block;
  pointer-events: auto;
  background: var(--color-background-muted, #f6f8fa);
}

.preview h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px;
  line-height: 1.3;
}

.preview h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 6px;
  line-height: 1.3;
}

.preview h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px;
  line-height: 1.3;
}

.preview p {
  margin: 0 0 8px;
}

.preview code {
  background: var(--color-background-neutral-muted, #afb8c133);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 400;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

.preview ul {
  margin: 0 0 8px;
  padding-left: 20px;
  list-style-type: disc;
}

.preview li {
  margin: 0 0 2px;
  display: list-item;
}

.preview ol {
  margin: 0 0 8px;
  padding-left: 20px;
  list-style-type: decimal;
}

/* GFM: Task lists — accent-colored checkboxes */
.preview input[type="checkbox"] {
  margin-right: 6px;
  pointer-events: none;
  accent-color: var(--sb--markdown-accent);
}

.preview li:has(input[type="checkbox"]) {
  list-style: none;
  margin-left: -20px;
}

/* GFM: Strikethrough */
.preview del {
  text-decoration: line-through;
  color: var(--sb--markdown-muted);
}

/* GFM: Tables */
.preview table {
  border-collapse: collapse;
  margin: 8px 0;
  width: 100%;
  font-size: 13px;
}

.preview th,
.preview td {
  border: 1px solid var(--color-border, #d0d7de);
  padding: 6px 12px;
  text-align: left;
}

.preview th {
  background: var(--color-background-muted, #f6f8fa);
  font-weight: 600;
}

/* Code blocks */
.preview pre {
  padding: 12px 16px;
  border-radius: 6px;
  border: 1px solid var(--color-border-muted, #d8dee4);
  overflow-x: auto;
  margin: 8px 0;
  background: var(--color-background-neutral-muted, #afb8c133);
  line-height: 1.4;
}

/* When inspector highlighter sets inline background, let it through */
.preview pre[style] {
  border-radius: 6px;
  border: 1px solid var(--color-border-muted, #d8dee4);
  overflow-x: auto;
  margin: 8px 0;
}

.preview pre code {
  background: none;
  padding: 0;
  font-size: 12px;
  font-weight: 400;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  display: block;
}

/* Suppress line numbers from inspector highlighter's .line spans */
.preview :global(.line::before) {
  display: none !important;
}

/* Blockquotes */
.preview blockquote {
  border-left: 4px solid var(--color-border, #d0d7de);
  margin: 8px 0;
  padding: 4px 16px;
  color: var(--sb--markdown-muted);
}

/* Horizontal rules */
.preview hr {
  border: none;
  border-top: 1px solid var(--color-border, #d0d7de);
  margin: 16px 0;
}

.preview :global(.placeholder) {
  color: var(--sb--markdown-muted);
  font-style: italic;
}

.editor {
  display: block;
  width: 100%;
  height: 100%;
  box-sizing: border-box;

  padding: 16px 20px;
  border: none;
  outline: none;
  background: var(--sb--markdown-bg);
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--sb--markdown-fg);
  resize: none;
}

/* ── Expanded preview in modal ──────────────────────────────────── */

.expandedPreview {
  --sb--markdown-bg: var(--color-background, #ffffff);
  --sb--markdown-fg: var(--color-foreground, #1f2328);
  --sb--markdown-muted: var(--color-foreground-muted, #656d76);
  --sb--markdown-accent: var(--color-background-accent-emphasis, #2f81f7);
  padding: 32px 40px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--sb--markdown-fg);
  background: var(--sb--markdown-bg);
  font-family: var(--tc-font-stack, system-ui, -apple-system, sans-serif);
  max-width: 800px;
  margin: 0 auto;
}

.expandedPreview * {
  pointer-events: auto;
  color: inherit;
}

.expandedPreview a {
  color: var(--sb--markdown-accent);
  text-decoration: none;
  cursor: pointer;
}

.expandedPreview a:hover {
  text-decoration: underline;
}

.expandedPreview img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--color-border, #d0d7de);
  margin: 8px 0;
  display: block;
}

.expandedPreview video {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--color-border, #d0d7de);
  margin: 8px 0;
  display: block;
}

.expandedPreview h1 { font-size: 24px; font-weight: 700; margin: 0 0 12px; line-height: 1.3; }
.expandedPreview h2 { font-size: 20px; font-weight: 600; margin: 0 0 10px; line-height: 1.3; }
.expandedPreview h3 { font-size: 17px; font-weight: 600; margin: 0 0 6px; line-height: 1.3; }
.expandedPreview p { margin: 0 0 12px; }

.expandedPreview code {
  background: var(--color-background-neutral-muted, #afb8c133);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.expandedPreview pre {
  padding: 12px 16px;
  border-radius: 6px;
  border: 1px solid var(--color-border-muted, #d8dee4);
  overflow-x: auto;
  margin: 8px 0;
  background: var(--color-background-neutral-muted, #afb8c133);
  line-height: 1.4;
}

.expandedPreview pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  white-space: pre;
  display: block;
}

.expandedPreview ul { margin: 0 0 12px; padding-left: 24px; list-style: disc; }
.expandedPreview ol { margin: 0 0 12px; padding-left: 24px; list-style: decimal; }
.expandedPreview li { margin: 0 0 4px; display: list-item; }

.expandedPreview blockquote {
  border-left: 4px solid var(--color-border, #d0d7de);
  margin: 12px 0;
  padding: 4px 16px;
  color: var(--sb--markdown-muted);
}

.expandedPreview table {
  border-collapse: collapse;
  margin: 12px 0;
  width: 100%;
  font-size: 14px;
}

.expandedPreview th,
.expandedPreview td {
  border: 1px solid var(--color-border, #d0d7de);
  padding: 6px 12px;
  text-align: left;
}

.expandedPreview th {
  background: var(--color-background-muted, #f6f8fa);
  font-weight: 600;
}

.expandedPreview hr {
  border: none;
  border-top: 1px solid var(--color-border, #d0d7de);
  margin: 16px 0;
}

.expandedPreview input[type="checkbox"] {
  margin-right: 6px;
  pointer-events: none;
  accent-color: var(--sb--markdown-accent);
}

.expandedPreview li:has(input[type="checkbox"]) {
  list-style: none;
  margin-left: -24px;
}

/* ── Expanded editor ─────────────────────────────────────────────── */

.expandedEditorWrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--color-background, #ffffff);
}

.expandedEditor {
  display: block;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 32px 40px;
  border: none;
  outline: none;
  resize: none;
  background: var(--color-background, #ffffff);
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-foreground, #1f2328);
  overflow: auto;
}
