:root {
  --accent: #9b5f13;
  --accent-dark: #6c3f08;
  --accent-soft: #f3e2bd;
  --gold-bright: #d6a84d;
}

body {
  background-image:
    linear-gradient(rgba(25, 21, 16, .03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(25, 21, 16, .03) 1px, transparent 1px),
    radial-gradient(circle at 82% 12%, rgba(214, 168, 77, .13), transparent 27%);
}

.eyebrow span {
  color: var(--accent-soft);
  background: var(--accent-dark);
}

.brand-mark {
  font-size: 24px;
}

.brand-mark.small {
  font-size: 20px;
}

.hero-ledger {
  position: relative;
  justify-self: end;
  width: min(100%, 430px);
  padding: 27px;
  overflow: hidden;
  color: #fff6e7;
  background: #211910;
  border: 1.5px solid var(--ink);
  border-radius: 17px;
  box-shadow: 10px 10px 0 var(--accent);
  transform: rotate(-1.2deg);
}

.hero-ledger::before {
  content: "¥";
  position: absolute;
  right: -15px;
  top: -53px;
  color: rgba(214, 168, 77, .14);
  font-family: var(--font-display);
  font-size: 192px;
  line-height: 1;
  pointer-events: none;
}

.hero-ledger::after {
  content: "";
  position: absolute;
  left: 27px;
  right: 27px;
  bottom: 68px;
  border-top: 1px dashed rgba(214, 168, 77, .32);
}

.ledger-top {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: #b7a58e;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .11em;
}

.ledger-label {
  position: relative;
  z-index: 1;
  margin: 27px 0 4px;
  color: #b7a58e;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .14em;
}

.ledger-amount {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(34px, 4.7vw, 48px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.05em;
}

.ledger-words {
  position: relative;
  z-index: 1;
  margin: 0;
  padding-bottom: 45px;
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: clamp(24px, 3.3vw, 32px);
  font-weight: 700;
  line-height: 1.55;
  letter-spacing: .035em;
}

.ledger-stamp {
  position: absolute;
  z-index: 2;
  right: 25px;
  bottom: 18px;
  padding: 6px 10px;
  color: var(--gold-bright);
  border: 1.5px solid rgba(214, 168, 77, .55);
  border-radius: 7px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  transform: rotate(-8deg);
}

.converter-card,
.rmb-preview {
  min-width: 0;
}

.amount-wrap {
  position: relative;
}

.money-prefix {
  position: absolute;
  z-index: 1;
  left: 15px;
  top: 50%;
  color: var(--accent-dark);
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 700;
  line-height: 1;
  transform: translateY(-50%);
  pointer-events: none;
}

#amountInput {
  padding-left: 44px;
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.quick-label {
  margin: 17px 0 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
}

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

.quick-amount {
  min-height: 44px;
  padding: 8px 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--soft-line);
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.quick-amount:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.rule-strip {
  margin-top: 28px;
  padding-top: 23px;
  border-top: 1px dashed var(--soft-line);
}

.rule-strip .subcard-heading {
  margin-bottom: 12px;
}

.rule-strip h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
}

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

.rule-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  min-width: 0;
  padding: 9px 11px;
  background: var(--paper);
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  font-size: 11.5px;
}

.rule-item code {
  flex: 0 0 auto;
  padding: 0;
  color: var(--accent-dark);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}

.rule-item span {
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.rmb-preview {
  box-shadow: 5px 5px 0 var(--accent);
}

.preview-topline {
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .09em;
}

.live-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(31, 111, 90, .1);
}

.preview-spec {
  margin-left: auto;
  color: var(--accent-dark);
}

.preview-label {
  margin: 21px 0 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .13em;
}

