:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --line: #d8e1ea;
  --text: #162231;
  --muted: #667487;
  --primary: #2558d9;
  --primary-soft: #edf3ff;
  --danger: #c93636;
  --shadow: 0 18px 45px rgba(30, 54, 82, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f7f9fc 0, var(--bg) 100%);
  color: var(--text);
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
}

button, input, textarea { font: inherit; }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 60px;
}

.hero {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 32px 34px;
  margin-bottom: 18px;
  border-radius: 24px;
  color: white;
  background: linear-gradient(135deg, #182c52, #285ed2);
  box-shadow: var(--shadow);
}

.hero-left {
  flex: 1 1 auto;
  min-width: 0;
}

.hero-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 24px;
  flex: 0 0 auto;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.hero-home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  color: rgba(255, 255, 255, .78);
  text-decoration: none;
  transition:
    color .18s ease,
    background .18s ease,
    transform .18s ease;
}

.hero-home-btn:hover,
.hero-home-btn:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, .12);
  outline: none;
}

.hero-home-btn:active {
  transform: scale(.94);
}

.hero-karnaugh {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  flex: 0 0 auto;
  cursor: help;
  outline: none;
}

.hero-karnaugh-info {
  display: grid;
  gap: 2px;
  text-align: right;
  line-height: 1.25;
}

.hero-karnaugh-info strong {
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.hero-karnaugh-info span {
  color: rgba(255, 255, 255, .76);
  font-size: 12px;
  font-weight: 700;
}

.hero-karnaugh img {
  display: block;
  width: 82px;
  height: 82px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, .30);
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(8, 24, 58, .24);
  transition:
    transform .2s ease,
    border-color .2s ease,
    box-shadow .2s ease;
}

.hero-karnaugh:hover img,
.hero-karnaugh:focus-visible img,
.hero-karnaugh:focus-within img {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, .55);
  box-shadow: 0 11px 24px rgba(8, 24, 58, .30);
}

.hero-karnaugh-tooltip {
  position: absolute;
  top: calc(100% + 13px);
  right: 0;
  z-index: 30;
  width: 310px;
  padding: 14px 16px;
  border: 1px solid rgba(31, 58, 103, .14);
  border-radius: 13px;
  background: rgba(255, 255, 255, .98);
  color: #263a59;
  box-shadow: 0 16px 36px rgba(17, 35, 68, .22);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(7px);
  transition:
    opacity .18s ease,
    visibility .18s ease,
    transform .18s ease;
}

.hero-karnaugh-tooltip::before {
  content: "";
  position: absolute;
  right: 28px;
  bottom: 100%;
  border: 7px solid transparent;
  border-bottom-color: rgba(255, 255, 255, .98);
}

.hero-karnaugh-tooltip strong {
  display: block;
  margin-bottom: 6px;
  color: #234b96;
  font-size: 14px;
}

.hero-karnaugh-tooltip p {
  margin: 0;
  color: #5f6d80;
  font-size: 12px;
  line-height: 1.65;
}

.hero-karnaugh:hover .hero-karnaugh-tooltip,
.hero-karnaugh:focus-visible .hero-karnaugh-tooltip,
.hero-karnaugh:focus-within .hero-karnaugh-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(29px, 5vw, 45px); }
h2 { margin-bottom: 0; font-size: 21px; }
.hero-copy { margin-bottom: 0; opacity: .86; }

.hero-badge {
  display: grid;
  place-items: center;
  min-width: 88px;
  height: 88px;
  border: 1px solid rgba(255,255,255,.34);
  border-radius: 50%;
  background: rgba(255,255,255,.10);
  font-weight: 900;
}

