:root {
  --rips-bg: #f4efe7;
  --rips-surface: rgb(255 252 247 / 0.92);
  --rips-surface-strong: #fffdf8;
  --rips-ink: #221d16;
  --rips-muted: #6f6256;
  --rips-line: rgb(53 41 28 / 0.14);
  --rips-accent: #0f766e;
  --rips-accent-strong: #0a4f4a;
  --rips-alert: #b42318;
  --rips-alert-soft: rgb(180 35 24 / 0.09);
  --rips-info: #155eef;
  --rips-info-soft: rgb(21 94 239 / 0.08);
  --rips-shadow: 0 30px 80px rgb(34 29 22 / 0.12);
  --rips-radius-lg: 26px;
  --rips-radius-md: 18px;
  --rips-radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body.rips-workbench-body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgb(15 118 110 / 0.18), transparent 24%),
    radial-gradient(circle at left 20%, rgb(194 115 56 / 0.14), transparent 18%),
    linear-gradient(180deg, #f7f2ea 0%, #efe7db 100%);
  color: var(--rips-ink);
  font-family: "Didact Gothic", sans-serif;
}

.rips-workbench {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 320px minmax(0, 1fr);
}

:is(.rips-step-card, .rips-panel, .rips-case-summary-card, .rips-finding, .rips-trace-table) {
  border: 1px solid var(--rips-line);
  border-radius: var(--rips-radius-lg);
  background: var(--rips-surface);
  box-shadow: var(--rips-shadow);
  backdrop-filter: blur(16px);
}

:is(.rips-step-strip, .rips-dashboard-grid, .rips-workspace-grid, .rips-metrics, .rips-defaults-grid, .rips-field-grid, .rips-repeatable) {
  display: grid;
  gap: 16px;
}

:is(.rips-sidebar__brand h1, .rips-hero h2, .rips-step-card h3, .rips-section-head h2, .rips-section-head h3, .rips-form-section__head h4) {
  font-family: "Poppins", sans-serif;
}

.rips-eyebrow {
  margin: 0 0 8px;
  color: rgb(248 243 237 / 0.6);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.rips-muted {
  margin: 0;
  color: var(--rips-muted);
}

.rips-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px;
  border-right: 1px solid rgb(255 255 255 / 0.08);
  background: rgb(34 29 22 / 0.94);
  color: #f8f3ed;

  .rips-muted {
    color: rgb(248 243 237 / 0.72);
  }

  .rips-sidebar__brand h1 {
    margin: 0 0 8px;
    font-size: 2rem;
    line-height: 1;
  }

  .rips-sidebar__actions {
    margin: 24px 0 28px;
  }

  .rips-sidebar__section {
    display: grid;
    gap: 12px;
  }
}

:is(.rips-sidebar__actions, .rips-inline-actions) {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.rips-link-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgb(255 255 255 / 0.14);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-decoration: none;

  &:is(:hover, :focus-visible) {
    border-color: rgb(255 255 255 / 0.3);
    background: rgb(255 255 255 / 0.06);
  }

  &.rips-link-chip--solid {
    border-color: transparent;
    background: linear-gradient(135deg, #0f766e, #155eef);
    color: #fff;
  }

  &[disabled] {
    opacity: 0.56;
    cursor: not-allowed;
  }
}

.rips-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  :is(h2, h3) {
    margin: 0;
  }
}

.rips-case-list {
  display: grid;
  max-height: calc(100vh - 240px);
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.rips-case-card {
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: var(--rips-radius-md);
  background: rgb(255 255 255 / 0.05);
  cursor: pointer;
  padding: 14px;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;

  &:is(:hover, :focus-visible) {
    border-color: rgb(255 255 255 / 0.3);
    background: rgb(255 255 255 / 0.08);
    transform: translateY(-1px);
  }

  &.is-active {
    border-color: rgb(255 255 255 / 0.44);
    background: linear-gradient(135deg, rgb(15 118 110 / 0.34), rgb(21 94 239 / 0.18));
  }

  .rips-case-card__title {
    margin: 0 0 4px;
    font-weight: 700;
  }

  :is(.rips-case-card__meta, .rips-case-card__types) {
    margin: 0;
    color: rgb(248 243 237 / 0.72);
    font-size: 0.92rem;
  }
}

.rips-main {
  padding: 30px 28px 40px;
}

.rips-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;

  h2 {
    margin: 0 0 8px;
    font-size: clamp(1.8rem, 3vw, 3rem);
    line-height: 0.98;
  }

  .rips-hero__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }
}

:is(.rips-status-badge, .rips-pill) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0 12px;
}

.rips-pill {
  background: rgb(34 29 22 / 0.08);
}

