:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --bg-strong: #e8edf6;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-strong: #ffffff;
  --panel-muted: #f8faff;
  --ink: #101828;
  --ink-soft: #344054;
  --muted: #667085;
  --muted-light: #98a2b3;
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.14);
  --accent: #4f46e5;
  --accent-strong: #3730a3;
  --accent-bright: #6366f1;
  --accent-soft: rgba(79, 70, 229, 0.09);
  --cyan: #0891b2;
  --cyan-soft: #e8f7fb;
  --blue-soft: #edf4ff;
  --amber-soft: #fff7e8;
  --violet-soft: #f3efff;
  --danger: #d92d20;
  --danger-soft: #fff0ee;
  --success: #039855;
  --success-soft: #ecfdf3;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 4px 14px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 12px 30px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, 0.12);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --font-sans: "Aptos", "Segoe UI Variable", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-head: "Aptos Display", "Segoe UI Variable Display", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at 8% 0%, rgba(99, 102, 241, 0.08), transparent 27rem),
    radial-gradient(circle at 100% 28%, rgba(8, 145, 178, 0.06), transparent 30rem),
    linear-gradient(180deg, #f8faff 0%, var(--bg) 38%, #eef2f8 100%);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(99, 102, 241, 0.2);
  outline-offset: 2px;
}

::selection {
  color: #fff;
  background: rgba(79, 70, 229, 0.8);
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) auto auto;
  gap: 18px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.07);
  background: rgba(250, 252, 255, 0.86);
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.04);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
}

.topbar::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.28), transparent);
  pointer-events: none;
}

.topbar__brand {
  min-width: 0;
}

.topbar__brand h1,
.panel-heading h2,
.section-title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-head);
  font-weight: 760;
  letter-spacing: -0.025em;
}

.topbar__brand h1 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(1.35rem, 2vw, 1.65rem);
  line-height: 1;
}

.topbar__brand h1::before {
  content: "";
  width: 12px;
  height: 28px;
  flex: none;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-bright), var(--cyan));
  box-shadow: 0 5px 14px rgba(79, 70, 229, 0.28);
}

.topbar__eyebrow,
.panel-kicker {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar__headline,
.workspace-badges,
.topbar__status,
.topbar__actions,
.toolbar-row,
.action-row,
.process-header__actions,
.canvas-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar__headline {
  gap: 12px;
}

.topbar__actions,
.canvas-toolbar__actions {
  justify-content: flex-end;
}

.workspace-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 10px;
  border: 1px solid rgba(79, 70, 229, 0.12);
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(79, 70, 229, 0.055);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.02em;
}

.topbar__brand p,
.panel-heading p,
.hint-text,
.muted-text,
.section-copy {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.52;
}

.topbar__brand p {
  max-width: 620px;
  overflow: hidden;
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-chip {
  position: relative;
  min-width: 122px;
  padding: 9px 12px 9px 15px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
}

.status-chip::before {
  content: "";
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 0;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-bright), var(--cyan));
}

.status-chip__label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted-light);
  font-size: 0.66rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.status-chip strong {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  min-height: 0;
}

.nav-rail {
  position: sticky;
  top: 89px;
  height: calc(100vh - 89px);
  height: calc(100dvh - 89px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 12px;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  background:
    radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.32), transparent 16rem),
    linear-gradient(180deg, #172033 0%, #111827 70%, #0f172a 100%);
  scrollbar-width: none;
}

.nav-rail::-webkit-scrollbar {
  display: none;
}

.nav-rail__group {
  display: grid;
  gap: 7px;
}

.nav-rail__item {
  position: relative;
  min-height: 52px;
  padding: 8px 7px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: #aeb9ce;
  background: transparent;
  text-align: center;
  font-size: 0.71rem;
  font-weight: 700;
  line-height: 1.22;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.nav-rail__item:hover,
.nav-rail__item:focus-visible {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.07);
  transform: translateY(-1px);
}

