/* SHARD responsive workspace layout. */

/* ─────────────── Viewport-fitted layouts ─────────────── */
html { height: 100%; }

body.landing-page {
  height: 100dvh;
  overflow: hidden;
}

body.landing-page .topbar,
body.app-page .topbar {
  height: 88px;
  min-height: 0;
}

body.landing-page .landing {
  height: calc(100dvh - 88px);
  min-height: 0;
}

body.landing-page .hero {
  height: min(100%, 1120px);
  min-height: 0;
}

@media (min-width: 1061px) {
  body.app-page {
    height: 100dvh;
    overflow: hidden;
  }

  body.app-page .workspace {
    height: calc(100dvh - 88px);
    min-height: 0;
    overflow: hidden;
  }

  body.app-page .rail,
  body.app-page .canvas,
  body.app-page .focus-layout,
  body.app-page .evidence-column,
  body.app-page .editor-column,
  body.app-page .section-block {
    min-height: 0;
  }

  body.app-page .rail {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 14px 16px;
  }

  body.app-page .inline-panel {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-top: 14px;
    padding-top: 12px;
  }

  body.app-page .rail #model-config-status {
    margin-top: auto;
    padding-top: 8px;
  }

  body.app-page .canvas {
    height: 100%;
    overflow: hidden;
    padding: 14px;
  }

  body.app-page .focus-layout {
    height: 100%;
    align-items: stretch;
    gap: 14px;
  }

  body.app-page .evidence-column,
  body.app-page .editor-column {
    display: grid;
    gap: 12px;
    overflow: hidden;
  }

  body.rule-page,
  body.batch-page {
    --rule-context-textarea-height: clamp(70px, 5.8vh, 84px);
    --rule-business-textarea-height: clamp(210px, 17.4vh, 252px);
    --matched-generation-block-height: clamp(226px, 21vh, 256px);
    --matched-shape-profile-block-height: clamp(126px, 12vh, 150px);
  }

  body.rule-page .editor-column,
  body.batch-page .editor-column {
    grid-template-rows: minmax(145px, 0.3fr) minmax(190px, 0.42fr) minmax(290px, 1fr) 220px;
  }

  body.batch-page .evidence-column {
    grid-template-rows: var(--matched-generation-block-height) var(--matched-shape-profile-block-height) auto minmax(0, 1fr);
  }

  body.rule-page .evidence-column {
    grid-template-rows: var(--matched-generation-block-height) var(--matched-shape-profile-block-height) auto auto;
  }

  body.app-page .section-block {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 0;
    padding: 12px;
  }

  body.app-page .field-label {
    margin: 9px 0 5px;
    font-size: 0.68rem;
  }

  body.app-page .input {
    height: 34px;
    padding: 0 10px;
    font-size: 0.84rem;
  }

  body.app-page .file-drop {
    min-height: 54px;
    padding: 9px;
  }

  body.app-page .microcopy {
    margin-top: 5px;
    font-size: 0.76rem;
    line-height: 1.28;
  }

  body.app-page .switcher {
    margin-top: 10px;
  }

  body.app-page .switch-button,
  body.app-page .primary-button,
  body.app-page .secondary-button,
  body.app-page .text-button,
  body.app-page .icon-button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 0.8rem;
  }

  body.app-page .session-actions {
    margin-top: 8px;
    gap: 6px;
  }

  body.app-page .custom-model-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 7px;
  }

  body.app-page .custom-model-row .secondary-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  body.app-page .textarea {
    min-height: 0;
    resize: none;
    padding: 9px;
    font-size: 0.84rem;
    line-height: 1.32;
  }

  body.app-page .textarea.compact { height: 54px; }
  body.app-page .textarea.large { height: 88px; }

  body.rule-page .generation-context-block .textarea,
  body.batch-page .generation-context-block .textarea,
  body.rule-page .business-rule-block .textarea,
  body.rule-page .selected-target-block .textarea {
    flex: 1 1 auto;
    height: auto;
  }

  body.rule-page .generation-context-block .textarea,
  body.batch-page .generation-context-block .textarea {
    flex: 0 0 var(--rule-context-textarea-height);
    height: var(--rule-context-textarea-height);
    min-height: var(--rule-context-textarea-height);
    max-height: var(--rule-context-textarea-height);
  }

  body.rule-page .business-rule-block .textarea {
    flex: 0 0 var(--rule-business-textarea-height);
    height: var(--rule-business-textarea-height);
    min-height: var(--rule-business-textarea-height);
    max-height: var(--rule-business-textarea-height);
  }

  body.rule-page .generation-context-block,
  body.batch-page .generation-context-block {
    height: var(--matched-generation-block-height);
    min-height: var(--matched-generation-block-height);
    max-height: var(--matched-generation-block-height);
  }

  body.rule-page .shape-profile-block,
  body.batch-page .shape-profile-block {
    height: var(--matched-shape-profile-block-height);
    min-height: var(--matched-shape-profile-block-height);
    max-height: var(--matched-shape-profile-block-height);
  }

  body.batch-page .current-business-rule-block .textarea {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    resize: none;
  }

  body.batch-page .generated-shapes-block .queue-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc((var(--queue-card-height) * 5) + (8px * 4) + 8px);
  }

  body.rule-page .shape-profile-block .microcopy,
  body.batch-page .shape-profile-block .microcopy {
    flex: 0 0 auto;
    margin: 4px 0 0;
  }

  body.rule-page .shape-profile-block .profile-file-drop,
  body.batch-page .shape-profile-block .profile-file-drop {
    flex: 0 0 42px;
    min-height: 42px;
    margin-top: 7px;
    padding: 6px 10px;
    display: flex;
    flex-direction: row;
    gap: 8px;
  }

  body.rule-page .shape-profile-block .profile-file-drop span,
  body.rule-page .shape-profile-block .profile-file-drop small,
  body.batch-page .shape-profile-block .profile-file-drop span,
  body.batch-page .shape-profile-block .profile-file-drop small {
    white-space: nowrap;
  }

  body.rule-page .shape-profile-block .profile-file-drop span,
  body.batch-page .shape-profile-block .profile-file-drop span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 750;
  }

  body.rule-page .shape-profile-block .profile-file-drop small,
  body.batch-page .shape-profile-block .profile-file-drop small {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
  }

  body.rule-page .profile-file-list,
  body.batch-page .profile-file-list {
    display: grid;
    flex: 1 1 auto;
    gap: 6px;
    min-height: 0;
    margin-top: 7px;
    overflow: auto;
  }

  body.rule-page .profile-file-list .microcopy,
  body.batch-page .profile-file-list .microcopy {
    margin: 0;
  }

  body.rule-page .profile-file-item,
  body.batch-page .profile-file-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-height: 28px;
    padding: 3px 5px 3px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    font-size: 0.76rem;
  }

  body.rule-page .profile-file-item code,
  body.batch-page .profile-file-item code {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.rule-page .profile-file-item span,
  body.batch-page .profile-file-item span {
    color: var(--muted);
    flex: 0 0 auto;
  }

  body.rule-page .profile-file-remove,
  body.batch-page .profile-file-remove {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 1rem;
    font-weight: 900;
    line-height: 1;
    padding: 0;
  }

  body.rule-page .profile-file-remove:hover,
  body.batch-page .profile-file-remove:hover {
    border-color: var(--err);
    color: var(--err);
    background: var(--err-soft);
  }

  body.rule-page .selected-target-block .textarea {
    flex: 0 0 54px;
    min-height: 54px;
    max-height: none;
  }

  body.rule-page .ontology-search-block .section-title {
    align-items: stretch;
  }

  body.rule-page .entity-filter-switch {
    flex: 0 0 min(310px, 42%);
    grid-template-columns: 0.7fr 1fr 1.22fr;
    margin-top: 0;
    max-width: none;
    min-width: 260px;
  }

  body.rule-page .ontology-search-block {
    min-height: 0;
  }

  body.rule-page .ontology-search-block .entity-list {
    flex: 0 0 auto;
    gap: 4px;
    height: clamp(230px, 23vh, 280px);
    max-height: clamp(230px, 23vh, 280px) !important;
    overflow-y: auto;
  }

  body.app-page .code-wrap {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 8px;
  }

  body.app-page .code-highlight,
  body.app-page .code-wrap .code-editor {
    min-height: 0 !important;
    height: 100%;
    padding: 10px;
    font-size: 0.82rem;
    line-height: 1.42;
  }

  body.app-page .metadata-grid {
    margin: 10px 0 8px;
    gap: 7px;
  }

  body.app-page .metadata-grid div {
    padding: 8px;
  }

  body.app-page dt { font-size: 0.62rem; }
  body.app-page dd { font-size: 0.78rem; }

  body.app-page .ontology-search-row {
    margin-top: 8px;
    gap: 6px;
  }

  body.rule-page .ontology-search-block .section-title {
    min-height: 28px;
  }

  body.rule-page .ontology-search-block .entity-filter-switch {
    flex-basis: min(286px, 42%);
    min-width: 238px;
    min-height: 28px;
    height: 28px;
  }

  body.rule-page .ontology-search-block .entity-filter-switch .switch-button {
    display: grid;
    place-items: center;
    min-height: 28px;
    height: 28px;
    padding: 0 8px;
    font-size: 0.72rem;
    line-height: 1;
  }

  body.rule-page .ontology-search-block .ontology-search-row {
    margin-top: 5px;
    gap: 4px;
  }

  body.rule-page .ontology-search-block .ontology-search-row .input,
  body.rule-page .ontology-search-block .ontology-search-row button {
    height: 28px;
    min-height: 28px;
    max-height: 28px;
    padding: 0 8px;
    font-size: 0.72rem;
  }

  body.rule-page .ontology-search-block #ontology-search-status {
    margin-top: 3px;
    font-size: 0.68rem;
    line-height: 1.15;
  }

  body.rule-page .ontology-search-block .entity-list {
    margin-top: 5px;
  }

  body.app-page .entity-list,
  body.app-page .accepted-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none !important;
    overflow: auto;
  }

  body.app-page .queue-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc((var(--queue-card-height) * 5) + (8px * 4) + 8px) !important;
    overflow: auto;
  }

  body.app-page .entity-list,
  body.app-page .queue-list {
    margin-top: 8px;
  }

  body.app-page .entity-card,
  body.app-page .queue-card {
    padding: 8px 10px;
  }

  body.app-page .entity-card {
    min-height: 42px;
    line-height: 1.22;
  }

  body.rule-page .ontology-search-block .entity-card {
    min-height: 36px;
    padding: 5px 8px;
    overflow: hidden;
  }

  body.rule-page .ontology-search-block .entity-card strong {
    margin-bottom: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.76rem;
    line-height: 1.08;
  }

  body.rule-page .ontology-search-block .entity-card span {
    margin-top: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.66rem;
    line-height: 1.08;
  }

  body.rule-page .ontology-search-block .entity-card .entity-reason {
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.61rem;
    line-height: 1.08;
  }

  body.rule-page .ontology-search-block .entity-card.ranked {
    padding-left: 38px;
  }

  body.rule-page .ontology-search-block .score {
    left: 7px;
    top: 50%;
    width: 24px;
    height: 24px;
    transform: translateY(-50%);
    font-size: 0.64rem;
  }

  body.app-page .validation-panel {
    margin-top: 6px;
    padding: 6px 9px;
    max-height: 76px;
    overflow: auto;
    font-size: 0.8rem;
    line-height: 1.25;
  }

  body.app-page .accepted-item {
    height: 28px;
    min-height: 28px;
    max-height: 28px;
    padding: 2px 3px 2px 8px;
  }

  body.app-page .accepted-list {
    flex: 0 0 92px;
    height: 92px;
    grid-auto-rows: 28px;
    align-content: start;
    gap: 4px;
    max-height: 92px !important;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-gutter: stable;
  }

  body.app-page .accepted-item code {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
  }

  body.app-page .accepted-item .accepted-remove-button {
    min-height: 22px;
    padding: 0 7px;
    font-size: 0.68rem;
  }

  body.app-page .full-width {
    margin-top: 9px;
  }
}

