/* 블록 레시피 도우미 — 데스크톱 폭 계약(720~960px) 준수, 모바일 360px 안전 */

.br-wrap {
  max-width: 880px;
  margin: 0 auto;
}

.br-header {
  text-align: center;
  margin-bottom: 1.5rem;
}
.br-title {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  color: var(--color-ink-primary, #1f2333);
}
.br-sub {
  margin-top: 0.5rem;
  color: var(--color-ink-secondary, #4b5168);
  line-height: 1.6;
}
.br-kit {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--color-ink-tertiary, #6b7280);
}

.br-card {
  background: var(--color-surface, #ffffff);
  border: 1px solid rgba(51, 65, 85, 0.14);
  border-radius: 8px;
  padding: 1.4rem;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.07);
  max-width: 100%;
  box-sizing: border-box;
}

.br-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.br-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.br-field > label,
.br-field-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-ink-primary, #1f2333);
}

.br-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.75rem 0.85rem;
  font-size: 1rem;
  line-height: 1.5;
  border: 1.5px solid rgba(51, 65, 85, 0.22);
  border-radius: 8px;
  background: #fff;
  color: #1f2333;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.br-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}
.br-textarea {
  resize: vertical;
  min-height: 3.2rem;
}

.br-hint {
  font-size: 0.82rem;
  color: var(--color-ink-tertiary, #6b7280);
}

.br-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
}

.br-choice {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.br-choice label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.7rem;
  border: 1.5px solid rgba(99, 102, 141, 0.22);
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  background: #fff;
}
.br-choice input[type="radio"] {
  accent-color: #0f766e;
}

.br-submit {
  width: 100%;
  min-height: 48px;
  padding: 0.85rem 1.2rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  background: #0f766e;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: filter 160ms ease, transform 120ms ease;
}
.br-submit:hover { filter: brightness(1.05); }
.br-submit:active { transform: translateY(1px); }
.br-submit:disabled { opacity: 0.7; cursor: progress; }

.br-error,
.br-field-error {
  color: #c2410c;
  font-size: 0.88rem;
}
.br-error {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
}

.br-result {
  margin-top: 1.4rem;
}
.br-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}
.br-result-head h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-ink-primary, #1f2333);
}
.br-copy {
  padding: 0.45rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.08);
  border: 1.5px solid rgba(37, 99, 235, 0.26);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.br-copy.is-copied {
  color: #15803d;
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.4);
}
.br-notice {
  font-size: 0.88rem;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.9rem;
}

.br-assembly {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.br-assembly-note {
  margin: 0;
  color: #475569;
  font-size: 0.9rem;
  line-height: 1.5;
}

.br-assembly-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.br-summary-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.25rem 0.55rem;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 999px;
  background: #f0fdfa;
  color: #115e59;
  font-size: 0.86rem;
  font-weight: 700;
  word-break: keep-all;
}

.br-diagram-scroller {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.br-step {
  border-top: 1px solid rgba(51, 65, 85, 0.14);
  padding-top: 1rem;
}

.br-step:first-child {
  border-top: 0;
  padding-top: 0;
}

.br-step-head {
  margin-bottom: 0.65rem;
}

.br-step-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: #0f172a;
}

.br-step-head p {
  margin: 0.2rem 0 0;
  color: #64748b;
  font-size: 0.88rem;
}

.br-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  min-width: min(620px, 100%);
}

.br-block {
  --block-bg: #e2e8f0;
  --block-border: rgba(15, 23, 42, 0.18);
  --block-text: #0f172a;
  position: relative;
  display: inline-block;
  max-width: 100%;
  color: var(--block-text);
  background: var(--block-bg);
  border: 1px solid var(--block-border);
  border-radius: 8px;
  box-shadow: inset 0 -2px 0 rgba(15, 23, 42, 0.12), 0 1px 2px rgba(15, 23, 42, 0.08);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.35;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.br-block--cat-control {
  --block-bg: #fbbf24;
  --block-border: #d97706;
  --block-text: #3b2600;
}

.br-block--cat-sensor {
  --block-bg: #22c55e;
  --block-border: #15803d;
  --block-text: #052e16;
}

.br-block--cat-output {
  --block-bg: #fb7185;
  --block-border: #be123c;
  --block-text: #3f0612;
}

.br-block--cat-logic {
  --block-bg: #60a5fa;
  --block-border: #2563eb;
  --block-text: #082f49;
}

.br-block--cat-debug {
  --block-bg: #a78bfa;
  --block-border: #7c3aed;
  --block-text: #2e1065;
}

.br-block--cat-missing {
  --block-bg: #e5e7eb;
  --block-border: #94a3b8;
  --block-text: #334155;
  border-style: dashed;
}

.br-block-face {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.38rem;
  min-height: 38px;
  padding: 0.5rem 0.7rem;
}

.br-block-label {
  display: inline-block;
  max-width: 100%;
}

.br-block-missing {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  color: #475569;
  background: #f8fafc;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.br-block--hat {
  border-top-left-radius: 24px;
  border-top-right-radius: 12px;
}

.br-block--hat::before {
  content: "";
  position: absolute;
  top: -11px;
  left: 14px;
  width: 58px;
  height: 22px;
  border-radius: 28px 28px 0 0;
  background: var(--block-bg);
  border: 1px solid var(--block-border);
  border-bottom: 0;
}

.br-block--command::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 34px;
  width: 34px;
  height: 8px;
  border-radius: 0 0 8px 8px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-top: 0;
}