.nav-rail__item.is-active {
  color: #fff;
  border-color: rgba(129, 140, 248, 0.26);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.86), rgba(79, 70, 229, 0.72));
  box-shadow: 0 10px 24px rgba(49, 46, 129, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.nav-rail__item.is-active::after {
  content: "";
  position: absolute;
  right: -13px;
  top: 50%;
  width: 3px;
  height: 24px;
  border-radius: 999px 0 0 999px;
  background: #a5b4fc;
  transform: translateY(-50%);
  box-shadow: 0 0 14px rgba(165, 180, 252, 0.72);
}

.nav-rail__footer {
  display: grid;
  gap: 3px;
  padding: 11px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 13px;
  color: #dbe4f2;
  background: rgba(255, 255, 255, 0.055);
  text-align: center;
}

.nav-rail__footer-label {
  color: #8492a9;
  font-size: 0.64rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-rail__footer strong {
  font-size: 0.76rem;
}

.main-stage {
  min-width: 0;
  padding: 20px;
}

.view-panel {
  display: none;
  min-height: calc(100vh - 130px);
  min-height: calc(100dvh - 130px);
}

.view-panel.is-visible {
  display: block;
  animation: view-in 230ms ease both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.editor-shell {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr) 310px;
  gap: 16px;
  min-height: calc(100vh - 132px);
  min-height: calc(100dvh - 132px);
  align-items: start;
}

.palette-panel,
.canvas-panel,
.inspector-panel,
.sheet-panel,
.compare-panel,
.metrics-panel,
.history-panel,
.report-panel {
  border: 1px solid rgba(15, 23, 42, 0.075);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-md);
}

.palette-panel,
.inspector-panel {
  position: sticky;
  top: 108px;
  max-height: calc(100vh - 132px);
  max-height: calc(100dvh - 132px);
  overflow: auto;
  padding: 17px;
  background: rgba(250, 252, 255, 0.94);
  scrollbar-width: thin;
  scrollbar-color: rgba(102, 112, 133, 0.28) transparent;
}

.palette-panel::-webkit-scrollbar,
.inspector-panel::-webkit-scrollbar,
.canvas-stage::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
.report-preview::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.palette-panel::-webkit-scrollbar-thumb,
.inspector-panel::-webkit-scrollbar-thumb,
.canvas-stage::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
.report-preview::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(102, 112, 133, 0.28);
  background-clip: padding-box;
}

.canvas-panel {
  display: flex;
  min-width: 0;
  min-height: calc(100vh - 132px);
  min-height: calc(100dvh - 132px);
  overflow: hidden;
  flex-direction: column;
  background: #fff;
  box-shadow: 0 18px 48px rgba(16, 24, 40, 0.1);
}

.panel-heading,
.section-header,
.canvas-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-heading--stack {
  display: block;
}

.panel-heading h2 {
  font-size: 1.13rem;
}

.panel-heading p {
  font-size: 0.79rem;
}

.palette-panel__group + .palette-panel__group,
.stack-section + .stack-section {
  margin-top: 19px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.palette-chip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  align-items: start;
  min-height: 100px;
  padding: 12px 11px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-xs);
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.palette-chip:hover,
.palette-chip:focus-visible,
.palette-chip.is-armed {
  border-color: rgba(79, 70, 229, 0.28);
  background: #fff;
  box-shadow: 0 9px 24px rgba(79, 70, 229, 0.1);
  transform: translateY(-2px);
}

.palette-chip.is-armed {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08), 0 10px 26px rgba(79, 70, 229, 0.12);
}

.palette-chip__shape {
  display: grid;
  place-items: center;
  width: 42px;
  height: 39px;
  border: 1px solid rgba(15, 23, 42, 0.04);
  border-radius: 13px;
  background: var(--bg-strong);
}

