/* v2 공통 UX — 시나리오 A/B 비교 · 결과 PNG·딥링크 · 최근 기록 · 모바일 결과 바 (seo_common.py) */

/* ---------------------------------------------------------------- ④ 버튼·입력 시인성
   기본 테마의 여백·색은 그대로 두고, 테두리·그림자·호버·포커스만 또렷하게 올린다. */
.btn {
  border: 1px solid var(--primary-dark, #0b5f59);
  box-shadow: 0 2px 0 rgba(11, 35, 32, 0.10), 0 6px 16px rgba(15, 118, 110, 0.14);
  transition: transform 0.12s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.btn:hover {
  background: var(--primary-dark, #0b5f59);
  transform: translateY(-1px);
  box-shadow: 0 4px 0 rgba(11, 35, 32, 0.10), 0 10px 22px rgba(15, 118, 110, 0.22);
}
.btn:active { transform: translateY(0); box-shadow: 0 1px 0 rgba(11, 35, 32, 0.12); }
a:focus-visible, button:focus-visible, [role="button"]:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--primary, #0f766e);
  outline-offset: 2px;
}
.field input, .field select, .field textarea {
  border-color: #c2d2ce;
  border-color: color-mix(in srgb, var(--primary, #0f766e) 22%, #ffffff);
  box-shadow: inset 0 1px 2px rgba(16, 33, 43, 0.05);
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}
.field input[type="number"]:hover, .field input[type="text"]:hover, .field select:hover { border-color: #5ea9a1; border-color: color-mix(in srgb, var(--primary, #0f766e) 55%, #ffffff); }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary, #0f766e);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
  outline: none;
}
.check-row input[type="checkbox"], .check-row input[type="radio"] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 1px solid #9db2ad;
  border-radius: 4px;
}
.share-btn { border-color: #c2d2ce; box-shadow: 0 1px 2px rgba(16, 33, 43, 0.06); }.share-btn:hover { box-shadow: 0 3px 10px rgba(15, 118, 110, 0.18); }

/* ---------------------------------------------------------------- 가로 오버플로 방지
   좁은 화면에서 긴 select 옵션·표가 그리드 트랙을 밀어내 페이지가 가로로 늘어나던 문제를 막는다.
   (grid 트랙 minmax(0,1fr) + 패널·입력 min-width:0 — 레이아웃 자체는 그대로) */
.calc-workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 880px) { .calc-workspace { grid-template-columns: minmax(0, 1fr); } }
.calc-workspace > *, .panel, .panel > * { min-width: 0; }
.field input, .field select, .field textarea { width: 100%; max-width: 100%; min-width: 0; }
.panel .table-scroll, .article-box .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.panel table, .article-box table { max-width: 100%; }
/* 영문 사이트의 넓은 본문 표(4~6열)가 페이지 전체를 가로로 늘리던 문제 —
   표는 그대로 두고 감싸는 상자 안에서 가로 스크롤한다. */
.article-box, .panel, .card { max-width: 100%; }
.article-box { overflow-x: auto; }
.panel, .card { overflow-x: auto; }
.workspace, .calc-grid { min-width: 0; }
.workspace > *, .calc-grid > * { min-width: 0; }

/* ---------------------------------------------------------------- v2 도구 바 */
.v2-bar {
  margin: 16px 0 0;
  padding: 13px 16px 14px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #dde5ea);
  border-radius: var(--radius, 14px);
  box-shadow: var(--shadow, 0 4px 18px rgba(16, 33, 43, 0.06));
}
.v2-bar-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.v2-bar-title {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--ink-muted, #43555f);
}
.v2-slot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 11px;
  border: 1px solid #a7e0d6;
  border-color: color-mix(in srgb, var(--primary, #0f766e) 32%, #ffffff);
  border-radius: 999px;
  background: var(--primary-soft, #e7f4f2);
  color: var(--primary-dark, #0b5f59);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v2-slot[hidden] { display: none; }
.v2-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.v2-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid #c2d2ce;
  border-color: color-mix(in srgb, var(--primary, #0f766e) 26%, #ffffff);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink, #10212b);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.12s ease;
}
.v2-btn:hover:not(:disabled) {
  background: var(--primary-soft, #f2f8f6);
  border-color: var(--primary, #0f766e);
  color: var(--primary-dark, #0b5f59);
  box-shadow: 0 3px 10px rgba(15, 118, 110, 0.16);
}
.v2-btn:active:not(:disabled) { transform: translateY(1px); }
.v2-btn:disabled { opacity: 0.5; cursor: not-allowed; background: #f4f7f7; color: #6b7d87; }
.v2-btn-primary {
  background: var(--primary, #0f766e);
  border-color: var(--primary-dark, #0b5f59);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.24);
}
.v2-btn-primary:hover:not(:disabled) { background: var(--primary-dark, #0b5f59); border-color: var(--primary-dark, #0b5f59); color: #ffffff; }
.v2-btn.is-done { background: #e8f5ef; border-color: #1f7a5a; color: #15694d; }
.v2-btn-primary.is-done { background: #1f7a5a; border-color: #1f7a5a; color: #ffffff; }
.v2-ico, .v2-btn > svg, .v2-btn .share-ico {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.v2-btn-text { white-space: nowrap; }
.v2-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--primary-soft, #e7f4f2);
  color: var(--primary-dark, #0b5f59);
  font-size: 11px;
  font-weight: 800;
}
.v2-btn-primary .v2-count { background: rgba(255, 255, 255, 0.24); color: #ffffff; }
.v2-hint { margin: 10px 0 0; font-size: 0.78rem; line-height: 1.55; color: var(--ink-soft, #6b7d87); }
.v2-hint[hidden] { display: none; }

/* ---------------------------------------------------------------- 공통 토스트 */
.v2-toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 10050;
  max-width: 88vw;
  transform: translate(-50%, 14px);
  padding: 11px 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: #16221f;
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 12px 32px rgba(11, 35, 32, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.v2-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- A/B 비교 모달 */
.v2-modal {
  position: fixed;
  inset: 0;
  z-index: 10010;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(9, 27, 25, 0.58);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}
.v2-modal.is-on { opacity: 1; visibility: visible; }
.v2-modal-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  overflow: hidden;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 26px 64px rgba(9, 27, 25, 0.36);
}
.v2-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  background: #f6fbfa;
  border-bottom: 1px solid #e2ebe8;
}
.v2-modal-head h2 { margin: 0; font-size: 1.04rem; letter-spacing: -0.01em; }
.v2-x {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #43555f;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.v2-x:hover { background: var(--primary-soft, #e7f4f2); border-color: color-mix(in srgb, var(--primary, #0f766e) 30%, #ffffff); color: var(--primary-dark, #0b5f59); }
.v2-modal-body { padding: 16px 18px; overflow: auto; }
.v2-modal-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding: 13px 18px;
  border-top: 1px solid #e2ebe8;
  background: #fbfdfc;
}
.v2-sum {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #cfe6e1;
  border-color: color-mix(in srgb, var(--primary, #0f766e) 22%, #ffffff);
  border-left: 4px solid var(--primary, #0f766e);
  border-radius: 10px;
  background: #f4fbf9;
  background: color-mix(in srgb, var(--primary, #0f766e) 5%, #ffffff);
  font-size: 0.94rem;
  font-weight: 700;
  color: #0b3a35;
  color: var(--ink, #0b3a35);
}
.v2-sum.is-up { border-left-color: #ea580c; background: #fff8f2; border-color: #f6d3b8; color: #8a3a06; }
.v2-sum.is-down { border-left-color: #1f7a5a; background: #f2fbf6; color: #15694d; }
.v2-cmp { margin: 0 0 6px; border: 1px solid #e2ebe8; border-radius: 12px; overflow: hidden; }
.v2-cmp-head, .v2-cmp-row {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 9px 12px;
}
.v2-cmp-head {
  background: #f2f7f6;
  background: color-mix(in srgb, var(--primary, #0f766e) 5%, #ffffff);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #43555f;
}
.v2-cmp-row { border-top: 1px solid #eef3f2; font-size: 0.86rem; }
.v2-cmp-row.is-primary { background: #f6fbfa; background: color-mix(in srgb, var(--primary, #0f766e) 4%, #ffffff); }
.v2-cmp-label { font-weight: 700; color: #10212b; overflow-wrap: anywhere; }
.v2-cmp-a, .v2-cmp-b { color: #33474f; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.v2-cmp-b { font-weight: 700; color: #0b2b3c; }
.v2-cmp-d { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.v2-cmp-d.is-up { color: #c2410c; }
.v2-cmp-d.is-down { color: #15795a; }
.v2-cmp-d.is-flat { color: #6b7d87; font-weight: 600; }
.v2-inputs { margin: 14px 0 0; padding: 12px 14px; border: 1px dashed #d7e3e0; border-radius: 10px; background: #fbfdfc; }
.v2-inputs h3 { margin: 0 0 8px; font-size: 0.78rem; font-weight: 800; color: #43555f; }
.v2-inputs ul { margin: 0; padding: 0; list-style: none; }
.v2-inputs li { display: flex; flex-wrap: wrap; gap: 4px 8px; padding: 3px 0; font-size: 0.82rem; color: #33474f; }
.v2-inputs .v2-in-label { font-weight: 700; }
.v2-inputs .v2-in-arrow { color: #6b7d87; }
.v2-inputs .v2-in-new { font-weight: 800; color: var(--primary-dark, #0b5f59); }
.v2-empty-note { margin: 0 0 12px; font-size: 0.86rem; color: #43555f; }

/* ---------------------------------------------------------------- 최근 계산 기록 */
.v2-hist {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10020;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 24px));
  max-height: min(70vh, 520px);
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #dde5ea;
  border-radius: 16px;
  box-shadow: 0 20px 52px rgba(11, 35, 32, 0.26);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}
.v2-hist.is-on { opacity: 1; visibility: visible; transform: none; }
.v2-hist-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 15px; border-bottom: 1px solid #e8efed; background: #f7fbfa; }
.v2-hist-head h2 { margin: 0; font-size: 0.95rem; }
.v2-hist-body { padding: 10px 12px; overflow: auto; }
.v2-hist-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f0f4f3; }
.v2-hist-item:last-child { border-bottom: 0; }
.v2-hist-main { flex: 1; min-width: 0; }
.v2-hist-value { display: block; font-size: 0.98rem; font-weight: 800; color: #0b2b3c; }
.v2-hist-meta { display: block; font-size: 0.74rem; color: #6b7d87; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v2-hist-card { border: 0; background: transparent; color: var(--primary, #0f766e); font-family: inherit; font-size: 0.78rem; font-weight: 800; cursor: pointer; padding: 4px 6px; border-radius: 7px; }
.v2-hist-card:hover { background: var(--primary-soft, #e7f4f2); text-decoration: underline; }
.v2-hist-del { border: 0; background: transparent; color: #8a5a4a; font-family: inherit; font-size: 0.76rem; font-weight: 700; cursor: pointer; padding: 4px 6px; border-radius: 7px; }
.v2-hist-del:hover { background: #fbeee9; color: #b91c1c; }
.v2-hist-empty { margin: 8px 4px; font-size: 0.82rem; color: #6b7d87; line-height: 1.6; }

/* ---------------------------------------------------------------- 모바일 하단 고정 결과 바 */
.v2-mbbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9000;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid #cfe0dc;
  box-shadow: 0 -10px 26px rgba(11, 35, 32, 0.14);
}
.v2-mbbar.is-on { display: flex; }
body.v2-mb-open { padding-bottom: 78px; }
.v2-mb-main {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.v2-mb-label { max-width: 100%; font-size: 11px; font-weight: 700; color: #6b7d87; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v2-mb-value { max-width: 100%; font-size: 17px; font-weight: 800; color: #0b2b3c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v2-mb-x {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid #d7e3e0;
  border-radius: 999px;
  background: #ffffff;
  color: #43555f;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.v2-mb-x:hover { background: #eef4f2; border-color: #a7c8c2; }

/* ---------------------------------------------------------------- 반응형 */
@media (max-width: 1120px) {
  /* 헤더: 계산기 메뉴가 한 줄에 다 들어가지 않는 폭에서는 옆으로 넘기지(가로 스크롤·잘림)
     않고 브랜드 아래에 칩(pill)으로 여러 줄에 접어 모든 메뉴를 화면 안에 보이게 한다.
     여러 줄 sticky는 본문을 덮으므로 이 구간에서는 헤더를 static으로 둔다
     (넓은 화면 1121px 이상은 기존 한 줄 sticky 헤더 그대로). */
  .site-header { position: static; }
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    min-height: 0;
    padding: 10px 16px;
  }
  .brand { flex: 0 0 auto; align-self: flex-start; }
  .brand small { display: none; }
  .nav-links {
    flex: 1 1 auto;
    flex-wrap: wrap;
    justify-content: flex-start;
    min-width: 0;
    gap: 6px;
    overflow-x: visible;
    scrollbar-width: auto;
    padding: 0;
  }
  .nav-links a {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    white-space: nowrap;
    font-size: 0.76rem;
    line-height: 1.4;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--surface-alt, #f1f5f9);
    border: 1px solid var(--border, #e2e8f0);
    color: var(--ink-muted, #475569);
  }
  .nav-links a:hover { text-decoration: none; color: var(--primary, #2563eb); }
  .nav-links a.active,
  .nav-links a.active:hover {
    background: var(--primary, #2563eb);
    border-color: var(--primary, #2563eb);
    color: #ffffff;
    box-shadow: none;
  }
}
@media (max-width: 430px) {
  /* 좁은 폰: 링크가 16~17개인 사이트도 칩 줄 수를 3~4줄로 줄인다 */
  .nav-links { gap: 4px; }
  .nav-links a { font-size: 0.7rem; padding: 3px 8px; }
}
@media (max-width: 760px) {
  .v2-bar { padding: 12px 13px 13px; }
  .v2-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
  .v2-actions .v2-btn { width: 100%; padding: 10px 8px; font-size: 12.8px; gap: 5px; }
  .v2-actions .v2-btn:nth-child(5) { grid-column: 1 / -1; }
  .v2-hint { font-size: 0.74rem; }
  .v2-hist { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 64vh; }
  /* 토스트는 하단 도구 바·결과 바를 가리지 않도록 헤더 아래로 */
  .v2-toast { top: 70px; bottom: auto; transform: translate(-50%, -10px); }
  .v2-toast.is-on { transform: translate(-50%, 0); }
  .v2-modal { padding: 10px; align-items: flex-end; }
  .v2-modal-card { max-height: 88vh; border-radius: 16px 16px 0 0; }
  .v2-cmp-head, .v2-cmp-row { padding: 8px 10px; gap: 4px; }
}
@media (max-width: 520px) {
  .v2-cmp-head { display: none; }
  .v2-cmp-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); row-gap: 2px; font-size: 0.8rem; }
  .v2-cmp-label { grid-column: 1 / -1; font-size: 0.82rem; }
  .v2-cmp-a::before, .v2-cmp-b::before, .v2-cmp-d::before {
    display: block;
    font-size: 0.66rem;
    font-weight: 700;
    color: #8a9a96;
    letter-spacing: 0.01em;
  }
  .v2-cmp-a::before { content: attr(data-l); }
  .v2-cmp-b::before { content: attr(data-l); }
  .v2-cmp-d::before { content: attr(data-l); }
}
@media (prefers-reduced-motion: reduce) {
  .v2-btn, .v2-modal, .v2-hist, .v2-toast, .btn { transition: none; }
}

/* ---------------------------------------------------------------- 인쇄 */
@media print {
  .v2-bar, .v2-modal, .v2-hist, .v2-mbbar, .v2-toast { display: none !important; }
  body.v2-mb-open { padding-bottom: 0 !important; }
}
