:root {
  --ink: #172019;
  --muted: #657168;
  --paper: #f5f7f2;
  --card: #ffffff;
  --line: #dfe5dd;
  --green: #176345;
  --green-soft: #e2efe6;
  --red: #bc3b45;
  --red-soft: #f9e8e8;
  --shadow: 0 18px 45px rgba(28, 49, 35, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 85% 5%, rgba(172, 211, 177, 0.45), transparent 26rem),
    var(--paper);
  color: var(--ink);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

button, input, select { font: inherit; }
button { color: inherit; }

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 72px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 0.85fr;
  align-items: end;
  gap: 56px;
  padding: 0 6px 52px;
}

.eyebrow, .section-kicker {
  margin: 0 0 12px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(2.55rem, 5.6vw, 5.5rem);
  line-height: 0.98;
  letter-spacing: -0.065em;
}
h1 em { color: var(--green); font-style: normal; }
h2 { margin-bottom: 0; font-size: clamp(1.35rem, 2.4vw, 2rem); letter-spacing: -0.04em; }

.hero-copy {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.total-panel, .formula-panel {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255,255,255,0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.total-panel { padding: 28px; }
.total-heading, .section-heading, .card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.text-button, .remove-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.text-button { padding: 8px 0; text-decoration: underline; text-underline-offset: 4px; }

.totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 26px;
}

.totals article {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
}

.totals span, .totals small { display: block; color: var(--muted); }
.totals span { font-size: 0.82rem; font-weight: 700; }
.totals strong { display: block; margin: 8px 0 5px; font-size: clamp(1.3rem, 2.7vw, 2rem); letter-spacing: -0.04em; }
.totals small { font-size: 0.72rem; }
.totals .accent-result { background: var(--green); border-color: var(--green); color: white; }
.totals .accent-result span, .totals .accent-result small { color: rgba(255,255,255,0.72); }
.totals .accent-result.loss { background: var(--red); border-color: var(--red); }

.trades-section { padding: 64px 0; }
.section-heading { margin-bottom: 24px; }
.primary-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--ink);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 9px 20px rgba(23,32,25,0.17);
}
.primary-button span { margin-right: 5px; font-size: 1.15em; }

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

.trade-card {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 12px 30px rgba(28, 49, 35, 0.055);
}

.name-field { min-width: 0; flex: 1; }
.trade-name {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.22rem;
  font-weight: 800;
}
.remove-button { padding: 8px 0 8px 12px; font-size: 0.78rem; }
.remove-button:hover { color: var(--red); }

.core-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0 14px;
}
.core-inputs label > span:first-child, .cost-row > label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}
.money-input {
  display: flex;
  align-items: center;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbf9;
}
.money-input:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,99,69,0.1); }
.money-input input {
  min-width: 0;
  width: 100%;
  padding: 12px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 750;
}
.money-input b { color: var(--muted); font-size: 0.73rem; }

.costs { margin-bottom: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.costs summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 2px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  list-style: none;
}
.costs summary::-webkit-details-marker { display: none; }
.costs summary::before { content: "＋"; margin-right: 5px; color: var(--green); }
.costs[open] summary::before { content: "−"; }
.costs summary > span:first-child { margin-right: auto; }
.cost-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.cost-grid { display: grid; gap: 11px; padding: 2px 0 16px; }
.cost-row { display: grid; grid-template-columns: 1fr 1.5fr; align-items: center; gap: 12px; }
.cost-row > label { margin: 0; }
.cost-control { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cost-control:focus-within { border-color: var(--green); }
.cost-control input, .cost-control select {
  min-width: 0;
  border: 0;
  outline: 0;
  background: #fafbf9;
}
.cost-control input { width: 100%; padding: 9px 10px; }
.cost-control select { padding: 0 9px; border-left: 1px solid var(--line); color: var(--muted); }

.trade-result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 6px;
}
.trade-result > div:not(.rate-pill) { padding: 12px; border-radius: 13px; background: #f6f8f5; }
.trade-result span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 0.7rem; }
.trade-result strong { font-size: 1rem; letter-spacing: -0.025em; }
.trade-result .profit-row { grid-column: 1 / 2; background: var(--green-soft); }
.trade-result .profit-row.loss { background: var(--red-soft); }
.rate-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background: var(--green);
  color: white;
  font-size: 1.2rem;
  font-weight: 850;
}
.rate-pill.loss { background: var(--red); }

.formula-panel {
  display: grid;
  grid-template-columns: 0.72fr 1fr;
  gap: 26px 46px;
  padding: 30px;
}
.formula-list p { margin: 0 0 11px; color: var(--muted); font-size: 0.9rem; }
.formula-list span { color: var(--green); font-weight: 800; }
.notice { grid-column: 1 / -1; margin: 0; padding-top: 18px; border-top: 1px solid var(--line); color: #7b847d; font-size: 0.72rem; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 620px); padding: 38px 0 32px; }
  .hero { grid-template-columns: 1fr; gap: 24px; padding: 0 3px 34px; }
  h1 { font-size: clamp(2.65rem, 12vw, 4rem); }
  .hero-copy { max-width: 34rem; }
  .total-panel { padding: 20px; border-radius: 22px; }
  .total-heading { align-items: flex-start; }
  .totals { grid-template-columns: 1fr 1fr; }
  .totals .accent-result { grid-column: 1 / -1; }
  .trades-section { padding: 46px 0; }
  .trades-grid { grid-template-columns: 1fr; }
  .formula-panel { grid-template-columns: 1fr; gap: 24px; padding: 22px; }
  .notice { grid-column: auto; }
}

@media (max-width: 430px) {
  .core-inputs { grid-template-columns: 1fr 1fr; }
  .core-inputs label:last-child { grid-column: 1 / -1; }
  .trade-card { padding: 18px; }
  .section-heading { align-items: flex-end; }
  .primary-button { padding: 11px 14px; }
  .totals strong { font-size: 1.15rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .trade-card { animation: enter 280ms ease-out both; }
  @keyframes enter { from { opacity: 0; transform: translateY(8px); } }
}
