.cb-panel {
  --cb-accent: var(--ct-blue, #2aab98);
  --cb-accent-soft: rgba(42, 171, 152, 0.12);
  --cb-border: var(--ct-border, #e2e8f0);
  --cb-muted: #64748b;
  --cb-bg: #f8fafc;
  --cb-text: #0f172a;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.92rem;
}

.cb-topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: linear-gradient(180deg, #fbfefe 0%, #f4faf9 100%);
  border: 1px solid var(--cb-border);
  border-radius: 14px;
}

.cb-topbar-main {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: min(100%, 18rem);
  flex: 1;
}

.cb-name {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--cb-muted);
}

.cb-name input { max-width: 18rem; }

.cb-status {
  font-weight: 650;
  color: var(--cb-text);
  line-height: 1.35;
}

.cb-topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.cb-btn-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.2rem;
  background: #fff;
  border: 1px solid var(--cb-border);
  border-radius: 10px;
}

.cb-more { position: relative; }
.cb-more > summary {
  list-style: none;
  cursor: pointer;
}
.cb-more > summary::-webkit-details-marker { display: none; }
.cb-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 20;
  min-width: 10.5rem;
  display: flex;
  flex-direction: column;
  padding: 0.35rem;
  background: #fff;
  border: 1px solid var(--cb-border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}
.cb-more-menu button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #334155;
}
.cb-more-menu button:hover { background: var(--cb-bg); }
.cb-more-menu button.is-danger { color: #b91c1c; }

.cb-privacy {
  margin: 0;
  font-size: 0.8rem;
  color: var(--cb-muted);
  padding: 0 0.15rem;
}

.cb-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.cb-step {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-align: left;
  border: 1px solid var(--cb-border);
  background: #fff;
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  color: #334155;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.cb-step:hover { border-color: rgba(42, 171, 152, 0.45); }
.cb-step.is-active {
  border-color: var(--cb-accent);
  background: var(--cb-accent-soft);
  box-shadow: 0 0 0 1px rgba(42, 171, 152, 0.15);
}
.cb-step.is-done .cb-step-num {
  background: var(--cb-accent);
  color: #fff;
}

.cb-step-num {
  flex: 0 0 auto;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  background: #e2e8f0;
  color: #475569;
}

.cb-step.is-active .cb-step-num {
  background: var(--cb-accent);
  color: #fff;
}

.cb-step-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}
.cb-step-text strong {
  font-size: 0.92rem;
  font-weight: 700;
}
.cb-step-text small {
  color: var(--cb-muted);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cb-pane { display: none; }
.cb-pane.is-active { display: block; }

.cb-section {
  background: #fff;
  border: 1px solid var(--cb-border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
}

.cb-section-title {
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--cb-text);
}

.cb-section-sub {
  margin: 0.75rem 0 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
}

.cb-section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.cb-section-title-row .cb-section-title { margin: 0; }

.cb-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--cb-muted);
  line-height: 1.45;
}

.cb-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.45rem;
  padding: 1.75rem 1.25rem;
  border: 1.5px dashed rgba(42, 171, 152, 0.45);
  border-radius: 14px;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(42, 171, 152, 0.1), transparent 55%),
    #fbfffe;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.cb-drop:hover,
.cb-drop.is-dragover {
  border-color: var(--cb-accent);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(42, 171, 152, 0.16), transparent 55%),
    #f3fbf9;
}
.cb-drop-icon {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cb-accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
}
.cb-drop-title {
  margin: 0.25rem 0 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--cb-text);
}
.cb-drop-desc {
  margin: 0;
  max-width: 34rem;
  color: var(--cb-muted);
  font-size: 0.86rem;
  line-height: 1.5;
}
.cb-drop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-top: 0.55rem;
}
.cb-drop-actions .btn { pointer-events: auto; }

.cb-check,
.cb-check-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-size: 0.88rem;
  margin-bottom: 0.65rem;
}

.cb-map-wrap {
  overflow-x: auto;
  margin-bottom: 0.75rem;
  border: 1px solid var(--cb-border);
  border-radius: 10px;
}

.cb-map-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 0;
}
.cb-map-table th,
.cb-map-table td {
  border-bottom: 1px solid var(--cb-border);
  border-right: 1px solid var(--cb-border);
  padding: 0.55rem 0.65rem;
  text-align: left;
  vertical-align: middle;
}
.cb-map-table tr:last-child th,
.cb-map-table tr:last-child td { border-bottom: 0; }
.cb-map-table th { background: var(--cb-bg); font-weight: 650; }
.cb-map-table select {
  min-width: 7.5rem;
  max-width: 100%;
}

