* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f6f8;
  color: #222;
}

.header {
  background: #1f2937;
  color: #fff;
  padding: 14px 20px;
}

.header a {
  color: #fff;
  margin-right: 14px;
  text-decoration: none;
  font-weight: 700;
}

.container {
  max-width: 1100px;
  margin: 28px auto;
  padding: 0 16px;
}

.card {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  margin-bottom: 16px;
}

h1 {
  font-size: 24px;
  margin: 0 0 18px;
}

h2 {
  font-size: 20px;
  margin-top: 0;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 10px;
  border: 1px solid #cfd6df;
  border-radius: 8px;
  margin: 6px 0 12px;
}

button,
.btn {
  display: inline-block;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

button.secondary,
.btn.secondary {
  background: #4b5563;
}

button.danger {
  background: #dc2626;
}

.error {
  color: #dc2626;
  font-weight: 700;
}

.success {
  color: #16a34a;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid #e5e7eb;
  padding: 10px;
  text-align: left;
}

.practice-wrap {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
}

.board {
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 14px;
  overflow: hidden;
}

#practiceSvg {
  width: 100%;
  height: 470px;
  display: block;
  background: #fbfdff;
}

.node circle {
  fill: #fff;
  stroke: #111827;
  stroke-width: 3;
}

.node text {
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
}

.node.selected circle {
  fill: #dbeafe;
  stroke: #2563eb;
}

.wire {
  stroke: #111827;
  stroke-width: 5;
  stroke-linecap: round;
}

.result-list {
  margin: 10px 0 0;
  padding-left: 18px;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  background: #e5e7eb;
  border-radius: 999px;
  font-size: 12px;
}

@media (max-width: 850px) {
  .practice-wrap {
    grid-template-columns: 1fr;
  }
}

.single-board {
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 14px;
  overflow: hidden;
  padding: 8px;
}

.singleSvg {
  width: 100%;
  max-height: 460px;
  display: block;
  background: #fff;
}

.single-line {
  stroke: #111827;
  stroke-width: 5;
  stroke-linecap: round;
}

.single-title {
  font-size: 28px;
  font-weight: 700;
}

.single-label {
  font-size: 22px;
  font-weight: 700;
}

.single-small {
  font-size: 15px;
  font-weight: 700;
}

.board-title {
  padding: 10px 14px;
  font-weight: 800;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.device-group {
  fill: #ffffff;
  stroke: #cbd5e1;
  stroke-width: 2;
}

.device-group-label {
  font-size: 14px;
  font-weight: 800;
  fill: #334155;
}

.node circle {
  fill: #fff;
  stroke: #111827;
  stroke-width: 3;
}

.node.selected circle {
  fill: #dbeafe;
  stroke: #2563eb;
}

.wire {
  stroke: #111827;
  stroke-width: 5;
  stroke-linecap: round;
}

.wire-tools {
  float: right;
  display: inline-flex;
  gap: 6px;
}

.wire-tool {
  padding: 5px 10px;
  font-size: 13px;
  border-radius: 999px;
  border: 2px solid transparent;
}

.wire-tool.active {
  outline: 3px solid #93c5fd;
}

.wire-tool-black {
  background: #111827;
  color: #fff;
}

.wire-tool-white {
  background: #fff;
  color: #111827;
  border-color: #94a3b8;
}

.wire-tool-return {
  background: #dc2626;
  color: #fff;
}

.diagram-title {
  font-size: 24px;
  font-weight: 800;
}

.diagram-device {
  fill: #fff;
  stroke: #111827;
  stroke-width: 3;
}

.joint-area {
  fill: rgba(148, 163, 184, 0.08);
  stroke: #94a3b8;
  stroke-width: 2;
}

.dash-area {
  fill: none;
  stroke: #64748b;
  stroke-width: 2;
  stroke-dasharray: 8 6;
}

.diagram-label {
  font-size: 18px;
  font-weight: 800;
}

#practiceSvg {
  height: 460px;
}

.node circle {
  fill: #fff;
  stroke: #111827;
  stroke-width: 3;
}

.node text {
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
}

.node.selected circle {
  fill: #dbeafe;
  stroke: #2563eb;
}

.wire {
  stroke-width: 4;
  stroke-linecap: round;
}

.wire-black {
  stroke: #111827;
}

.wire-white {
  stroke: #60a5fa;
}

.wire-return {
  stroke: #dc2626;
}

/* --- practice page split layout --- */
.practice-page {
  max-width: 1500px;
}

.practice-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.practice-main-column {
  min-width: 0;
}

.practice-side-column {
  min-width: 0;
}

.practice-side-card {
  position: sticky;
  top: 16px;
}

.practice-board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.practice-board-header h2 {
  margin: 0;
}

.practice-drawing-card {
  padding-bottom: 14px;
}

.practice-board-full {
  border: 1px solid #d1d5db;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.side-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.side-actions button {
  flex: 1 1 auto;
}

.wire-tools {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

@media (max-width: 1100px) {
  .practice-page-grid {
    grid-template-columns: 1fr;
  }

  .practice-side-card {
    position: static;
  }
}

/* --- force 3-column practice layout: single / drawing / side --- */
.practice-page {
  max-width: 1680px !important;
}

.practice-page-grid {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 260px !important;
  gap: 16px !important;
  align-items: start !important;
}

.practice-main-column {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 16px !important;
  align-items: start !important;
}

.practice-main-column > .card {
  margin-bottom: 0 !important;
}

.practice-side-column {
  min-width: 0 !important;
}

.practice-side-card {
  position: sticky !important;
  top: 16px !important;
}

.singleSvg {
  height: 520px !important;
  max-height: none !important;
}

#practiceSvg {
  height: 520px !important;
}

