:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f7f8;
  color: #1f2933;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  min-height: 84px;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid #d7e0e5;
  background: #ffffff;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
}

#api-label {
  margin-top: 6px;
  color: #5d6b78;
  font-size: 14px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.token-field {
  display: grid;
  gap: 4px;
  color: #40505f;
  font-size: 12px;
}

.token-field input {
  min-width: 220px;
}

.status-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #d7e0e5;
  border-radius: 6px;
  background: #f8fafb;
  white-space: nowrap;
}

.dot.warn {
  background: #c98a1f;
}

.error-banner {
  position: fixed;
  left: 18px;
  right: 18px;
  top: 84px;
  z-index: 100;
  margin: 0;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #e0a3a3;
  border-radius: 8px;
  background: #fbeaea;
  color: #7a2323;
  box-shadow: 0 4px 16px rgba(122, 35, 35, 0.12);
}

/* `.error-banner { display: flex }` is an author-stylesheet rule, so it beats
   the browser's default `[hidden] { display: none }` UA-stylesheet rule at
   equal specificity - without this, toggling the `hidden` property (e.g. the
   Dismiss button, or the initial markup before any error has occurred) has
   no visible effect and the banner shows permanently, empty. */
.error-banner[hidden] {
  display: none;
}

.error-banner pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.error-banner button {
  flex-shrink: 0;
  border-color: #cf4a4a;
  color: #b83232;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8b98a5;
}

.dot.ok {
  background: #1f9d55;
}

.dot.bad {
  background: #d64545;
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  grid-template-areas:
    "create main"
    "access access"
    "detail detail";
  gap: 16px;
  padding: 18px;
  align-items: start;
}

.main-column {
  grid-area: main;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.view-pane[hidden] {
  display: none !important;
}

.view-tabs {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid #d7e0e5;
  border-radius: 8px;
  background: #f3f6f8;
}

.view-tab {
  min-height: 34px;
  padding: 6px 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #40505f;
  cursor: pointer;
}

.view-tab.active {
  background: #ffffff;
  color: #1f2933;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
  font-weight: 600;
}

.recipes-view {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
  min-height: calc(100vh - 120px);
  align-items: stretch;
}

.recipe-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.recipe-intro {
  margin: 0;
  padding: 12px 16px 0;
  color: #526271;
  font-size: 12px;
  line-height: 1.45;
}

.recipe-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px 16px;
  overflow: auto;
  flex: 1;
}

.recipe-item {
  display: grid;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 12px;
  border: 1px solid #d7e0e5;
  border-radius: 8px;
  background: #f8fafb;
  color: #23313d;
  cursor: pointer;
}

.recipe-item:hover:not(:disabled) {
  border-color: #9eb6c5;
  background: #ffffff;
}

.recipe-item.active {
  border-color: #2f6fed;
  background: #eef4ff;
  box-shadow: inset 0 0 0 1px #2f6fed;
}

.recipe-item:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.recipe-item-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.recipe-item-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: #5d6b78;
  overflow-wrap: anywhere;
}

.recipe-item-meta {
  font-size: 11px;
  color: #6b7c8a;
}

.recipe-viewer {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.recipe-viewer-header {
  min-height: 64px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e2e8ed;
}

.recipe-subtitle {
  margin-top: 4px;
  color: #5d6b78;
  font-size: 13px;
}

.recipe-viewer-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #eef2f5;
  background: #f8fafb;
}

.recipe-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #d7e0e5;
  color: #40505f;
  font-size: 12px;
}

.recipe-chip code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: #23313d;
}

.recipe-code-wrap {
  flex: 1;
  min-height: 0;
  padding: 12px 16px 16px;
}

.recipe-content {
  margin: 0;
  height: 100%;
  min-height: 28rem;
  max-height: calc(100vh - 260px);
  overflow: auto;
  padding: 14px 16px;
  border: 1px solid #1c2733;
  border-radius: 8px;
  background: #0f1720;
  color: #e7eef5;
  font-size: 12.5px;
  line-height: 1.5;
  tab-size: 2;
}

.recipe-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

@media (max-width: 1100px) {
  .recipes-view {
    grid-template-columns: 1fr;
  }

  .recipe-content {
    max-height: 24rem;
  }
}

.panel {
  background: #ffffff;
  border: 1px solid #d7e0e5;
  border-radius: 8px;
  min-width: 0;
}

.create-panel {
  grid-area: create;
}

.workshop-intro {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #c5d4dc;
  border-radius: 10px;
  background: #eef6f8;
  font-size: 0.92rem;
  line-height: 1.45;
  color: #334e68;
}

.workshop-intro strong {
  display: block;
  margin-bottom: 6px;
  color: #1f2933;
}

.workshop-intro ol {
  margin: 0 0 8px;
  padding-left: 1.25rem;
}

.workshop-intro p {
  margin: 0;
  color: #486581;
}

