:root {
  color-scheme: dark;
  --bg: #020712;
  --panel: rgba(7, 17, 39, .94);
  --panel-deep: rgba(3, 10, 26, .97);
  --line: rgba(76, 195, 255, .22);
  --line-strong: rgba(76, 195, 255, .48);
  --cyan: #4cc3ff;
  --cyan-soft: #8cddff;
  --purple: #c43ce5;
  --violet: #8c7cff;
  --green: #47edbd;
  --gold: #ffc768;
  --red: #ff718b;
  --text: #f4f7ff;
  --muted: #9aa9c1;
  --dim: #6f7f99;
  --radius: 18px;
  --shadow: 0 24px 65px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 8%, rgba(31, 117, 255, .12), transparent 28rem),
    radial-gradient(circle at 88% 28%, rgba(196, 60, 229, .11), transparent 30rem),
    linear-gradient(rgba(2, 7, 18, .91), rgba(2, 7, 18, .98)),
    url("/aigency-dev-lab/tool-background-1.png") center / cover fixed;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.ui-shell {
  width: min(1580px, calc(100% - 36px));
  margin: 0 auto;
  padding: 18px 0 0;
}

.lab-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid rgba(76, 195, 255, .22);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(5, 15, 39, .97), rgba(13, 7, 32, .94)),
    url("/aigency-dev-lab/hero.jpg") center / cover no-repeat;
  box-shadow: var(--shadow);
  isolation: isolate;
}

.lab-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(3, 12, 33, .98), rgba(5, 12, 31, .88) 58%, rgba(22, 7, 42, .78)),
    radial-gradient(circle at 88% 22%, rgba(208, 35, 232, .2), transparent 34%);
}

.lab-hero::after {
  content: "";
  position: absolute;
  right: -92px;
  bottom: -165px;
  z-index: -1;
  width: 370px;
  height: 370px;
  border: 1px solid rgba(76, 195, 255, .2);
  border-radius: 50%;
  box-shadow:
    0 0 0 48px rgba(76, 195, 255, .025),
    0 0 0 96px rgba(208, 35, 232, .018);
}

.course-topbar {
  min-height: 76px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(76, 195, 255, .18);
  background: rgba(2, 8, 23, .9);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .26);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.course-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.course-logo {
  width: 200px;
  height: auto;
  display: block;
  object-fit: contain;
  object-position: left center;
}

.course-brand-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.course-brand-text span {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .03em;
}

.course-brand-text small {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
  line-height: 1.35;
  text-transform: uppercase;
}

.lab-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
}

.session-actions,
.output-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.model-badge {
  min-height: 36px;
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(70, 230, 168, .32);
  border-radius: 9px;
  color: #d8e5f5;
  background:
    linear-gradient(135deg, rgba(70, 230, 168, .08), rgba(76, 195, 255, .07));
  box-shadow:
    0 7px 20px rgba(0, 0, 0, .18),
    inset 0 1px 0 rgba(255, 255, 255, .05);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
  white-space: nowrap;
}

.return-lab-button {
  min-height: 38px;
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(76, 195, 255, .38);
  border-radius: 9px;
  color: #dff6ff;
  background: rgba(76, 195, 255, .08);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .2s ease, transform .2s ease, background .2s ease;
}

.return-lab-button:hover {
  border-color: var(--cyan);
  background: rgba(76, 195, 255, .14);
  transform: translateY(-1px);
}

.return-lab-icon {
  color: var(--cyan);
  font-size: 14px;
  line-height: 1;
}

.model-badge-dot,
.save-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #64748b;
  box-shadow: 0 0 0 4px rgba(100, 116, 139, .11);
}

.model-badge.connected,
.model-badge.is-connected {
  color: #eafff7;
  border-color: rgba(70, 230, 168, .48);
}

.model-badge.connected .model-badge-dot,
.model-badge.is-connected .model-badge-dot {
  background: var(--green);
  box-shadow:
    0 0 0 4px rgba(70, 230, 168, .1),
    0 0 11px rgba(70, 230, 168, .7);
}

.model-badge.error,
.model-badge.is-error {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, .38);
}