.palette-chip__shape-core {
  position: relative;
  display: block;
  width: 23px;
  height: 15px;
  border-radius: 10px;
  background: #4f64df;
  box-shadow: 0 3px 8px rgba(79, 70, 229, 0.18);
}

.palette-chip__body {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.palette-chip__body strong {
  display: block;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.palette-chip__body span {
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.35;
}

.palette-chip--start .palette-chip__shape { background: var(--success-soft); }
.palette-chip--start .palette-chip__shape-core { width: 25px; height: 16px; border-radius: 999px; background: #12a66a; }
.palette-chip--activity .palette-chip__shape { background: var(--blue-soft); }
.palette-chip--activity .palette-chip__shape-core { border-radius: 6px; background: #4f64df; }
.palette-chip--decision .palette-chip__shape { background: var(--amber-soft); }
.palette-chip--decision .palette-chip__shape-core { width: 18px; height: 18px; border-radius: 4px; background: #d28a18; transform: rotate(45deg); }
.palette-chip--wait .palette-chip__shape { background: var(--violet-soft); }
.palette-chip--wait .palette-chip__shape-core { width: 25px; height: 13px; border-radius: 999px; background: #8158d8; }
.palette-chip--subprocess .palette-chip__shape { background: var(--cyan-soft); }
.palette-chip--subprocess .palette-chip__shape-core { border-radius: 6px; background: #1689ad; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.82); }
.palette-chip--end .palette-chip__shape { background: var(--danger-soft); }
.palette-chip--end .palette-chip__shape-core { width: 25px; height: 16px; border-radius: 999px; background: #d84b42; }

.stack-actions {
  display: grid;
  gap: 10px;
}

.stack-actions--compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #eef2f8;
}

.palette-note {
  display: grid;
  gap: 5px;
  padding: 13px;
  border: 1px dashed rgba(79, 70, 229, 0.24);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(79, 70, 229, 0.05), rgba(8, 145, 178, 0.035));
}

.palette-note strong {
  color: var(--accent-strong);
  font-size: 0.83rem;
}

.palette-note span {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
}

.canvas-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 252, 255, 0.94);
}

.canvas-toolbar__identity {
  display: grid;
  grid-row: 1 / span 2;
  align-self: center;
  gap: 7px;
  min-width: 0;
  width: 100%;
}

.canvas-toolbar__label,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 760;
}

.canvas-toolbar__label {
  width: fit-content;
  border: 1px solid rgba(79, 70, 229, 0.15);
  color: var(--accent-strong);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.11), rgba(8, 145, 178, 0.07));
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.breadcrumbs button {
  max-width: 360px;
  min-height: 29px;
  padding: 0 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: #fff;
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: 160ms ease;
}

.breadcrumbs button:hover,
.breadcrumbs button:focus-visible {
  border-color: rgba(79, 70, 229, 0.22);
  color: var(--accent-strong);
  transform: translateY(-1px);
}

.canvas-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.process-header__meta .canvas-stats {
  margin-top: 10px;
}

.canvas-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  box-shadow: var(--shadow-xs);
}

.canvas-stat strong {
  color: var(--ink);
  font-size: 0.8rem;
}

.canvas-stat span {
  color: var(--muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

.zoom-group {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
}

.zoom-group .btn {
  min-height: 32px;
}

.process-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.process-header__meta {
  min-width: 0;
}

.field,
.stack-field {
  display: grid;
  gap: 7px;
}

.field--compact {
  gap: 5px;
}

.field-label {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 680;
}

.field-help {
  margin-top: -2px;
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.42;
}

.field-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 8px;
}

input[type="text"],
input[type="number"],
input[type="file"],
textarea,
select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.02);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.5;
}

input[type="file"] {
  padding: 7px;
  overflow: hidden;
}

input[type="file"]::file-selector-button {
  min-height: 31px;
  margin-right: 10px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink-soft);
  background: #f7f9fc;
  font: inherit;
  font-weight: 650;
}

