:root {
  color-scheme: light;
  --shell: #ededed;
  --panel: #f4f4f4;
  --panel-edge: #bdbdbd;
  --panel-light: #ffffff;
  --text: #111111;
  --muted: #505050;
  --blue-title: #0b2fff;
  --green: #0a8a22;
  --red: #bf1a1a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--text);
  background: #d8d8d8;
}

.sidebar-scroll,
.pane-content,
.plot-stage,
.plot-stage-content,
pre,
textarea,
.props-body {
  scrollbar-width: auto;
  scrollbar-color: #8f8f8f #d9d9d9;
}

.sidebar-scroll::-webkit-scrollbar,
.pane-content::-webkit-scrollbar,
.plot-stage::-webkit-scrollbar,
.plot-stage-content::-webkit-scrollbar,
pre::-webkit-scrollbar,
textarea::-webkit-scrollbar,
.props-body::-webkit-scrollbar {
  width: 18px;
  height: 18px;
}

.sidebar-scroll::-webkit-scrollbar-track,
.pane-content::-webkit-scrollbar-track,
.plot-stage::-webkit-scrollbar-track,
.plot-stage-content::-webkit-scrollbar-track,
pre::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track,
.props-body::-webkit-scrollbar-track {
  background: #d9d9d9;
  border-left: 1px solid #f2f2f2;
  border-top: 1px solid #f2f2f2;
}

.sidebar-scroll::-webkit-scrollbar-thumb,
.pane-content::-webkit-scrollbar-thumb,
.plot-stage::-webkit-scrollbar-thumb,
.plot-stage-content::-webkit-scrollbar-thumb,
pre::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb,
.props-body::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, #bcbcbc, #909090);
  border: 2px solid #d9d9d9;
  border-radius: 10px;
}

.sidebar-scroll::-webkit-scrollbar-corner,
.pane-content::-webkit-scrollbar-corner,
.plot-stage::-webkit-scrollbar-corner,
.plot-stage-content::-webkit-scrollbar-corner,
pre::-webkit-scrollbar-corner,
textarea::-webkit-scrollbar-corner,
.props-body::-webkit-scrollbar-corner {
  background: #d9d9d9;
}

.desktop-shell {
  min-height: 100vh;
  background: var(--shell);
}

.window-titlebar {
  height: 30px;
  background: #f5f5f5;
  border-bottom: 1px solid #cfcfcf;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
}

.window-title {
  font-size: 13px;
}

.window-actions {
  display: flex;
  gap: 10px;
}

.window-actions span {
  width: 12px;
  height: 12px;
  border: 1px solid #8d8d8d;
  background: #fbfbfb;
}

.menu-bar {
  min-height: 22px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
  background: #fafafa;
  border-bottom: 1px solid #cfcfcf;
}

.menu-bar button {
  border: 0;
  background: transparent;
  padding: 2px 8px;
  font: inherit;
  cursor: default;
}

.menu-status {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.tab-strip {
  padding: 4px 4px 0;
  border-bottom: 1px solid #c0c0c0;
  background: #ededed;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 64px;
  padding: 4px 8px;
  border: 1px solid #b7b7b7;
  border-bottom: 0;
  background: #ececec;
  font-size: 13px;
}

.tab.active {
  background: #ffffff;
}

.tab button {
  border: 1px solid #c76c6c;
  color: #ffffff;
  background: #eb6b53;
  width: 16px;
  height: 16px;
  line-height: 1;
  padding: 0;
  border-radius: 3px;
  cursor: pointer;
}

.app-layout {
  display: grid;
  grid-template-columns: 430px 12px minmax(0, 1fr);
  gap: 0;
  padding: 2px;
  min-height: calc(100vh - 58px);
  height: max(calc(100vh - 58px), 980px);
}

.vertical-splitter {
  position: relative;
  min-width: 12px;
  background: linear-gradient(to right, #d6d6d6, #c6c6c6);
  border-left: 1px solid #eeeeee;
  border-right: 1px solid #9d9d9d;
  cursor: ew-resize;
}

.vertical-splitter::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 64px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: #8f8f8f;
  box-shadow: 1px 0 0 #f4f4f4;
}

.legacy-sidebar,
.workspace-pane {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  box-shadow: inset 1px 1px 0 var(--panel-light), inset -1px -1px 0 #d2d2d2;
}

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

.sidebar-title,
.pane-titlebar {
  height: 22px;
  padding: 2px 6px;
  background: #e8e8e8;
  border-bottom: 1px solid var(--panel-edge);
  font-size: 13px;
  display: flex;
  align-items: center;
}

.sidebar-scroll {
  padding: 8px 8px 14px;
  overflow: auto;
}

.sample-selector {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}

.sample-selector select,
.sample-selector input,
.form-grid input,
.form-grid select,
textarea {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid #bdbdbd;
  background: #ffffff;
  padding: 3px 4px;
  font: inherit;
}

.download-zip-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.download-zip-controls input {
  min-width: 0;
  width: 220px;
  box-sizing: border-box;
  border: 1px solid #bdbdbd;
  background: #ffffff;
  padding: 3px 4px;
  font: inherit;
}

.command-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.command-row-secondary {
  margin-top: -2px;
}

.action-button,
.small-button,
.tiny-button,
.secondary-button {
  border: 1px solid #bcbcbc;
  background: linear-gradient(180deg, #ffffff 0%, #efefef 100%);
  color: #000000;
  cursor: pointer;
  font: inherit;
}

.action-button {
  flex: 1 1 0;
  min-height: 30px;
}

.action-primary {
  color: var(--red);
}

#save-config {
  color: var(--green);
}

.small-button {
  min-height: 26px;
  padding: 0 10px;
}

.tiny-button,
.secondary-button {
  min-height: 24px;
  padding: 0 10px;
}

.advanced-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 10px;
  border-top: 1px solid #afafaf;
  border-bottom: 1px solid #afafaf;
  margin-bottom: 10px;
}

