:root {
  --card-bg: var(--surface);
  --card-border: var(--border);
  --card-shadow: var(--shadow);
}



.ladder-panel {
  max-width: 1100px;
  margin: 0 auto;
}

.calc-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.card-header h3 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.card-header p {
  margin: 0;
  color: var(--muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}


/* Collapsible Options Panel */
.options-collapsible {
  position: relative;
  z-index: 10;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
}

.options-collapsible:not(.collapsed) {
  border: none;
  box-shadow: none;
  overflow: visible;
}

.options-collapsible.collapsed {
  background: transparent;
  overflow: visible;
}

.options-toggle {
  width: 100%;
  padding: 12px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  line-height: 1;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  z-index: 20;
}

.options-collapsible.collapsed .options-toggle {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: white;
  box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.4);
  margin-bottom: 0;
}

.options-collapsible.collapsed .options-toggle:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 35px -5px rgba(99, 102, 241, 0.5);
  filter: brightness(1.1);
}

.options-collapsible:not(.collapsed) .options-toggle {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  margin-bottom: 24px;
}

.options-collapsible:not(.collapsed) .options-toggle:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.options-toggle i {
  font-size: 1.1em;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  flex-shrink: 0;
}

.options-collapsible.collapsed .options-toggle i {
  transform: rotate(180deg);
}

.options-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  
  max-height: 0;
  opacity: 0;
  transform: translateY(-12px) scale(0.98);
  transform-origin: top center;
  
  transition: 
    max-height 0.6s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s ease,
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.options-content:not(.collapsed) {
  max-height: 1500px;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.options-content.collapsed {
  max-height: 0;
  opacity: 0;
}

.options-content > * {
  padding: 24px;
}

.options-content > .count-controls,
.options-content > .center-actions {
  display: grid;
  gap: 16px;
}

.controls {
  display: grid;
  gap: 16px;
  position: relative;
}

.controls > * {
  position: relative;
  z-index: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-weight: 600;
  color: var(--muted);
}

.field-hint {
  font-size: 0.85rem;
  color: var(--muted);
}

.count-controls {
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
  padding: 0 24px 24px 24px;
}

.count-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface-2);
  padding: 6px;
  border-radius: 99px;
  border: 1px solid var(--border);
}

.count-value {
  font-size: 1.25rem;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
}

#count-decrease, #count-increase {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  padding: 0;
  font-size: 1.2rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

#count-decrease:hover, #count-increase:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.05);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#count-decrease.is-disabled, #count-increase.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
  box-shadow: none;
}

.ladder-inputs-wrapper {
  position: relative;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
  padding: 24px 24px 0 24px;
}

.ladder-inputs {
  display: grid;
  --ladder-col-width: 150px;
  --line-gap: 96px;
  gap: var(--line-gap);
  position: relative;
  overflow-x: hidden;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

.ladder-inputs.is-scroll {
  max-width: 100%;
  margin: 0;
  overflow-x: auto;
  scroll-behavior: smooth;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.ladder-inputs.is-scroll::-webkit-scrollbar {
  display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.ladder-inputs.is-scroll {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.ladder-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 4px;
  position: relative;
  z-index: 2;
}

.ladder-row--bottom .inputs-row {
  order: 1;
}

.ladder-row--bottom .input-header {
  order: 2;
  margin-top: 6px;
}

.input-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}


.inputs-row {
  display: grid;
  grid-template-columns: repeat(var(--ladder-count, 6), minmax(0, 1fr));
  gap: 0;
  min-width: 0;
  width: 100%;
}

.ladder-inputs.is-scroll .inputs-row {
  grid-template-columns: repeat(var(--ladder-count, 6), minmax(var(--ladder-col-width), 1fr));
  min-width: calc(var(--ladder-count, 6) * var(--ladder-col-width));
}

.ladder-lines {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  grid-template-columns: repeat(var(--ladder-count, 6), minmax(0, 1fr));
  gap: 0;
  height: var(--line-gap);
  align-items: stretch;
  z-index: 0;
  pointer-events: none;
  min-width: 0;
  width: 100%;
}

.ladder-inputs.is-scroll .ladder-lines {
  grid-template-columns: repeat(var(--ladder-count, 6), minmax(var(--ladder-col-width), 1fr));
  min-width: calc(var(--ladder-count, 6) * var(--ladder-col-width));
  gap: 10px;
}

.ladder-line-vert {
  justify-self: center;
  width: 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.65);
  box-shadow: 0 8px 14px rgba(15, 23, 42, 0.18);
  height: 100%;
}

.value-input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  position: relative;
  z-index: 3;
  width: 100%;
  min-width: 0;
}

.center-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 12px 0;
}

.status-row {
  display: flex;
  justify-content: center;
}

.status-text {
  color: var(--muted);
  font-size: 0.95rem;
}

.status-text.is-error {
  color: #ff6b6b;
}

.ladder-stage-wrapper {
  position: relative;
  width: 100%;
}

.ladder-stage {
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 18px;
  display: grid;
  gap: 30px;
  overflow-x: hidden;
  --ladder-col-width: 150px;
  position: relative;
  align-items: center;
  width: 100%;
}