input:hover,
textarea:hover,
select:hover {
  border-color: rgba(79, 70, 229, 0.22);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: rgba(79, 70, 229, 0.52);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.09);
}

.canvas-stage {
  position: relative;
  flex: 1;
  min-height: 560px;
  overflow: auto;
  padding: 18px;
  background-color: #edf1f7;
  background-image:
    linear-gradient(rgba(79, 70, 229, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 70, 229, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 50% 15%, rgba(255, 255, 255, 0.95), rgba(238, 242, 248, 0.74) 62%);
  background-size: 24px 24px, 24px 24px, 100% 100%;
}

.diagram-canvas {
  display: block;
  width: 1800px;
  height: 1100px;
  margin: 0 auto;
  border: 1px solid rgba(15, 23, 42, 0.05);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.38);
  box-shadow: 0 18px 42px rgba(16, 24, 40, 0.055);
}

.canvas-stage__footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #fafcff;
  font-size: 0.7rem;
}

.sheet-panel,
.compare-panel,
.metrics-panel,
.history-panel,
.report-panel {
  padding: clamp(18px, 2.2vw, 28px);
}

.section-header {
  margin-bottom: 22px;
}

.section-title {
  font-size: clamp(1.35rem, 2vw, 1.72rem);
}

.section-copy {
  max-width: 760px;
  font-size: 0.86rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid--wide {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.metric-card,
.attachment-item,
.snapshot-item,
.log-item,
.surface-block {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  box-shadow: var(--shadow-xs);
}

.metric-card {
  position: relative;
  min-height: 112px;
  padding: 17px;
  overflow: hidden;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-bright), var(--cyan));
  opacity: 0.78;
}