.rips-status-badge {
  background: #7b6f61;
  color: #fff;

  &.rips-status-badge--approved {
    background: var(--rips-accent);
  }

  &.rips-status-badge--rejected {
    background: var(--rips-alert);
  }

  &.rips-status-badge--notified {
    background: #946200;
  }

  &.rips-status-badge--idle {
    background: #7b6f61;
  }
}

.rips-step-strip {
  margin-bottom: 22px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.rips-step-card {
  display: flex;
  gap: 14px;
  padding: 18px;

  .rips-step-card__index {
    color: var(--rips-accent);
    font: 700 1.4rem/1 "Poppins", sans-serif;
  }

  p {
    margin: 6px 0 0;
    color: var(--rips-muted);
  }
}

.rips-dashboard-grid {
  margin-bottom: 22px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rips-workspace-grid {
  align-items: start;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.95fr);
}

.rips-panel {
  padding: 22px;

  &.rips-panel--form {
    padding-bottom: 12px;
  }

  &.rips-panel--summary {
    min-height: 184px;
  }
}

:is(.rips-kv-grid, .rips-metrics) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rips-kv-grid {
  dt {
    color: var(--rips-muted);
    font-size: 0.84rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  dd {
    margin: 6px 0 0;
    font-size: 1.05rem;
    font-weight: 700;
  }
}

.rips-metric {
  border: 1px solid rgb(53 41 28 / 0.08);
  border-radius: var(--rips-radius-md);
  background: rgb(255 255 255 / 0.68);
  padding: 14px;

  .rips-metric__label {
    display: block;
    color: var(--rips-muted);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .rips-metric__value {
    margin: 6px 0 0;
    font-size: 1.05rem;
    font-weight: 700;
  }
}

.rips-form {
  display: grid;
  gap: 18px;
}

.rips-form-section {
  border: 1px solid var(--rips-line);
  border-radius: var(--rips-radius-md);
  background: rgb(255 255 255 / 0.56);
  padding: 18px;

  &.rips-form-section--template {
    border-style: dashed;
  }

  .rips-form-section__head {
    margin-bottom: 14px;

    h4 {
      margin: 0;
    }

    p {
      margin: 6px 0 0;
      color: var(--rips-muted);
    }
  }
}

.rips-field-grid {
  &.rips-field-grid--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  &.rips-field-grid--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.rips-field {
  display: grid;
  gap: 8px;

  span {
    font-size: 0.9rem;
    font-weight: 700;
  }

  :is(input, select) {
    min-height: 46px;
    width: 100%;
    border: 1px solid rgb(53 41 28 / 0.16);
    border-radius: var(--rips-radius-sm);
    background: #fffdf9;
    color: var(--rips-ink);
    font: inherit;
    padding: 0 12px;

    &:focus {
      outline: 2px solid rgb(21 94 239 / 0.18);
      border-color: rgb(21 94 239 / 0.42);
    }
  }

  &.rips-field--actions {
    justify-content: flex-end;

    .rips-button {
      width: 100%;
    }
  }
}

.rips-repeatable {
  :is(input, select) {
    min-height: 46px;
    width: 100%;
    border: 1px solid rgb(53 41 28 / 0.16);
    border-radius: var(--rips-radius-sm);
    background: #fffdf9;
    color: var(--rips-ink);
    font: inherit;
    padding: 0 12px;

    &:focus {
      outline: 2px solid rgb(21 94 239 / 0.18);
      border-color: rgb(21 94 239 / 0.42);
    }
  }
}

.rips-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-weight: 700;
}

.rips-advanced-panel {
  margin-top: 16px;

  summary {
    cursor: pointer;
    font-weight: 700;
  }

  &[open] summary {
    margin-bottom: 12px;
  }
}

.rips-template-scope {
  min-height: 46px;
  border: 1px solid rgb(53 41 28 / 0.12);
  border-radius: var(--rips-radius-sm);
  background: rgb(255 255 255 /  0.72);
  color: var(--rips-ink);
  padding: 12px 14px;
}

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

:is(.rips-default-card, .rips-repeatable-row) {
  border: 1px solid rgb(53 41 28 / 0.12);
  border-radius: var(--rips-radius-md);
  background: rgb(255 255 255 / 0.74);
}

.rips-default-card {
  padding: 16px;

  h5 {
    margin: 0 0 4px;
    font: 700 1rem/1.2 "Poppins", sans-serif;
  }

  p {
    margin: 0 0 14px;
    color: var(--rips-muted);
    font-size: 0.92rem;
  }
}

.rips-repeatable-row {
  display: grid;
  gap: 12px;
  padding: 14px;

  .rips-repeatable-row__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .rips-repeatable-row__title {
    font-weight: 700;
  }

  .rips-repeatable-row__grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

:is(.rips-inline-add, .rips-remove-button, .rips-button) {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;

  &:hover {
    filter: brightness(0.97);
  }
}

:is(.rips-inline-add, .rips-remove-button) {
  min-height: 38px;
  background: rgb(15 118 110 / 0.08);
  color: var(--rips-accent-strong);
  padding: 0 14px;
}

.rips-sticky-actions {
  position: sticky;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  background: linear-gradient(180deg, rgb(247 242 234 / 0) 0%, rgb(247 242 234 / 0.94) 24%, rgb(247 242 234 / 1) 100%);
  padding: 18px 0 12px;
}

.rips-button {
  min-height: 46px;
  background: linear-gradient(135deg, var(--rips-accent), #155eef);
  color: #fff;
  padding: 0 18px;

  &.rips-button--secondary {
    background: linear-gradient(135deg, #c27338, #8a3d14);
  }

  &.rips-button--ghost {
    background: rgb(34 29 22 / 0.08);
    color: var(--rips-ink);
  }

  &[disabled] {
    opacity: 0.56;
    cursor: not-allowed;
  }
}

.rips-result-stack,
.rips-findings,
.rips-inline-feedback__details {
  display: grid;
}

.rips-result-stack {
  gap: 18px;
}

.rips-findings {
  gap: 12px;
}

.rips-inline-feedback__details {
  gap: 10px;
}

.rips-inline-feedback {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  border: 1px solid transparent;
  border-radius: var(--rips-radius-md);
  padding: 18px;

  &[hidden] {
    display: none;
  }

  &.rips-inline-feedback--error {
    border-color: rgb(180 35 24 / 0.22);
    background: linear-gradient(180deg, rgb(180 35 24 / 0.08), rgb(255 252 247 / 0.96));
  }

  .rips-inline-feedback__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    h4 {
      margin: 0;
    }
  }

  .rips-inline-feedback__message {
    margin: 0;
    color: var(--rips-ink);
    font-weight: 600;
  }
}

.rips-empty-state {
  border: 1px dashed rgb(53 41 28 / 0.16);
  border-radius: var(--rips-radius-md);
  background: rgb(255 255 255 / 0.44);
  color: var(--rips-muted);
  padding: 22px;

  &.rips-empty-state--compact {
    padding: 14px;
  }
}

.rips-finding {
  padding: 16px;

  &.rips-finding--reject {
    border-color: rgb(180 35 24 / 0.22);
    background: linear-gradient(180deg, rgb(180 35 24 / 0.06), rgb(255 252 247 / 0.96));
  }

  &.rips-finding--notify {
    border-color: rgb(21 94 239 / 0.18);
    background: linear-gradient(180deg, rgb(21 94 239 / 0.05), rgb(255 252 247 / 0.96));
  }

  .rips-finding__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
  }

  .rips-finding__code {
    font: 700 0.82rem/1 "Poppins", sans-serif;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .rips-finding__meta {
    color: var(--rips-muted);
    font-size: 0.88rem;
  }
}

.rips-code-block {
  max-height: 480px;
  overflow: auto;
  margin: 0;
  border-radius: var(--rips-radius-md);
  background: #201c17;
  color: #f6f1e8;
  font-size: 0.88rem;
  line-height: 1.55;
  padding: 18px;
}

.rips-trace-table {
  overflow: hidden;

  table {
    width: 100%;
    border-collapse: collapse;
  }

  :is(th, td) {
    border-bottom: 1px solid rgb(53 41 28 / 0.1);
    padding: 12px 14px;
    text-align: left;
    vertical-align: top;
  }

  th {
    color: var(--rips-muted);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
}

@media (max-width: 1280px) {
  :is(.rips-step-strip, .rips-dashboard-grid, .rips-workspace-grid, .rips-defaults-grid, .rips-field-grid.rips-field-grid--three, .rips-repeatable-row .rips-repeatable-row__grid) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .rips-workbench {
    grid-template-columns: 1fr;
  }

  .rips-sidebar {
    position: static;
    height: auto;
  }

  .rips-main {
    padding: 20px 16px 28px;
  }

  :is(.rips-step-strip, .rips-dashboard-grid, .rips-workspace-grid, .rips-defaults-grid, .rips-field-grid.rips-field-grid--two, .rips-field-grid.rips-field-grid--three, .rips-repeatable-row .rips-repeatable-row__grid, .rips-kv-grid, .rips-metrics) {
    grid-template-columns: 1fr;
  }

  :is(.rips-hero, .rips-sticky-actions) {
    flex-direction: column;
    align-items: stretch;
  }
}