@media (min-width: 1061px) and (max-height: 880px) {
  body.app-page .topbar,
  body.landing-page .topbar {
    height: 74px;
    padding: 8px 24px;
  }

  body.app-page .brand-logo-link,
  body.landing-page .brand-logo-link {
    --brand-logo-width: clamp(166px, 13vw, 190px);
  }

  body.app-page .workspace {
    height: calc(100dvh - 74px);
  }

  body.landing-page .landing {
    height: calc(100dvh - 74px);
  }

  body.app-page .rail,
  body.app-page .canvas {
    padding: 10px 12px;
  }

  body.app-page .focus-layout,
  body.app-page .evidence-column,
  body.app-page .editor-column {
    gap: 9px;
  }

  body.app-page .section-block {
    padding: 9px;
  }

  body.app-page .field-label {
    margin: 7px 0 4px;
  }

  body.app-page .textarea.compact { height: 44px; }
  body.app-page .textarea.large { height: 68px; }

  body.app-page .code-highlight,
  body.app-page .code-wrap .code-editor {
    padding: 8px;
    font-size: 0.76rem;
    line-height: 1.34;
  }

  body.rule-page .editor-column,
  body.batch-page .editor-column {
    grid-template-rows: 132px 190px minmax(290px, 1fr) 220px;
  }

  body.rule-page .evidence-column {
    grid-template-rows: var(--matched-generation-block-height) var(--matched-shape-profile-block-height) auto auto;
  }

  body.batch-page .evidence-column {
    grid-template-rows: var(--matched-generation-block-height) var(--matched-shape-profile-block-height) auto minmax(0, 1fr);
  }

  body.rule-page,
  body.batch-page {
    --rule-context-textarea-height: 66px;
    --rule-business-textarea-height: 198px;
    --matched-generation-block-height: 206px;
    --matched-shape-profile-block-height: 124px;
  }

  body.rule-page .entity-filter-switch {
    flex-basis: min(286px, 44%);
    min-width: 238px;
  }

  body.rule-page .ontology-search-block .entity-list {
    height: clamp(190px, 20vh, 230px);
    max-height: clamp(190px, 20vh, 230px) !important;
  }
}