.preview-number {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(30px, 4.4vw, 43px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.rmb-result-box {
  margin-top: 20px;
  padding: 18px;
  background: var(--accent-soft);
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  box-shadow: 3px 3px 0 rgba(25, 21, 16, .18);
}

.rmb-result-box .preview-label {
  margin-top: 0;
  color: #79511c;
}

#result {
  margin: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  font-family: var(--font-display);
  font-size: clamp(24px, 3.2vw, 34px);
  font-weight: 700;
  line-height: 1.55;
  letter-spacing: .04em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#result.is-error {
  color: var(--accent-dark);
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0;
}

.parts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.part {
  min-width: 0;
  padding: 10px 11px;
  background: var(--paper);
  border: 1px solid var(--soft-line);
  border-radius: 8px;
}

.part span {
  display: block;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.part strong {
  display: block;
  margin-top: 2px;
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.result-actions > button {
  flex: 1 1 115px;
}

.premium-tools {
  margin-top: 56px;
  scroll-margin-top: 28px;
}

.premium-heading {
  margin-bottom: 22px;
}

.premium-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr);
  gap: 30px;
  align-items: start;
}

.premium-grid > .card {
  min-width: 0;
}

.batch-heading h3 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 25px;
  line-height: 1.22;
  letter-spacing: -.025em;
}

.batch-actions {
  margin-top: 16px;
}

#batchInput {
  min-height: 182px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.75;
}

.batch-summary {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.batch-results {
  margin-top: 16px;
}

.batch-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--soft-line);
  border-radius: 10px;
}

.batch-table {
  min-width: 590px;
  background: #fffdf8;
}

.batch-table th {
  position: sticky;
  top: 0;
  color: var(--muted);
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .08em;
  white-space: nowrap;
}

.batch-table td {
  font-size: 12px;
}

.batch-table .cell-index {
  width: 42px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.batch-table .cell-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.batch-table .cell-upper {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}

.batch-table .cell-error {
  color: #9c2813;
  font-size: 11.5px;
  line-height: 1.55;
}

.batch-table tr.is-invalid td {
  background: #fff1ec;
}

#upperInput {
  font-size: 15px;
}

.sample-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 2px;
}

.sample-chip {
  min-height: 44px;
  padding: 7px 10px;
  color: var(--accent-dark);
  background: var(--paper);
  border: 1px solid var(--soft-line);
  border-radius: 7px;
  font-size: 10.5px;
  line-height: 1.35;
  cursor: pointer;
}

.sample-chip:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.reverse-output {
  margin-top: 18px;
  padding: 17px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  box-shadow: 3px 3px 0 var(--accent);
}

.reverse-output .preview-label {
  margin-top: 0;
}

#reverseAmount {
  min-height: 42px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: clamp(27px, 3.4vw, 36px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}

#reverseAmount.is-error {
  color: var(--accent-dark);
  font-family: var(--font-sans);
  font-size: 18px;
  letter-spacing: 0;
}

.reverse-echo {
  min-height: 22px;
  margin: 8px 0 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 1.65;
}

@media (max-width: 900px) {
  .hero-ledger {
    justify-self: start;
    width: min(100%, 480px);
  }

  .premium-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .hero-ledger {
    width: min(100%, 430px);
    padding: 21px;
    box-shadow: 7px 7px 0 var(--accent);
    transform: none;
  }

  .hero-ledger::after {
    left: 21px;
    right: 21px;
  }

  .ledger-label {
    margin-top: 21px;
  }

  .ledger-words {
    padding-bottom: 38px;
  }

  .ledger-stamp {
    right: 19px;
    bottom: 14px;
  }

  #amountInput {
    font-size: 22px;
  }

  .preview-number {
    font-size: clamp(28px, 8vw, 38px);
  }

  #result {
    font-size: clamp(22px, 7vw, 30px);
  }

  .premium-tools {
    margin-top: 44px;
  }

  .batch-heading h3 {
    font-size: 22px;
  }

  .batch-table {
    min-width: 560px;
  }
}

@media (max-width: 400px) {
  .hero-ledger {
    padding: 18px;
  }

  .hero-ledger::after {
    left: 18px;
    right: 18px;
  }

  .ledger-words {
    font-size: 23px;
  }

  .quick-row {
    gap: 6px;
  }

  .quick-amount {
    flex: 1 1 auto;
  }

  .rule-grid {
    grid-template-columns: 1fr;
  }

  .rule-item {
    padding: 8px 10px;
  }

  .rmb-result-box {
    padding: 14px;
  }

  .parts {
    gap: 6px;
  }

  .part {
    padding: 8px;
  }

  .part strong {
    font-size: 12.5px;
  }

  .reverse-output {
    padding: 14px;
  }
}
