.chart-shell {
  width: 100%;
  max-width: none;
}

.chart-workspace {
  height: calc(100vh - 68px);
  min-height: 670px;
  display: grid;
  grid-template-columns: minmax(270px, 292px) minmax(286px, 318px) minmax(0, 1fr);
  gap: 12px;
  padding: 12px clamp(8px, 1vw, 18px) 18px;
  background:
    radial-gradient(circle at 14% 0, rgba(15, 159, 139, .055), transparent 27rem),
    #ffffff;
}

.chart-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: #ffffff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chart-panel-header,
.candidate-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.chart-panel-header h1,
.candidate-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  letter-spacing: -.025em;
}

.draft-state {
  flex: 0 0 auto;
  padding: 4px 7px;
  color: var(--teal);
  border-radius: 6px;
  background: rgba(15, 159, 139, .08);
  font-size: 9px;
  font-weight: 750;
}

.setup-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.chart-setup-form {
  padding: 12px 14px 13px;
  border-bottom: 1px solid var(--line-soft);
}

.field-label {
  display: block;
  margin: 0 0 5px;
  color: #3f5263;
  font-size: 11px;
  font-weight: 750;
}

.field-label:not(:first-child) { margin-top: 11px; }

.text-field,
#claimElementsInput {
  width: 100%;
  color: var(--text);
  border: 1px solid #c5d2dc;
  border-radius: 10px;
  background: #ffffff;
  outline: 0;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.text-field {
  height: 38px;
  padding: 0 10px;
  font-size: 12px;
}

#claimElementsInput {
  min-height: 150px;
  max-height: 260px;
  padding: 10px;
  resize: vertical;
  font-family: "Arial Narrow", "Malgun Gothic", sans-serif;
  font-size: 12px;
  line-height: 1.46;
}

.text-field:focus,
#claimElementsInput:focus {
  border-color: rgba(15, 159, 139, .72);
  box-shadow: 0 0 0 3px rgba(15, 159, 139, .1);
}

.text-field::placeholder,
#claimElementsInput::placeholder { color: #8a98a5; }

.chart-select-shell select { height: 38px; font-size: 12px; box-shadow: none; }

.field-help {
  margin: 6px 1px 0;
  color: var(--muted-2);
  font-size: 9px;
  line-height: 1.45;
}

.setup-button {
  width: 100%;
  min-height: 39px;
  margin-top: 10px;
  font-size: 11px;
}

.chart-progress {
  padding: 12px 15px;
  border-bottom: 1px solid var(--line-soft);
  background: #f9fbfc;
}

.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
}

.progress-copy strong { color: #334657; }

.progress-track {
  height: 5px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe7ec;
}

.progress-track span {
  width: 0;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--teal-strong);
  transition: width .2s ease;
}

.element-list,
.candidate-list {
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  scrollbar-color: #b8c5cf transparent;
  scrollbar-width: thin;
}

.element-item {
  width: 100%;
  display: grid;
  grid-template-columns: 29px minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  padding: 10px 9px;
  color: inherit;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  cursor: pointer;
}