@media (min-width: 1061px) and (min-height: 980px) {
  body.app-page .rail {
    padding: 20px 16px 24px;
  }

  body.app-page .rail .file-drop {
    min-height: 68px;
    padding: 12px;
  }

  body.app-page .rail .session-actions {
    margin-top: 12px;
    gap: 8px;
  }

  body.app-page .rail .session-actions .secondary-button,
  body.app-page .rail .switch-button,
  body.app-page .rail .secondary-button,
  body.app-page .rail .primary-button {
    min-height: 38px;
  }

  body.app-page .rail .field-label {
    margin: 13px 0 7px;
  }

  body.app-page .rail .input {
    height: 40px;
  }

  body.app-page .rail .microcopy {
    margin-top: 7px;
    line-height: 1.36;
  }

  body.app-page .rail .inline-panel {
    margin-top: 22px;
    padding-top: 18px;
  }

  body.app-page .rail .provider-config {
    margin-top: 16px;
  }

  body.app-page .rail .switcher {
    margin-top: 14px;
  }

  body.app-page .rail .custom-model-row {
    gap: 8px;
  }

  body.rule-page .rail {
    padding-top: 24px;
    padding-bottom: 30px;
  }

  body.rule-page .rail .panel-heading {
    margin-bottom: 8px;
  }

  body.rule-page .rail .file-drop {
    min-height: clamp(92px, 8vh, 118px);
    padding: 18px 14px;
  }

  body.rule-page .rail .session-actions {
    margin-top: 18px;
  }

  body.rule-page .rail .session-actions .secondary-button {
    min-height: 42px;
  }

  body.rule-page .rail .inline-panel {
    margin-top: 34px;
    padding-top: 26px;
  }

  body.rule-page .rail .field-label {
    margin: 17px 0 8px;
  }

  body.rule-page .rail .input {
    height: 44px;
  }

  body.rule-page .rail .switcher {
    margin-top: 16px;
  }

  body.rule-page .rail .switch-button,
  body.rule-page .rail .secondary-button,
  body.rule-page .rail .primary-button {
    min-height: 42px;
  }

  body.rule-page .rail .provider-config {
    margin-top: 20px;
  }

  body.rule-page .rail #model-config-status {
    padding-top: 18px;
  }
}