.ladder-stage.is-scroll {
  overflow-x: auto;
  scroll-behavior: smooth;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.ladder-stage.is-scroll::-webkit-scrollbar {
  display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.ladder-stage.is-scroll {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.value-row {
  display: grid;
  grid-template-columns: repeat(var(--ladder-count, 6), minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.ladder-stage.is-scroll .value-row {
  grid-template-columns: repeat(var(--ladder-count, 6), minmax(var(--ladder-col-width), 1fr));
  min-width: calc(var(--ladder-count, 6) * var(--ladder-col-width));
}

.value-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: center;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.2s ease;
}

.value-chip.is-empty {
  color: var(--muted);
  border-style: dashed;
  background: rgba(148, 163, 184, 0.08);
}

.value-chip:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.value-chip.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(106, 167, 255, 0.25);
}

.value-chip.is-visited {
  background: rgb(16, 185, 129, 0.25)!important;
  border-color: rgba(96, 165, 250, 0.8);
  color: var(--text);
  position: relative;
}

.value-chip.is-visited::after {
  position: absolute;
  top: 50%;
    left: 30px;
  transform: translateY(-50%);
  color: #10b981;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.ladder-stage.is-preview .value-chip {
  pointer-events: none;
  cursor: default;
}

.ladder-stage.is-preview .value-chip:hover {
  transform: none;
  border-color: var(--border);
  box-shadow: none;
}

.ladder-board {
  width: 100%;
  height: 560px;
  position: relative;
  min-width: 0;
  overflow: visible;
}

#ladder-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ladder-stage.is-scroll .ladder-board {
  min-width: calc(var(--ladder-count, 6) * var(--ladder-col-width));
}

#ladder-svg {
  width: 100%;
  height: 100%;
}

.ladder-line {
  stroke: rgba(148, 163, 184, 0.7);
  stroke-width: 7;
  stroke-linecap: round;
}

.ladder-rung {
  stroke: rgba(148, 163, 184, 0.95);
  stroke-width: 7;
  stroke-linecap: round;
}

.ladder-path {
  stroke: #60a5fa;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  filter: drop-shadow(0 6px 12px rgba(56, 189, 248, 0.35));
}

.result-card {
  padding: 24px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: none;
  margin-top: 16px;
  box-shadow: var(--shadow);
}

.result-card.is-visible {
  display: block;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.result-label {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.result-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.result-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.result-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px -3px rgba(0, 0, 0, 0.1);
  border-color: var(--primary);
}

.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 2px;
}

.result-index {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-badge {
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  font-size: 0.6rem;
  font-weight: 700;
}

html[data-theme="dark"] .result-badge {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.result-map {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.result-pill {
  width: 100%;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.75rem;
  text-align: center;
  color: var(--text);
  line-height: 1.3;
  word-break: break-all;
}

.result-pill:first-child {
  background: rgba(59, 130, 246, 0.08); /* Blue tint */
  color: #2563eb;
  border-color: rgba(59, 130, 246, 0.2);
}

.result-pill:last-child {
  background: rgba(16, 185, 129, 0.08); /* Green tint */
  color: #059669;
  border-color: rgba(16, 185, 129, 0.2);
}

html[data-theme="dark"] .result-pill:first-child {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.3);
}

html[data-theme="dark"] .result-pill:last-child {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.result-arrow {
  color: var(--muted);
  font-size: 0.9rem;
  opacity: 0.6;
}

.action-hint {
  color: var(--muted);
  text-align: center;
}

/* Scroll Navigation Buttons */
.scroll-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  z-index: 20;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  flex-shrink: 0;
  transform-origin: center;
}

.scroll-nav-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.scroll-nav-btn:hover {
  transform: translateY(-50%) !important;
}

.ladder-stage-wrapper .scroll-nav-btn {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(37, 99, 235, 0.9));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
}

.ladder-stage-wrapper .scroll-nav-btn::before {
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.05));
}

.ladder-stage-wrapper .scroll-nav-btn:hover {
  transform: translateY(-50%);
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.45);
  background: linear-gradient(135deg, rgba(29, 78, 216, 1), rgba(30, 64, 175, 1));
}

.ladder-stage-wrapper .scroll-nav-btn:hover::before {
  opacity: 1;
}

.ladder-stage-wrapper .scroll-nav-btn:active {
  transform: translateY(-50%) scale(0.96);
}

.ladder-inputs-wrapper .scroll-nav-btn {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.9), rgba(5, 150, 105, 0.9));
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
}

.ladder-inputs-wrapper .scroll-nav-btn::before {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0));
}

.ladder-inputs-wrapper .scroll-nav-btn:hover {
  transform: translateY(-50%);
  box-shadow: 0 10px 24px rgba(16, 185, 129, 0.45);
  background: linear-gradient(135deg, rgba(5, 150, 105, 1), rgba(4, 120, 87, 1));
}

.ladder-inputs-wrapper .scroll-nav-btn:hover::before {
  opacity: 1;
}

.ladder-inputs-wrapper .scroll-nav-btn:active {
  transform: translateY(-50%) scale(0.96);
}

.scroll-nav-btn.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.scroll-nav-btn--left {
  left: 12px;
}

.scroll-nav-btn--right {
  right: 12px;
}

html[data-theme="dark"] .ladder-stage {
  background: rgba(15, 23, 42, 0.6);
}

@media (max-width: 768px) {
  /* 모바일 사다리 3개 이상일 때 가로 스크롤 */
  .ladder-stage.is-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .ladder-stage.is-scroll .ladder-board {
    min-width: calc(var(--ladder-count, 6) * 80px);
  }

  /* 모바일 체크마크 크기 조정 */
  .value-chip.is-visited::after {
    font-size: 0.9rem;
        left: 25px;
  }
  .ladder-inputs {
    max-width: 100%;
    margin: 0;
    overflow-x: auto;
    scroll-behavior: smooth;
  }
}
