@import url("https://cdn.jsdelivr.net/npm/pretendard@1.3.9/dist/web/static/pretendard.min.css");

:root {
  color-scheme: light;
  --bg: #f7f3ec;
  --surface: #fffdf8;
  --surface-soft: #f3ebdd;
  --ink: #2a2017;
  --muted: #897a66;
  --line: #e6dcc8;
  --accent: #a85626;
  --accent-dark: #87431d;
  --blue: #b8862f;
  --red: #dc2626;
  --amber: #b45309;
  --shadow: 0 8px 24px rgba(120, 72, 30, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  font-family:
    Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  background: #382517;
  color: #fbf6ee;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.topbar__row {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #e2ba74;
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.topbar-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: #e6d9c2;
  font-size: 13px;
}

.topbar-tags span {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 7px 10px;
}

.page-frame {
  width: min(1280px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.verdict-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.verdict-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.verdict-label,
.card-subtitle,
.hint {
  color: var(--muted);
}

.verdict-label {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 700;
}

.verdict-title {
  font-size: clamp(24px, 3.2vw, 36px);
  line-height: 1.1;
  font-weight: 800;
}

.verdict-caption {
  margin: 8px 0 0;
  font-size: 14px;
}

.verdict-delta {
  color: var(--accent-dark);
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.stat-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
  background: #fdfbf5;
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 18px;
}

.bars-compare {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.bars-row {
  display: grid;
  grid-template-columns: 84px minmax(80px, 1fr) minmax(110px, auto);
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.bars-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #ebe0cd;
}

.bars-fill {
  width: 0;
  height: 100%;
  transition: width 180ms ease;
}

.bars-fill.keep {
  background: var(--blue);
}

.bars-fill.switch {
  background: var(--accent);
}

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

.tabset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 14px;
  font-weight: 700;
}

.tab.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.run-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.run-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.run-status.is-pending {
  color: var(--amber);
}

.run-button {
  min-width: 112px;
  border: 1px solid var(--accent);
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  font-weight: 900;
}

.run-button.is-pending {
  background: var(--amber);
  border-color: var(--amber);
}

.verdict-band.is-stale {
  border-color: #f59e0b;
}

.tabset-pane {
  display: none;
}

.tabset-pane.is-active {
  display: block;
}

.input-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 4px 14px rgba(23, 33, 38, 0.04);
}

.card-wide {
  grid-column: 1 / -1;
}

.card-heading {
  min-height: 38px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-subtitle {
  margin: 5px 0 0;
  font-size: 13px;
}

.field-set,
.tier-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

label,
.full-label,
.field-cell {
  display: grid;
  gap: 6px;
  color: #4a3a29;
  font-size: 13px;
  font-weight: 700;
}

.field-labelrow {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tip-wrap {
  position: relative;
  display: inline-flex;
}

.tip-button {
  border: 1px solid #cab896;
  border-radius: 999px;
  background: #fdfaf3;
  color: var(--accent-dark);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.tip-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  left: auto;
  right: 0;
  width: min(760px, calc(100vw - 48px));
  max-height: 420px;
  overflow: auto;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 14px;
  color: #4a3a29;
  line-height: 1.5;
}

.rate-tip-panel {
  width: min(560px, calc(100vw - 48px));
}

.help-panel--align-left {
  right: auto;
  left: 0;
}

.tip-wrap:hover .tip-panel,
.tip-wrap:focus-within .tip-panel {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.tip-wrap .tip-panel.is-closed {
  visibility: hidden;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

.tip-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.tip-title {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.tip-close {
  display: none;
  border: 1px solid #cab896;
  border-radius: 999px;
  background: #fdfaf3;
  color: var(--accent-dark);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.tip-summary {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.tip-summary.tip-warn {
  color: var(--amber);
  font-weight: 600;
}

.tip-note-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tip-note {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fdfbf5;
  padding: 10px;
}

.tip-note-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.tip-note p {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
}

.tip-note small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-tag {
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 900;
}

.status-tag.confirmed {
  background: #eef1dc;
  color: #5d6420;
}

.status-tag.unconfirmed {
  background: #fff3d7;
  color: #92400e;
}

.status-tag.pending {
  background: #efe9dd;
  color: #6a5a44;
}

input,
select {
  min-width: 0;
  width: 100%;
  border: 1px solid #d6c6a8;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.2);
  outline-offset: 2px;
}

.hint {
  margin: 12px 0 0;
  font-size: 13px;
}

.inline-note {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-soft);
  color: #463323;
  font-size: 14px;
}

.solid-button,
.ghost-button,
.remove-button {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 9px 12px;
  font-weight: 800;
}

.solid-button {
  background: var(--accent);
  color: #fff;
}

.ghost-button {
  background: #f3ecde;
  color: #2d1f12;
}

.remove-button {
  background: #fff1f2;
  color: var(--red);
  border-color: #fecdd3;
}

.button-set {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.bank-detail {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  color: #4a3a29;
  font-size: 14px;
}

.note-block {
  margin: 8px 0 0;
  color: #4a3a29;
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.note-block strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.rate-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #f4ecdd;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.table-scroll {
  overflow-x: auto;
}

.deposit-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}

.deposit-table th,
.deposit-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
}

.deposit-table th {
  color: var(--muted);
  font-size: 13px;
}

.deposit-table td:last-child,
.deposit-table th:last-child {
  width: 96px;
}

.alert-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.alert-item {
  border: 1px solid #fed7aa;
  border-radius: 12px;
  background: #fff7ed;
  color: var(--amber);
  padding: 10px 12px;
  font-size: 14px;
}

.filter-input {
  max-width: 320px;
}

.bank-grid {
  display: grid;
  gap: 12px;
}

.bank-tile {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #fdfbf5;
}

.bank-tile h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.bank-tile p {
  margin: 8px 0 0;
  color: #4a3a29;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.part-list,
.log-list,
.ref-list,
.rule-list {
  display: grid;
  gap: 10px;
}

.part-item,
.log-item,
.ref-item,
.rule-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fdfbf5;
}

.part-item h3,
.log-item h3,
.rule-item h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.rule-item ul {
  margin: 0;
  padding-left: 20px;
  color: #4a3a29;
  font-size: 14px;
  line-height: 1.65;
}

.rule-item li + li {
  margin-top: 4px;
}

.pair-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  color: #4a3a29;
  font-size: 14px;
}

.pair-grid span:nth-child(odd) {
  color: var(--muted);
}

.ref-item a {
  color: var(--accent-dark);
  font-weight: 800;
}

@media (max-width: 900px) {
  .topbar__row,
  .verdict-main {
    align-items: flex-start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .verdict-delta {
    text-align: left;
  }

  .stat-grid,
  .input-grid,
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar__row,
  .page-frame {
    width: min(100% - 20px, 1280px);
  }

  .page-frame {
    padding-bottom: 88px;
  }

  .verdict-band,
  .panel {
    padding: 14px;
  }

  .stat-grid,
  .input-grid,
  .detail-grid,
  .field-set,
  .tier-grid,
  .tip-note-grid,
  .pair-grid {
    grid-template-columns: 1fr;
  }

  .field-labelrow {
    align-items: flex-start;
  }

  .tip-panel {
    position: fixed;
    top: auto;
    right: 10px;
    bottom: 76px;
    left: 10px;
    width: auto;
    max-height: min(68vh, 520px);
  }

  .help-panel--align-left {
    right: 10px;
    left: 10px;
  }

  .tip-close {
    display: inline-flex;
  }

  .bars-row {
    grid-template-columns: 76px minmax(80px, 1fr);
  }

  .bars-row strong {
    grid-column: 2;
  }

  .card-heading {
    display: grid;
  }

  .tabs {
    display: block;
  }

  .tabset-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .run-actions {
    position: fixed;
    z-index: 20;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 12px;
    margin-left: 0;
    justify-content: space-between;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
    padding: 10px;
  }

  .run-button {
    min-width: 132px;
  }

  .filter-input {
    max-width: none;
  }
}

/* Blog-port footer: source credit + back-to-blog link. */
.app-credit {
  margin: 28px auto 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.app-credit .hint {
  margin: 6px 0;
  font-size: 13px;
  line-height: 1.6;
}
.app-credit a {
  color: inherit;
  text-decoration: underline;
}

/* Transient confirmation toast for one-shot actions (rebuild / reset). */
.action-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  z-index: 50;
  max-width: min(92vw, 420px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #fffdf8;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.action-toast.is-shown {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Tactile press feedback so every button click is felt, not just hovered. */
.ghost-button:active,
.solid-button:active,
.run-button:active,
.remove-button:active {
  transform: translateY(1px) scale(0.99);
}

/* ── Result summary: make the verdict the hero, demote the rest ────────── */

/* Hero block holds the headline + the bar comparison — the actual answer. */
.verdict-hero {
  display: grid;
  gap: 16px;
  border: 1px solid #ecd9bf;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff8ef, #fdf2e3);
  padding: 20px;
}

/* Headline row no longer needs its own divider — the hero block frames it. */
.verdict-hero .verdict-main {
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(168, 86, 38, 0.16);
}

.verdict-title {
  font-size: clamp(26px, 3.6vw, 40px);
}

.verdict-delta {
  font-size: clamp(26px, 3.4vw, 38px);
}

/* The comparison bars are the visual answer — give them more presence. */
.verdict-hero .bars-compare {
  margin-top: 0;
  gap: 12px;
}

.verdict-hero .bars-track {
  height: 16px;
  background: #efe3cf;
}

.verdict-hero .bars-row strong {
  font-size: 15px;
  font-weight: 800;
}

/* Winner emphasis: brighten the winning side, fade the runner-up. */
.verdict-band.winner-keep .bars-row[data-side="switch"],
.verdict-band.winner-switch .bars-row[data-side="keep"] {
  opacity: 0.5;
}

.verdict-band.winner-keep .bars-row[data-side="keep"] strong,
.verdict-band.winner-switch .bars-row[data-side="switch"] strong {
  color: var(--accent-dark);
}

/* Secondary metrics: collapsible, quieter, visually subordinate to the hero. */
.verdict-extra {
  margin-top: 14px;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.share-actions .ghost-button {
  border: 1px solid var(--line);
}

.verdict-extra > summary {
  cursor: pointer;
  width: fit-content;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.verdict-extra > summary::-webkit-details-marker {
  display: none;
}

.verdict-extra > summary::before {
  content: "▸ ";
  color: var(--accent);
}

.verdict-extra[open] > summary::before {
  content: "▾ ";
}

.verdict-extra .stat-grid {
  margin-top: 12px;
}

.verdict-extra .metric {
  min-height: 0;
  padding: 11px;
  background: var(--surface-soft);
  border-color: transparent;
}

.verdict-extra .metric strong {
  font-size: 16px;
}

/* ── Input tab de-clutter ──────────────────────────────────────────────── */

/* Tooltip triggers unified as a single round ⓘ icon instead of varied text. */
.tip-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}

/* Advanced rate fields, collapsed by default to keep first view simple. */
.advanced-rates {
  margin-top: 14px;
}

/* Make the toggle look like a tappable button so it is easy to find and press. */
.advanced-rates > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--accent);
  border-radius: 11px;
  background: #f3ecde;
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.advanced-rates > summary:hover {
  background: #ecdfc8;
  box-shadow: var(--shadow);
}

.advanced-rates > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.advanced-rates > summary::-webkit-details-marker {
  display: none;
}

.advanced-rates > summary::before {
  content: "▸";
}

.advanced-rates[open] > summary {
  margin-bottom: 14px;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.advanced-rates[open] > summary::before {
  content: "▾";
}

.advanced-rates .hint {
  margin-top: 0;
}

.advanced-rates .field-set {
  margin-top: 12px;
}

/* "= NN만원" readout under raw-won amount inputs. */
.unit-hint {
  min-height: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
