.cfd {
  --cfd-ink: var(--shell-ink, #182638);
  --cfd-muted: var(--shell-muted, #52647b);
  --cfd-line: var(--shell-border, #d6dee9);
  --cfd-accent: var(--shell-accent, #215BCE);
  --cfd-well: #F5F7FB;
  --cfd-select: var(--shell-selected, #edf2ff);
  container: cfd / inline-size;
  box-sizing: border-box;
  min-width: 0;
  color: var(--cfd-ink);
  font-size: 14px;
  line-height: 1.55;
}

.cfd *, .cfd *::before, .cfd *::after { box-sizing: border-box; }
.cfd [hidden] { display: none !important; }
.cfd h3 { margin: 0; font-size: 15px; font-weight: 720; line-height: 1.5; }
.cfd p { margin: 0; }
.cfd label {
  display: grid;
  gap: 5px;
  margin: 0;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}
.cfd :is(input:not([type=checkbox], [type=file]),select,textarea) {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--cfd-line);
  border-radius: 7px;
  background: #fff;
  color: var(--cfd-ink);
  font: inherit;
  font-size: 14px;
}
.cfd input[type=number] { font-variant-numeric: tabular-nums; }
.cfd button {
  min-height: 42px;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 7px;
  box-shadow: none;
  font: inherit;
  font-size: 13px;
  font-weight: 620;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}
.cfd button:disabled { cursor: default; }
.cfd :focus-visible, .cfd .cfd-file:focus-within {
  outline: 3px solid var(--cfd-accent);
  outline-offset: 2px;
}
.cfd .cfd-secondary, .cfd .cfd-palette-button {
  background: #fff;
  border: 1px solid var(--cfd-line);
  color: var(--cfd-ink);
}
.cfd .cfd-primary {
  background: var(--cfd-accent);
  color: #fff;
  border: 1px solid var(--cfd-accent);
}
.cfd .cfd-secondary:hover:not(:disabled), .cfd .cfd-palette-button:hover:not(:disabled) {
  background: var(--cfd-select);
  filter: none;
}

.cfd-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px 18px;
  padding: 0 0 14px;
}
.cfd-title-group {
  display: flex;
  flex: 1 1 300px;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 12px;
  min-width: 0;
}
.cfd-title-group label { flex: 1 1 184px; max-width: 380px; }
.cfd-revision {
  align-self: flex-end;
  margin: 0 0 6px;
  padding: 4px 9px;
  background: #f4f6f9;
  border: 1px solid var(--cfd-line);
  border-radius: 999px;
  color: var(--cfd-muted);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 650;
}
.cfd-revision-live { color: #22604b; background: #eaf6ef; border-color: #bcdcc9; }
.cfd-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.cfd-history-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.cfd-side > .cfd-history-actions { margin-bottom: 10px; }
.cfd .cfd-history-actions > button { min-height: 44px; }
.cfd-publish-confirmation {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 14px; padding: 12px 14px; border: 1px solid #9ab0e5; border-radius: 8px; background: var(--cfd-select);
}
.cfd p.cfd-status {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-left: 3px solid var(--cfd-accent);
  border-radius: 0 5px 5px 0;
  background: var(--cfd-select);
  color: var(--cfd-ink);
  font-size: 13px;
}
.cfd p.cfd-error { border-left-color: #ad352b; color: #7c211e; background: #fff1ed; }
.cfd-layout {
  display: grid;
  grid-template-columns: 185px minmax(0,1fr) 246px;
  align-items: stretch;
  min-width: 0;
  border: 1px solid var(--cfd-line);
  border-radius: 11px;
  background: #fff;
}
.cfd-rail, .cfd-side {
  display: flex;
  flex-direction: column;
  gap: 11px;
  min-width: 0;
  padding: 14px;
  background: #fff;
  border-radius: 10px;
}
.cfd-rail { border-right: 1px solid var(--cfd-line); border-radius: 10px 0 0 10px; }
.cfd-side { border-left: 1px solid var(--cfd-line); border-radius: 0 10px 10px 0; }
.cfd .cfd-file {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  overflow: hidden;
  background: var(--cfd-select);
  border: 1px dashed #829cdb;
  border-radius: 7px;
  color: var(--cfd-accent);
  cursor: pointer;
}
.cfd .cfd-file span::before { content: '+ '; }
.cfd .cfd-file input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.cfd .cfd-hint { color: var(--cfd-muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.cfd-pages { display: grid; gap: 5px; list-style: none; margin: 0; padding: 0; }
.cfd .cfd-page-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: #f5f7fa;
  color: var(--cfd-ink);
  border: 1px solid transparent;
}
.cfd .cfd-page-button[aria-current] {
  background: var(--cfd-select);
  border-color: #9ab0e5;
  color: #21469f;
}
.cfd .cfd-page-count { color: var(--cfd-muted); font-size: 11px; white-space: nowrap; }

.cfd-stage {
  min-width: 0;
  background: var(--cfd-well);
}
.cfd-stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 9px 12px;
  background: #f9fafc;
  border-bottom: 1px solid var(--cfd-line);
}
.cfd .cfd-document-name {
  flex: 1 1 130px;
  min-width: 0;
  font-size: 13px;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.cfd .cfd-jump { display: none; }
.cfd-sheet-area {
  max-height: min(68dvh, 740px);
  min-height: 390px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px clamp(10px, 2cqw, 22px) 22px;
}
.cfd-empty {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 9px;
  min-height: 340px;
  text-align: center;
  color: var(--cfd-muted);
}
.cfd-empty h3 { color: var(--cfd-ink); }
.cfd-empty-mark {
  display: grid;
  place-items: center;
  width: 45px;
  height: 54px;
  margin-bottom: 3px;
  color: var(--cfd-accent);
  border: 1px solid #bccbeb;
  border-radius: 5px;
  background: #fff;
  font-size: 23px;
}
.cfd p.cfd-page-status {
  color: var(--cfd-muted);
  margin: 0 0 10px;
  font-size: 12px;
}
.cfd-page-status:empty { display: none; }
.cfd-paper {
  position: relative;
  isolation: isolate;
  width: min(100%, 650px);
  margin: 0 auto;
  aspect-ratio: 595 / 842;
  background: #fff;
  box-shadow: 0 1px 4px #18315330, 0 0 0 1px #cad4e3;
}
.cfd-paper img, .cfd-overlays { position: absolute; inset: 0; width: 100%; height: 100%; }
.cfd-field-box {
  position: absolute;
  z-index: 1;
  min-width: 0;
  color: #183d8f;
  border: 1px solid #5977c3;
  background: #e8effdeb;
  touch-action: none;
}
.cfd-field-box[data-source=signer] { color: #135146; border-color: #448379; background: #dff4edef; }
.cfd-field-box[data-source=static] { color: #37495f; border-color: #79899e; background: #f3f5f8ee; }
.cfd-field-box[data-required=true] { color: #153b83; border-color: #215bce; background: #e4eeffef; }
.cfd-field-box.cfd-selected { z-index: 2; outline: 2px solid var(--cfd-accent); outline-offset: 0; }
.cfd .cfd-field-button {
  display: block;
  overflow: hidden;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0 3px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: clamp(9px, 1.4cqw, 12px);
  text-align: left;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: move;
  touch-action: none;
}
.cfd .cfd-grip {
  display: none;
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  border: 1px solid #fff;
  border-radius: 3px;
  background: var(--cfd-accent);
  color: #fff;
  font-size: 12px;
  cursor: nwse-resize;
  touch-action: none;
}
.cfd-selected .cfd-grip, .cfd-field-box:focus-within .cfd-grip { display: block; }
.cfd-sample .cfd-field-box {
  border: 0;
  border-bottom: 1px dotted #8397bf;
  background: #ffffffde;
  color: var(--cfd-ink);
  pointer-events: none;
}
.cfd-field-sample {
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 0 3px;
  height: 100%;
  font-size: clamp(9px, 1.4cqw, 13px);
  white-space: nowrap;
}
.cfd-field-box:is([data-type=radio],[data-type=multiline],[data-type=checkbox_group]) .cfd-field-sample { display: block; white-space: pre-wrap; }

.cfd-palette, .cfd-geometry {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 6px;
}
.cfd .cfd-palette-button { min-height: 40px; padding: 7px 4px; }
.cfd-inspector {
  display: grid;
  align-content: start;
  gap: 9px;
  border-top: 1px solid var(--cfd-line);
  padding-top: 11px;
}
.cfd-inspector-detail { min-width: 0; border-top: 1px solid var(--cfd-line); }
.cfd-inspector-detail > summary {
  min-height: 44px;
  padding: 11px 0;
  color: var(--cfd-ink);
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}
.cfd-inspector-detail > summary:hover { color: var(--cfd-accent); }
.cfd-inspector-detail > :not(summary) { margin-bottom: 9px; }
.cfd .cfd-inline-error { color: #932d23; }
.cfd input[aria-invalid=true] { border-color: #ad352b; }
.cfd-options { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 10px; border: 1px solid var(--cfd-line); border-radius: 7px; }
.cfd-options legend { padding: 0 4px; font-weight: 700; }
.cfd-option-row { display: grid; gap: 6px; min-width: 0; padding: 7px 0; border-bottom: 1px solid var(--cfd-line); }
.cfd-option-row > button { justify-self: start; }
.cfd .cfd-check {
  display: flex;
  align-items: center;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 7px;
  min-height: 44px;
}
.cfd-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--cfd-accent); }
.cfd .cfd-delete {
  justify-self: start;
  padding-inline: 10px;
  border: 1px solid #e6c8c3;
  color: #932d23;
  background: #fff8f6;
}
.cfd-sample-list { display: grid; gap: 0; margin: 0; }
.cfd-sample-list > div { display: grid; gap: 2px; border-bottom: 1px solid var(--cfd-line); padding: 8px 0; }
.cfd-sample-list dt { font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.cfd-sample-list dd { margin: 0; color: var(--cfd-accent); overflow-wrap: anywhere; white-space: pre-wrap; }
.cfd-sample-list code { display: block; color: var(--cfd-muted); font-size: 11px; font-weight: 500; }
.cfd-sample-list small { color: var(--cfd-muted); }

@media (min-height: 720px) {
  @container cfd (width > 920px) {
    .cfd-stage {
      position: sticky;
      inset-block-start: 16px;
      align-self: start;
    }
  }
}

@container cfd (max-width: 920px) {
  .cfd-layout { grid-template-columns: 140px minmax(0,1fr) 212px; }
  .cfd-rail, .cfd-side { padding: 10px; }
}
@container cfd (max-width: 760px) {
  .cfd-layout { grid-template-columns: minmax(0,1fr); }
  .cfd-rail, .cfd-side { border: 0; border-radius: 0; padding: 13px; }
  .cfd-rail { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); align-items: end; }
  .cfd-rail h3, .cfd-pages { grid-column: 1/-1; }
  .cfd-pages { grid-template-columns: repeat(auto-fit,minmax(78px,1fr)); }
  .cfd-stage { border-block: 1px solid var(--cfd-line); }
  .cfd .cfd-jump { display: inline-block; }
  .cfd-sheet-area { max-height: none; min-height: 210px; }
  .cfd-empty { min-height: 190px; }
  .cfd-palette { grid-template-columns: repeat(auto-fit,minmax(84px,1fr)); }
  .cfd button:not(.cfd-field-button,.cfd-grip), .cfd :is(input:not([type=checkbox], [type=file]),select,textarea) { min-height: 44px; }
}
@container cfd (max-width: 380px) {
  .cfd-title-group label { max-width: none; }
  .cfd-actions > button { flex: 1 1 auto; }
  .cfd-rail { grid-template-columns: minmax(0,1fr); }
}
@media (prefers-reduced-motion: reduce) { .cfd * { scroll-behavior: auto; transition: none; } }

.cfd input:required { background: #EDF4FF; }
.cfd .cfd-page-text { width: min(100%, 820px); margin: 12px auto 0; overflow-wrap: anywhere; }
.cfd .cfd-page-text summary { color: var(--cfd-accent); cursor: pointer; }
.cfd .cfd-page-text p { white-space: pre-wrap; margin-block: 8px; }
.cfd-workspace { width: 100%; max-width: none; min-width: 0; }
.cfd-files { display: grid; gap: 12px; list-style: none; padding: 0; margin: 0; min-width: 0; }
.cfd-files > li { min-width: 0; padding-bottom: 12px; border-bottom: 1px solid var(--cfd-line); }
.cfd-file-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.cfd .cfd-file-actions button { flex: 1 1 40%; min-width: 0; padding: 5px; font-size: 12px; }
.cfd-pages > li { display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 8px; }
.cfd-pages .cfd-page-button { width: 100%; }
.cfd .cfd-page-action { flex: 1; min-width: 0; padding: 4px; border: 1px solid var(--cfd-line); background: #fff; color: var(--cfd-muted); font-size: 11px; }
.cfd-orphans { background: #fff7e8; border: 1px solid #e8cc91; border-radius: 10px; padding: 10px; min-width: 0; }
.cfd-orphan { display: grid; gap: 7px; margin-top: 12px; overflow-wrap: anywhere; }
.cfd-orphan button { width: 100%; white-space: normal; }
@container cfd (max-width: 760px) {
  .cfd-files, .cfd-orphans { grid-column: 1/-1; }
  .cfd-files { grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); }
  .cfd-pages { grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); }
}