.cb-map-table-transpose th[scope="row"] {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 4.5rem;
  background: #f1f5f9;
  box-shadow: 1px 0 0 var(--cb-border);
}
.cb-map-table-transpose th[scope="col"] {
  white-space: nowrap;
  text-align: center;
  min-width: 7.5rem;
}
.cb-map-table-transpose td {
  text-align: center;
}
.cb-map-table-transpose .cb-map-sample {
  color: var(--cb-muted);
  font-size: 0.84rem;
  white-space: nowrap;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cb-preview-fold {
  border: 1px solid var(--cb-border);
  border-radius: 10px;
  padding: 0.45rem 0.7rem 0.65rem;
  background: var(--cb-bg);
}
.cb-preview-fold > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.86rem;
  color: #334155;
}
.cb-preview {
  overflow-x: auto;
  max-height: 220px;
  margin-top: 0.55rem;
  font-size: 0.8rem;
  background: #fff;
  border-radius: 8px;
}
.cb-preview table {
  width: 100%;
  border-collapse: collapse;
}
.cb-preview th,
.cb-preview td {
  border: 1px solid var(--cb-border);
  padding: 0.28rem 0.4rem;
  white-space: nowrap;
}
.cb-errors {
  color: #b91c1c;
  font-size: 0.88rem;
  margin-top: 0.55rem;
}

.cb-config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
.cb-config-grid > .cb-section { margin-bottom: 0; }

.cb-mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.cb-mode-card {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  margin: 0;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--cb-border);
  border-radius: 12px;
  background: var(--cb-bg);
  cursor: pointer;
}
.cb-mode-card:has(input:checked) {
  border-color: var(--cb-accent);
  background: var(--cb-accent-soft);
}
.cb-mode-card strong {
  display: block;
  font-size: 0.9rem;
}
.cb-mode-card small {
  display: block;
  color: var(--cb-muted);
  font-size: 0.76rem;
  line-height: 1.35;
  margin-top: 0.1rem;
}

.cb-inline,
.cb-option-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.cb-inline-tight { margin-bottom: 0.85rem; }
.cb-inline label,
.cb-option-grid label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.cb-inline input[type="number"],
.cb-inline .form-select,
.cb-option-grid .form-select {
  width: auto;
  min-width: 4.5rem;
  display: inline-block;
  flex-shrink: 0;
}
.cb-option-grid {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.cb-class-list,
.cb-tiers,
.cb-weights {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.cb-class-avg-hint { margin: 0 0 0.35rem; }
.cb-class-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--cb-border);
  border-radius: 10px;
}
.cb-class-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 0;
}
.cb-class-table th,
.cb-class-table td {
  border-bottom: 1px solid var(--cb-border);
  padding: 0.4rem 0.55rem;
  vertical-align: middle;
}
.cb-class-table tr:last-child td { border-bottom: 0; }
.cb-class-table th {
  background: var(--cb-bg);
  font-weight: 650;
  text-align: left;
  white-space: nowrap;
}
.cb-class-table .cb-class-idx {
  width: 2.2rem;
  color: var(--cb-muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.cb-class-table input[type="text"] { min-width: 6.5rem; }
.cb-class-table input[type="number"] { width: 5.5rem; }

.cb-tier-row,
.cb-weight-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--cb-border);
  border-radius: 10px;
  background: var(--cb-bg);
}
.cb-tier-row input[type="number"] { width: 5rem; }
.cb-weight-row span:first-child { min-width: 4.5rem; font-size: 0.86rem; }
.cb-weight-row input[type="range"] { flex: 1; min-width: 7rem; }
.cb-weight-row [data-cb-weight-val] {
  min-width: 1.5rem;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.cb-subjects {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.cb-subjects label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--cb-border);
  border-radius: 999px;
  background: #fff;
  font-size: 0.84rem;
  cursor: pointer;
}
.cb-subjects label:has(input:checked) {
  border-color: var(--cb-accent);
  background: var(--cb-accent-soft);
  color: #0f766e;
}

.cb-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.cb-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  font-size: 0.84rem;
  color: #475569;
  white-space: nowrap;
}
.cb-sort .form-select {
  width: auto;
  min-width: 8.5rem;
}

.cb-report {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}
.cb-stat {
  background: var(--cb-bg);
  border: 1px solid var(--cb-border);
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
}
.cb-stat strong {
  display: block;
  font-size: 1.15rem;
  color: var(--cb-text);
  font-variant-numeric: tabular-nums;
}
.cb-stat span {
  font-size: 0.76rem;
  color: var(--cb-muted);
}

.cb-issues {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.85rem;
  font-size: 0.86rem;
}
.cb-issues .is-hard,
.cb-issues .is-soft {
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
}
.cb-issues .is-hard {
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
}
.cb-issues .is-soft {
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
}

.cb-class-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}
.cb-class-tab {
  border: 1px solid var(--cb-border);
  background: #fff;
  border-radius: 999px;
  padding: 0.32rem 0.75rem;
  font-size: 0.84rem;
  color: #334155;
}
.cb-class-tab.is-active {
  border-color: var(--cb-accent);
  background: var(--cb-accent-soft);
  color: #0f766e;
  font-weight: 650;
}

