:root {
  color-scheme: light;
  font: 15px/1.45 system-ui, sans-serif;
  --ink: #172b2a;
  --muted: #526465;
  --line: #d7e0de;
  --accent: #006654;
  --accent-faint: #e9f4ef;
  --bg: #f4f7f6;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { display: grid; grid-template-columns: 216px minmax(0, 1fr); margin: 0; background: var(--bg); color: var(--ink); min-height: 100vh; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 3.4vw, 3rem); letter-spacing: -.045em; line-height: 1.15; }
h2 { font-size: 1.06rem; letter-spacing: -.015em; }
button, select, input { font: inherit; }
button, .button, .file-label {
  display: inline-flex; justify-content: center; align-items: center; min-height: 39px;
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 12px;
  background: white; color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none;
}
button:hover:not(:disabled), .file-label:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: solid 2px #007b62; outline-offset: 3px; }
select, input[type="text"], input[type="search"] {
  min-height: 38px; border-radius: 6px; border: 1px solid var(--line);
  color: var(--ink); background: white; padding: 6px 10px;
}
.primary { background: var(--accent); border-color: var(--accent); color: white; }
.primary:hover:not(:disabled) { background: #004b40; }
.nav { padding: 27px 17px; background: #102928; color: #f3f8f7; }
.brand { color: inherit; font-size: 1.16rem; font-weight: 700; display: flex; gap: 10px; align-items: center; text-decoration: none; padding: 2px 8px 28px; }
.brand-glyph { background: #76dfb4; color: #102928; padding: 3px 7px; border-radius: 5px; }
.nav-link, .saved-flow { display: block; text-decoration: none; color: #d6e7e3; padding: 10px 11px; border-radius: 7px; }
.nav-link.active { background: #264743; color: white; font-weight: 650; }
.nav-link:hover, .saved-flow:hover { background: #264743; }
.saved { border-top: 1px solid #3d5753; margin: 25px 0; padding: 21px 0; }
.saved h2 { padding: 0 10px; color: #b4c9c5; font-weight: 500; font-size: .85rem; }
.saved-flow span { display: block; font-size: .85rem; color: #b4c9c5; }
main { max-width: 1480px; width: 100%; margin: 0 auto; padding: 32px clamp(15px, 3vw, 44px) 55px; min-width: 0; }
.page-header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-end; margin-bottom: 24px; flex-wrap: wrap; }
.context { font-size: .86rem; color: var(--accent); font-weight: 650; margin-bottom: 5px; }
.subtitle { margin-top: 5px; color: var(--muted); }
.version, .actions, .result-actions, .paging { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.version span, .meta { color: var(--muted); font-size: .86rem; }
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 234px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.canvas { min-width: 0; background-color: #f7faf9; background-image: radial-gradient(#d3dfdb 1px, transparent 1px); background-size: 14px 14px; padding: 20px; }
.canvas-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.canvas-head span, .settings p { color: var(--muted); font-size: .87rem; }
.nodes { display: flex; align-items: center; padding: 27px 1px 17px; overflow-x: auto; }
.node {
  display: flex; flex-direction: column; flex: 1 0 112px; min-height: 108px;
  align-items: flex-start; justify-content: space-between; text-align: left;
  gap: 4px; padding: 10px; background: white; box-shadow: 0 4px 14px #173e3310;
}
.node[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: #f8fffa; }
.node span, .node small { color: var(--muted); font-weight: 500; font-size: .77rem; }
.node strong { font-size: .92rem; line-height: 1.2; }
.edge { position: relative; flex: 0 0 clamp(12px, 2vw, 24px); border-top: 1px solid #829a94; }
.edge::after { content: ""; position: absolute; right: 0; top: -4px; width: 6px; height: 6px; border: solid #829a94; border-width: 1px 1px 0 0; transform: rotate(45deg); }
.settings { background: white; padding: 19px; border-left: 1px solid var(--line); }
.settings h2 { margin-bottom: 17px; }
.settings label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 5px; }
.settings select, .settings input[type=text] { width: 100%; }
.settings p { margin-top: 11px; }
.settings .check { display: flex; align-items: center; gap: 6px; }
.panel { margin-top: 16px; border: 1px solid var(--line); border-radius: 10px; padding: 19px; background: white; }
.upload, .run-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.upload { margin-top: 13px; }
.file-picker { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
#selected-file { font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
#source, .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.file-picker:focus-within .file-label { outline: 2px solid var(--accent); outline-offset: 3px; }
.notice { background: var(--accent-faint); border-radius: 7px; padding: 10px; margin-bottom: 12px; }
.notice[data-error="true"] { background: #ffefed; color: #982f23; }
.status { background: var(--accent-faint); color: #125146; padding: 4px 9px; border-radius: 5px; font-size: .85rem; }
.status[data-failed="true"] { background: #ffefed; color: #982f23; }
.metrics { display: flex; gap: 12px 26px; flex-wrap: wrap; padding: 15px 0 9px; }
.metric { display: flex; align-items: baseline; gap: 6px; }
.metric strong { font-size: 1.35rem; letter-spacing: -.035em; }
.metric span { font-size: .87rem; color: var(--muted); }
.result-actions { margin: 10px 0; }
.table-controls { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 9px; }
.table-controls input { flex: 1 1 240px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 9px 8px; vertical-align: top; }
th { background: #eef4f2; white-space: nowrap; }
td small { display: block; color: var(--muted); margin-top: 2px; }
td:nth-child(4) { white-space: nowrap; }
.paging { justify-content: flex-end; margin-top: 10px; font-size: .87rem; }
.source-view { display: block; }
.source-view main { max-width: 850px; }
.source-head .context { margin-top: 20px; }
.source-values { display: grid; grid-template-columns: 105px 1fr; gap: 6px 10px; border-bottom: 1px solid var(--line); padding-bottom: 15px; }
.source-values dt { color: var(--muted); }
.source-values dd { margin: 0; }
.remarks { white-space: pre-line; margin: 9px 0; }
@media (max-width: 1100px) {
  .builder { grid-template-columns: minmax(0, 1fr); }
  .settings { border-left: 0; border-top: 1px solid var(--line); }
  .settings select, .settings input[type=text] { max-width: 420px; }
}
@media (max-width: 690px) {
  body { display: block; }
  .nav { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 10px; }
  .nav nav { display: flex; }
  .brand { padding: 3px; }
  .saved { display: none; }
  main { padding-top: 19px; }
  .canvas, .settings, .panel { padding: 13px; }
}

.user-session { display: grid; gap: 8px; margin: 20px 0 0; padding: 0 10px; color: #d6e7e3; }
.user-session button { justify-self: start; font-size: .85rem; }

.pipeline-page { display: block; background: #f1f5f3; }
.studio-header, .studio-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.studio-header { min-height: 60px; padding: 10px clamp(14px, 2.5vw, 36px); background: #102928; color: #d6e7e3; }
.studio-path, .template-tools, .upload-fields { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.studio-path h1 { color: white; font-size: 1.16rem; letter-spacing: -.02em; }
.studio-brand { color: #102928; background: #76dfb4; border-radius: 7px; font-weight: 750; padding: 4px 8px; text-decoration: none; }
.account { position: relative; }
.account summary { cursor: pointer; }
.account form { position: absolute; right: 0; top: 26px; z-index: 2; min-width: max-content; }
.studio { max-width: 1800px; padding: 18px clamp(10px, 2vw, 28px) 32px; }
.studio-toolbar { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.template-tools label, .upload-fields label { font-weight: 650; font-size: .9rem; }
.template-tools select { max-width: min(65vw, 420px); }
.studio-body { display: grid; grid-template-columns: 186px minmax(0, 1fr) 224px; min-height: 324px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.library { background: #fff; border-right: 1px solid var(--line); padding: 15px 12px; }
.library h2 { margin-bottom: 14px; }
.library h3 { margin: 12px 0 5px; color: var(--muted); font-size: .83rem; }
.library-item { justify-content: flex-start; width: 100%; text-align: left; font-weight: 530; font-size: .82rem; padding: 5px 7px; min-height: 31px; margin-bottom: 4px; background: #f7faf9; line-height: 1.25; }
.library-item[data-stage="input"] { border-left: 3px solid #008876; }
.library-item[data-stage="process"] { border-left: 3px solid #4569a6; }
.library-item[data-stage="output"] { border-left: 3px solid #a16a1b; }
.canvas { display: flex; flex-direction: column; padding: 14px 16px; }
.nodes { flex: 1; min-height: 140px; padding: 18px 6px; }
.node { flex: 0 0 148px; min-height: 82px; padding: 0; overflow: hidden; border-radius: 7px; }
.node strong { padding: 9px 8px; width: 100%; min-height: 42px; display: flex; align-items: center; background: var(--node-tint); }
.node small { padding: 2px 8px 8px; }
.node[data-stage="input"] { --node-tint: #def2eb; }
.node[data-stage="process"] { --node-tint: #e6eef9; }
.node[data-stage="output"] { --node-tint: #fff0da; }
.edge[data-invalid="true"] { border-color: #aa3b30; }
.edge[data-invalid="true"]::after { border-color: #aa3b30; }
#validation[data-error="true"] { color: #982f23; }
.settings { padding: 15px 14px; }
.settings h3 { font-size: .94rem; line-height: 1.25; margin: 0 0 10px; }
.settings .field { margin-top: 10px; }
.settings .field select { font-size: .84rem; }
.step-ports { display: grid; grid-template-columns: auto 1fr; gap: 5px 8px; font-size: .82rem; color: var(--muted); }
.step-ports dd { margin: 0; font-weight: 650; color: var(--ink); }
.step-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.step-actions button { min-height: 30px; font-size: .8rem; padding: 4px 9px; }
.run-tools { margin-top: 12px; }
.upload-fields input[type=text] { width: min(210px, 57vw); }
#selected-file { max-width: 260px; }
.results { border: 1px solid var(--line); border-radius: 8px; background: white; padding: 13px; }
#history { max-width: min(100%, 420px); }
.results .paging { margin: 0; }
.results button { min-height: 33px; }
dialog { width: min(430px, 90vw); border: 1px solid var(--line); border-radius: 11px; padding: 20px; color: var(--ink); box-shadow: 0 16px 80px #10292830; }
dialog::backdrop { background: #112b2852; }
dialog form { display: grid; gap: 9px; }
dialog .actions { justify-content: flex-end; }
#save-error:empty { display: none; }
@media (max-width: 1030px) {
  .studio-body { grid-template-columns: 155px minmax(0, 1fr) 180px; }
  .studio-body .settings { border-left: 1px solid var(--line); border-top: 0; }
  .node { flex-basis: 118px; }
}
@media (max-width: 730px) {
  .studio-body { grid-template-columns: minmax(0, 1fr); }
  .library { border-right: none; border-bottom: 1px solid var(--line); }
  .library h2 { margin-bottom: 3px; }
  .library-item { width: auto; margin-right: 5px; }
  .studio-body .settings { border-left: 0; border-top: 1px solid var(--line); }
  .nodes { min-height: 115px; }
}

.document-warning { margin: 10px 0; border-left: 3px solid #a16a1b; background: #fff6e8; padding: 8px 12px; color: #735018; }
.document-blocks { display: grid; }
.document-block { padding: 11px 8px; border-bottom: 1px solid var(--line); }
.document-block:last-child { border-bottom: 0; }
.document-block a { font-size: .88rem; font-weight: 650; }
.document-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.document-block .document-text { margin-top: 4px; }