.workshop-intro code {
  font-size: 0.88em;
}

.summary-panel {
  /* sits in .main-column flex stack — height follows metrics only */
  flex: 0 0 auto;
}

.sessions-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sessions-panel .table-wrap {
  flex: 1 1 auto;
  min-height: 12rem;
  max-height: min(50vh, 28rem);
}

.access-panel {
  grid-area: access;
}

.detail-panel {
  grid-area: detail;
}

.panel-header {
  min-height: 54px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e2e8ed;
}

.panel-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.form-grid {
  padding: 16px;
  display: grid;
  gap: 14px;
}

label,
fieldset {
  display: grid;
  gap: 7px;
  color: #40505f;
  font-size: 13px;
}

fieldset {
  margin: 0;
  padding: 12px;
  border: 1px solid #d7e0e5;
  border-radius: 6px;
}

legend {
  padding: 0 4px;
}

input,
select {
  min-height: 38px;
  width: 100%;
  border: 1px solid #c8d3da;
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
  color: #1f2933;
}

.checkbox-list {
  display: grid;
  gap: 8px;
}

.checkbox-list button.active {
  outline: 2px solid #2563eb;
  background: #eff6ff;
}

.catalog-form textarea {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.catalog-shell {
  display: grid;
  gap: 16px;
  padding: 18px;
  width: 100%;
  box-sizing: border-box;
}

.catalog-guide {
  overflow: hidden;
}

.build-ladder {
  margin: 0;
  padding: 12px 16px 4px 2rem;
  color: #334e68;
  font-size: 13px;
  line-height: 1.45;
}

.build-ladder li {
  margin-bottom: 6px;
}

.catalog-guide-note {
  padding-bottom: 8px !important;
}

.catalog-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 16px 14px;
  border-top: 1px solid #e2e8ed;
}

.catalog-subtab {
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid #d7e0e5;
  border-radius: 6px;
  background: #f8fafb;
  color: #40505f;
  cursor: pointer;
}

.catalog-subtab.active {
  background: #1f4b7a;
  border-color: #1f4b7a;
  color: #fff;
  font-weight: 600;
}

/* Outer pane is only a visibility wrapper — list and editor are separate cards. */
.catalog-pane.panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  min-height: 0;
}

.catalog-pane[hidden] {
  display: none !important;
}

.catalog-split {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.6fr);
  gap: 16px;
  align-items: stretch;
}

.catalog-list-pane,
.catalog-form-pane {
  background: #ffffff;
  border: 1px solid #d7e0e5;
  border-radius: 8px;
  min-width: 0;
  min-height: 420px;
}

.catalog-form-pane .catalog-form {
  max-width: none;
}

@media (max-width: 900px) {
  .catalog-split {
    grid-template-columns: 1fr;
  }

  .catalog-list-pane,
  .catalog-form-pane {
    min-height: 0;
  }
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-row > label {
  min-width: 0;
}

.hint {
  font-weight: 400;
  color: #667785;
  font-size: 11px;
}

.preset-summary {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #bfd4f2;
  border-radius: 6px;
  background: #f0f6ff;
  color: #334e68;
  font-size: 12px;
  line-height: 1.4;
}

.preset-summary strong {
  color: #1f2933;
}

.preset-summary code {
  font-size: 11px;
}

.preset-desc {
  color: #526271;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
}

.catalog-picker {
  max-height: min(52vh, 480px);
  overflow: auto;
  padding: 0 16px 12px;
  margin-bottom: 4px;
}

.catalog-item {
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  width: 100%;
  min-height: auto;
}

.catalog-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 4px;
  border: 1px solid #d7e0e5;
  border-radius: 6px;
  background: #fff;
}

.catalog-row.active {
  outline: 2px solid #2563eb;
  background: #eff6ff;
}

.catalog-row-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.catalog-item.active {
  outline: none;
  background: transparent;
}

button.danger,
.danger {
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid #e0a3a3;
  border-radius: 6px;
  background: #fbeaea;
  color: #7a2323;
  cursor: pointer;
  white-space: nowrap;
}

button.danger:hover,
.danger:hover {
  background: #f5d6d6;
}

label.file-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid #c8d3da;
  border-radius: 6px;
  background: #f8fafb;
  color: #334e68;
  cursor: pointer;
  font-size: 13px;
}

label.file-button:hover {
  background: #eef2f5;
}

.catalog-item-title {
  font-weight: 600;
  color: #1f2933;
  font-size: 13px;
}

.catalog-item-meta {
  color: #667785;
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.entitlement-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px;
  border: 1px solid #d7e0e5;
  border-radius: 6px;
  background: #fff;
}

.entitlement-item.active {
  outline: 2px solid #2563eb;
  background: #eff6ff;
}

.entitlement-select {
  display: grid;
  gap: 2px;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 4px 6px;
  cursor: pointer;
  min-height: auto;
  width: 100%;
}