.model-badge.error .model-badge-dot,
.model-badge.is-error .model-badge-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(251, 113, 139, .1);
}

.hero-main {
  padding: clamp(22px, 3vw, 34px) clamp(24px, 3.4vw, 44px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 36px;
}

.hero-eyebrow {
  margin: 0 0 9px;
  color: #8de1ff;
  font-size: .71rem;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

.hero-main h1 {
  margin: 0;
  color: #fff;
  font-family: Montserrat, Inter, sans-serif;
  font-size: clamp(2rem, 3.6vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -.045em;
  line-height: 1.02;
}

.gradient-word {
  color: transparent;
  background: linear-gradient(92deg, #8de1ff, var(--cyan) 42%, #ec8bff);
  -webkit-background-clip: text;
  background-clip: text;
}

.hero-copy {
  max-width: 790px;
  margin: 12px 0 0;
  color: #bdc8df;
  font-size: clamp(.94rem, 1.25vw, 1.05rem);
  line-height: 1.62;
}

.hero-workflow {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(126px, 1fr));
  gap: 9px;
  list-style: none;
}

.hero-workflow li {
  min-height: 48px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 12px;
  color: #dfe7f8;
  background: rgba(4, 9, 24, .66);
  font-size: .76rem;
  font-weight: 800;
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.workflow-number {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 1px solid rgba(76, 195, 255, .38);
  border-radius: 8px;
  color: #8de1ff;
  background: rgba(76, 195, 255, .08);
  font-size: .65rem;
  font-weight: 900;
}

.session-bar,
.welcome-strip {
  margin-top: 14px;
  border: 1px solid rgba(76, 195, 255, .16);
  background: rgba(4, 12, 30, .82);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .2);
}

.session-bar {
  min-height: 62px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-radius: 14px;
}

.session-status {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.save-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(71, 237, 189, .6);
}
.save-dot.saving { background: var(--gold); }
.session-status strong { display: block; font-size: .78rem; }
.session-status span { display: block; margin-top: 2px; color: var(--dim); font-size: .65rem; }

.lab-button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid rgba(76, 195, 255, .38);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(14, 75, 116, .82), rgba(31, 40, 93, .88));
  color: #f5f8ff;
  cursor: pointer;
  font-size: .7rem;
  font-weight: 800;
  transition: transform .16s ease, border-color .16s ease, filter .16s ease;
}
.lab-button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--cyan); filter: brightness(1.08); }
.lab-button:disabled { opacity: .55; cursor: wait; }
.lab-button.subtle { background: rgba(6, 16, 37, .76); color: #bac7dc; }
.lab-button.primary { background: linear-gradient(110deg, #188dd0, #875de4 58%, #b932cf); box-shadow: 0 10px 26px rgba(112, 65, 218, .23); }
.lab-button.danger { border-color: rgba(255, 113, 139, .55); background: rgba(116, 24, 47, .72); }
.lab-button.compact { min-height: 34px; align-self: flex-end; }
.lab-button.full { width: 100%; justify-content: center; }

.welcome-strip {
  padding: 13px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 14px;
}
.welcome-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(71, 237, 189, .28);
  border-radius: 10px;
  background: rgba(20, 104, 91, .18);
  color: var(--green);
}
.welcome-strip strong { display: block; color: #dffdf5; font-size: .78rem; }
.welcome-strip p { margin: 3px 0 0; color: #91a9b4; font-size: .68rem; line-height: 1.45; }

.workspace-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(280px, .88fr) minmax(330px, 1.08fr) minmax(360px, 1.12fr);
  gap: 14px;
  align-items: stretch;
}

.studio-panel {
  min-width: 0;
  height: 810px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(7, 17, 40, .97), rgba(3, 10, 26, .97));
  box-shadow: var(--shadow);
}

.panel-header {
  min-height: 74px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  border-bottom: 1px solid rgba(76, 195, 255, .17);
  background: rgba(10, 24, 52, .6);
}

.panel-title { min-width: 0; display: flex; align-items: center; gap: 11px; }
.panel-number {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(76, 195, 255, .45);
  border-radius: 11px;
  background: rgba(22, 101, 149, .16);
  color: var(--cyan);
  font: 800 .68rem Montserrat, sans-serif;
}
.panel-number.purple { color: #d98bec; border-color: rgba(196, 60, 229, .42); background: rgba(122, 40, 145, .16); }
.panel-number.green { color: var(--green); border-color: rgba(71, 237, 189, .4); background: rgba(27, 124, 102, .16); }
.panel-title h2 { margin: 0; font: 800 .84rem/1.25 Montserrat, sans-serif; }
.panel-title p { margin: 3px 0 0; color: var(--muted); font-size: .62rem; line-height: 1.35; }
.count-badge, .connection-label, .map-state {
  padding: 5px 8px;
  flex: 0 0 auto;
  border: 1px solid rgba(142, 124, 255, .28);
  border-radius: 999px;
  background: rgba(50, 32, 95, .38);
  color: #d9cffb;
  font-size: .57rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.panel-body {
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--cyan) rgba(255, 255, 255, .04);
}
.panel-body::-webkit-scrollbar, .conversation::-webkit-scrollbar, .map-content::-webkit-scrollbar { width: 5px; }
.panel-body::-webkit-scrollbar-thumb, .conversation::-webkit-scrollbar-thumb, .map-content::-webkit-scrollbar-thumb { border-radius: 99px; background: linear-gradient(var(--cyan), var(--purple)); }

.field-label, .choice-group legend, .output-label {
  display: block;
  margin: 0 0 7px;
  color: #dce5f5;
  font-size: .67rem;
  font-weight: 750;
}
.field-label:not(:first-child), .output-label:not(:first-child) { margin-top: 14px; }
.field-label span, .choice-group legend span { color: var(--dim); font-weight: 500; }

.lab-input, .lab-select, .lab-textarea, .composer textarea, .output-area {
  width: 100%;
  border: 1px solid rgba(76, 195, 255, .25);
  border-radius: 10px;
  outline: none;
  background: rgba(1, 7, 20, .82);
  color: #edf4ff;
  font-size: .71rem;
  line-height: 1.5;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.lab-input, .lab-select { height: 40px; padding: 0 11px; }
.lab-select { appearance: auto; }
.lab-textarea, .output-area { padding: 10px 11px; resize: vertical; }
.lab-input:focus, .lab-select:focus, .lab-textarea:focus, .composer textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(76, 195, 255, .09); }
::placeholder { color: #61718b; }
.code-input, .code-output { font-family: "SFMono-Regular", Consolas, monospace; }

.field-grid { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-group {
  margin: 15px 0 0;
  padding: 12px;
  display: grid;
  gap: 9px;
  border: 1px solid rgba(142, 124, 255, .2);
  border-radius: 11px;
  background: rgba(28, 20, 64, .18);
}
.choice-group legend { padding: 0 5px; margin: 0; }
.choice-group label { display: flex; align-items: flex-start; gap: 8px; color: #aebbd0; font-size: .65rem; line-height: 1.4; }
.choice-group input { margin: 2px 0 0; accent-color: var(--cyan); }

.drop-zone {
  min-height: 102px;
  margin-top: 15px;
  padding: 13px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  border: 1px dashed rgba(76, 195, 255, .42);
  border-radius: 12px;
  background: rgba(12, 52, 78, .13);
  text-align: center;
  cursor: pointer;
}
.drop-zone.dragging { border-color: var(--green); background: rgba(29, 113, 91, .18); }
.drop-icon { color: var(--cyan); font-size: 1.25rem; }
.drop-zone strong { font-size: .7rem; }
.drop-zone small { color: var(--dim); font-size: .58rem; line-height: 1.4; }

.evidence-warning {
  margin-top: 10px;
  padding: 9px 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid rgba(255, 199, 104, .16);
  border-radius: 9px;
  background: rgba(103, 67, 13, .12);
}
.evidence-warning span { color: var(--gold); font-weight: 900; }
.evidence-warning p { margin: 0; color: #a99879; font-size: .58rem; line-height: 1.45; }

.source-list { margin-top: 10px; display: grid; gap: 7px; }
.source-item {
  padding: 8px 9px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(76, 195, 255, .14);
  border-radius: 9px;
  background: rgba(3, 11, 26, .68);
}
.source-item strong { display: block; overflow: hidden; color: #cfd9e9; font-size: .62rem; text-overflow: ellipsis; white-space: nowrap; }
.source-item small { display: block; margin-top: 2px; color: var(--dim); font-size: .55rem; }
.remove-source {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 113, 139, .08);
  color: #dc8b9b;
  cursor: pointer;
}

.paste-source { margin-top: 10px; border: 1px solid rgba(142, 124, 255, .18); border-radius: 10px; background: rgba(18, 12, 44, .17); }
.paste-source summary { padding: 10px 12px; color: #aebbd0; cursor: pointer; font-size: .64rem; font-weight: 700; }
.paste-fields { padding: 0 11px 11px; display: grid; gap: 8px; }

.collaboration-panel { position: relative; }
.conversation {
  min-height: 0;
  padding: 16px;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--purple) rgba(255, 255, 255, .04);
}
.message { max-width: 88%; }
.message.assistant { align-self: flex-start; }
.message.user { align-self: flex-end; }
.message-role { margin: 0 0 4px 3px; color: var(--dim); font-size: .55rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.message-bubble {
  padding: 11px 13px;
  border: 1px solid rgba(76, 195, 255, .18);
  border-radius: 5px 13px 13px 13px;
  background: rgba(11, 31, 59, .72);
  color: #cad5e6;
  font-size: .7rem;
  line-height: 1.58;
  white-space: pre-wrap;
}
.message.user .message-bubble {
  border-color: rgba(196, 60, 229, .25);
  border-radius: 13px 5px 13px 13px;
  background: rgba(75, 27, 100, .45);
  color: #efe6f6;
}

.prompt-chips {
  padding: 9px 13px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 0 0 auto;
  border-top: 1px solid rgba(255, 255, 255, .05);
}
.prompt-chips button {
  padding: 6px 9px;
  border: 1px solid rgba(142, 124, 255, .22);
  border-radius: 999px;
  background: rgba(38, 26, 78, .28);
  color: #bcb1df;
  cursor: pointer;
  font-size: .57rem;
}
.prompt-chips button:hover { border-color: var(--purple); color: #fff; }

.composer { padding: 12px; flex: 0 0 auto; border-top: 1px solid var(--line); background: rgba(2, 8, 21, .8); }
.composer textarea { min-height: 82px; padding: 10px 11px; resize: none; }
.composer-footer { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.composer-footer > span { color: var(--dim); font-size: .56rem; }
.button-spinner { display: none; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.is-loading .button-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.readiness-card {
  margin: 14px 14px 10px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(76, 195, 255, .2);
  border-radius: 12px;
  background: rgba(3, 11, 29, .78);
}
.readiness-ring {
  --readiness: 0;
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle 23px, #081229 97%, transparent), conic-gradient(var(--green) calc(var(--readiness) * 1%), rgba(255,255,255,.08) 0);
}
.readiness-ring strong { font-size: .86rem; }
.readiness-card > div:last-child > strong { font-size: .7rem; }
.readiness-card p { margin: 4px 0 0; color: var(--muted); font-size: .59rem; line-height: 1.4; }

.map-counts {
  margin: 0 14px 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 9px;
  overflow: hidden;
}
.map-counts span { padding: 8px 3px; color: var(--dim); text-align: center; font-size: .52rem; }
.map-counts span + span { border-left: 1px solid rgba(255, 255, 255, .06); }
.map-counts strong { display: block; margin-bottom: 2px; color: #e9eef8; font-size: .76rem; }

.map-tabs {
  padding: 0 14px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
.map-tabs button {
  min-height: 34px;
  border: 1px solid rgba(76, 195, 255, .13);
  border-radius: 8px 8px 0 0;
  background: rgba(5, 13, 31, .55);
  color: var(--dim);
  cursor: pointer;
  font-size: .58rem;
  font-weight: 750;
}
.map-tabs button.active { border-color: rgba(76, 195, 255, .38); background: rgba(15, 70, 105, .28); color: var(--cyan-soft); }

.map-content {
  min-height: 0;
  margin: 0 14px;
  padding: 12px;
  flex: 1 1 auto;
  overflow-y: auto;
  border: 1px solid rgba(76, 195, 255, .14);
  border-radius: 0 0 11px 11px;
  background: rgba(2, 8, 21, .55);
  scrollbar-width: thin;
}
.map-summary {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid rgba(71, 237, 189, .14);
  border-radius: 9px;
  background: rgba(18, 84, 69, .1);
  color: #a7c7bf;
  font-size: .62rem;
  line-height: 1.5;
}
.empty-copy { color: var(--dim); }

.record-list, .role-list, .security-rule-list, .relationship-list { display: grid; gap: 9px; }
.record-card, .role-card, .relationship-card, .security-card {
  padding: 11px;
  border: 1px solid rgba(76, 195, 255, .16);
  border-radius: 10px;
  background: rgba(7, 18, 39, .74);
}
.record-heading, .role-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 9px;
}
.record-card h3, .role-card h3, .relationship-card h3, .security-card h3 { margin: 0; color: #eef4ff; font-size: .7rem; }
.record-card p, .role-card p, .relationship-card p, .security-card p { margin: 4px 0 0; color: var(--muted); font-size: .58rem; line-height: 1.45; }
.ownership-chip {
  padding: 4px 7px;
  border: 1px solid rgba(71, 237, 189, .2);
  border-radius: 999px;
  color: var(--green);
  font-size: .5rem;
  white-space: nowrap;
}
.field-table { width: 100%; margin-top: 9px; border-collapse: collapse; font-size: .55rem; }
.field-table th { padding: 5px; color: var(--dim); text-align: left; border-bottom: 1px solid rgba(255,255,255,.07); }
.field-table td { padding: 6px 5px; color: #afbdd2; vertical-align: top; border-bottom: 1px solid rgba(255,255,255,.045); }
.field-table code { color: var(--cyan-soft); font-size: .53rem; }
.sensitive-mark { color: var(--gold); }

.connection-list,
.workflow-list,
.safeguard-list,
.mapping-list {
  display: grid;
  gap: 9px;
}

.connection-card,
.workflow-card,
.safeguard-card,
.mapping-card {
  padding: 11px;
  border: 1px solid rgba(76, 195, 255, .16);
  border-radius: 10px;
  background: rgba(7, 18, 39, .74);
}

.connection-heading,
.workflow-heading,
.safeguard-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 9px;
}

.connection-card h3,
.workflow-card h3,
.safeguard-card h3,
.mapping-card h3 {
  margin: 0;
  color: #eef4ff;
  font-size: .7rem;
}

.connection-card p,
.workflow-card p,
.safeguard-card p,
.mapping-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .58rem;
  line-height: 1.45;
}

.direction-chip,
.risk-chip {
  padding: 4px 7px;
  border: 1px solid rgba(71, 237, 189, .2);
  border-radius: 999px;
  color: var(--green);
  font-size: .5rem;
  white-space: nowrap;
}

.risk-chip.high {
  border-color: rgba(255, 113, 139, .3);
  color: var(--red);
}

.risk-chip.medium {
  border-color: rgba(255, 199, 104, .3);
  color: var(--gold);
}

.detail-grid {
  margin-top: 9px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.detail-grid div {
  padding: 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .025);
}

.detail-grid strong {
  display: block;
  margin-bottom: 3px;
  color: var(--dim);
  font-size: .48rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.detail-grid span {
  display: block;
  color: #bac7da;
  font-size: .55rem;
  line-height: 1.4;
}

.flow-steps {
  margin: 9px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
  list-style: none;
}

.flow-steps li {
  padding: 7px 8px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 7px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .025);
  color: #aebbd0;
  font-size: .55rem;
  line-height: 1.4;
}

.flow-steps li > span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(76, 195, 255, .22);
  border-radius: 6px;
  color: var(--cyan);
  font-size: .48rem;
}

.flow-steps strong {
  display: block;
  color: #d5deeb;
  font-size: .56rem;
}

.list-output {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 7px;
}

.list-output li {
  color: #a9b7cb;
  font-size: .6rem;
  line-height: 1.5;
}

.check-list,
.asset-list,
.recovery-list,
.dependency-list,
.variable-list,
.maintenance-list {
  display: grid;
  gap: 9px;
}

.check-card,
.asset-card,
.recovery-card,
.dependency-card,
.variable-card,
.maintenance-card {
  padding: 11px;
  border: 1px solid rgba(76, 195, 255, .16);
  border-radius: 10px;
  background: rgba(7, 18, 39, .74);
}

.check-heading,
.asset-heading,
.recovery-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 9px;
}

.check-card h3,
.asset-card h3,
.recovery-card h3,
.dependency-card h3,
.variable-card h3,
.maintenance-card h3 {
  margin: 0;
  color: #eef4ff;
  font-size: .7rem;
}

.check-card p,
.asset-card p,
.recovery-card p,
.dependency-card p,
.variable-card p,
.maintenance-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .58rem;
  line-height: 1.45;
}

.status-chip {
  padding: 4px 7px;
  border: 1px solid rgba(255, 199, 104, .27);
  border-radius: 999px;
  color: var(--gold);
  font-size: .5rem;
  white-space: nowrap;
}

.status-chip.ready {
  border-color: rgba(71, 237, 189, .3);
  color: var(--green);
}

.status-chip.blocked {
  border-color: rgba(255, 113, 139, .34);
  color: var(--red);
}

.status-chip.verify {
  border-color: rgba(76, 195, 255, .3);
  color: var(--cyan);
}

.asset-meta,
.recovery-meta {
  margin-top: 9px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.asset-meta div,
.recovery-meta div {
  padding: 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .025);
}

.asset-meta strong,
.recovery-meta strong {
  display: block;
  margin-bottom: 3px;
  color: var(--dim);
  font-size: .48rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.asset-meta span,
.recovery-meta span {
  color: #bac7da;
  font-size: .55rem;
  line-height: 1.4;
}

.document-output {
  min-height: 190px;
}

.visual-upload {
  margin-top: 15px;
}

.visual-grid {
  margin-top: 9px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.visual-card {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(76, 195, 255, .18);
  border-radius: 9px;
  background: #020713;
}

.visual-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.visual-card button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(255, 113, 139, .35);
  border-radius: 8px;
  background: rgba(25, 5, 15, .88);
  color: #ff9aaa;
  cursor: pointer;
}

.visual-card span {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 5px 6px;
  overflow: hidden;
  background: linear-gradient(transparent, rgba(0, 4, 14, .94));
  color: #dce7f7;
  font-size: .5rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finding-list,
.token-list,
.component-list,
.layout-list,
.accessibility-list {
  display: grid;
  gap: 9px;
}

.finding-card,
.token-card,
.component-card,
.layout-card,
.accessibility-card {
  padding: 11px;
  border: 1px solid rgba(76, 195, 255, .16);
  border-radius: 10px;
  background: rgba(7, 18, 39, .74);
}

.finding-heading,
.token-heading,
.component-heading,
.accessibility-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 9px;
}

.finding-card h3,
.token-card h3,
.component-card h3,
.layout-card h3,
.accessibility-card h3 {
  margin: 0;
  color: #eef4ff;
  font-size: .7rem;
}

.finding-card p,
.token-card p,
.component-card p,
.layout-card p,
.accessibility-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .58rem;
  line-height: 1.45;
}

.score-chip {
  padding: 4px 7px;
  border: 1px solid rgba(255, 199, 104, .3);
  border-radius: 999px;
  color: var(--gold);
  font-size: .5rem;
  white-space: nowrap;
}

.score-chip.strong {
  border-color: rgba(71, 237, 189, .3);
  color: var(--green);
}

.score-chip.needs_work {
  border-color: rgba(255, 113, 139, .34);
  color: var(--red);
}

.token-swatch {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 7px;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.2);
}

.token-value {
  color: var(--cyan-soft) !important;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.compact-list {
  margin: 8px 0 0;
  padding-left: 17px;
  display: grid;
  gap: 5px;
}

.compact-list li {
  color: #a9b7cb;
  font-size: .55rem;
  line-height: 1.42;
}

.permission-list { margin-top: 9px; display: grid; gap: 6px; }
.permission-row { padding: 7px; border-radius: 8px; background: rgba(255,255,255,.025); }
.permission-row strong { display: block; color: #cad6e8; font-size: .57rem; }
.permission-flags { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; }
.permission-flags span { padding: 3px 5px; border-radius: 5px; background: rgba(255, 255, 255, .05); color: var(--dim); font-size: .48rem; }
.permission-flags span.allowed { background: rgba(71, 237, 189, .1); color: var(--green); }
.permission-condition { margin-top: 5px !important; color: #8698b2 !important; }
.section-caption { margin: 14px 0 7px; color: var(--purple); font-size: .57rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.output-area { min-height: 145px; resize: vertical; font-size: .6rem; }
.output-actions { margin: 7px 0 13px; }
.output-actions .lab-button { flex: 1; min-height: 34px; padding: 0 8px; font-size: .58rem; }

.map-footer { padding: 12px 14px 14px; flex: 0 0 auto; }
.map-footer p { margin: 7px 0 0; color: var(--dim); text-align: center; font-size: .53rem; line-height: 1.4; }

.course-footer {
  margin-top: 30px;
  padding: 35px 20px 45px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-top: 1px solid rgba(76, 195, 255, .14);
  color: var(--muted);
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  text-align: center;
}

.course-footer img {
  width: 170px;
  height: auto;
  object-fit: contain;
}

.course-footer p {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.course-footer span {
  font-size: 11px;
  line-height: 1.5;
}

.course-footer .footer-copyright {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.confirm-dialog {
  width: min(430px, calc(100% - 28px));
  padding: 0;
  border: 1px solid rgba(76, 195, 255, .35);
  border-radius: 16px;
  background: #071127;
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0,0,0,.65);
}
.confirm-dialog::backdrop { background: rgba(0, 3, 12, .78); backdrop-filter: blur(4px); }
.confirm-content { padding: 22px; }
.confirm-content h2 { margin-bottom: 8px; font-size: 1rem; }
.confirm-content p { color: var(--muted); font-size: .7rem; line-height: 1.55; }
.confirm-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 8px; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; }
.toast {
  max-width: 340px;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(5, 17, 39, .97);
  color: #dce8f7;
  box-shadow: 0 15px 40px rgba(0,0,0,.45);
  font-size: .67rem;
}
.toast.error { border-color: rgba(255, 113, 139, .48); }
.toast.success { border-color: rgba(71, 237, 189, .45); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1250px) {
  .workspace-grid { grid-template-columns: 1fr 1fr; }
  .map-panel { grid-column: 1 / -1; height: 760px; }
}

@media (max-width: 980px) {
  .hero-main { grid-template-columns: minmax(0, 1fr); }
  .hero-workflow { max-width: 590px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hero-workflow li { justify-content: center; }
}

@media (max-width: 900px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .studio-panel, .map-panel { grid-column: auto; height: 750px; }
}

@media (max-width: 640px) {
  .ui-shell { width: min(100% - 20px, 1580px); padding-top: 10px; }
  .lab-hero { border-radius: 17px; }
  .course-topbar { min-height: 68px; padding: 9px 13px; }
  .course-brand-text { display: none; }
  .course-logo { width: 135px; height: 44px; }
  .model-badge { min-height: 34px; padding: 8px 10px; }
  .lab-header-actions { gap: 7px; }
  .return-lab-button { width: 38px; padding: 8px; }
  .return-lab-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .model-name { display: none; }
  .hero-main { padding: 20px 18px 22px; }
  .hero-workflow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-workflow li { min-width: 0; justify-content: flex-start; }
  .session-bar { align-items: stretch; flex-direction: column; }
  .session-actions { display: grid; grid-template-columns: repeat(3, 1fr); }
  .session-actions .lab-button { min-width: 0; padding: 0 7px; font-size: .61rem; }
  .welcome-strip { align-items: flex-start; }
  .studio-panel, .map-panel { height: 720px; }
  .field-grid { grid-template-columns: 1fr; }
  .map-tabs button { font-size: .53rem; }
  .output-actions { flex-direction: column; align-items: stretch; }
  .course-footer { padding-bottom: 34px; }
}