.cb-class-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.75rem;
}
.cb-class-col {
  border: 1px solid var(--cb-border);
  border-radius: 12px;
  background: #fff;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cb-class-col.is-dim { opacity: 0.38; }
.cb-class-col-h {
  padding: 0.65rem 0.75rem 0.55rem;
  border-bottom: 1px solid var(--cb-border);
  background: linear-gradient(180deg, #f8fffd, #f8fafc);
}
.cb-class-col-h strong {
  display: block;
  font-size: 0.95rem;
}
.cb-class-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
}
.cb-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  background: #fff;
  border: 1px solid var(--cb-border);
  color: #475569;
}
.cb-cap {
  margin-top: 0.45rem;
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}
.cb-cap > span {
  display: block;
  height: 100%;
  background: var(--cb-accent);
  border-radius: inherit;
}
.cb-cap.is-over > span { background: #dc2626; }

.cb-class-col-b {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-height: 140px;
  max-height: 420px;
  overflow: auto;
}
.cb-stu {
  border: 1px solid var(--cb-border);
  border-radius: 9px;
  padding: 0.4rem 0.55rem;
  background: #fff;
  cursor: grab;
  font-size: 0.84rem;
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  align-items: center;
  transition: box-shadow .12s ease, border-color .12s ease;
}
.cb-stu:hover {
  border-color: rgba(42, 171, 152, 0.5);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}
.cb-stu:active { cursor: grabbing; }
.cb-stu.is-drag { opacity: 0.45; }
.cb-stu small { color: var(--cb-muted); }
.cb-stu-score {
  font-variant-numeric: tabular-nums;
  color: #0f766e;
  font-weight: 650;
  font-size: 0.8rem;
}
.cb-class-col.is-over {
  outline: 2px dashed var(--cb-accent);
  outline-offset: -2px;
}

.cb-progress {
  margin-bottom: 0.85rem;
  padding: 0.7rem 0.85rem;
  background: #effcf8;
  border: 1px solid rgba(42, 171, 152, 0.35);
  border-radius: 12px;
}
.cb-progress-bar {
  height: 7px;
  border-radius: 999px;
  background: rgba(42, 171, 152, 0.18);
  overflow: hidden;
  margin-bottom: 0.45rem;
}
.cb-progress-bar > span {
  display: block;
  height: 100%;
  width: 35%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2aab98, #5ec8b8);
  animation: cb-progress 1.1s ease-in-out infinite;
}
.cb-progress-text { font-size: 0.86rem; color: #0f766e; }
@keyframes cb-progress {
  0% { transform: translateX(-60%); }
  100% { transform: translateX(220%); }
}

.cb-footer {
  position: sticky;
  bottom: 0.5rem;
  z-index: 15;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--cb-border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}
.cb-footer-spacer { flex: 1; }

.cb-footer [data-cb-act="prev"],
.cb-footer [data-cb-act="next"] {
  border-color: var(--cb-accent);
  color: #0f766e;
  background: #fff;
  font-weight: 650;
  min-width: 5.5rem;
}
.cb-footer [data-cb-act="prev"]:hover:not(:disabled),
.cb-footer [data-cb-act="next"]:hover:not(:disabled) {
  background: var(--cb-accent-soft);
  border-color: var(--cb-accent);
  color: #0f766e;
}
.cb-footer [data-cb-act="next"] {
  background: var(--cb-accent);
  border-color: var(--cb-accent);
  color: #fff;
}
.cb-footer [data-cb-act="next"]:hover:not(:disabled) {
  filter: brightness(0.95);
  background: var(--cb-accent);
  color: #fff;
}
.cb-footer [data-cb-act="prev"]:disabled,
.cb-footer [data-cb-act="next"]:disabled {
  opacity: 0.45;
  border-color: #cbd5e1;
  color: #94a3b8;
  background: #f8fafc;
}
.cb-footer [data-cb-act="solve2"] {
  font-weight: 700;
  min-width: 6.5rem;
  box-shadow: 0 4px 12px rgba(42, 171, 152, 0.28);
}

.cb-empty-hint {
  padding: 1.25rem;
  text-align: center;
  color: var(--cb-muted);
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .cb-config-grid { grid-template-columns: 1fr; }
  .cb-steps { grid-template-columns: 1fr; }
  .cb-mode-cards { grid-template-columns: 1fr; }
  .cb-step-text small { display: none; }
}

@media (max-width: 640px) {
  .cb-topbar { padding: 0.75rem; }
  .cb-name input { max-width: none; }
  .cb-class-board { grid-template-columns: 1fr; }
  .cb-footer { bottom: 0; border-radius: 12px 12px 0 0; }
}

@media print {
  .cb-topbar, .cb-steps, .cb-footer, .cb-privacy, .cb-result-actions, [data-pane="import"], [data-pane="config"] {
    display: none !important;
  }
  .cb-pane[data-pane="result"] { display: block !important; }
  .cb-class-col.is-dim { opacity: 1; }
}
