:root {
  color-scheme: dark;
  --portal-bg: #0a0a0a;
  --portal-card: #161616;
  --portal-hover: #222;
  --text: #f0f0f0;
  --muted: #888;
  --border: #333;
  --blue: #3a86ff;
  --green: #4caf50;
  --red: #f44336;
  --pink: #ff4fa3;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-width: 100%; min-height: 100%; }
body { margin: 0; background: var(--portal-bg); color: var(--text); }
button, input, select { font: inherit; }
button, .button { cursor: pointer; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.status {
  position: fixed;
  left: 50%; top: 12px;
  z-index: 250;
  transform: translateX(-50%);
  display: none;
  max-width: min(640px, calc(100vw - 32px));
  padding: 9px 14px;
  border: 1px solid #31543a;
  background: #0d1910;
  color: #8cffaa;
  box-shadow: 0 6px 24px #0009;
  font-size: 13px;
}
.status.visible { display: block; }
.status.error { border-color: #70303a; background: #1d0d10; color: #ff8c9d; }

.entry-warning-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background: #000;
}
.entry-warning-panel {
  width: min(620px, 100%);
  padding: 36px;
  border: 1px solid #343434;
  background: #0c0c0c;
  text-align: left;
}
.warning-kicker {
  margin: 0 0 12px !important;
  color: var(--pink) !important;
  font: 11px "Cascadia Mono", Consolas, monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.entry-warning-panel h1 { margin: 0 0 18px; font-size: clamp(28px, 5vw, 42px); font-weight: 400; letter-spacing: -.04em; }
.entry-warning-panel p { max-width: 540px; margin: 0 0 14px; color: #bbb; line-height: 1.6; }
.entry-warning-panel .warning-session-note { color: #777; font-size: 13px; }
.entry-warning-panel button { margin-top: 14px; padding: 11px 16px; border: 1px solid var(--blue); border-radius: 0; background: #080808; color: #fff; }
.entry-warning-panel button:hover, .entry-warning-panel button:focus-visible { background: #111; outline: 1px solid var(--blue); outline-offset: 2px; }

/* Trevor's stimulus portal structure and visual language. */
.portal-view { min-height: 100vh; padding: 56px 32px; }
.portal-container { width: 100%; max-width: 800px; margin: 0 auto; text-align: center; }
.portal-header { margin-bottom: 56px; }
.portal-header h1 { margin: 0 0 8px; font-size: 40px; line-height: 1.15; font-weight: 400; letter-spacing: -.05em; }
.portal-header p { margin: 0; color: var(--muted); font-size: 18px; }
.portal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.stimulus-card {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  border: 1px solid #262626;
  border-radius: 12px;
  background: var(--portal-card);
  color: inherit;
  text-align: center;
  transition: transform .2s ease, background-color .2s ease, border-color .2s ease;
}
.stimulus-card:hover, .stimulus-card:focus-visible { transform: translateY(-2px); background: var(--portal-hover); border-color: var(--blue); outline: 0; }
.stimulus-card h2 { margin: 0 0 8px; font-size: 21px; line-height: 1.4; font-weight: 500; }
.stimulus-card span { color: var(--muted); font-size: 14px; letter-spacing: .05em; text-transform: uppercase; }
.stimulus-card.design-card { border-style: dashed; }

.portal-filebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 0 0 24px;
  padding: 12px 14px;
  border: 1px solid #262626;
  background: #101010;
  text-align: left;
}
.portal-filebar strong, .portal-filebar span { display: block; }
.portal-filebar strong { font-size: 14px; font-weight: 500; }
.portal-filebar span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.file-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.portal-filebar button, .portal-filebar .button, .section-heading button {
  min-height: 32px; padding: 6px 9px; border: 1px solid #3b3b3b; background: #090909; color: #ddd; font-size: 12px; text-decoration: none;
}
.portal-filebar button:hover, .portal-filebar .button:hover, .section-heading button:hover { border-color: var(--blue); color: #fff; }
.accent-button { border-color: var(--blue) !important; color: #fff !important; }

.custom-profile-section { margin-top: 56px; padding-top: 24px; border-top: 1px solid #242424; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 20px; text-align: left; }
.section-heading h2 { margin: 0; font-size: 24px; font-weight: 400; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.compact-grid .stimulus-card { min-height: 116px; padding: 20px; }
.compact-grid .stimulus-card h2 { font-size: 17px; }
.empty-library { grid-column: 1 / -1; margin: 0; padding: 28px; border: 1px dashed #292929; color: var(--muted); font-size: 13px; }
.portal-footer { margin-top: 48px; color: #666; font-size: 12px; }
.portal-footer span { color: #999; }
.portal-footer a { display: block; width: fit-content; margin: 8px auto 0; color: #888; }
.portal-footer a:hover, .portal-footer a:focus-visible { color: #bbb; }
.shortcut-guide { margin: -8px 0 24px; color: #777; font: 11px "Cascadia Mono", Consolas, monospace; }
kbd { min-width: 19px; display: inline-block; padding: 2px 5px; border: 1px solid #3a3a3a; background: #111; color: #ccc; font: inherit; text-align: center; }

/* Full-canvas designers, following Trevor's sim.html and strobe.html layouts. */
.designer-view { position: fixed; inset: 0; overflow: hidden; background: #000; }
#preview-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; background: #000; }
.designer-toolbar {
  position: absolute;
  left: 50%; bottom: 10px;
  z-index: 40;
  transform: translateX(-50%);
  max-width: calc(100vw - 20px);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px;
  border: 1px solid #333;
  background: #050505ee;
  font: 11px "Cascadia Mono", Consolas, monospace;
  white-space: nowrap;
}
.designer-toolbar button, .designer-toolbar .button, .designer-toolbar select {
  min-height: 29px;
  padding: 5px 8px;
  border: 1px solid #3a3a3a;
  border-radius: 0;
  background: #050505;
  color: #eee;
  text-decoration: none;
}
.designer-toolbar button:hover, .designer-toolbar .button:hover, .designer-toolbar select:focus { border-color: #666; background: #111; }
.designer-toolbar select { width: min(270px, 25vw); }
.designer-toolbar .danger { color: #ff8c96; }
.toolbar-spacer { width: 10px; }
.designer-shortcuts {
  position: absolute;
  left: 12px;
  bottom: 84px;
  z-index: 18;
  color: #777;
  font: 10px "Cascadia Mono", Consolas, monospace;
  pointer-events: none;
}

.designer-panel { position: absolute; z-index: 20; }
.simulation-panel {
  top: 0; right: 0;
  width: 400px; height: 100%;
  overflow-y: auto;
  padding: 15px;
  border-left: 1px solid #333;
  background: #1e1e1e;
  color: #e0e0e0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
.simulation-heading h1 { margin: 0 0 15px; padding-bottom: 10px; border-bottom: 1px solid #444; color: #fff; font-size: 19px; }
.main-actions { display: flex; gap: 10px; margin-bottom: 10px; }
.main-actions button { width: 100%; padding: 8px 12px; border: 0; border-radius: 4px; color: #fff; font-weight: 700; }
.randomize-button { background: var(--green); }
.randomize-button:hover { background: #45a049; }
.reset-button { background: var(--red); }
.reset-button:hover { background: #d32f2f; }

.simulation-editor details { margin: 0; }
.simulation-editor summary {
  margin-top: 15px;
  padding: 5px;
  border-radius: 4px;
  background: #2a2a2a;
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  list-style-position: inside;
}
.simulation-editor summary::marker { content: ""; }
.simulation-editor .field-grid, .simulation-editor .pattern-content, #simulation-metadata { padding: 10px 0 0 10px; border-left: 2px solid #555; }
.field-grid { display: grid; grid-template-columns: 1fr minmax(160px, 2fr); gap: 5px 10px; align-items: center; }
.field-grid label { font-size: 13px; color: #d0d0d0; }
.paired-input { min-width: 0; display: grid; grid-template-columns: minmax(80px, 1fr) 60px; gap: 8px; align-items: center; }
.paired-input input[type="range"] { width: 100%; min-width: 0; margin: 0; accent-color: #168df1; }
.field-grid input[type="number"], .field-grid input[type="text"], .field-grid select, .metadata-grid input {
  width: 100%; min-width: 0; padding: 3px 5px; border: 1px solid #555; border-radius: 3px; background: #333; color: #fff; font-size: 12px;
}
.field-grid input[type="color"] { justify-self: end; width: 30px; height: 30px; border: 0; padding: 0; background: transparent; }
.field-grid input[type="checkbox"] { justify-self: end; width: 18px; height: 18px; accent-color: var(--green); }
.pattern-toolbar { display: flex; gap: 8px; padding: 8px 0 0 10px; border-left: 2px solid #555; }
.pattern-toolbar button { flex: 1; padding: 6px; border: 0; border-radius: 4px; background: #2196f3; color: #fff; font-weight: 700; }
.pattern-block { margin: 8px 0 0 10px; padding: 7px; border: 1px solid #444; background: #181818; }
.pattern-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.pattern-heading strong { color: #b39ddb; font-size: 13px; }
.pattern-heading button { padding: 3px 6px; border: 0; border-radius: 3px; background: var(--red); color: #fff; font-size: 11px; }
.quest-section { margin-top: 20px; padding-top: 15px; border-top: 2px solid #444; }
.quest-section h3 { margin: 0 0 10px; color: #b39ddb; font-size: 16px; }
.metadata-grid { display: grid; grid-template-columns: 1fr 150px; gap: 6px 10px; align-items: center; }
.metadata-grid label { color: #bbb; font-size: 12px; }
.metadata-grid .readback { color: #b39ddb; font-size: 12px; }

.strobe-panel {
  top: 10px; left: 10px;
  width: 280px;
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  border: 1px solid #333;
  background: #000000f2;
  color: #fff;
  font: 11px "Cascadia Mono", Consolas, monospace;
}
.strobe-panel.collapsed { width: auto; }
.strobe-header { width: 100%; display: flex; justify-content: space-between; gap: 18px; padding: 6px 10px; border: 0; background: #111; color: #fff; font: inherit; }
.strobe-panel-body { padding: 10px; border-top: 1px solid #222; }
.strobe-control-group { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid #222; }
.strobe-control-group:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.strobe-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.strobe-field { min-width: 0; }
.strobe-field label, .group-label { display: block; margin-bottom: 4px; color: #888; text-transform: uppercase; font-size: 10px; }
.strobe-field input:not([type="checkbox"]), .strobe-field select, .quest-strobe-group input {
  width: 100%; min-width: 0; padding: 4px; border: 1px solid #333; border-radius: 0; background: #000; color: #fff; font: inherit;
}
.strobe-field input[type="color"] { height: 24px; padding: 0; }
.strobe-field.checkbox-field { display: flex; align-items: center; gap: 4px; padding-top: 3px; }
.strobe-field.checkbox-field label { margin: 0; color: #fff; text-transform: none; }
.strobe-panel button:not(.strobe-header) { width: 100%; margin-top: 6px; padding: 6px; border: 1px solid #333; border-radius: 0; background: #000; color: #fff; font: inherit; text-transform: uppercase; }
.strobe-panel button:not(.strobe-header):hover { background: #111; border-color: #555; }
.quest-strobe-group .metadata-grid { display: block; }
.quest-strobe-group .metadata-grid > * { display: block; margin-top: 4px; }

.selected-summary { position: absolute; left: 12px; bottom: 56px; z-index: 18; padding: 4px 7px; background: #000b; color: #aaa; font: 10px "Cascadia Mono", Consolas, monospace; }

@media (max-width: 760px) {
  .portal-view { padding: 36px 16px; }
  .portal-header { margin-bottom: 36px; }
  .portal-header h1 { font-size: 34px; }
  .portal-grid { grid-template-columns: 1fr; gap: 14px; }
  .portal-filebar, .section-heading { align-items: stretch; flex-direction: column; }
  .file-actions { justify-content: flex-start; }
  .simulation-panel { width: min(400px, 100vw); }
  .designer-view.simulation-mode #preview-canvas { right: 0; width: 100%; }
  .designer-toolbar { left: 10px; right: 10px; transform: none; overflow-x: auto; }
  .designer-toolbar select { width: 180px; }
  .entry-warning-view { padding: 18px; }
  .entry-warning-panel { padding: 24px 20px; }
  .designer-shortcuts { display: none; }
}

@media (min-width: 761px) {
  .designer-view.simulation-mode #preview-canvas { right: 400px; width: calc(100% - 400px); }
}