.metric-card:hover {
  border-color: rgba(79, 70, 229, 0.16);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.metric-card__label {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.metric-card__value {
  display: block;
  margin-top: 11px;
  color: var(--ink);
  font-family: var(--font-head);
  font-size: clamp(1.55rem, 3vw, 2rem);
  font-weight: 780;
  letter-spacing: -0.035em;
}

.compare-layout,
.metrics-layout,
.history-layout,
.report-layout,
.stack-surface,
.inspector-layout,
.attachment-list,
.snapshot-list,
.log-list {
  display: grid;
  gap: 15px;
}

.compare-layout {
  grid-template-columns: 1.2fr 1fr;
}

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

.surface-block {
  padding: 16px;
}

.surface-block h3 {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.surface-block--hero {
  border-color: rgba(79, 70, 229, 0.13);
  background:
    radial-gradient(circle at 100% 0%, rgba(99, 102, 241, 0.12), transparent 18rem),
    linear-gradient(145deg, #fff, #f7f9ff);
}

.stack-section {
  padding-top: 3px;
}

.mini-pill-row,
.quick-editor__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 750;
}

.mini-pill--work { color: #4338ca; background: #eef2ff; }
.mini-pill--wait { color: #1d4ed8; background: #eff6ff; }
.mini-pill--neutral { color: #475467; background: #f2f4f7; }
.mini-pill--accent { color: #075985; background: #e6f7fb; }

.surface-block details,
.surface-block summary {
  margin: 0;
}

details.surface-block {
  padding-bottom: 0;
}

details.surface-block summary {
  position: relative;
  margin: -16px -16px 0;
  padding: 16px 42px 16px 16px;
  list-style: none;
  cursor: pointer;
  font-weight: 720;
}

details.surface-block summary::after {
  content: "+";
  position: absolute;
  top: 50%;
  right: 16px;
  color: var(--accent);
  font-size: 1.1rem;
  transform: translateY(-50%);
}

details.surface-block[open] summary::after {
  content: "−";
}

details.surface-block summary::-webkit-details-marker {
  display: none;
}

details.surface-block[open] summary {
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.inline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.diagram-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.preview-frame {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.preview-frame header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  background: #fafcff;
  font-size: 0.82rem;
  font-weight: 720;
}

.preview-frame svg {
  display: block;
  width: 100%;
  height: 320px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
}

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

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f8faff;
  font-size: 0.7rem;
  font-weight: 760;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: rgba(79, 70, 229, 0.026);
}

.pill {
  border: 1px solid transparent;
}

.pill--added { color: #027a48; background: var(--success-soft); }
.pill--removed { color: #b42318; background: var(--danger-soft); }
.pill--changed { color: #b54708; background: var(--amber-soft); }
.pill--neutral { color: #475467; background: #f2f4f7; }

.plain-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.attachment-item,
.snapshot-item,
.log-item {
  padding: 15px;
}

.attachment-item__meta,
.snapshot-item__meta,
.log-item__meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
}

.report-preview {
  min-height: 520px;
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: #344054;
  background: #fbfcfe;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.84rem;
  line-height: 1.62;
  white-space: pre-wrap;
}

.empty-state {
  padding: 34px 24px;
  border: 1px dashed rgba(79, 70, 229, 0.25);
  border-radius: 15px;
  color: var(--muted);
  background: linear-gradient(145deg, rgba(79, 70, 229, 0.035), rgba(8, 145, 178, 0.025));
  text-align: center;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.quick-editor-layer {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 10;
  width: 380px;
  max-width: calc(100% - 36px);
  pointer-events: none;
}

.quick-editor {
  position: relative;
  width: 100%;
  padding: 17px;
  border: 1px solid rgba(79, 70, 229, 0.16);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 22px 54px rgba(16, 24, 40, 0.18);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  pointer-events: auto;
  animation: quick-editor-in 180ms ease both;
}

@keyframes quick-editor-in {
  from { opacity: 0; transform: translateY(-5px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.quick-editor__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.quick-editor__header h3 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 1.03rem;
}

.quick-editor__kicker {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.quick-editor__close {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: #f8faff;
  font-size: 0.72rem;
}

.quick-editor__form {
  display: grid;
  gap: 13px;
  margin-top: 15px;
}

.quick-editor__form textarea {
  min-height: 82px;
}

.quick-editor__actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.btn {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink-soft);
  background: #fff;
  box-shadow: var(--shadow-xs);
  font-size: 0.78rem;
  font-weight: 680;
  white-space: nowrap;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease, color 150ms ease;
}

.btn:hover,
.btn:focus-visible {
  border-color: rgba(79, 70, 229, 0.24);
  color: var(--accent-strong);
  background: #fff;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0) scale(0.985);
}

.btn.is-active,
.btn--primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.btn.is-active:hover,
.btn--primary:hover,
.btn.is-active:focus-visible,
.btn--primary:focus-visible {
  color: #fff;
  background: linear-gradient(135deg, #5758e8, #3730a3);
  box-shadow: 0 11px 24px rgba(79, 70, 229, 0.28);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.78);
}

.btn--danger {
  color: var(--danger);
  border-color: rgba(217, 45, 32, 0.2);
  background: rgba(255, 255, 255, 0.9);
}

.btn--danger:hover,
.btn--danger:focus-visible {
  color: #b42318;
  border-color: rgba(217, 45, 32, 0.28);
  background: var(--danger-soft);
}

.btn--icon {
  width: 36px;
  padding: 0;
}

.btn--zoom-readout {
  min-width: 62px;
}

.toast-region {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 60;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 270px;
  max-width: 360px;
  padding: 13px 15px 13px 17px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 13px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: toast-in 220ms ease both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast--error { border-left-color: var(--danger); }
.toast--success { border-left-color: var(--success); }

.inspector-panel .surface-block,
.inspector-panel .attachment-item,
.inspector-panel .snapshot-item,
.inspector-panel .log-item {
  box-shadow: none;
}

.inspector-panel .surface-block {
  background: rgba(255, 255, 255, 0.82);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1480px) {
  .editor-shell {
    grid-template-columns: 224px minmax(0, 1fr) 286px;
    gap: 13px;
  }

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

@media (max-width: 1260px) {
  .topbar {
    grid-template-columns: minmax(280px, 1fr) auto;
  }

  .topbar__actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .editor-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .inspector-panel {
    position: static;
    grid-column: 1 / -1;
    max-height: none;
  }

  .compare-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .topbar {
    position: relative;
    grid-template-columns: 1fr;
    padding: 15px 16px;
  }

  .topbar__status,
  .topbar__actions {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .nav-rail {
    position: sticky;
    top: 0;
    z-index: 25;
    height: auto;
    min-height: 66px;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding: 8px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(17, 24, 39, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .nav-rail__group {
    display: flex;
    gap: 5px;
  }

  .nav-rail__item {
    min-width: 94px;
    min-height: 46px;
  }

  .nav-rail__item.is-active::after {
    top: auto;
    right: 20px;
    bottom: -9px;
    left: 20px;
    width: auto;
    height: 3px;
    border-radius: 999px 999px 0 0;
    transform: none;
  }

  .nav-rail__footer {
    min-width: 108px;
  }

  .main-stage {
    padding: 14px;
  }

  .editor-shell,
  .form-grid,
  .form-grid--wide,
  .inline-grid,
  .diagram-preview-grid {
    grid-template-columns: 1fr;
  }

  .palette-panel,
  .inspector-panel {
    position: static;
    max-height: none;
  }

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

  .canvas-toolbar {
    grid-template-columns: 1fr;
  }

  .canvas-toolbar__identity {
    grid-row: auto;
  }

  .canvas-toolbar__actions,
  .zoom-group {
    justify-self: start;
  }

  .process-header,
  .canvas-stage__footer {
    display: grid;
    grid-template-columns: 1fr;
  }

  .canvas-panel {
    min-height: 760px;
  }
}

@media (max-width: 720px) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .topbar__brand p {
    white-space: normal;
  }

  .topbar__status {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .status-chip {
    min-width: 0;
  }

  .topbar__actions,
  .canvas-toolbar__actions,
  .process-header__actions,
  .action-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .topbar__actions .btn,
  .canvas-toolbar__actions .btn,
  .process-header__actions .btn,
  .action-row .btn {
    width: 100%;
    min-height: 44px;
  }

  .main-stage {
    padding: 10px;
  }

  .sheet-panel,
  .compare-panel,
  .metrics-panel,
  .history-panel,
  .report-panel,
  .palette-panel,
  .inspector-panel {
    padding: 15px;
    border-radius: 16px;
  }

  .canvas-panel {
    min-height: 690px;
    border-radius: 16px;
  }

  .canvas-toolbar,
  .process-header {
    padding: 12px;
  }

  .canvas-stage {
    min-height: 480px;
    padding: 9px;
  }

  .grid-cards,
  .palette-grid,
  .metrics-layout,
  .history-layout,
  .field-split {
    grid-template-columns: 1fr;
  }

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

  .palette-chip {
    min-height: 92px;
  }

  .section-header {
    display: grid;
  }

  .section-title {
    font-size: 1.35rem;
  }

  .metric-card {
    min-height: 98px;
  }

  .quick-editor-layer {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
    max-width: none;
  }

  .quick-editor {
    max-height: calc(100dvh - 150px);
    overflow: auto;
  }

  .toast-region {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }
}

@media (max-width: 430px) {
  .palette-grid {
    grid-template-columns: 1fr;
  }

  .topbar__actions,
  .canvas-toolbar__actions,
  .process-header__actions,
  .action-row {
    grid-template-columns: 1fr;
  }

  .workspace-badges {
    display: none;
  }

  .zoom-group {
    width: 100%;
    justify-content: space-between;
  }

  .zoom-group .btn {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