.practice-board-full {
  height: auto !important;
}

@media (max-width: 1250px) {
  .practice-page-grid {
    grid-template-columns: 1fr !important;
  }

  .practice-main-column {
    grid-template-columns: 1fr !important;
  }

  .practice-side-card {
    position: static !important;
  }
}

/* --- wider practice page tuning --- */
.practice-page {
  width: calc(100vw - 24px) !important;
  max-width: none !important;
  margin: 20px auto !important;
  padding: 0 8px !important;
}

.practice-page-grid {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 210px !important;
  gap: 12px !important;
  align-items: start !important;
}

.practice-main-column {
  display: grid !important;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr) !important;
  gap: 12px !important;
  align-items: start !important;
}

.practice-side-card {
  position: sticky !important;
  top: 12px !important;
}

.side-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.side-actions button {
  flex: 1 1 auto;
}

.singleSvg {
  height: 560px !important;
  max-height: none !important;
}

#practiceSvg {
  height: 560px !important;
}

@media (max-width: 1400px) {
  .practice-main-column {
    grid-template-columns: 1fr !important;
  }

  .practice-page-grid {
    grid-template-columns: 1fr !important;
  }

  .practice-side-card {
    position: static !important;
  }
}

.diagram-label {
  font-size: 16px !important;
  font-weight: 800 !important;
}

.node text {
  font-size: 12px !important;
  font-weight: 800 !important;
}

.practice-side-card {
  width: 100%;
}

/* --- connection group mode --- */
.hint-text {
  color: #475569;
  font-size: 14px;
}

.group-tools-wrap {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f8fafc;
}

.group-tools-wrap h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.group-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.group-tool {
  text-align: left;
  background: #fff;
  color: #111827;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
}

.group-tool.active {
  border-color: #2563eb;
  background: #dbeafe;
}

.group-tool-label {
  display: block;
  font-weight: 800;
  font-size: 13px;
}

.group-tool-meta {
  display: block;
  color: #475569;
  font-size: 12px;
  margin-top: 3px;
}

.current-group-box {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 12px;
  font-size: 13px;
}

.current-group-title {
  font-weight: 800;
  color: #1d4ed8;
  margin-bottom: 4px;
}

.group-list-box {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 9px;
  margin-bottom: 8px;
  background: #fff;
  font-size: 12px;
}

.group-list-title {
  font-weight: 800;
  margin-bottom: 3px;
}

.group-list-meta {
  color: #475569;
  margin-bottom: 4px;
}

.group-list-members {
  color: #111827;
  line-height: 1.5;
}

.muted {
  color: #94a3b8;
}

.group-line {
  stroke-width: 4;
  stroke-linecap: round;
  opacity: 0.72;
}

.group-line-ring {
  stroke: #111827;
}

.group-line-push {
  stroke: #2563eb;
}

.connector-dot {
  stroke: #111827;
  stroke-width: 2;
}

.connector-ring {
  fill: #111827;
}

.connector-push {
  fill: #2563eb;
}

.connector-label {
  font-size: 12px;
  font-weight: 800;
  fill: #334155;
}

.node-badge {
  font-size: 11px;
  font-weight: 900;
  fill: #dc2626;
}

.group-node.selected circle {
  fill: #fef08a;
  stroke: #ca8a04;
}

/* --- declutter group diagram --- */
.practice-page {
  width: calc(100vw - 18px) !important;
  max-width: none !important;
}

.practice-page-grid {
  grid-template-columns: minmax(0, 1fr) 260px !important;
}

.practice-main-column {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr) !important;
}

.group-tools {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)) !important;
}

.group-tool {
  padding: 7px 9px !important;
}

.group-tool-label {
  font-size: 12px !important;
}

.group-tool-meta {
  font-size: 11px !important;
}

#practiceSvg {
  height: 620px !important;
}

.node circle {
  r: 8;
}

.node text {
  font-size: 11px !important;
  font-weight: 800 !important;
}

.diagram-label {
  font-size: 14px !important;
}

.diagram-title {
  font-size: 22px !important;
}

.joint-area {
  fill: rgba(148, 163, 184, 0.06) !important;
  stroke: #94a3b8 !important;
  stroke-width: 2 !important;
}

.group-line {
  stroke-width: 3 !important;
  opacity: 0.62 !important;
}

.connector-label {
  font-size: 10px !important;
}

.connector-dot {
  opacity: 0.9;
}

.group-list-box {
  padding: 7px !important;
  font-size: 11px !important;
}

.current-group-box {
  font-size: 12px !important;
  padding: 8px !important;
}

.practice-side-column {
  width: 260px !important;
}

.practice-side-card {
  width: 260px !important;
}

/* admin wide layout */
body .container {
  max-width: 1180px;
}

body .card {
  overflow-x: auto;
}

body table {
  width: 100%;
}

body th,
body td {
  vertical-align: middle;
}

.desc-preview {
  max-width: 520px;
}

/* wide layout */
.container {
  max-width: 1440px;
  width: calc(100% - 48px);
}

.card {
  overflow-x: auto;
}

table {
  width: 100%;
}

th,
td {
  vertical-align: middle;
}

.desc-preview,
.question-text-preview {
  max-width: 620px;
}