.element-item + .element-item { margin-top: 3px; }
.element-item:hover { background: #f4f8fa; }
.element-item.is-active {
  border-color: rgba(15, 159, 139, .42);
  background: linear-gradient(135deg, rgba(15, 159, 139, .11), rgba(15, 159, 139, .035));
}

.element-number {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 800;
}

.element-item.is-active .element-number { color: #ffffff; border-color: var(--teal); background: var(--teal); }
.element-copy { min-width: 0; }
.element-copy strong {
  display: -webkit-box;
  overflow: hidden;
  color: #253644;
  font-family: "Arial Narrow", "Malgun Gothic", sans-serif;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 650;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.element-copy small { display: block; margin-top: 5px; color: var(--muted-2); font-size: 9px; }

.element-check {
  min-width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  color: #738291;
  border-radius: 7px;
  background: #edf2f5;
  font-size: 9px;
  font-weight: 800;
}

.element-item.is-complete .element-check { color: #ffffff; background: var(--teal); }

.candidate-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.candidate-header { flex-direction: column; align-items: stretch; }
.candidate-search-form { min-width: 0; margin: 0; }
.candidate-search-row { display: flex; align-items: stretch; gap: 6px; min-width: 0; }
.candidate-search-row .text-field { flex: 1 1 0; width: 0; min-width: 0; }
.candidate-search-row .refresh-candidates { min-height: 38px; }
.candidate-search-row .text-field:disabled { color: var(--muted); background: #f4f7f8; }

.candidate-heading-copy { min-width: 0; }
.candidate-heading-copy > p:last-child {
  display: -webkit-box;
  margin: 6px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-family: "Arial Narrow", "Malgun Gothic", sans-serif;
  font-size: 11px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.refresh-candidates { flex: 0 0 auto; }

.candidate-feedback {
  min-height: 33px;
  padding: 9px 12px;
  overflow: hidden;
  color: var(--muted-2);
  border-bottom: 1px solid var(--line-soft);
  background: #f9fbfc;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.candidate-feedback.is-error { color: var(--red); }
.candidate-list .result-card { padding: 10px 8px; }
.candidate-list .result-title { font-size: 12px; }
.candidate-list .result-topline { font-size: 10px; }
.candidate-list .result-bottom { font-size: 9px; }

.chart-empty {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  color: var(--muted);
  text-align: center;
}

.chart-empty strong { color: #314352; font-size: 13px; }
.chart-empty p { max-width: 225px; margin: 7px 0 0; font-size: 10px; line-height: 1.55; }
.compact-empty { min-height: 150px; }

.chart-capture-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.chart-viewer-empty {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 30px;
  background:
    linear-gradient(rgba(15, 159, 139, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 159, 139, .045) 1px, transparent 1px);
  background-size: 30px 30px;
}

.chart-viewer {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.chart-viewer-header {
  min-width: 0;
  min-height: 136px;
  max-height: 260px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: #f7faf9;
}

.chart-current-claim-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chart-current-claim-heading h2 { margin: 0; color: var(--teal); font-size: 12px; font-weight: 700; }
.chart-current-claim-heading span { flex: 0 0 auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-current-claim-text {
  min-width: 0;
  min-height: 0;
  max-height: 192px;
  overflow: auto;
  margin: 0;
  padding-right: 8px;
  color: var(--text);
  font-family: Arial, "Malgun Gothic", sans-serif;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
}
.chart-current-claim-text:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

.chart-toolbar { min-height: 58px; padding: 8px 10px; }
.chart-range-controls label { width: 70px; }

.chart-capture-area {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 286px;
  overflow: hidden;
}

.chart-page-stage { padding: 18px; }

#chartPageCanvas {
  display: block;
  min-width: 0;
  width: 100%;
  height: auto;
  max-width: none;
  border-radius: 2px;
  background: var(--paper);
  box-shadow: 0 10px 28px rgba(34, 52, 68, .2);
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.chart-evidence-rail {
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  border-left: 1px solid var(--line-soft);
  background: #f7f9fb;
  scrollbar-width: thin;
}

.chart-title-preview { min-height: 52px; }
.chart-title-preview img { max-height: 72px; }
.selected-evidence-section { min-height: 156px; }
.selected-rail-heading { align-items: flex-start; }

.selected-evidence-list {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}

.mini-empty {
  padding: 19px 8px;
  color: var(--muted-2);
  border: 1px dashed #c5d0d8;
  border-radius: 8px;
  text-align: center;
  font-size: 9px;
}

.selected-evidence-item {
  padding: 7px;
  border: 1px solid #d5dfe6;
  border-radius: 9px;
  background: #ffffff;
}

.selected-evidence-preview {
  display: grid;
  grid-template-columns: 38% minmax(0, 1fr);
  gap: 5px;
}

.selected-evidence-preview img {
  width: 100%;
  height: 47px;
  display: block;
  object-fit: contain;
  border: 1px solid #e0e6eb;
  border-radius: 4px;
  background: #fbfbf8;
}

.selected-evidence-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.selected-evidence-meta strong {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: #334657;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
}

.evidence-actions { display: flex; gap: 3px; }
.evidence-action {
  width: 24px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #607284;
  border: 1px solid #d2dce3;
  border-radius: 6px;
  background: #f8fafb;
  cursor: pointer;
  font-size: 10px;
}
.evidence-action:hover:not(:disabled) { border-color: #9dafbd; background: #edf3f6; }
.evidence-action.is-delete:hover { color: var(--red); border-color: rgba(201, 65, 65, .4); background: rgba(201, 65, 65, .05); }

.element-nav-actions {
  display: grid;
  grid-template-columns: 1fr 1.45fr;
  gap: 6px;
  margin-top: 9px;
}

.chart-download-button {
  min-height: 40px;
  margin-top: 10px;
  color: #ffffff;
  border-color: var(--teal);
  background: var(--teal);
  font-size: 11px;
}
.chart-download-button:hover:not(:disabled) { color: #ffffff; border-color: #087267; background: #087267; }

.chart-note {
  margin: 7px 3px 0;
  color: var(--muted-2);
  text-align: center;
  font-size: 8px;
  line-height: 1.45;
}
.chart-note.is-ready { color: var(--teal); font-weight: 700; }

.candidate-list .result-card.is-preferred {
  border-color: rgba(15, 159, 139, .5);
  background: linear-gradient(135deg, rgba(15, 159, 139, .12), rgba(15, 159, 139, .035));
}

.candidate-list .result-card.is-preferred .result-rank {
  color: #ffffff;
  background: var(--teal);
}

@media (max-width: 1500px) {
  .chart-workspace { grid-template-columns: 270px 286px minmax(0, 1fr); }
  .chart-capture-area { grid-template-columns: minmax(0, 1fr) 252px; }
  .chart-range-controls { display: none; }
}

@media (max-width: 1200px) {
  .chart-workspace {
    height: auto;
    grid-template-columns: minmax(270px, 1fr) minmax(290px, 1.2fr);
  }
  .setup-panel, .candidate-panel { min-height: 650px; }
  .chart-capture-panel { min-height: 790px; grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .chart-workspace { grid-template-columns: 1fr; padding-inline: 10px; }
  .setup-panel, .candidate-panel { min-height: 620px; }
  .chart-capture-panel { min-height: 980px; grid-column: auto; }
  .chart-capture-area { grid-template-columns: 1fr; }
  .chart-evidence-rail { border-top: 1px solid var(--line-soft); border-left: 0; }
  .chart-toolbar { flex-wrap: wrap; }
}