@media (min-width: 1061px) {
  body.app-page .rail .inline-panel {
    align-items: stretch;
  }

  body.app-page .rail .provider-switch,
  body.app-page .rail .provider-config,
  body.app-page .rail .provider-config .input,
  body.app-page .rail .inline-panel > .input,
  body.app-page .rail .custom-model-row,
  body.app-page .rail .custom-model-row > .input,
  body.app-page .rail .custom-model-row > .secondary-button,
  body.app-page .rail #model-config-status {
    width: 100% !important;
    min-width: 0;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    justify-self: stretch;
  }

  body.app-page .rail .provider-switch {
    min-height: 38px;
  }

  body.app-page .rail .custom-model-row {
    grid-template-columns: 1fr !important;
  }

  body.app-page .rail .custom-model-row .secondary-button {
    grid-column: auto;
  }
}

@media (min-width: 1061px) and (min-height: 980px) {
  body.app-page .rail .provider-switch,
  body.app-page .rail .provider-config,
  body.app-page .rail .inline-panel > .field-label,
  body.app-page .rail .inline-panel > .input,
  body.app-page .rail .custom-model-row {
    width: 100% !important;
    margin-left: auto;
    margin-right: auto;
  }

  body.app-page .rail #model-config-status {
    width: 100% !important;
    margin-left: auto;
    margin-right: auto;
  }

  body.app-page .rail .provider-config .field-label,
  body.app-page .rail .provider-config .input {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  body.app-page .rail .custom-model-row {
    grid-template-columns: 1fr !important;
  }

  body.app-page .rail .custom-model-row .secondary-button {
    grid-column: auto;
    justify-self: stretch;
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 960px) {
  body.landing-page {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }

  body.landing-page .topbar {
    height: auto;
    min-height: 88px;
  }

  body.landing-page .landing,
  body.landing-page .hero {
    height: auto;
  }
}

/* Rigid left rail.
   Keep this block last: every interactive box keeps the same geometry and
   provider changes may remove fields, but must never resize controls. */
@media (min-width: 1061px) {
  body.app-page .rail {
    --rail-control-height: clamp(36px, 3.25vh, 42px);
    --rail-provider-height: clamp(38px, 3.05vh, 42px);
    --rail-upload-height: clamp(96px, 8.6vh, 132px);
    --rail-control-width: 100%;
    --rail-label-height: 13px;
    --rail-label-size: 0.7rem;
    --rail-label-top: 8px;
    --rail-label-bottom: 4px;
    --rail-control-gap: 7px;
    --rail-note-height: 58px;
    --rail-custom-padding: 8px;
    --rail-ontology-gap: 4px;
    --rail-namespace-gap: 9px;
    --rail-ontology-note-height: 22px;
    --rail-section-gap: clamp(24px, 2.8vh, 40px);
    overflow-x: hidden;
    overflow-y: scroll;
    scrollbar-gutter: stable;
  }

  body.app-page .rail *,
  body.app-page .rail *::before,
  body.app-page .rail *::after {
    box-sizing: border-box;
  }

  body.app-page .rail .panel-heading {
    flex: 0 0 var(--rail-control-height);
    min-height: var(--rail-control-height);
    margin: 0 0 var(--rail-control-gap);
  }

  body.app-page .rail .icon-button {
    width: var(--rail-control-height) !important;
    height: var(--rail-control-height) !important;
    min-width: var(--rail-control-height) !important;
    min-height: var(--rail-control-height) !important;
    padding: 0 !important;
  }

  body.app-page .rail .field-label {
    display: block;
    flex: 0 0 auto;
    width: var(--rail-control-width) !important;
    height: var(--rail-label-height) !important;
    margin: var(--rail-label-top) 0 var(--rail-label-bottom) !important;
    font-size: var(--rail-label-size) !important;
    line-height: var(--rail-label-height) !important;
    overflow: hidden;
    white-space: nowrap;
  }

  body.app-page .rail .input,
  body.app-page .rail .secondary-button,
  body.app-page .rail .primary-button,
  body.app-page .rail .switcher {
    box-sizing: border-box !important;
    flex: 0 0 auto;
    width: var(--rail-control-width) !important;
    min-width: 0 !important;
    max-width: var(--rail-control-width) !important;
    height: var(--rail-control-height) !important;
    min-height: var(--rail-control-height) !important;
    max-height: var(--rail-control-height) !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    font-size: 0.9rem !important;
  }

  body.app-page .rail .input {
    padding: 0 10px !important;
  }

  body.app-page .rail #base-namespace,
  body.app-page .rail #ontology-prefix,
  body.app-page .rail #shape-namespace,
  body.app-page .rail #shape-prefix {
    padding-right: 7px !important;
    padding-left: 7px !important;
    font-size: 0.78rem !important;
  }

  body.app-page .rail .file-drop {
    display: flex !important;
    box-sizing: border-box !important;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: var(--rail-control-width) !important;
    min-width: 0 !important;
    max-width: var(--rail-control-width) !important;
    height: var(--rail-upload-height) !important;
    min-height: var(--rail-upload-height) !important;
    max-height: var(--rail-upload-height) !important;
    margin: 0 !important;
    padding: 10px !important;
    border-style: dashed;
  }

  body.app-page .rail .file-drop span,
  body.app-page .rail .file-drop small {
    line-height: 1;
    white-space: nowrap;
  }

  body.app-page .rail .file-drop span {
    font-size: 0.98rem;
  }

  body.app-page .rail .file-drop small {
    font-size: 0.78rem;
  }

  body.app-page .rail > #ontology-summary,
  body.app-page .rail > .session-actions + .microcopy {
    flex-basis: var(--rail-ontology-note-height);
    height: var(--rail-ontology-note-height) !important;
    min-height: var(--rail-ontology-note-height) !important;
    max-height: var(--rail-ontology-note-height) !important;
    margin-top: var(--rail-ontology-gap) !important;
    line-height: 1.2 !important;
  }

  body.app-page .rail > #ontology-summary {
    --rail-ontology-summary-height: calc(var(--rail-ontology-note-height) + 12px);
    flex-basis: var(--rail-ontology-summary-height);
    height: var(--rail-ontology-summary-height) !important;
    min-height: var(--rail-ontology-summary-height) !important;
    max-height: var(--rail-ontology-summary-height) !important;
    overflow: visible;
  }

  body.app-page .rail > .namespace-label-row {
    margin-top: var(--rail-ontology-gap) !important;
  }

  body.app-page .rail .namespace-label-row {
    flex: 0 0 var(--rail-label-height);
    width: var(--rail-control-width);
    min-height: var(--rail-label-height);
  }

  body.app-page .rail .namespace-label-row .field-label {
    width: auto !important;
    height: var(--rail-label-height) !important;
    margin: 0 !important;
    line-height: var(--rail-label-height) !important;
  }

  body.app-page .rail .namespace-source {
    padding: 2px 6px;
    font-size: 0.6rem;
  }

  body.app-page .rail .namespace-mini-panels {
    flex: 0 0 auto;
    width: var(--rail-control-width);
    gap: var(--rail-namespace-gap);
    margin-top: var(--rail-namespace-gap);
  }

  body.app-page .rail .namespace-mini-panel {
    padding-top: 6px;
  }

  body.app-page .rail .namespace-mini-panel:first-child {
    padding-top: 12px;
  }

  body.app-page .rail .namespace-mini-title {
    height: var(--rail-label-height);
  }

  body.app-page .rail .namespace-mini-title h3 {
    font-size: var(--rail-label-size);
    line-height: var(--rail-label-height);
  }

  body.app-page .rail .namespace-input-row {
    grid-template-columns: minmax(0, 1fr) 66px;
    gap: var(--rail-control-gap);
    margin-top: 3px;
  }

  body.app-page .rail .namespace-input-row label > span {
    height: 9px;
    margin-bottom: 2px;
    font-size: 0.55rem;
    line-height: 9px;
  }

  body.app-page .rail .namespace-input-row .input {
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
  }

  body.app-page .rail .microcopy {
    flex: 0 0 var(--rail-note-height);
    width: var(--rail-control-width) !important;
    height: var(--rail-note-height) !important;
    max-height: var(--rail-note-height) !important;
    margin: var(--rail-control-gap) 0 0 !important;
    font-size: 0.76rem !important;
    line-height: 1.32 !important;
    overflow: hidden;
  }

  body.app-page .rail > .namespace-summary {
    flex: 0 0 var(--rail-ontology-note-height);
    height: var(--rail-ontology-note-height) !important;
    min-height: var(--rail-ontology-note-height) !important;
    max-height: var(--rail-ontology-note-height) !important;
    margin-top: var(--rail-ontology-gap) !important;
    line-height: 1.2 !important;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  body.app-page .rail > .shape-namespace-row {
    margin-top: var(--rail-ontology-gap) !important;
  }

  body.app-page .rail .session-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto !important;
    gap: var(--rail-control-gap) !important;
    width: var(--rail-control-width) !important;
    height: var(--rail-control-height) !important;
    margin: var(--rail-control-gap) 0 0 !important;
  }

  body.app-page .rail .session-toolbar {
    flex: 0 0 auto;
    width: var(--rail-control-width);
    margin: 0 0 12px;
    padding: 0 0 10px;
  }

  body.app-page .rail .session-toolbar .session-actions {
    margin-top: 0 !important;
  }

  body.app-page .rail .session-toolbar .session-note {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin-top: 5px !important;
  }

  body.app-page .rail > .session-actions {
    margin-top: var(--rail-ontology-gap) !important;
  }

  body.app-page .rail .switcher {
    gap: 0 !important;
    align-items: stretch !important;
  }

  body.app-page .rail .switch-button {
    display: grid !important;
    place-items: center !important;
    box-sizing: border-box !important;
    width: 100% !important;
    height: var(--rail-control-height) !important;
    min-width: 0 !important;
    min-height: var(--rail-control-height) !important;
    max-height: var(--rail-control-height) !important;
    padding: 0 !important;
    border-top: 0 !important;
    border-bottom: 0 !important;
    border-left: 0 !important;
    border-right: 1px solid var(--ink) !important;
    border-radius: 0 !important;
    line-height: 1 !important;
    transform: none !important;
    box-shadow: none !important;
  }

  body.app-page .rail .switch-button:last-child {
    border-right: 0 !important;
  }

  body.app-page .rail .switch-button.active {
    background: var(--ink) !important;
    color: var(--surface) !important;
    transform: none !important;
    box-shadow: none !important;
  }

  body.app-page .rail .switch-button:not(.active) {
    background: var(--surface) !important;
    color: var(--ink) !important;
  }

  body.app-page .rail .inline-panel {
    flex: 0 0 auto;
    width: var(--rail-control-width) !important;
    margin-top: var(--rail-section-gap) !important;
    padding-top: var(--rail-section-gap) !important;
  }

  body.app-page .rail .model-panel {
    display: flex !important;
    flex-direction: column;
    align-items: stretch !important;
  }

  body.app-page .rail .model-panel h2 {
    flex: 0 0 auto;
    height: 20px;
    margin: 0 !important;
    line-height: 20px;
  }

  body.app-page .rail .provider-switch {
    height: var(--rail-provider-height) !important;
    min-height: var(--rail-provider-height) !important;
    max-height: var(--rail-provider-height) !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body.app-page .rail .provider-switch .switch-button {
    height: var(--rail-provider-height) !important;
    min-height: var(--rail-provider-height) !important;
    max-height: var(--rail-provider-height) !important;
    font-size: 0.9rem !important;
  }

  body.app-page .rail .provider-config-stack {
    position: static;
    flex: 0 0 auto;
    width: var(--rail-control-width) !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    overflow: visible;
  }

  body.app-page .rail .provider-config {
    position: static;
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    transition: none !important;
  }

  body.app-page .rail .provider-config.is-inactive {
    display: none !important;
    visibility: visible;
    opacity: 1;
    pointer-events: none;
  }

  body.app-page .rail .provider-config.is-active {
    display: block !important;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  body.app-page .rail .custom-model-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: var(--rail-control-gap) !important;
    width: var(--rail-control-width) !important;
    min-width: 0 !important;
    max-width: var(--rail-control-width) !important;
    height: calc(var(--rail-control-height) * 3 + var(--rail-control-gap) * 2 + var(--rail-custom-padding) * 2) !important;
    min-height: calc(var(--rail-control-height) * 3 + var(--rail-control-gap) * 2 + var(--rail-custom-padding) * 2) !important;
    max-height: calc(var(--rail-control-height) * 3 + var(--rail-control-gap) * 2 + var(--rail-custom-padding) * 2) !important;
    margin: 0 !important;
    padding: var(--rail-custom-padding) !important;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
  }

  body.app-page .rail .custom-model-row > * {
    width: var(--rail-control-width) !important;
    min-width: 0 !important;
    max-width: var(--rail-control-width) !important;
    height: var(--rail-control-height) !important;
    min-height: var(--rail-control-height) !important;
    max-height: var(--rail-control-height) !important;
    margin: 0 !important;
  }

  body.app-page .rail .model-panel #model-config-status {
    flex: 0 0 var(--rail-note-height);
    box-sizing: border-box !important;
    width: var(--rail-control-width) !important;
    height: var(--rail-note-height) !important;
    min-height: var(--rail-note-height) !important;
    max-height: var(--rail-note-height) !important;
    margin: var(--rail-control-gap) 0 0 !important;
    overflow: hidden;
  }
}

@media (min-width: 1061px) and (max-height: 1100px) {
  body.app-page .rail {
    --rail-control-height: 35px;
    --rail-provider-height: 38px;
    --rail-upload-height: 96px;
    --rail-label-height: 11px;
    --rail-label-size: 0.64rem;
    --rail-label-top: 6px;
    --rail-label-bottom: 4px;
    --rail-control-gap: 5px;
    --rail-note-height: 52px;
    --rail-custom-padding: 7px;
    --rail-ontology-gap: 3px;
    --rail-namespace-gap: 9px;
    --rail-ontology-note-height: 18px;
    --rail-section-gap: 22px;
  }

  body.app-page .rail .session-actions + .microcopy {
    display: none !important;
  }

  body.app-page .rail .model-panel h2 {
    height: 18px;
    line-height: 18px;
  }
}
