/* Built-in W3Schools Tryit-Inspired Live Web Compiler */
body.lc-fs-open {
  overflow: hidden;
}

.lc-card {
  container-type: inline-size;
  container-name: lc;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--line2, #e2e8f0);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
  overflow: hidden;
  color: var(--ink, #0f172a);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.lc-card.fullscreen {
  position: fixed;
  inset: 12px;
  z-index: 1200;
  height: auto !important;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.25);
}

.lc-card.fullscreen .lc-main {
  flex: 1;
  min-height: 0;
}

/* Clean Docs-Style Workbench Header */
.lc-top {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card2, #f8fafc);
  border-bottom: 1px solid var(--line2, #e2e8f0);
}
.lc-top.compact {
  padding: 8px 12px;
}

.lc-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lc-kicker {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-text, #047857);
}

.lc-prompt {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--sub, #475569);
  font-weight: 500;
}

.lc-inline-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--line2, #e2e8f0);
  color: var(--ink, #0f172a);
}

.lc-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.lc-act-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lc-act-utils {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}

.lc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line, #cbd5e1);
  background: var(--surface, #ffffff);
  color: var(--ink, #0f172a);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.lc-btn:hover {
  background: var(--card, #f1f5f9);
  border-color: var(--line, #94a3b8);
}

.lc-btn.util,
.lc-btn.ghost,
.lc-btn.verify {
  background: var(--surface, #ffffff);
  border: 1px solid var(--line, #cbd5e1);
  color: var(--ink, #0f172a);
}
.lc-btn.util:hover,
.lc-btn.ghost:hover,
.lc-btn.verify:hover {
  background: var(--card, #f1f5f9);
  border-color: var(--accent, #0062c4);
  color: var(--ink, #0f172a);
}

.lc-btn.run {
  background: #047857;
  border-color: #047857;
  color: #ffffff;
  padding: 6px 14px;
  font-weight: 700;
}
.lc-btn.run:hover {
  background: #065f46;
  border-color: #065f46;
}

/* Mobile Pane Switcher */
.lc-pane-switch {
  display: none;
  gap: 6px;
  padding: 7px 12px;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
}

.lc-pane-btn {
  flex: 1;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line, #cbd5e1);
  background: var(--surface, #ffffff);
  color: var(--ink, #0f172a);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.lc-pane-btn.active {
  background: #047857;
  border-color: #047857;
  color: #ffffff;
}

.lc-checks-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.lc-checks-bar:empty,
.lc-checks-bar[hidden],
.lc-console[hidden] {
  display: none;
}

.lc-chk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #64748b;
}

.lc-chk.pass {
  border-color: #04AA6D;
  background: #ecfdf5;
  color: #047857;
  font-weight: 600;
}

.lc-chk.fail {
  border-color: #dc2626;
  background: #fef2f2;
  color: #dc2626;
  font-weight: 600;
}

.lc-fb {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
}

.lc-fb.ok { color: #047857; }
.lc-fb.no { color: #dc2626; }

.lc-hint-box {
  padding: 9px 14px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  font-size: 13px;
  line-height: 1.45;
}

.lc-main {
  flex: 1;
  min-height: 430px;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.lc-main.stacked {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(210px, 255px) minmax(260px, 340px);
  min-height: 0;
}
.lc-main.stacked .lc-editor-pane {
  border-right: 0;
  border-bottom: 1px solid var(--line2, #e2e8f0);
}
.lc-card.fullscreen .lc-main.stacked {
  grid-template-rows: 1fr 1fr;
}

/* Clean Code Editor Pane */
.lc-editor-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line2, #e2e8f0);
  background: var(--surface, #ffffff);
}

.lc-tabs {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.lc-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #334155;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  min-height: 44px;
}

.lc-tab.active {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.lc-tab-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.lc-snippets {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.lc-chip, .lc-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--line, #cbd5e1);
  background: var(--surface, #ffffff);
  color: var(--ink, #0f172a);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.lc-chip:hover, .lc-copy-btn:hover {
  border-color: #04AA6D;
  background: #04AA6D;
  color: #ffffff;
}

.lc-code-wrap {
  position: relative;
  flex: 1;
  min-height: 220px;
  display: flex;
  overflow: hidden;
}

.lc-gutter {
  width: 40px;
  padding: 12px 8px 12px 0;
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre;
  color: #94a3b8;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  user-select: none;
  overflow: hidden;
  flex: none;
}

.lc-textarea {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 12px 14px;
  border: 0;
  outline: none;
  resize: none;
  background: #ffffff;
  color: #0f172a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.55;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}

/* Optional Dark Code Editor Mode (toggled via ◐ Dark) */
.lc-card.dark-ed .lc-editor-pane { background: #1e293b; }
.lc-card.dark-ed .lc-tabs { background: #0f172a; border-color: #334155; }
.lc-card.dark-ed .lc-tab { color: #94a3b8; }
.lc-card.dark-ed .lc-tab.active { background: #1e293b; border-color: #475569; color: #f8fafc; }
.lc-card.dark-ed .lc-chip, .lc-card.dark-ed .lc-copy-btn { background: #1e293b; border-color: #475569; color: #e2e8f0; }
.lc-card.dark-ed .lc-gutter { background: #0f172a; border-color: #334155; color: #64748b; }
.lc-card.dark-ed .lc-textarea { background: #1e293b; color: #f8fafc; }

/* Result Pane */
.lc-preview-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #ffffff;
}

.lc-browser-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  min-height: 44px;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.lc-res-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.lc-live-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #04AA6D;
}
.lc-live-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #04AA6D;
}

.lc-vp-btns {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
}

.lc-vp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--line, #cbd5e1);
  background: var(--surface, #ffffff);
  color: var(--ink, #0f172a);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.lc-vp.active {
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}

.lc-stage-wrap {
  flex: 1;
  min-height: 220px;
  display: flex;
  justify-content: center;
  align-items: stretch;
  background: #ffffff;
  padding: 6px;
  overflow: auto;
}

.lc-iframe {
  width: 100%;
  height: 100%;
  min-height: 220px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #ffffff;
  transition: width 0.2s ease;
}

.lc-iframe.vp-tablet { width: 640px; max-width: 100%; border-color: #cbd5e1; }
.lc-iframe.vp-mobile { width: 375px; max-width: 100%; border-color: #cbd5e1; }

.lc-console {
  height: 115px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: #0f172a;
  border-top: 1px solid var(--line2, #e2e8f0);
  color: #f8fafc;
}

.lc-console.collapsed {
  height: 30px;
  background: var(--card2, #f8fafc);
}

.lc-console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  background: #1e293b;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  cursor: pointer;
  flex: none;
}

.lc-console.collapsed .lc-console-head {
  background: var(--card2, #f8fafc);
  color: var(--sub, #475569);
}

html[data-theme="dark"] .lc-checks-bar,
html[data-theme="dark"] .lc-tabs,
html[data-theme="dark"] .lc-browser-bar,
html[data-theme="dark"] .lc-pane-switch {
  background: var(--card2, #0f172a);
  border-color: var(--line, #334155);
}
html[data-theme="dark"] .lc-tab {
  color: #cbd5e1;
}
html[data-theme="dark"] .lc-tab.active,
html[data-theme="dark"] .lc-chk,
html[data-theme="dark"] .lc-vp,
html[data-theme="dark"] .lc-chip,
html[data-theme="dark"] .lc-copy-btn {
  background: var(--surface, #111827);
  border-color: var(--line, #334155);
  color: var(--ink, #f1f5f9);
}
html[data-theme="dark"] .lc-vp.active {
  background: #f1f5f9;
  border-color: #f1f5f9;
  color: #0f172a;
}
html[data-theme="dark"] .lc-res-label { color: var(--ink, #f1f5f9); }
html[data-theme="dark"] .lc-gutter { background: #0b1120; border-color: #1e293b; }
html[data-theme="dark"] .lc-textarea { background: #111827; color: #f1f5f9; }
html[data-theme="dark"] .lc-stage-wrap { background: #0f172a; }
html[data-theme="dark"] .lc-console.collapsed,
html[data-theme="dark"] .lc-console.collapsed .lc-console-head {
  background: #0f172a;
  color: #94a3b8;
}

.lc-console-logs {
  flex: 1;
  overflow: auto;
  padding: 6px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.45;
}

.lc-log {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  white-space: pre-wrap;
  word-break: break-word;
}
.lc-log.warn { color: #facc15; }
.lc-log.error { color: #f87171; }

/* ---------- Container & Viewport Responsive Rules ---------- */
@container lc (max-width: 740px) {
  .lc-pane-switch { display: flex; }
  .lc-main {
    grid-template-columns: 1fr;
    grid-template-rows: 260px 320px;
    min-height: 0;
  }
  .lc-main[data-pane="code"] { grid-template-rows: 380px; }
  .lc-main[data-pane="code"] .lc-preview-pane { display: none; }
  .lc-main[data-pane="preview"] { grid-template-rows: 380px; }
  .lc-main[data-pane="preview"] .lc-editor-pane { display: none; }
  .lc-editor-pane { border-right: 0; border-bottom: 6px solid #e7e9eb; }
  .lc-fb { margin-left: 0; width: 100%; }
  .lc-icon-btn { display: none; }
}

@media (max-width: 860px) {
  .lc-pane-switch { display: flex; }
  .lc-main {
    grid-template-columns: 1fr;
    grid-template-rows: 260px 320px;
    min-height: 0;
  }
  .lc-main[data-pane="code"] { grid-template-rows: 380px; }
  .lc-main[data-pane="code"] .lc-preview-pane { display: none; }
  .lc-main[data-pane="preview"] { grid-template-rows: 380px; }
  .lc-main[data-pane="preview"] .lc-editor-pane { display: none; }
  .lc-editor-pane { border-right: 0; border-bottom: 6px solid #e7e9eb; }
  .lc-fb { margin-left: 0; width: 100%; }
}

@media (max-width: 560px) {
  .lc-card.fullscreen { inset: 0; border-radius: 0; }
  .lc-top { padding: 10px 12px; gap: 8px; }
  .lc-head { min-width: 100%; }
  .lc-actions { flex-direction: column; align-items: stretch; gap: 6px; }
  .lc-act-primary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }
  .lc-act-utils {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }
  .lc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    font-size: 13px;
    min-height: 44px;
  }
  .lc-btn.util { min-height: 44px; }
}