.legacy-section {
  margin-bottom: 14px;
  border-top: 1px solid #afafaf;
  padding-top: 8px;
}

.legacy-section h2 {
  margin: 0 0 10px;
  color: var(--blue-title);
  font-size: 18px;
  font-style: italic;
  font-weight: 700;
}

.form-grid {
  display: grid;
  gap: 8px;
}

.form-grid label {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.form-grid label span {
  line-height: 1.2;
}

.form-row-wide {
  grid-template-columns: 1fr !important;
  align-items: start !important;
}

.inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.study-grid {
  display: grid;
  gap: 10px;
}

.study-panel {
  margin: -4px 0 8px 0;
  padding: 8px 10px 10px 18px;
  border: 1px solid #c8c8c8;
  background: linear-gradient(180deg, #fafafa 0%, #f1f1f1 100%);
  box-shadow: inset 1px 1px 0 #ffffff;
}

.study-panel-title {
  margin: 0 0 8px;
  color: #2f4f9f;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.study-subgrid {
  display: grid;
  gap: 8px;
}

.study-subgrid label {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.study-inline-toggle {
  grid-template-columns: minmax(0, 1fr) 24px !important;
}

.header-toggle {
  grid-template-columns: minmax(0, 1fr) 24px !important;
  font-size: 12px;
}

.study-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  align-items: center;
  gap: 8px;
}

.study-toggle span {
  color: #000000;
  font-size: 16px;
  font-style: italic;
  font-weight: 700;
}

#status-pill,
.health-pill,
.subtle-pill {
  padding: 2px 8px;
  border: 1px solid #b8b8b8;
  background: #ffffff;
  font-size: 12px;
}

.workspace-area {
  display: grid;
  grid-template-rows: minmax(520px, 2.4fr) 12px minmax(160px, 0.8fr);
  gap: 0;
  min-height: 0;
}

.workspace-pane-large {
  min-height: 0;
}

.workspace-splitter {
  position: relative;
  min-height: 12px;
  background: linear-gradient(to bottom, #d6d6d6, #c6c6c6);
  border-top: 1px solid #eeeeee;
  border-bottom: 1px solid #9d9d9d;
  cursor: ns-resize;
}

.workspace-splitter::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 4px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: #8f8f8f;
  box-shadow: 0 1px 0 #f4f4f4;
}

.workspace-bottom {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 12px minmax(240px, 1fr);
  grid-template-areas: "result splitter json";
  gap: 0;
  min-height: 0;
}

.workspace-bottom > #result-pane {
  grid-area: result;
  min-width: 0;
}

.workspace-bottom > #workspace-bottom-splitter {
  grid-area: splitter;
}

.workspace-bottom > #json-pane {
  grid-area: json;
  min-width: 0;
}

.workspace-area-results-bottom {
  grid-template-rows: minmax(520px, 2.4fr) 12px minmax(140px, 0.7fr) minmax(180px, 0.9fr);
}

.workspace-area-results-bottom .workspace-bottom {
  grid-template-columns: 1fr;
  grid-template-areas: "json";
}

.workspace-area-results-bottom #workspace-bottom-splitter {
  display: none;
}

.pane-content {
  padding: 8px;
  height: calc(100% - 22px);
  box-sizing: border-box;
  overflow: auto;
}

.pane-summary {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 10px;
}

.summary-header,
.subpanel-heading,
.subpanel-heading-spread {
  display: flex;
  align-items: center;
  gap: 8px;
}

.subpanel-heading-spread {
  justify-content: space-between;
}

