/* Message studio ---------------------------------------------------------------------- */
.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  gap: 20px;
  align-items: start;
}
@media (max-width: 1240px) {
  .studio {
    grid-template-columns: 1fr;
  }
}
.studio-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.studio-bar .input {
  width: 220px;
}
.menu {
  position: relative;
}
.menu-pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  min-width: 300px;
  max-height: 420px;
  overflow: auto;
  padding: 8px;
  border-radius: var(--r-md);
  background: var(--panel-solid);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  animation: pop 0.2s var(--ease);
}
.menu-pop .lbl {
  padding: 8px 10px 4px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 600;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: 0.14s;
}
.menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
.menu-item small {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
}
.menu-item .x {
  margin-left: auto;
}
.blocks {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.block {
  border-radius: var(--r-md);
  background: var(--panel);
  border: 1px solid var(--line);
  transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.block:hover {
  border-color: var(--line-2);
}
.block.dragging {
  opacity: 0.35;
}
.block.over {
  box-shadow: 0 -3px 0 var(--brand);
}
.block.hidden-block {
  opacity: 0.5;
}
.block.has-error {
  border-color: rgba(240, 77, 95, 0.55);
}
.block-h {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}
.block-h .grip {
  cursor: grab;
  color: var(--dim);
  display: grid;
  place-items: center;
  width: 24px;
  height: 28px;
  border-radius: 6px;
}
.block-h .grip:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}
.block-h .grip svg {
  width: 18px;
  height: 18px;
}
.block-h .name {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 14px;
}
.block-h .name svg {
  width: 16px;
  height: 16px;
  color: var(--brand);
}
.block-b {
  padding: 0 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sub-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sub-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border-radius: var(--r-sm);
  background: rgba(8, 10, 16, 0.55);
  border: 1px solid var(--line);
}
.sub-item .fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.sub-item .fields .wide {
  grid-column: 1 / -1;
}
.add-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
.add-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: var(--r-md);
  border: 1px dashed var(--line-3);
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: 0.18s;
}
.add-tile:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: #fff;
}
.add-tile svg {
  width: 20px;
  height: 20px;
  color: var(--brand);
}
.swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: var(--c);
  padding: 0;
  transition: 0.15s;
}
.swatch:hover {
  transform: scale(1.12);
}
.swatch.on {
  border-color: #fff;
}
.problems {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.problem {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 13.5px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--bad-soft);
  color: #ffabb5;
}
.problem.warn {
  background: var(--warn-soft);
  color: #ffd28a;
}
.problem svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 2px;
}
.counter {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.counter.high {
  color: var(--warn);
}
.counter.over {
  color: var(--bad);
}
.preview-col {
  position: sticky;
  top: calc(var(--topbar) + 20px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - var(--topbar) - 40px);
}
@media (max-width: 1240px) {
  .preview-col {
    position: static;
    max-height: none;
  }
}
.preview-shell {
  border-radius: var(--r-lg);
  background: #313338;
  border: 1px solid var(--line-2);
  overflow: auto;
  padding: 18px 16px;
  min-height: 140px;
}

/* Discord skin used by the live preview -------------------------------------------------- */
.dc-message {
  display: flex;
  gap: 14px;
  font-family: "gg sans", "Noto Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  color: #dbdee1;
  font-size: 15.5px;
  line-height: 1.375;
  --blurple: #5865f2;
}
.dc-avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff3d7f, #b18cff);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  margin-top: 2px;
}
.dc-main {
  min-width: 0;
  flex: 1;
}
.dc-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.dc-name {
  font-weight: 600;
  color: #f2f3f5;
}
.dc-app {
  background: #5865f2;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.dc-time-stamp {
  color: #949ba4;
  font-size: 12px;
  margin-left: 4px;
}
.dc-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 100%;
}
.dc-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px 14px 16px;
  border-radius: 8px;
  background: #2b2d31;
  border: 1px solid #3f4147;
  border-left: 4px solid var(--accent, #4e5058);
  max-width: 520px;
}
.dc-container.no-accent {
  border-left-width: 1px;
}
.dc-md > *:first-child {
  margin-top: 0;
}
.dc-md p {
  margin: 0;
  word-wrap: anywhere;
}
.dc-md p + p,
.dc-md p + .dc-list,
.dc-md .dc-list + p {
  margin-top: 4px;
}
.dc-h1 {
  font-size: 1.5em;
  font-weight: 700;
  margin: 8px 0 4px;
  line-height: 1.2;
  color: #f2f3f5;
}
.dc-h2 {
  font-size: 1.25em;
  font-weight: 700;
  margin: 6px 0 4px;
  color: #f2f3f5;
}
.dc-h3 {
  font-size: 1.05em;
  font-weight: 700;
  margin: 4px 0 2px;
  color: #f2f3f5;
}
.dc-sub {
  font-size: 0.8em;
  color: #949ba4;
  margin: 2px 0;
}
.dc-list {
  margin: 4px 0;
  padding-left: 1.4em;
}
.dc-quote {
  margin: 4px 0;
  padding-left: 12px;
  border-left: 4px solid #4e5058;
  color: #dbdee1;
}
.dc-pre {
  margin: 6px 0;
  padding: 8px 10px;
  background: #1e1f22;
  border: 1px solid #2b2d31;
  border-radius: 6px;
  overflow: auto;
  font-size: 13.5px;
}
.dc-pre code {
  background: none;
  border: 0;
  padding: 0;
  color: #dbdee1;
}
.dc-code {
  background: #1e1f22 !important;
  border: 0 !important;
  border-radius: 4px;
  padding: 0 4px !important;
  font-size: 0.88em;
  color: #dbdee1;
}
.dc-link {
  color: #00a8fc;
}
.dc-mention {
  background: rgba(88, 101, 242, 0.3);
  color: #c9cdfb;
  padding: 0 3px;
  border-radius: 3px;
  font-weight: 500;
}
.dc-mention.role {
  color: var(--c, #c9cdfb);
  background: color-mix(in srgb, var(--c, #5865f2) 22%, transparent);
}
.dc-spoiler {
  background: #1e1f22;
  color: transparent;
  border-radius: 4px;
  cursor: pointer;
}
.dc-spoiler.open {
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
}
.dc-emoji {
  width: 1.375em;
  height: 1.375em;
  vertical-align: -0.3em;
}
.dc-time {
  background: rgba(255, 255, 255, 0.07);
  padding: 0 3px;
  border-radius: 3px;
}
.dc-sep {
  height: 8px;
}
.dc-sep.large {
  height: 16px;
}
.dc-sep.line {
  position: relative;
}
.dc-sep.line::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: #4e5058;
}
.dc-gallery {
  display: grid;
  gap: 4px;
  border-radius: 8px;
  overflow: hidden;
}
.dc-gallery.n1 {
  grid-template-columns: 1fr;
}
.dc-gallery.n2 {
  grid-template-columns: 1fr 1fr;
}
.dc-gallery.n3,
.dc-gallery.n4 {
  grid-template-columns: 1fr 1fr;
}
.dc-gallery.n3 .dc-media:first-child {
  grid-row: span 2;
  height: 100%;
}
.dc-media {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  background: #1e1f22;
  min-height: 60px;
}
.dc-media.broken {
  min-height: 90px;
  background:
    repeating-linear-gradient(45deg, #1e1f22, #1e1f22 10px, #232428 10px, #232428 20px);
}
.dc-thumb {
  width: 84px;
  height: 84px;
  border-radius: 8px;
  overflow: hidden;
  flex: none;
}
.dc-thumb .dc-media {
  height: 100%;
}
.dc-section {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}
.dc-section-body {
  min-width: 0;
  flex: 1;
}
.dc-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.dc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 2px 16px;
  border: 0;
  border-radius: 3px;
  font: 500 14px/16px "gg sans", "Noto Sans", "Segoe UI", sans-serif;
  color: #fff;
  cursor: default;
}
.dc-btn.primary {
  background: #5865f2;
}
.dc-btn.secondary {
  background: #4e5058;
}
.dc-btn.success {
  background: #248046;
}
.dc-btn.danger {
  background: #da373c;
}
.dc-btn.link {
  background: #4e5058;
}
.dc-btn.disabled {
  opacity: 0.5;
}
.dc-btn svg {
  width: 15px;
  height: 15px;
}
.dc-emoji-u {
  font-size: 1.15em;
}
.dc-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 40px;
  border-radius: 4px;
  background: #1e1f22;
  color: #949ba4;
  border: 1px solid #1e1f22;
  max-width: 400px;
}
.dc-select svg {
  width: 18px;
  height: 18px;
}

.menu-item svg { width: 18px; height: 18px; flex: none; color: var(--brand); }
.menu-item > div { min-width: 0; }
.menu-item.grow-item { cursor: default; }
.studio-bar .select { width: auto; flex: 0 1 260px; }
.studio-bar .input { flex: 0 1 220px; }

/* Operations composer workspace ------------------------------------------------------- */
.studio.studio-workspace {
  /* The writing surface is the primary area.  The two supporting columns have
     firm, modest bounds so the editor never becomes a narrow, empty-looking
     strip on normal desktop displays. */
  grid-template-columns: minmax(270px, 300px) minmax(520px, 1fr) minmax(340px, 400px);
  gap: 18px;
  align-items: start;
}
.studio-rail { min-width: 0; }
.studio-editor {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255,255,255,.025), transparent 180px), var(--panel);
}
.studio-editor-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 14px;
}
.studio-editor-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 12px; min-width: 0; }
.studio-editor-h small { font-size: 11.5px; }
.studio-workspace .block { box-shadow: 0 10px 24px rgba(0,0,0,.08); }
.studio-workspace .block-h { background: rgba(255,255,255,.018); border-bottom: 1px solid rgba(255,255,255,.035); }
.studio-workspace .block-b { padding-top: 14px; }
.studio-workspace .preview-col > .card:first-child { border-color: rgba(255,61,127,.3); box-shadow: 0 16px 36px rgba(0,0,0,.18); }
.studio-workspace .preview-shell { min-height: 280px; }
.studio-sidecar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
  align-items: start;
}
.studio-sidecar .card-h { padding-top: 15px; }
.studio-sidecar .card-b { padding-bottom: 16px; }
.studio-rail .textarea { min-height: 116px; }
.studio-rail .card-b { padding: 18px 20px 20px; }
.studio-rail .swatches { gap: 9px; }
.studio-rail .swatch { width: 27px; height: 27px; }
.studio-rail .markdown-tools { padding: 3px 0 1px; }
.markdown-tools .btn { min-width: 28px; padding-inline: 7px; font-size: 11px; }
.markdown-tools .btn[title="Code"], .markdown-tools .btn[title="Spoiler"] { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
/* At browser zoom or medium desktop widths, preserve a deliberate reading
   order: controls, writer, then preview.  Keeping the writer above the
   preview prevents a blank centre column while composing. */
@media (max-width: 1480px) {
  .studio.studio-workspace {
    grid-template-columns: minmax(270px, 300px) minmax(0, 1fr);
    align-items: start;
  }
  .studio-workspace .studio-rail { grid-column: 1; grid-row: 1 / span 2; }
  .studio-workspace .studio-editor { grid-column: 2; grid-row: 1; }
  .studio-workspace .preview-col { grid-column: 2; grid-row: 2; position: static; max-height: none; }
}
@media (max-width: 1180px) {
  .studio-sidecar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1060px) {
  .studio.studio-workspace { grid-template-columns: 1fr; }
  .studio-workspace .studio-rail,
  .studio-workspace .preview-col,
  .studio-workspace .studio-editor { grid-column: auto; grid-row: auto; }
  .studio-sidecar { grid-template-columns: 1fr; }
}


/* Message studio: clean two-column layout ------------------------------------------------ */
.ms-bar {
  position: sticky;
  top: calc(var(--topbar, 60px) + 8px);
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 18px;
}
.ms-bar-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex: 1 1 300px;
  min-width: 0;
}
.ms-bar-fields .input {
  flex: 1 1 150px;
  max-width: 190px;
  min-width: 0;
}
.ms-bar-fields .select {
  flex: 1 1 170px;
  max-width: 230px;
  min-width: 0;
  width: auto;
}
.ms-bar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.ms-jump {
  display: none;
}
.ms-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  gap: 18px;
  align-items: start;
}
.ms-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.ms-preview {
  position: sticky;
  top: calc(var(--topbar, 60px) + 88px);
  max-height: calc(100vh - var(--topbar, 60px) - 108px);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.ms-preview > .card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-color: rgba(255, 61, 127, 0.3);
}
.ms-preview .preview-shell {
  flex: 1 1 auto;
  min-height: 240px;
  margin: 14px 16px 0;
}
@media (max-width: 1100px) {
  .ms-grid {
    grid-template-columns: 1fr;
  }
  .ms-preview {
    position: static;
    max-height: none;
  }
  .ms-jump {
    display: inline-flex;
  }
  .ms-bar {
    position: static;
  }
}
@media (max-width: 640px) {
  .ms-bar-actions {
    width: 100%;
    margin-left: 0;
  }
  .ms-bar-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
  .ms-bar-fields .input,
  .ms-bar-fields .select {
    max-width: none;
    flex-basis: 100%;
  }
}
.ms-settings {
  padding: 0;
  overflow: hidden;
}
.ms-sec + .ms-sec {
  border-top: 1px solid var(--line);
}
.ms-sec summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 20px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  user-select: none;
}
.ms-sec summary::-webkit-details-marker {
  display: none;
}
.ms-sec summary:hover {
  background: rgba(255, 255, 255, 0.025);
}
.ms-sec summary .chev {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--muted);
  transition: transform 0.2s var(--ease, ease);
}
.ms-sec[open] summary .chev {
  transform: rotate(180deg);
}
.ms-sec-b {
  padding: 2px 20px 20px;
}
.ms-sum {
  margin-left: auto;
  font-size: 13px;
  font-weight: 400;
}
.ms-color {
  margin-left: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--c, #ff3d7f);
  border: 1px solid var(--line-2);
}
.ms-sec .textarea {
  min-height: 110px;
}
.ms-blocks .card-h {
  align-items: baseline;
}
.ms-add {
  border-top: 1px dashed var(--line-2);
  padding-top: 16px;
}
.ms-add .label {
  margin-bottom: 10px;
}
.ms-library {
  margin-top: 18px;
}
.ms-library .card-h {
  padding-bottom: 6px;
}
.ms-library .tabs {
  flex-wrap: wrap;
}
.block-h .btn.icon {
  flex: none;
}
@media (min-width: 641px) {
  .ms-bar-fields {
    flex: 0 1 auto;
    flex-wrap: nowrap;
  }
  .ms-bar-fields .input {
    flex: 0 1 160px;
    width: 160px;
  }
  .ms-bar-fields .select {
    flex: 0 1 200px;
    width: 200px;
  }
}

.ms-source {
  align-items: flex-start;
  margin-bottom: 18px;
}
.ms-warn {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--warn);
}