button.secondary,
.secondary {
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid #c8d3da;
  border-radius: 6px;
  background: #f8fafb;
  color: #334e68;
  cursor: pointer;
  white-space: nowrap;
}

button.secondary:hover,
.secondary:hover {
  background: #eef2f5;
}

.mount-checks {
  padding: 4px 0;
  max-height: 220px;
  overflow: auto;
}

.empty-hint {
  margin: 0;
  color: #667785;
  font-size: 12px;
}

input[readonly] {
  background: #f3f6f8;
  color: #526271;
}

@media (max-width: 720px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

.variant-help {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #d9e2ec;
  color: #334e68;
  font-size: 13px;
  line-height: 1.45;
}

.variant-help h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.variant-help ol {
  margin: 0;
  padding-left: 1.25rem;
}

.variant-help li {
  margin-bottom: 6px;
}

.check-row,
label.check-row {
  display: flex !important;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  color: #1f2933;
  grid-template-columns: none;
}

.check-row.inline {
  align-items: center;
}

.check-row input,
label.check-row input {
  flex: 0 0 auto;
  width: 16px !important;
  min-width: 16px;
  min-height: 16px !important;
  margin-top: 3px;
  padding: 0;
}

.check-row span {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.35;
}

.check-row small {
  display: block;
  color: #667785;
  line-height: 1.35;
}

.profile-detail {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #d7e0e5;
  border-radius: 6px;
  background: #f8fafb;
  color: #526271;
  font-size: 12px;
}

.profile-detail code {
  overflow-wrap: anywhere;
  color: #23313d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.profile-description {
  margin: 4px 0 0;
  line-height: 1.4;
  max-width: 42rem;
}

button.linkish {
  justify-self: start;
  min-height: auto;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: #0b5fff;
  text-decoration: underline;
  cursor: pointer;
}

button {
  min-height: 36px;
  border: 1px solid #b8c5ce;
  border-radius: 6px;
  background: #ffffff;
  color: #23313d;
  padding: 7px 12px;
  cursor: pointer;
}

button:hover {
  background: #f0f4f6;
}

button.primary {
  border-color: #1d6f8f;
  background: #1d6f8f;
  color: #ffffff;
}

button.danger {
  border-color: #cf4a4a;
  color: #b83232;
}

.summary-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.metric {
  padding: 12px;
  border: 1px solid #d7e0e5;
  border-radius: 8px;
  background: #f8fafb;
}

.metric strong {
  display: block;
  font-size: 24px;
}

.metric span {
  color: #5d6b78;
  font-size: 13px;
}

.capacity-detail {
  margin: 16px 16px 0;
  padding: 10px 12px;
  border: 1px solid #d7e0e5;
  border-radius: 6px;
  background: #f8fafb;
  color: #40505f;
  font-size: 12px;
  display: grid;
  gap: 4px;
}

.capacity-detail.warn {
  border-color: #e0c07f;
  background: #fdf6e6;
  color: #7a5a12;
}

.capacity-bar {
  height: 6px;
  border-radius: 999px;
  background: #e2e8ed;
  overflow: hidden;
}

.capacity-bar-fill {
  height: 100%;
  background: #1d6f8f;
}

.capacity-bar-fill.warn {
  background: #c98a1f;
}

.table-toolbar {
  padding: 0 16px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.table-toolbar input[type="search"] {
  min-width: 220px;
  flex: 1 1 220px;
}

.table-toolbar select {
  min-width: 160px;
  flex: 0 0 auto;
}

.check-row.inline {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  color: #40505f;
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8ed;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: #526271;
  background: #f8fafb;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.row-actions button {
  padding: 5px 9px;
  font-size: 12px;
  min-height: 30px;
}

.status {
  display: inline-block;
  min-width: 82px;
  padding: 4px 8px;
  border-radius: 999px;
  text-align: center;
  background: #e8eef2;
}

.status.running {
  background: #dff3e6;
  color: #17633a;
}

.status.failed {
  background: #f8dddd;
  color: #9c2f2f;
}

.status.deleted,
.status.expired {
  background: #eceff2;
  color: #526271;
}

#detail {
  margin: 0;
  padding: 16px;
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  background: #0f1720;
  color: #d8e2eb;
  border-radius: 0 0 8px 8px;
  font-size: 12px;
}

.access-detail {
  padding: 16px;
  display: grid;
  gap: 12px;
  color: #40505f;
  font-size: 13px;
}

.access-detail p {
  line-height: 1.45;
}

.access-detail code,
.access-detail pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.access-detail pre {
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-radius: 6px;
  background: #0f1720;
  color: #d8e2eb;
  white-space: pre-wrap;
  word-break: break-word;
}

.access-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #1f2933;
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(31, 41, 51, 0.22);
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "main"
      "create"
      "access"
      "detail";
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