pre,
textarea {
  background: #ffffff;
  color: #000000;
  min-height: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.4 "Consolas", "Courier New", monospace;
}

#summary-view {
  min-height: 220px;
}

#response-view {
  min-height: 220px;
}

#config-editor {
  min-height: 180px;
  resize: vertical;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.summary-card,
.meta-grid div {
  border: 1px solid #c7c7c7;
  background: #ffffff;
  padding: 8px;
}

.summary-card span,
.meta-grid span,
.activity-note {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-card strong,
.meta-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.activity-panel {
  margin-top: 8px;
}

.investigation-panel {
  display: grid;
  gap: 12px;
}

.investigation-group {
  border: 1px solid #9f9f9f;
  background: #f5f5f5;
  padding: 10px;
}

.investigation-group h3 {
  margin: -18px auto 8px;
  width: fit-content;
  padding: 0 8px;
  background: #f5f5f5;
  color: var(--blue-title);
  font-size: 18px;
  font-style: normal;
  font-weight: 500;
}

.investigation-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.investigation-grid-compact {
  grid-template-columns: minmax(260px, 1fr) minmax(220px, 1fr) auto;
}

.investigation-grid label {
  display: grid;
  gap: 4px;
}

.investigation-grid span {
  font-size: 14px;
}

.investigation-grid select {
  min-width: 0;
}

.investigation-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.plot-stage {
  border: 1px solid #bdbdbd;
  background: #ffffff;
  min-height: 160px;
  padding: 10px;
  overflow: auto;
}

.plot-stage-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: nowrap;
}

.plot-stage-header h4 {
  margin: 0;
  font-size: 18px;
  flex: 0 1 auto;
}

.plot-stage-header p {
  margin: 0;
  color: var(--muted);
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.plot-stage-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}

.plot-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}

.plot-meta-item {
  margin: 0;
  padding: 3px 8px;
  border: 1px solid #c9c9c9;
  background: #f7f7f7;
  font-size: 12px;
  line-height: 1.25;
}

.plot-stage-note {
  margin: 10px 0 0;
  color: var(--muted);
}

.result-view {
  display: grid;
  gap: 10px;
}

.result-empty {
  margin: 0;
  border: 1px solid #c7c7c7;
  background: #ffffff;
  padding: 10px;
  color: var(--muted);
}

.result-section {
  border-top: 1px solid #bdbdbd;
  padding-top: 10px;
}

.result-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.result-section h3 {
  margin: 0 0 8px;
  color: var(--blue-title);
  font-size: 22px;
  font-style: italic;
  font-weight: 700;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 16px;
  row-gap: 8px;
  align-items: baseline;
}

.result-grid dt {
  margin: 0;
}

.result-grid dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.raw-response-toggle {
  margin-top: 10px;
}

.raw-response-toggle summary {
  cursor: pointer;
  font-weight: 600;
}

.activity-note {
  margin: 0 0 8px;
}

.activity-log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.activity-log li {
  border: 1px solid #c9c9c9;
  background: #ffffff;
  padding: 6px 8px;
  font-size: 12px;
}

.hidden {
  display: none !important;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(23, 33, 43, 0.44);
  backdrop-filter: blur(3px);
  z-index: 40;
}

.dialog {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.dialog-card {
  width: min(860px, calc(100% - 12px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fcfcfc;
  color: var(--text);
  border: 1px solid #a8a8a8;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  padding: 22px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.dialog-kicker {
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--blue-title);
}

.dialog-message {
  margin: 12px 0 16px;
  color: var(--muted);
}

.props-card {
  width: min(520px, calc(100% - 12px));
}

.props-body {
  display: grid;
  gap: 10px;
}

.props-form {
  display: grid;
  gap: 10px;
}

.props-form label {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.props-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.props-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.props-caption {
  padding: 6px 8px;
  border: 1px solid #c7c7c7;
  background: #ffffff;
  font-size: 12px;
}

#dialog-summary,
#dialog-details {
  min-height: 0;
  margin: 0;
}

#dialog-details {
  margin-top: 14px;
}

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .workspace-area {
    grid-template-rows: minmax(320px, 1fr) 12px minmax(220px, 1fr);
  }

  .workspace-bottom,
  .summary-strip,
  .meta-grid,
  .investigation-grid,
  .investigation-grid-compact {
    grid-template-columns: 1fr;
  }

  .vertical-splitter,
  .workspace-splitter {
    display: none;
  }
}

@media (max-width: 640px) {
  .download-zip-controls {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .download-zip-controls input {
    width: 100%;
  }

  .form-grid label {
    grid-template-columns: 1fr;
  }

  .study-subgrid label {
    grid-template-columns: 1fr;
  }

  .props-form label,
  .props-row {
    grid-template-columns: 1fr;
  }
}