.br-block--value {
  border-radius: 999px;
}

.br-block--boolean {
  border-radius: 0;
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 12px 100%, 0 50%);
}

.br-block--wrapper {
  display: inline-block;
  min-width: min(520px, 88vw);
  padding-bottom: 0.6rem;
}

.br-block--wrapper > .br-block-face {
  border-bottom: 1px solid rgba(15, 23, 42, 0.14);
}

.br-block-children,
.br-else-children {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0.55rem 0.65rem 0 1.1rem;
  padding: 0.45rem 0 0.45rem 0.8rem;
  border-left: 6px solid rgba(255, 255, 255, 0.75);
}

.br-else-children {
  margin-top: 0.25rem;
}

.br-else-label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  color: rgba(15, 23, 42, 0.78);
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
  font-weight: 800;
}

.br-slots,
.br-condition-slot {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.br-condition-slot {
  width: 100%;
  margin-top: 0.1rem;
}

.br-slot,
.br-condition-label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.br-slot-label,
.br-condition-label {
  color: rgba(15, 23, 42, 0.68);
  font-size: 0.72rem;
  font-weight: 900;
}

.br-slot-value {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(15, 23, 42, 0.13);
  font-weight: 800;
}

.br-block--inline {
  font-size: 0.78rem;
  vertical-align: middle;
  box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.12);
}

.br-block--inline .br-block-face {
  min-height: 28px;
  padding: 0.24rem 0.5rem;
}

.br-block--inline::before,
.br-block--inline.br-block--hat::before {
  display: none;
}

.br-missing-panel {
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  background: #f8fafc;
}

.br-missing-panel h3 {
  margin: 0 0 0.4rem;
  color: #334155;
  font-size: 0.95rem;
  font-weight: 800;
}

.br-missing-panel ul {
  margin: 0;
  padding-left: 1.1rem;
  color: #475569;
}

.br-details {
  margin-top: 1rem;
  border-top: 1px solid rgba(51, 65, 85, 0.14);
  padding-top: 0.75rem;
}

.br-details summary {
  cursor: pointer;
  color: #334155;
  font-weight: 800;
}

/* 마크다운 렌더 영역 */
.br-md-render {
  color: #2a2e3f;
  line-height: 1.7;
}
.br-md-render h2 {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 1.3rem 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid rgba(37, 99, 235, 0.18);
  color: #1d4ed8;
}
.br-md-render h3 { font-size: 1rem; font-weight: 700; margin: 1rem 0 0.4rem; }
.br-md-render ul,
.br-md-render ol { margin: 0.4rem 0 0.8rem 1.2rem; }
.br-md-render li { margin: 0.2rem 0; }
.br-md-render p { margin: 0.5rem 0; }
.br-md-render strong { color: #1f2333; }
.br-md-render table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6rem 0 1rem;
  font-size: 0.92rem;
}
.br-md-render th,
.br-md-render td {
  border: 1px solid rgba(99, 102, 141, 0.2);
  padding: 0.45rem 0.6rem;
  text-align: left;
  vertical-align: top;
}
.br-md-render th { background: rgba(37, 99, 235, 0.06); font-weight: 700; }

.br-raw {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  line-height: 1.7;
  color: #2a2e3f;
}

@media (max-width: 640px) {
  .br-grid-2 { grid-template-columns: 1fr; }
  .br-card { padding: 1.1rem; }
  .br-result-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .br-copy {
    width: 100%;
    min-height: 42px;
  }
  .br-stack {
    min-width: 0;
    width: 100%;
  }
  .br-block {
    max-width: 100%;
  }
  .br-block--wrapper {
    min-width: 0;
    width: 100%;
  }
  .br-block-children,
  .br-else-children {
    margin-left: 0.55rem;
    margin-right: 0.45rem;
    padding-left: 0.55rem;
    border-left-width: 4px;
  }
  .br-condition-slot {
    align-items: flex-start;
    flex-direction: column;
  }
}
}