.panel {
  padding: 26px;
  margin-bottom: 18px;
  border: 1px solid rgba(216, 225, 234, .9);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 8px 25px rgba(35, 60, 88, .06);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.step-badge {
  display: inline-block;
  margin-bottom: 7px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}
.step-badge.muted { background: #edf0f4; color: #657184; }

.mode-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.mode-card {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 18px 18px 18px 46px;
  border: 2px solid var(--line);
  border-radius: 16px;
  cursor: pointer;
  transition: .18s ease;
}

.mode-card:hover { border-color: #9cb7ef; transform: translateY(-1px); }
.mode-card.is-active { border-color: var(--primary); background: var(--primary-soft); }
.mode-card input { position: absolute; left: 18px; top: 21px; }
.mode-card-title { font-weight: 900; }
.mode-card-copy { color: var(--muted); font-size: 14px; line-height: 1.5; }

.field-label { display: block; margin-bottom: 9px; font-weight: 800; }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.sequence-input, .truth-input {
  width: 100%;
  border: 1px solid #cbd6e2;
  border-radius: 12px;
  background: white;
  color: var(--text);
  outline: none;
}
.sequence-input { height: 48px; padding: 0 15px; }
.truth-input { padding: 14px 15px; resize: vertical; line-height: 1.65; font-family: Consolas, monospace; }
.sequence-input:focus, .truth-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37,88,217,.10); }

.button {
  min-height: 44px;
  padding: 0 17px;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 800;
}
.button-primary { color: white; background: var(--primary); }
.button-secondary { color: #31507f; background: #edf2f8; }
.button:hover { filter: brightness(.98); }

.option-row, .input-actions { margin-top: 14px; }
.checkbox-label { display: inline-flex; align-items: center; gap: 8px; color: #45566c; font-size: 14px; }
.field-help { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.error-message {
    display: none;
    margin: 10px 4px 14px;
    color: var(--danger);
    font-weight: 800;
}

.error-message.has-error {
    display: block;
}
.is-hidden { display: none !important; }

.summary-chip {
  padding: 7px 10px;
  border-radius: 999px;
  background: #f0f4f8;
  color: #536176;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.sequence-flow {
  display: flex;
  align-items: center;
  gap: 9px;
  overflow-x: auto;
  min-height: 58px;
  padding: 6px 2px 10px;
}
.state-node {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  min-width: 54px;
  height: 54px;
  border: 2px solid #adc0e7;
  border-radius: 15px;
  background: #f7f9fd;
  font-weight: 900;
}
.flow-arrow { flex: 0 0 auto; color: #7b8ca5; font-size: 22px; }
.flow-note { color: var(--muted); }

.table-wrap { overflow-x: auto; }
.truth-table { width: 100%; min-width: 760px; border-collapse: separate; border-spacing: 0; text-align: center; }
.truth-table th, .truth-table td { padding: 11px 9px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.truth-table th:first-child, .truth-table td:first-child { border-left: 1px solid var(--line); }
.truth-table thead tr:first-child th { border-top: 1px solid var(--line); }
.truth-table thead tr:first-child th:first-child { border-top-left-radius: 12px; }
.truth-table thead tr:first-child th:last-child { border-top-right-radius: 12px; }
.truth-table th { background: #f4f7fb; font-size: 13px; }
.truth-table td { font-family: Consolas, monospace; font-weight: 700; }
.truth-table tr:hover td { background: #fafcff; }
.current-cell { background: #f6f9ff; }
.next-cell { background: #f8fbf6; }
.output-cell { background: #fff9ed; font-size: 17px; }
.dont-care { color: #b77600; }

@media (max-width: 900px) {
  .hero-karnaugh {
    display: none;
  }
}

@media (max-width: 720px) {
  .app-shell { width: min(100% - 18px, 1180px); margin-top: 10px; }
  .hero { padding: 24px 20px; border-radius: 18px; }
  .hero-right { display: none; }
  .hero-badge { display: none; }
  .panel { padding: 20px 16px; border-radius: 16px; }
  .mode-selector { grid-template-columns: 1fr; }
  .input-row { grid-template-columns: 1fr; }
  .panel-heading { align-items: flex-start; }
}

.output-selector-block {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.output-selector-label { margin: 0; }
.output-tabs {
  display: inline-flex;
  gap: 7px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f4f7fb;
}
.output-tab {
  min-width: 58px;
  height: 38px;
  padding: 0 15px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #536176;
  cursor: pointer;
  font-weight: 900;
}
.output-tab:hover { background: #e8eef7; }
.output-tab.is-active {
  color: white;
  background: var(--primary);
  box-shadow: 0 5px 14px rgba(37, 88, 217, .22);
}
.kmap-help { margin-bottom: 18px; }
.kmap-wrap {
  position: relative;
  overflow-x: auto;
  padding: 8px 2px 14px;
}
.kmap-table {
  width: min(100%, 680px);
  min-width: 540px;
  margin: 0 auto;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 6px;
  text-align: center;
}
.kmap-table th {
  height: 48px;
  color: #4f6077;
  font-size: 18px;
  font-weight: 900;
}
.kmap-table tbody th {
  width: 74px;
  font-size: 18px;
  font-weight: 900;
}
.kmap-corner {
  position: relative;
  min-width: 92px;
  background: linear-gradient(to top right, transparent 49%, #b7c4d4 49.5%, #b7c4d4 50.5%, transparent 51%);
}
.kmap-corner span:first-child {
  position: absolute;
  left: 6px;
  bottom: 5px;
  color: #304666;
  font-size: 15px;
  font-weight: 900;
}
.kmap-corner span:last-child {
  position: absolute;
  right: 6px;
  top: 5px;
  color: #304666;
  font-size: 15px;
  font-weight: 900;
}
.kmap-cell {
  position: relative;
  height: 94px;
  border: 2px solid #d3dce7;
  border-radius: 15px;
  background: #f8fafc;
  transition: transform .15s ease, border-color .15s ease;
}
.kmap-cell:hover { transform: translateY(-2px); border-color: #91a9cc; }
/* 사용자가 입력하는 0·1·X·점은 셀 정중앙 */
.kmap-value {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  margin: 0;
  font-family: Consolas, monospace;
  font-size: 31px;
  font-weight: 900;
  line-height: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* 참고용 여기표 번호는 셀 아래쪽 */
.kmap-minterm {
  position: absolute;
  left: 10px;
  bottom: 8px;
  margin: 0;
  color: #8491a3;
  font-family: Consolas, "Malgun Gothic", monospace;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  text-align: left;
  pointer-events: none;
}
/*
.kmap-cell.value-one { border-color: #6e91e7; background: #edf3ff; color: #1744ad; }
.kmap-cell.value-zero { background: #f7f9fb; color: #657184; }
.kmap-cell.value-x { border-style: dashed; border-color: #d7ae58; background: #fff8e9; color: #a16a00; }
*/
.kmap-cell.value-one,
.kmap-cell.value-zero,
.kmap-cell.value-x {
  border-style: solid;
  border-color: #d3dce7;
  background: #f8fafc;
  color: #263b59;
}
.kmap-cell.value-one .kmap-value,
.kmap-cell.value-zero .kmap-value,
.kmap-cell.value-x .kmap-value {
  color: #263b59;
  font-size: 31px;
  font-weight: 900;
}
.kmap-axis-label { display: none; }

@media (max-width: 720px) {
  .output-selector-block { align-items: flex-start; flex-direction: column; gap: 8px; }
  .output-tabs { width: 100%; overflow-x: auto; }
  .output-tab { flex: 1 0 58px; }
  .kmap-heading { gap: 8px; }

  /* 모바일에서는 카르노맵 자체가 화면 폭 안에 들어오도록 축소합니다. */
  .kmap-wrap {
    overflow-x: hidden;
    width: 100%;
    padding-inline: 0;
  }
  .kmap-table {
    width: 100%;
    min-width: 0;
    border-spacing: 3px;
  }
  .kmap-table th {
    height: 38px;
    font-size: 15px;
    font-weight: 900;
  }
  .kmap-table tbody th { width: 42px; }
  .kmap-corner { min-width: 48px; }
  .kmap-corner span:first-child,
  .kmap-corner span:last-child {
    font-size: 12px;
    font-weight: 900;
  }
  .kmap-cell {
    height: clamp(58px, 17vw, 74px);
    border-radius: 11px;
  }
  .kmap-value { font-size: clamp(22px, 7vw, 29px); }
  .kmap-minterm {
    left: 7px;
	bottom: 6px;
    margin: 0;
    font-size: 12px;
  }
}

@media (max-width: 420px) {
  .kmap-table { border-spacing: 2px; }
  .kmap-table tbody th { width: 36px; }
  .kmap-corner { min-width: 42px; }
  .kmap-cell {
    height: clamp(52px, 16vw, 64px);
    border-width: 1.5px;
    border-radius: 9px;
  }
  .kmap-minterm {
    left: 6px;
	bottom: 5px;
    font-size: 11px;
  }
}

/* 카르노맵 수동 묶기 선택 - 1차 패치 */
.group-selection-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 12px;
  padding: 14px 16px;
  border: 1px solid #d9e2ee;
  border-radius: 14px;
  background: #f8fafc;
}
.group-selection-toolbar > div:first-child {
  display: grid;
  gap: 4px;
}
.selection-guide {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.selection-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
}
.selection-count {
  min-width: 76px;
  text-align: center;
}
.button:disabled {
  cursor: not-allowed;
  opacity: .48;
  filter: none;
}
.kmap-cell {
  cursor: crosshair;
  user-select: none;
  touch-action: none;
}
.kmap-cell.is-selected {
  z-index: 1;
  border-color: #e14b72;
  background-image: linear-gradient(rgba(225, 75, 114, .16), rgba(225, 75, 114, .16));
  box-shadow:
    0 0 0 3px rgba(225, 75, 114, .18),
    inset 0 0 0 2px rgba(255, 255, 255, .62);
  transform: translateY(-2px);
}
.kmap-cell.is-selected .kmap-minterm {
  color: #a52e50;
  font-weight: 800;
}

@media (max-width: 720px) {
  .group-selection-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .selection-actions {
    justify-content: space-between;
  }
}

/* 카르노맵 수동 묶기 검사 - 2차 패치 */
.group-validation-message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 10px;
  padding: 13px 15px;
  border: 1px solid #d9e2ee;
  border-radius: 14px;
  background: #f8fafc;
  color: #536176;
  transition: border-color .18s ease, background .18s ease, color .18s ease;
}
.group-validation-message > div {
  display: grid;
  gap: 3px;
}
.group-validation-message strong {
  color: inherit;
  font-size: 14px;
}
.group-validation-message span:not(.group-validation-icon) {
  font-size: 13px;
  line-height: 1.5;
}
.group-validation-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #e9eef5;
  font-weight: 900;
}
.group-validation-message.is-ready {
  border-color: #a8bde8;
  background: #f2f6ff;
  color: #31507f;
}
.group-validation-message.is-ready .group-validation-icon {
  background: #dbe6ff;
  color: #2558d9;
}
.group-validation-message.is-valid {
  border-color: #87c59f;
  background: #effaf3;
  color: #24633a;
}
.group-validation-message.is-valid .group-validation-icon {
  background: #cdeed8;
  color: #17652f;
}
.group-validation-message.is-invalid {
  border-color: #e6a1af;
  background: #fff2f5;
  color: #9d2944;
}
.group-validation-message.is-invalid .group-validation-icon {
  background: #ffdbe3;
  color: #ad2342;
}
.kmap-cell.is-validation-valid {
  border-color: #2f9a55;
  box-shadow:
    0 0 0 4px rgba(47, 154, 85, .18),
    inset 0 0 0 2px rgba(255, 255, 255, .65);
}
.kmap-cell.is-validation-invalid {
  border-color: #d53b5c;
  box-shadow:
    0 0 0 4px rgba(213, 59, 92, .18),
    inset 0 0 0 2px rgba(255, 255, 255, .65);
}

@media (max-width: 720px) {
  .selection-actions {
    flex-wrap: wrap;
  }
  .selection-actions .button {
    flex: 1 1 120px;
  }
}

/* 카르노맵 수동 묶기 저장 - 4차 패치 */
.button-success {
  color: #fff;
  background: #168a4a;
  border-color: #168a4a;
  box-shadow: 0 5px 14px rgba(22, 138, 74, .18);
}
.button-success:hover:not(:disabled) { background: #11763e; }
.button-danger-soft {
  color: #a52c47;
  background: #fff2f5;
  border-color: #efb5c1;
}
.button-danger-soft:hover:not(:disabled) { background: #ffe6ec; }
.kmap-cell.has-saved-group { overflow: visible; }
.kmap-group-marker {
  --group-offset: 0;
  --group-badge-index: 0;
  position: absolute;
  z-index: calc(2 + var(--group-offset));
  inset: calc(5px + (var(--group-offset) * 4px));
  pointer-events: none;
  border: 3px solid var(--group-color);
  border-radius: calc(11px - (var(--group-offset) * 1px));
  box-shadow: 0 0 0 1px rgba(255,255,255,.72);
}
.kmap-group-number {
  position: absolute;
  top: -10px;
  right: calc(-9px + (var(--group-badge-index) * 24px));
  display: grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--group-color);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 2px 6px rgba(31, 41, 55, .22);
}
.saved-groups-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
}
.saved-groups-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.saved-groups-heading > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 9px;
}
.saved-groups-heading strong { font-size: 16px; }
.saved-groups-heading span { color: var(--muted); font-size: 13px; }
.saved-group-actions { display: flex; gap: 8px; }
.saved-groups-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.saved-group-empty {
  display: grid;
  gap: 3px;
  grid-column: 1 / -1;
  padding: 16px;
  border: 1px dashed #cad5e3;
  border-radius: 13px;
  background: #fafbfd;
  color: #657184;
}
.saved-group-empty strong { font-size: 14px; }
.saved-group-empty span { font-size: 13px; }
.saved-group-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px;
  border: 1px solid color-mix(in srgb, var(--group-color) 38%, #d8e0ea);
  border-left: 5px solid var(--group-color);
  border-radius: 13px;
  background: #fff;
}
.saved-group-card > div { display: grid; gap: 3px; min-width: 0; }
.saved-group-card strong { font-size: 14px; }
.saved-group-card span { color: #59677a; font-size: 12px; line-height: 1.4; }
.saved-group-card small {
  overflow: hidden;
  color: #8491a3;
  font-family: Consolas, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.saved-group-badge {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--group-color);
  color: #fff !important;
  font-weight: 900;
}
@media (max-width: 720px) {
  .saved-groups-heading { align-items: stretch; flex-direction: column; }
  .saved-group-actions { flex-wrap: wrap; }
  .saved-group-actions .button { flex: 1 1 135px; }
}

/* 묶음 논리식 생성 - 5차 패치 */
.logic-result-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
}
.logic-result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.logic-result-heading > div:first-child {
  display: grid;
  gap: 4px;
}
.logic-result-heading strong { font-size: 16px; }
.logic-result-heading span:not(.logic-status) {
  color: var(--muted);
  font-size: 13px;
}
.logic-status {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}
.logic-status.is-idle { background: #edf1f5; color: #667487; }
.logic-status.is-complete { background: #e7f7ed; color: #16723d; }
.logic-status.is-incomplete { background: #fff3dc; color: #a46100; }
.group-terms-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 10px;
}
.logic-empty {
  grid-column: 1 / -1;
  padding: 15px;
  border: 1px dashed #cad5e3;
  border-radius: 13px;
  background: #fafbfd;
  color: #687589;
  font-size: 13px;
}
.group-term-card {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 13px;
  border: 1px solid color-mix(in srgb, var(--group-color) 34%, #d8e0ea);
  border-radius: 13px;
  background: color-mix(in srgb, var(--group-color) 4%, #fff);
}
.group-term-number {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background: var(--group-color);
  color: #fff;
  font-weight: 900;
}
.group-term-details {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.group-term-details > span {
  color: #667487;
  font-size: 11px;
  font-weight: 800;
}
.group-term-details strong {
  color: #162231;
  font-family: Consolas, "Malgun Gothic", monospace;
  font-size: 19px;
  letter-spacing: .02em;
}
.group-term-details small {
  overflow: hidden;
  color: #8491a3;
  font-family: Consolas, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.final-expression-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 12px;
  padding: 17px 19px;
  border: 1px solid #b9ccef;
  border-radius: 15px;
  background: linear-gradient(135deg, #f6f9ff, #edf3ff);
}
.final-expression-label {
  flex: 0 0 auto;
  color: #536176;
  font-size: 12px;
  font-weight: 900;
}
.final-expression-card strong {
  overflow-wrap: anywhere;
  color: #1d4fc2;
  font-family: Consolas, "Malgun Gothic", monospace;
  font-size: clamp(18px, 3vw, 25px);
  text-align: right;
}
@media (max-width: 720px) {
  .logic-result-heading,
  .final-expression-card {
    align-items: flex-start;
    flex-direction: column;
  }
  .final-expression-card strong { text-align: left; }
}

/* 자동 최소 풀이 및 사용자 풀이 비교 - 6차 패치 */
.auto-solver-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
}
.auto-solver-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.auto-solver-heading > div:first-child { display: grid; gap: 4px; }
.auto-solver-heading strong { font-size: 16px; }
.auto-solver-heading span { color: var(--muted); font-size: 13px; }
.auto-solver-actions { display: flex; gap: 8px; }
.auto-solver-result {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #d7e0eb;
  border-radius: 16px;
  background: #fafcff;
}
.auto-result-empty { color: #687589; font-size: 13px; }
.auto-expression-card {
  display: grid;
  gap: 5px;
  padding: 15px 17px;
  border: 1px solid #b9ccef;
  border-radius: 14px;
  background: linear-gradient(135deg, #f6f9ff, #edf3ff);
}
.auto-expression-card > span { color: #536176; font-size: 12px; font-weight: 900; }
.auto-expression-card strong {
  color: #1d4fc2;
  font-family: Consolas, "Malgun Gothic", monospace;
  font-size: clamp(18px, 3vw, 24px);
  overflow-wrap: anywhere;
}
.auto-expression-card small { color: #718096; font-size: 12px; }
.auto-groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}
.auto-group-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid #d9e3ef;
  border-radius: 12px;
  background: #fff;
}
.auto-group-card > span {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #315fc7;
  color: #fff;
  font-weight: 900;
}
.auto-group-card > div { display: grid; gap: 2px; min-width: 0; }
.auto-group-card strong { font-family: Consolas, monospace; font-size: 16px; }
.auto-group-card small { color: #8491a3; font-family: Consolas, monospace; font-size: 11px; }
.comparison-card {
  display: grid;
  gap: 4px;
  padding: 13px 15px;
  border-radius: 13px;
  border: 1px solid #d6dee9;
}
.comparison-card strong { font-size: 14px; }
.comparison-card span { font-size: 13px; line-height: 1.5; }
.comparison-card.is-optimal { border-color: #a9d9ba; background: #edf9f1; color: #146b39; }
.comparison-card.is-incomplete { border-color: #efd09a; background: #fff8e9; color: #8b5900; }
.comparison-card.is-improvable { border-color: #e6b7c2; background: #fff2f5; color: #9b2945; }
@media (max-width: 720px) {
  .auto-solver-heading { align-items: stretch; flex-direction: column; }
  .auto-solver-actions { flex-wrap: wrap; }
  .auto-solver-actions .button { flex: 1 1 135px; }
}

/* MathJax 논리식 표시 */
.math-inline {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
}

.math-term {
  min-height: 1.8rem;
  font-size: 1.08rem;
  line-height: 1.2;
}

.math-equation {
  justify-content: center;
  min-height: 2.4rem;
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
  line-height: 1.25;
}

.final-expression-card strong,
.auto-expression-card > strong {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.15rem 0;
}

.group-term-details strong,
.auto-group-card strong {
  display: flex;
  align-items: center;
  min-height: 2rem;
}

mjx-container[jax="SVG"] {
  margin: 0 !important;
  max-width: 100%;
}

mjx-container[jax="SVG"] > svg {
  max-width: 100%;
  height: auto;
}

/* 카르노맵 직접 입력 및 정답 검증 */
.kmap-practice-toolbar {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  margin: 16px 0 10px;
  padding: 15px 16px;
  border: 1px solid #cfdcf0;
  border-radius: 16px;
  background: linear-gradient(135deg, #f8fbff, #f2f6ff);
}
.kmap-practice-toolbar > div:first-child { display: grid; gap: 4px; }
.kmap-practice-toolbar > div:first-child strong { font-size: 15px; }
.kmap-practice-toolbar > div:first-child span { color: var(--muted); font-size: 12px; }
.kmap-value-palette, .kmap-practice-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.kmap-value-button {
  min-width: 40px;
  height: 38px;
  padding: 0 11px;
  border: 1px solid #cbd6e5;
  border-radius: 10px;
  background: #fff;
  color: #526075;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.kmap-value-button:hover { border-color: #7796d9; color: #2857bd; }
.kmap-value-button.is-active { border-color: #315fc7; background: #315fc7; color: #fff; box-shadow: 0 6px 14px rgba(49,95,199,.2); }
.kmap-answer-message {
  margin-bottom: 12px;
  padding: 11px 14px;
  border: 1px solid #d8e0eb;
  border-radius: 12px;
  background: #fafbfd;
  color: #647287;
  font-size: 13px;
  font-weight: 700;
}
.kmap-answer-message.is-correct { border-color: #9fd4b1; background: #edf9f1; color: #176b3a; }
.kmap-answer-message.is-wrong { border-color: #efb7c3; background: #fff2f5; color: #9a2945; }
.kmap-answer-message.is-revealed { border-color: #b8c9ee; background: #f2f6ff; color: #3158ad; }
.kmap-cell.is-empty-value .kmap-value { color: #c2cad5; font-weight: 500; }
.kmap-cell.is-answer-wrong { box-shadow: inset 0 0 0 3px #e75072 !important; background: #fff0f4 !important; }
.kmap-cell.is-answer-correct { box-shadow: inset 0 0 0 2px rgba(35,157,88,.38); }
.group-selection-toolbar.is-locked { opacity: .52; filter: grayscale(.2); }
.group-selection-toolbar.is-locked::after { content: "카르노맵 정답 확인 후 사용할 수 있습니다"; color: #8a5a00; font-size: 12px; font-weight: 800; }

/* 플립플롭 여기표 */
.ff-table-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 15px; }
.ff-table-card { padding: 17px; border: 1px solid #d7e0eb; border-radius: 16px; background: #fbfcff; }
.ff-table-card h3 { margin: 0 0 12px; font-size: 16px; }
.ff-table-card table { width: 100%; border-collapse: collapse; text-align: center; }
.ff-table-card th, .ff-table-card td { padding: 9px 7px; border: 1px solid #dbe3ed; }
.ff-table-card th { background: #edf3ff; color: #35517f; font-size: 13px; }
.ff-table-card td { background: #fff; font-weight: 800; }
.ff-table-card p { margin: 11px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
@media (max-width: 900px) {
  .kmap-practice-toolbar { grid-template-columns: 1fr; align-items: stretch; }
  .ff-table-grid { grid-template-columns: 1fr; }
}

/* 카르노맵 입력·검사 통합 작업대 */
.kmap-workbench {
  margin: 16px 0 14px;
  padding: 16px;
  border: 1px solid #cbd8eb;
  border-radius: 18px;
  background: linear-gradient(145deg, #fbfdff, #f4f7fc);
  box-shadow: 0 8px 24px rgba(45, 70, 110, .06);
}
.kmap-workbench .kmap-practice-toolbar,
.kmap-workbench .group-selection-toolbar {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.kmap-workbench .kmap-answer-message {
  margin: 12px 0 0;
}
.kmap-workbench .group-validation-message {
  margin: 11px 0 0;
}
.workbench-divider {
  height: 1px;
  margin: 16px 0;
  background: linear-gradient(90deg, transparent, #cbd7e8 12%, #cbd7e8 88%, transparent);
}
.kmap-practice-toolbar {
  grid-template-columns: minmax(185px, 1fr) auto minmax(190px, auto) auto;
}
.kmap-practice-options {
  display: grid;
  gap: 6px;
  min-width: 190px;
}
.checkbox-label.compact {
  gap: 7px;
  font-size: 12px;
  white-space: nowrap;
}
.checkbox-label.compact input { margin: 0; }
.logic-heading-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.logic-order-control {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.logic-order-control select {
  height: 34px;
  padding: 0 30px 0 10px;
  border: 1px solid #ccd7e5;
  border-radius: 9px;
  background: #fff;
  color: #3e4d63;
  font: inherit;
  font-weight: 800;
}
.kmap-cell { -webkit-user-drag: none; }

@media (max-width: 1100px) {
  .kmap-practice-toolbar { grid-template-columns: 1fr auto; }
  .kmap-practice-options { min-width: 0; }
  .kmap-practice-actions { justify-content: flex-end; }
}
@media (max-width: 720px) {
  .kmap-workbench { padding: 13px; }
  .kmap-practice-toolbar { grid-template-columns: 1fr; }
  .kmap-practice-actions { justify-content: flex-start; }
  .logic-heading-tools { align-items: flex-start; flex-direction: column; }
}


/* 묶음 번호가 여러 개인 셀: 번호표를 겹치지 않게 나란히 표시 */
@media (max-width: 520px) {
  .kmap-group-number {
    right: calc(-7px + (var(--group-badge-index) * 20px));
    min-width: 19px;
    height: 19px;
    padding: 0 4px;
    font-size: 10px;
  }
}

/* v15 범용 프로젝트 설정 */
.project-settings-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
.settings-field{display:flex;flex-direction:column;gap:7px;font-weight:700;color:#314363}
.settings-field select,.name-input-grid input{min-height:42px;border:1px solid #c9d5e8;border-radius:11px;background:#fff;padding:8px 11px;font:inherit;color:#233758}
.name-editor-block{margin-top:15px}.name-input-grid{display:grid;grid-template-columns:repeat(5,minmax(75px,1fr));gap:9px;margin-top:8px}
.settings-actions{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-top:16px}
.kmap-multi-grid{display:flex;justify-content:center;gap:26px;align-items:flex-start}.kmap-map-panel{min-width:0}.kmap-layer-title{text-align:center;font-weight:800;color:#2b5fc2;margin-bottom:8px}
@media(max-width:760px){.project-settings-grid{grid-template-columns:1fr}.name-input-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.settings-actions{align-items:stretch;flex-direction:column}.kmap-multi-grid.is-five-variable{display:grid;grid-template-columns:1fr;gap:20px}.kmap-multi-grid.is-five-variable .kmap-table{width:100%;max-width:100%}}


/* v18 묶음 간략화 검사 */
.button-compact {
  padding: 8px 12px;
  min-height: 36px;
  white-space: nowrap;
}

.grouping-simplicity-result {
  margin-top: 14px;
  padding: 15px 16px;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  background: #f8fafc;
  display: grid;
  gap: 12px;
}

.grouping-simplicity-result .simplicity-result-copy {
  display: grid;
  gap: 4px;
}

.grouping-simplicity-result strong {
  color: #243653;
  font-size: 14px;
}

.grouping-simplicity-result span {
  color: #60708a;
  font-size: 13px;
  line-height: 1.5;
}

.grouping-simplicity-result small {
  color: #60708a;
  font-size: 12px;
}

.grouping-simplicity-result.is-optimal {
  border-color: #b9e8cf;
  background: #effbf4;
}

.grouping-simplicity-result.is-improvable {
  border-color: #f2c08c;
  background: #fff8ee;
}

.grouping-simplicity-result.is-incomplete {
  border-color: #f0c4cc;
  background: #fff5f7;
}

.simplicity-suggestion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}

.simplicity-suggestion-card {
  padding: 10px 12px;
  border: 1px solid rgba(217, 119, 6, .28);
  border-radius: 11px;
  background: rgba(255, 255, 255, .78);
  display: grid;
  gap: 2px;
}

.kmap-cell.is-simplicity-suggestion {
  box-shadow: inset 0 0 0 3px #f59e0b, 0 0 0 2px rgba(245, 158, 11, .18) !important;
  animation: simplicityPulse 1.25s ease-in-out infinite alternate;
}

@keyframes simplicityPulse {
  from { filter: brightness(1); }
  to { filter: brightness(1.06); }
}

@media (max-width: 720px) {
  .logic-heading-tools {
    flex-wrap: wrap;
  }
  .button-compact {
    width: 100%;
  }
}


/* v20: 돈케어 확인 패널 */
.truth-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}
.button-compact { min-height: 38px; padding: 0 13px; font-size: 13px; }
.dont-care-panel {
  margin: -4px 0 18px;
  padding: 16px;
  border: 1px solid #f0c568;
  border-radius: 15px;
  background: #fffaf0;
}
.dont-care-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.dont-care-panel-heading > div { display: flex; align-items: baseline; gap: 8px; }
.dont-care-panel-heading strong { color: #8a5a00; }
.dont-care-panel-heading span { color: #7b6850; font-size: 13px; }
.dont-care-note { white-space: nowrap; }
.dont-care-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dont-care-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 36px;
  padding: 0 11px;
  border: 1px solid #efd79e;
  border-radius: 10px;
  background: #fff;
  color: #9a6400;
  font-family: Consolas, monospace;
  font-size: 14px;
  font-weight: 900;
}
.dont-care-empty { padding: 10px; color: #7b6850; text-align: center; }
@media (max-width: 720px) {
  .truth-heading-actions { width: 100%; justify-content: flex-start; }
  .dont-care-panel-heading { align-items: flex-start; flex-direction: column; }
  .dont-care-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* v21: 정답이 아닌 카르노맵에서도 묶기 학습 */
.group-validation-message.is-warning {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
}
.group-validation-message.is-warning .group-validation-icon {
  background: #f59e0b;
  color: #fff;
}

/* 프로젝트 설정 접기 · 펼치기 */
.project-settings-panel {
  padding: 0;
  overflow: hidden;
  transition:
    border-color .2s ease,
    box-shadow .2s ease;
}

.project-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 82px;
  padding: 18px 26px;
}

.project-settings-title-area {
  min-width: 0;
}

.project-settings-title-area .step-badge {
  margin-bottom: 6px;
}

.project-settings-title-row {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.project-settings-title-row h2 {
  flex: 0 0 auto;
}

.project-settings-summary {
  overflow: hidden;
  padding: 6px 10px;
  border: 1px solid #d6e1f3;
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
  color: #60708a;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-settings-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.project-settings-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 112px;
  color: #fff;
  background: var(--primary);
}

.project-settings-toggle-arrow {
  display: inline-block;
  font-size: 10px;
  transition: transform .22s ease;
}

.project-settings-body {
  max-height: 1000px;
  padding: 4px 26px 26px;
  border-top: 1px solid rgba(185, 205, 247, .7);
  opacity: 1;
  overflow: hidden;
  transition:
    max-height .35s ease,
    padding .35s ease,
    border-color .25s ease,
    opacity .22s ease;
}

/* 기본 접힘 상태 */
.project-settings-panel.is-collapsed .project-settings-body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-color: transparent;
  opacity: 0;
  pointer-events: none;
}

.project-settings-panel:not(.is-collapsed)
  .project-settings-toggle-arrow {
  transform: rotate(180deg);
}

@media (max-width: 720px) {
  .project-settings-header {
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
    padding: 17px 16px;
  }

  .project-settings-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .project-settings-summary {
    max-width: 100%;
  }

  .project-settings-header-actions {
    width: 100%;
  }

  .project-settings-header-actions .button {
    flex: 1 1 0;
  }

  .project-settings-body {
    padding-right: 16px;
    padding-left: 16px;
  }
}

/* 표준 진리표 작성 연습 */
.truth-practice-message {
  margin: -4px 0 16px;
  padding: 11px 14px;
  border: 1px solid #d8e0eb;
  border-radius: 12px;
  background: #fafbfd;
  color: #647287;
  font-size: 13px;
  font-weight: 700;
}

.truth-practice-message.is-correct {
  border-color: #9fd4b1;
  background: #edf9f1;
  color: #176b3a;
}

.truth-practice-message.is-wrong {
  border-color: #efb7c3;
  background: #fff2f5;
  color: #9a2945;
}

.truth-practice-message.is-revealed {
  border-color: #b8c9ee;
  background: #f2f6ff;
  color: #3158ad;
}

.truth-practice-cell {
  position: relative;
  min-width: 48px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition:
    background-color .15s ease,
    box-shadow .15s ease,
    color .15s ease,
    transform .12s ease;
}

.truth-practice-cell:hover {
  z-index: 1;
  background: #edf3ff !important;
  box-shadow:
    inset 0 0 0 2px #8eaceb;
}

.truth-practice-cell:active {
  transform: scale(.96);
}

.truth-practice-cell.is-empty {
  color: #aeb9c8;
  font-size: 18px;
  font-weight: 500;
}

.truth-practice-cell.value-zero {
  color: #526075;
}

.truth-practice-cell.value-one {
  color: #1744ad;
}

.truth-practice-cell.value-x {
  color: #1744ad;
  /*background: #fff8e9;*/
}

/* 정답 입력 시 잠깐 나타나는 성공 효과 */
.truth-practice-cell.is-practice-correct-flash {
  color: #176b3a;
  background: #eaf8ef !important;
  box-shadow:
    inset 0 0 0 2px rgba(35, 157, 88, .48),
    0 0 0 3px rgba(35, 157, 88, .10);
  animation: truthCorrectFlash .85s ease forwards;
}

/* 하나의 4비트 문제 정답 표시 */
.truth-practice-cell.is-group-correct-flash {
  animation:
    truthGroupCorrectFlash
    .85s ease;
}

.truth-practice-cell.is-group-wrong-flash {
  animation:
    truthGroupWrongFlash
    .85s ease;
}

@keyframes truthGroupCorrectFlash {
  0% {
    background: #dff5e7;
    box-shadow:
      inset 0 0 0 2px
      rgba(35, 157, 88, .65);
  }

  55% {
    background: #edf9f1;
    box-shadow:
      inset 0 0 0 2px
      rgba(35, 157, 88, .28);
  }

  100% {
    box-shadow: none;
  }
}

@keyframes truthGroupWrongFlash {
  0% {
    background: #ffe5eb;
    box-shadow:
      inset 0 0 0 2px
      rgba(215, 59, 92, .68);
  }

  55% {
    background: #fff2f5;
    box-shadow:
      inset 0 0 0 2px
      rgba(215, 59, 92, .30);
  }

  100% {
    box-shadow: none;
  }
}

@keyframes truthCorrectFlash {
  0% {
    background: #dff5e7;
    box-shadow:
      inset 0 0 0 2px rgba(35, 157, 88, .62),
      0 0 0 4px rgba(35, 157, 88, .16);
  }

  55% {
    background: #edf9f1;
    box-shadow:
      inset 0 0 0 2px rgba(35, 157, 88, .34),
      0 0 0 2px rgba(35, 157, 88, .08);
  }

  100% {
    background: inherit;
    box-shadow: none;
  }
}

.truth-table tbody.is-practice-locked
  .truth-practice-cell {
  cursor: default;
}

.truth-table tbody.is-practice-locked
  .truth-practice-cell:hover {
  transform: none;
  background: inherit !important;
  box-shadow: none;
}

.decimal-cell {
  background: #fff;
  color: #162231;
  font-weight: 900;
}

.transition-cell {
  cursor: default;
  background: #fff;
}

@media (max-width: 720px) {
  .truth-practice-message {
    margin-top: 0;
  }

  .truth-practice-cell {
    min-width: 42px;
  }
}

/* =========================================================
   STEP 5: 출력값 안내 · 카르노맵 · 입력 도구 3열 배치
   ========================================================= */

.kmap-fill-layout {
  display: grid;
  grid-template-columns:
    minmax(180px, 220px)
    minmax(520px, 1fr)
    minmax(190px, 220px);
  align-items: start;
  gap: 18px;
  margin: 16px 0 20px;
}


/* 공통 카드 */
.output-reference-panel,
.kmap-main-column,
.kmap-entry-tools,
.kmap-grouping-workbench {
  border: 1px solid #d5dfec;
  border-radius: 17px;
  background: #fff;
  box-shadow:
    0 7px 22px
    rgba(41, 64, 94, .055);
}

/* ==========================================
   JK 출력 탭만 2줄
   ========================================== */

.output-reference-panel.is-jk-output
.output-guide-tabs {

    display: grid;

    grid-template-columns:
        repeat(4, 1fr);

    gap: 5px;
}

.output-reference-panel.is-jk-output
.output-guide-tabs
.output-tab{

    min-width:0;
    height:38px;
}

/*
 * 헤더가 두 줄이 되므로
 * 상태 셀도 높이를 맞춘다.
 */
.output-reference-panel.is-jk-output
.output-state-heading{

    align-self:stretch;
    min-height:82px;
}

/* JK 상태값 행은 탭과 동일하게 4열 기준 */
.output-reference-panel.is-jk-output
  .output-guide-row {
  grid-template-columns:
    42px
    repeat(4, minmax(0, 1fr));
  gap: 5px;
}

/* 선택되지 않은 출력 열은 공간까지 제거 */
.output-reference-panel.is-jk-output
  .output-guide-value {
  display: none;
}

/* 선택한 출력값만 해당 탭의 가로 위치에 표시 */
.output-reference-panel.is-jk-output
  .output-guide-value.is-selected-output {
  display: grid;
  grid-column:
    var(--selected-output-column);
  width: 100%;
  min-width: 0;
  min-height: 39px;
}


/* ---------------------------------------------------------
   왼쪽 출력값 안내표
   --------------------------------------------------------- */

.output-reference-panel {
  overflow: hidden;
}

.output-reference-heading {
  display: grid;
  gap: 3px;
  padding: 15px 16px 13px;
  border-bottom: 1px solid #dce4ef;
  background:
    linear-gradient(
      135deg,
      #f8faff,
      #f1f5fc
    );
}

.output-reference-heading strong {
  color: #263a59;
  font-size: 15px;
}

.output-reference-heading span {
  color: #718096;
  font-size: 11px;
}

.output-reference-table {
  --output-count: 4;
  padding: 12px;
}

.output-reference-head {
  display: grid;
  grid-template-columns:
    42px
    minmax(0, 1fr);
  align-items: stretch;
  gap: 6px;
  margin-bottom: 7px;
}

.output-state-heading {
  display: grid;
  place-items: center;
  min-height: 38px;
  border-radius: 9px;
  background: #edf1f6;
  color: #667487;
  font-size: 11px;
  font-weight: 900;
}


/* D1 D2 D3 D4 가로 탭 */
.output-guide-tabs {
  display: grid;
  grid-template-columns:
    repeat(
      var(--output-count),
      minmax(0, 1fr)
    );
  width: 100%;
  gap: 4px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.output-guide-tabs .output-tab {
  min-width: 0;
  height: 38px;
  padding: 0 4px;
  border: 1px solid #d6deea;
  border-radius: 9px;
  background: #f5f7fa;
  font-size: 13px;
}

.output-guide-tabs
  .output-tab.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow:
    0 4px 11px
    rgba(37, 88, 217, .18);
}


/* 상태별 값 */
.output-value-guide {
  display: grid;
  gap: 5px;
}

.output-guide-row {
  display: grid;
  grid-template-columns:
    42px
    repeat(
      var(--output-count),
      minmax(0, 1fr)
    );
  gap: 4px;
  min-height: 39px;
}

.output-guide-state,
.output-guide-value {
  display: grid;
  place-items: center;
  border-radius: 8px;
}

.output-guide-state {
  border: 1px solid #dce3ec;
  background: #f8fafc;
  color: #4b5d75;
  font-family: Consolas, monospace;
  font-size: 13px;
  font-weight: 900;
}

.output-guide-value {
  border: 1px solid transparent;
  color: #263b59;
  font-family: Consolas, monospace;
  font-size: 21px;
  font-weight: 900;
}

.output-guide-value.is-selected-output {
  border-color: #c9d8f4;
  background: #f4f7fd;
}

.output-guide-value.value-1 {
  color: #1744ad;
}

.output-guide-value.value-0 {
  color: #485b73;
}

/* X 및 선택되지 않은 열 */
.output-guide-value.is-blank-output {
  color: transparent;
}

.output-reference-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 12px 12px;
  padding: 9px 10px;
  border-radius: 9px;
  background: #f7f8fa;
  color: #778397;
  font-size: 11px;
}


/* ---------------------------------------------------------
   가운데 카르노맵
   --------------------------------------------------------- */

.kmap-main-column {
  min-width: 0;
  padding: 15px 16px 18px;
}

.kmap-main-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.kmap-main-heading strong {
  color: #263a59;
  font-size: 15px;
}

.kmap-main-heading span {
  color: #7b8798;
  font-size: 11px;
}

.kmap-main-column .kmap-wrap {
  padding-top: 3px;
  padding-bottom: 0;
}


/* ---------------------------------------------------------
   오른쪽 입력 도구
   --------------------------------------------------------- */

.kmap-entry-tools {
  padding: 15px;
}

.kmap-entry-tools-heading {
  display: grid;
  gap: 3px;
  margin-bottom: 13px;
}

.kmap-entry-tools-heading strong {
  color: #263a59;
  font-size: 15px;
}

.kmap-entry-tools-heading span {
  color: #718096;
  font-size: 11px;
}

.kmap-entry-tools
  .kmap-value-palette {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.kmap-entry-tools
  .kmap-value-button {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0;
  font-size: 16px;
}

.kmap-entry-tools
  .kmap-erase-button {
  grid-column: 1 / -1;
  font-size: 13px;
}

.kmap-entry-tools
  .kmap-practice-options {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid #e0e6ef;
}

.kmap-entry-tools
  .checkbox-label.compact {
  align-items: flex-start;
  white-space: normal;
  line-height: 1.4;
}

.kmap-entry-tools
  .kmap-practice-actions {
  display: grid;
  gap: 8px;
  margin-top: 15px;
}

.kmap-entry-tools
  .kmap-practice-actions .button {
  width: 100%;
  min-height: 40px;
}

.kmap-fill-count {
  justify-self: stretch;
  text-align: center;
}

.kmap-entry-tools
  .kmap-answer-message {
  margin: 11px 0 0;
  padding: 10px 11px;
  font-size: 11px;
  line-height: 1.5;
}


/* ---------------------------------------------------------
   묶기 작업대 분리
   --------------------------------------------------------- */

.kmap-grouping-workbench {
  margin: 0 0 18px;
  padding: 16px;
  background:
    linear-gradient(
      145deg,
      #fbfcfe,
      #f6f8fb
    );
}

.kmap-grouping-workbench
  .group-selection-toolbar {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.kmap-grouping-workbench
  .group-validation-message {
  margin: 12px 0 0;
}


/* 기존 통합 작업대는 새 구조에서 사용하지 않음 */
.kmap-workbench {
  display: contents;
}


/* =========================================================
   반응형
   ========================================================= */

@media (max-width: 1050px) {
  .kmap-fill-layout {
    grid-template-columns:
      minmax(180px, 220px)
      minmax(0, 1fr);
  }

  .kmap-entry-tools {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns:
      minmax(150px, .8fr)
      minmax(220px, 1fr)
      minmax(240px, 1.2fr);
    align-items: start;
    gap: 16px;
  }

  .kmap-entry-tools-heading {
    margin-bottom: 0;
  }

  .kmap-entry-tools
    .kmap-practice-options,
  .kmap-entry-tools
    .kmap-practice-actions {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  .kmap-entry-tools
    .kmap-answer-message {
    grid-column: 1 / -1;
  }
}


@media (max-width: 720px) {
  .kmap-fill-layout {
    display: flex;
    flex-direction: column;
    gap: 13px;
  }

  .output-reference-panel,
  .kmap-main-column,
  .kmap-entry-tools {
    width: 100%;
  }

  /* 모바일에서도 출력값·채우기·묶기를 분리 */
  .output-reference-panel {
    order: 1;
  }

  .kmap-main-column {
    order: 2;
    padding: 13px 9px 15px;
  }

  .kmap-entry-tools {
    order: 3;
    display: block;
    padding: 14px;
  }

  .kmap-entry-tools-heading {
    margin-bottom: 12px;
  }

  .kmap-entry-tools
    .kmap-practice-options,
  .kmap-entry-tools
    .kmap-practice-actions {
    margin-top: 14px;
  }

  .kmap-entry-tools
    .kmap-practice-options {
    padding-top: 13px;
    border-top: 1px solid #e0e6ef;
  }

  .output-reference-table {
    padding: 10px;
  }

  .output-guide-row {
    min-height: 36px;
  }

  .output-guide-value {
    font-size: 18px;
  }

  .kmap-main-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
    padding-inline: 5px;
  }

  .kmap-grouping-workbench {
    padding: 14px;
  }

  .kmap-grouping-workbench
    .group-selection-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

/* 표준 진리표 표시 순서 선택 */
.truth-order-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #657184;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.truth-order-control select {
  height: 38px;
  padding: 0 32px 0 11px;
  border: 1px solid #ccd7e5;
  border-radius: 10px;
  background: #fff;
  color: #314b72;
  font: inherit;
  font-weight: 900;
  outline: none;
}

.truth-order-control select:focus {
  border-color: var(--primary);
  box-shadow:
    0 0 0 3px
    rgba(37, 88, 217, .10);
}

@media (max-width: 720px) {
  .truth-order-control {
    width: 100%;
    justify-content: space-between;
  }

  .truth-order-control select {
    flex: 1 1 auto;
    min-width: 0;
  }
}

/* =========================================================
   모바일 출력 비트 선택 패널 개선
   D  : D1 D2 D3 D4
   JK : J1 K1 J2 K2 / J3 K3 J4 K4
   ========================================================= */

@media (max-width: 720px) {

  /*
   * 헤더는
   * [상태] [출력 탭 전체 영역]
   * 두 영역으로만 나눕니다.
   */
  .output-reference-head {
    display: grid;
    grid-template-columns:
      52px
      minmax(0, 1fr);
    align-items: stretch;
    gap: 7px;
    margin-bottom: 8px;
  }

  /*
   * 출력 탭은 모바일에서 한 줄에 최대 4개.
   *
   * D 플립플롭: 4개이므로 한 줄
   * JK 플립플롭: 8개이므로 두 줄
   */
  .output-guide-tabs {
    display: grid;
    grid-template-columns:
      repeat(4, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    overflow: visible;
  }

  .output-guide-tabs .output-tab {
    width: 100%;
    min-width: 0;
    height: 42px;
    padding: 0 5px;
    border: 1px solid #d4deeb;
    border-radius: 10px;
    background: #f6f8fb;
    color: #526075;
    font-size: 14px;
    font-weight: 900;
    white-space: nowrap;
  }

  .output-guide-tabs .output-tab.is-active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
    box-shadow:
      0 5px 12px
      rgba(37, 88, 217, .20);
  }

  /*
   * JK에서 탭이 두 줄이 되어도
   * 왼쪽 '상태' 칸이 같은 높이로 늘어납니다.
   */
  .output-state-heading {
    align-self: stretch;
    min-height: 42px;
    height: auto;
    padding: 8px 4px;
    font-size: 13px;
  }

  /*
   * 상태별 출력값 영역은 모바일에서
   * [상태 번호] [현재 선택된 출력값]
   * 두 칸만 사용합니다.
   */
  .output-guide-row {
    display: grid;
    grid-template-columns:
      52px
      minmax(0, 1fr);
    gap: 7px;
    min-height: 44px;
  }

  /*
   * 선택되지 않은 D/J/K 열은 숨깁니다.
   * 빈 열이 화면 폭을 차지하지 않게 합니다.
   */
  .output-guide-value {
    display: none;
  }

  /*
   * 현재 선택한 출력 열만 표시합니다.
   */
  .output-guide-value.is-selected-output {
    display: grid;
    width: 100%;
    min-height: 44px;
    place-items: center;
    border: 1px solid #c9d8f4;
    border-radius: 9px;
    background: #f4f7fd;
    font-size: 22px;
    font-weight: 900;
  }

  .output-guide-state {
    min-height: 44px;
    font-size: 14px;
  }

  .output-reference-table {
    padding: 12px;
  }
}

/* 카르노맵 참고용 여기표 숫자 숨기기 */
.kmap-container.hide-kmap-minterms
  .kmap-minterm,
#kmapContainer.hide-kmap-minterms
  .kmap-minterm {
  visibility: hidden;
}
/* 저장된 묶음 + 묶음 논리식 통합 */
.unified-group-result-section {
  position: relative;
}

.unified-group-heading {
  align-items: flex-end;
  margin-bottom: 10px;
}

.unified-group-title-area {
  display: grid !important;
  gap: 5px !important;
}

.unified-group-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.unified-group-summary .summary-divider {
  color: #a7b1bf;
}

.unified-group-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.unified-group-actions {
  justify-content: flex-end;
  margin-bottom: 12px;
}

.unified-groups-list {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.unified-group-card {
  align-items: flex-start;
  min-width: 0;
  padding: 15px;
  background: color-mix(in srgb, var(--group-color) 3.5%, #fff);
}

.unified-group-card-body {
  display: grid !important;
  gap: 5px !important;
  min-width: 0;
  width: 100%;
}

.unified-group-card-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 5px 12px;
}

.unified-group-card-heading strong {
  font-size: 14px;
}

.unified-group-card-heading span {
  color: #748195;
  font-size: 11px;
  font-weight: 700;
}

.unified-group-term {
  min-height: 30px;
  color: #172b4d;
  font-size: 20px !important;
  line-height: 1.35;
}

.unified-group-minterms,
.unified-group-removed {
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: normal !important;
  line-height: 1.45;
}

.unified-group-minterms {
  color: #66758b !important;
}

.unified-group-removed {
  color: #8a96a7 !important;
}

.unified-group-result-section .grouping-simplicity-result {
  margin-top: 14px;
}

.unified-group-result-section .final-expression-card {
  margin-top: 14px;
}

@media (max-width: 820px) {
  .unified-group-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .unified-group-tools {
    justify-content: flex-start;
  }

  .unified-group-actions .button {
    flex: 1 1 135px;
  }
}

/* v21: 다른 풀이 · 최소 풀이 */
.alternative-solutions-heading {
  align-items: flex-start;
}

.alternative-solver-actions {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auto-solution-navigation {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px;
  border: 1px solid #d7e0eb;
  border-radius: 12px;
  background: #f7f9fc;
}

.auto-nav-button {
  min-width: 38px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 17px;
}

.auto-solution-position {
  min-width: 84px;
  color: #42536b !important;
  font-size: 12px !important;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.alternative-solutions-section .auto-expression-card {
  position: relative;
  overflow: hidden;
}

.alternative-solutions-section .auto-expression-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: #315fc7;
  content: "";
}

/* 다른 풀이 카르노맵 미리보기 */
.kmap-wrap.is-alternative-previewing .kmap-group-marker {
  opacity: .2;
  filter: grayscale(.25);
}

.alternative-preview-marker {
  --preview-offset: 0;
  position: absolute;
  z-index: calc(20 + var(--preview-offset));
  inset: calc(3px + (var(--preview-offset) * 4px));
  border: 3px dashed var(--preview-color);
  border-radius: calc(13px - (var(--preview-offset) * 1px));
  background: color-mix(in srgb, var(--preview-color) 7%, transparent);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .86);
  pointer-events: none;
  animation: alternativePreviewIn .22s ease-out both;
}

.alternative-preview-marker > span {
  position: absolute;
  top: -11px;
  left: -9px;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--preview-color);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 2px 7px rgba(31, 41, 55, .24);
}

@keyframes alternativePreviewIn {
  from {
    opacity: 0;
    transform: scale(.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 900px) {
  .alternative-solver-actions {
    justify-content: flex-start;
  }

  .auto-solution-navigation {
    order: 2;
  }
}

@media (max-width: 720px) {
  .alternative-solver-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .alternative-solver-actions > .button,
  .auto-solution-navigation {
    width: 100%;
  }

  .auto-solution-navigation {
    grid-column: 1 / -1;
    justify-content: space-between;
  }

  .auto-solution-position {
    flex: 1;
  }
}


/* v22: 다른 풀이 탐색 결과 표현 개선 */
.auto-solution-navigation.is-single .auto-nav-button,
.auto-solution-navigation.is-empty .auto-nav-button {
  display: none;
}

.auto-solution-navigation.is-single,
.auto-solution-navigation.is-empty {
  padding-inline: 12px;
}

.auto-solution-navigation.is-single .auto-solution-position {
  min-width: 92px;
  color: #2558d9 !important;
}

.auto-solution-navigation.is-empty .auto-solution-position {
  min-width: 104px;
  color: #718096 !important;
}

.unique-minimum-solution-card {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 17px 18px;
  border: 1px solid #9ed8b4;
  border-radius: 14px;
  background: linear-gradient(135deg, #f2fbf5, #eaf8ef);
  color: #176b3a;
}

.unique-minimum-solution-card > div {
  display: grid;
  gap: 5px;
}

.unique-minimum-solution-card strong {
  font-size: 15px;
}

.unique-minimum-solution-card span {
  font-size: 13px;
  line-height: 1.5;
}

.unique-minimum-solution-card small {
  color: #4f7a5f;
  font-size: 12px;
}

.unique-solution-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background: #ccefd8;
  color: #176b3a;
  font-weight: 900;
}

/* =========================================================
   v4 모바일 카르노맵 입력 도구 압축 배치
   - 제목 오른쪽에 돈케어 옵션 2개
   - 0 / 1 / X / 지우기 한 줄
   - 입력 수 / 정답 검사 / 정답 보기 / 초기화 한 줄
   ========================================================= */
@media (max-width: 720px) {
  .kmap-entry-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "heading options"
      "palette palette"
      "actions actions"
      "message message";
    align-items: start;
    gap: 12px 10px;
    padding: 14px;
  }

  .kmap-entry-tools-heading {
    grid-area: heading;
    align-self: center;
    margin: 0;
  }

  .kmap-entry-tools .kmap-practice-options {
    grid-area: options;
    display: grid;
    gap: 5px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .kmap-entry-tools .checkbox-label.compact {
    align-items: center;
    gap: 5px;
    font-size: 11px;
    line-height: 1.25;
    white-space: nowrap;
  }

  .kmap-entry-tools .checkbox-label.compact input {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
  }

  .kmap-entry-tools .kmap-value-palette {
    grid-area: palette;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    margin: 0;
  }

  .kmap-entry-tools .kmap-value-button,
  .kmap-entry-tools .kmap-erase-button {
    grid-column: auto;
    width: 100%;
    min-width: 0;
    height: 42px;
    padding: 0 4px;
    font-size: 15px;
  }

  .kmap-entry-tools .kmap-erase-button {
    font-size: 13px;
  }

  .kmap-entry-tools .kmap-practice-actions {
    grid-area: actions;
    display: grid;
    grid-template-columns:
      minmax(76px, .9fr)
      repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 7px;
    margin: 0;
  }

  .kmap-entry-tools .kmap-practice-actions .button,
  .kmap-entry-tools .kmap-fill-count {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 0 5px;
    border-radius: 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  .kmap-entry-tools .kmap-fill-count {
    display: grid;
    place-items: center;
    justify-self: stretch;
  }

  .kmap-entry-tools .kmap-answer-message {
    grid-area: message;
    margin: 0;
  }
}

@media (max-width: 390px) {
  .kmap-entry-tools {
    gap: 10px 7px;
    padding: 12px;
  }

  .kmap-entry-tools-heading strong {
    font-size: 14px;
  }

  .kmap-entry-tools-heading span {
    font-size: 10px;
  }

  .kmap-entry-tools .checkbox-label.compact {
    font-size: 10px;
  }

  .kmap-entry-tools .kmap-practice-actions {
    grid-template-columns:
      minmax(68px, .85fr)
      repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .kmap-entry-tools .kmap-practice-actions .button,
  .kmap-entry-tools .kmap-fill-count {
    min-height: 38px;
    padding-inline: 3px;
    font-size: 11px;
  }
}

.site-footer-simple {
  justify-content: center;
  text-align: center;
}

.hero-brand{
    display:flex;
    align-items:center;
    gap:8px;
}

.hero-home-btn{
    display:flex;
    align-items:center;
    justify-content:center;

    width:18px;
    height:18px;

    color:rgba(255,255,255,.75);
    text-decoration:none;

    flex-shrink:0;
}

.hero-home-btn:hover{
    color:#fff;
}

.hero-home-btn:active{
    transform:scale(.95);
}
/* =========================================================
   5변수 카르노맵: 4×4 맵 2개를 가운데 카드 안에 나란히 표시
   ========================================================= */
@media (min-width: 761px) {
  .kmap-multi-grid.is-five-variable {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    justify-content: stretch;
    width: 100%;
    gap: 14px;
  }

  .kmap-multi-grid.is-five-variable .kmap-map-panel {
    min-width: 0;
    width: 100%;
  }

  .kmap-multi-grid.is-five-variable .kmap-table {
    width: 100%;
    min-width: 0;
    margin: 0;
    border-spacing: 4px;
  }

  .kmap-multi-grid.is-five-variable .kmap-table th {
    height: 42px;
    font-size: 16px;
  }

  .kmap-multi-grid.is-five-variable .kmap-table tbody th {
    width: 42px;
    font-size: 16px;
  }

  .kmap-multi-grid.is-five-variable .kmap-corner {
    min-width: 50px;
  }

  .kmap-multi-grid.is-five-variable .kmap-corner span:first-child,
  .kmap-multi-grid.is-five-variable .kmap-corner span:last-child {
    font-size: 13px;
  }

  .kmap-multi-grid.is-five-variable .kmap-cell {
    height: 76px;
    border-radius: 12px;
  }

  .kmap-multi-grid.is-five-variable .kmap-value {
    font-size: 27px;
  }

  .kmap-multi-grid.is-five-variable .kmap-minterm {
    left: 7px;
    bottom: 6px;
    font-size: 13px;
  }
}

/* =========================================================
   카르노맵 수정 모드 버튼
   기존 세로 액션 스택을 유지하여 버튼 추가로 인한
   PC/태블릿/모바일 레이아웃 흔들림을 최소화합니다.
   ========================================================= */
.kmap-edit-mode-button {
  width: 100%;
}

.kmap-edit-mode-button:disabled {
  opacity: .52;
  cursor: default;
}

/* 좁은 화면에서도 액션 버튼은 기존처럼 한 열로 유지 */
@media (max-width: 720px) {
  .kmap-entry-tools
    .kmap-practice-actions
    .button {
    width: 100%;
    min-width: 0;
  }
}

/* =========================================================
   모바일 카르노맵 채우기: 입력 개수 위치 조정
   - 모바일에서만 3/16칸 표시를 상단 정보 영역으로 이동
   - 정답 검사 / 수정 모드 / 정답 보기 / 초기화를 한 줄 유지
   ========================================================= */
@media (max-width: 720px) {
  .kmap-entry-tools {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
      "heading heading options options"
      "count   count   options options"
      "palette palette palette palette"
      "check   edit    reveal  reset"
      "message message message message";
  }

  /*
   * actions 래퍼 자체는 레이아웃에서 제거하고,
   * 내부 항목을 .kmap-entry-tools 그리드에 직접 참여시킵니다.
   */
  .kmap-entry-tools .kmap-practice-actions {
    display: contents;
  }

  .kmap-entry-tools .kmap-fill-count {
    grid-area: count;
    width: auto;
    min-width: 76px;
    max-width: 112px;
    min-height: 34px;
    align-self: start;
    justify-self: start;
    margin: 0;
    padding: 0 10px;
  }

  .kmap-entry-tools #checkKmapAnswerBtn {
    grid-area: check;
  }

  .kmap-entry-tools #editKmapAnswerBtn {
    grid-area: edit;
  }

  .kmap-entry-tools #revealKmapAnswerBtn {
    grid-area: reveal;
  }

  .kmap-entry-tools #resetKmapAnswerBtn {
    grid-area: reset;
  }

  .kmap-entry-tools
    #checkKmapAnswerBtn,
  .kmap-entry-tools
    #editKmapAnswerBtn,
  .kmap-entry-tools
    #revealKmapAnswerBtn,
  .kmap-entry-tools
    #resetKmapAnswerBtn {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 0 4px;
    font-size: 12px;
    white-space: nowrap;
  }
}

@media (max-width: 390px) {
  .kmap-entry-tools .kmap-fill-count {
    min-width: 68px;
    min-height: 32px;
    padding-inline: 7px;
    font-size: 11px;
  }

  .kmap-entry-tools
    #checkKmapAnswerBtn,
  .kmap-entry-tools
    #editKmapAnswerBtn,
  .kmap-entry-tools
    #revealKmapAnswerBtn,
  .kmap-entry-tools
    #resetKmapAnswerBtn {
    min-height: 38px;
    padding-inline: 2px;
    font-size: 11px;
  }
}

/* =========================================================
   프로젝트 설정 - D/JK 선택 셀렉트 상시 노출
   ========================================================= */
.project-settings-header {
  display: grid;
  grid-template-columns:
    minmax(250px, 1fr)
    minmax(180px, 260px)
    auto;
  align-items: center;
  column-gap: 12px;
}

.project-preset-quick {
  display: flex;
  align-items: center;
  min-width: 0;
  margin: 0;
}

.project-preset-quick select {
  width: 100%;
  height: 42px;
  padding: 0 36px 0 12px;
  border: 1px solid #cbd8e8;
  border-radius: 11px;
  background: #fff;
  color: #203a62;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  outline: none;
  cursor: pointer;
}

.project-preset-quick select:hover {
  border-color: #aebfd7;
}

.project-preset-quick select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 88, 217, .10);
}

/* 펼친 영역에는 입력 변수 수 / 비트 방향만 남습니다. */
.project-settings-body .project-settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .project-settings-header {
    grid-template-columns:
      minmax(220px, 1fr)
      minmax(170px, 230px);
  }

  .project-settings-header-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 720px) {
  .project-settings-header {
    display: flex;
    align-items: stretch;
    flex-direction: column;
  }

  .project-preset-quick {
    width: 100%;
  }

  .project-settings-body .project-settings-grid {
    grid-template-columns: 1fr;
  }
}


/* =========================================================
   JK 진리표 다중 열 세로 가이드
   Qn / Qn⁺ / Jn / Kn 각 열을 독립적으로 토글 강조
   ========================================================= */
.truth-table .jk-guide-header {
  cursor: pointer;
  user-select: none;
  transition:
    background-color .15s ease,
    box-shadow .15s ease,
    color .15s ease;
}

.truth-table .jk-guide-header:hover {
  background: #fff3c4;
  color: #7a5600;
  box-shadow: inset 0 -2px 0 rgba(212, 151, 0, .28);
}

.truth-table .jk-guide-header.is-jk-guide-active {
  background: #ffe7a0 !important;
  color: #6d4b00;
  box-shadow:
    inset 2px 0 0 rgba(211, 148, 0, .28),
    inset -2px 0 0 rgba(211, 148, 0, .28);
}

.truth-table td.is-jk-guide-active {
  background: #fff7d6 !important;
  box-shadow:
    inset 2px 0 0 rgba(211, 148, 0, .18),
    inset -2px 0 0 rgba(211, 148, 0, .18);
}

.truth-table td.truth-practice-cell.is-jk-guide-active:hover {
  background: #ffefb4 !important;
  box-shadow:
    inset 0 0 0 2px #d6a52a,
    inset 2px 0 0 rgba(211, 148, 0, .18),
    inset -2px 0 0 rgba(211, 148, 0, .18);
}

