:root {
  color-scheme: light;
  font-family: "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: #4c4741;
  background: #f9f7f2;
  font-variant-numeric: tabular-nums;
  --red: #b9082a;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid #a57935; outline-offset: 2px; }
.workspace {
  height: 100vh;
  height: 100dvh;
  max-width: 1440px;
  margin: auto;
  padding: 0 32px;
  display: grid;
  grid-template-rows: 40px minmax(0, 1fr) 28px;
}
header { display: flex; align-items: center; }
.logo { width: 75px; height: 30px; }
.brand { display: flex; align-items: center; gap: 14px; font-size: 16px; font-weight: 700; }
.brand img { width: 75px; height: 30px; }
.back { font-size: 12px; color: #71695e; }
main {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) calc(50vh - 28px);
  grid-template-rows: minmax(0, 1fr) calc(50dvh - 28px);
  gap: 10px;
  padding-top: 8px;
}
.summary {
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
  padding: 8px 24px 12px;
  display: grid;
  grid-template-rows: 24px 24px minmax(0, 1fr) auto;
  background: #fffdf9;
  border: none;
  border-radius: 10px;
}
.summary-heading { display: flex; align-items: center; justify-content: space-between; }
.summary-heading h1 { font-size: 16px; margin: 0; font-weight: 600; }
.summary-heading > span { font-size: 12px; color: #71695e; }
.amount-label { font-size: 18px; text-align: center; font-weight: 650; color: #76634e; }
.amount-label span { font-size: 12px; margin-left: 8px; font-weight: 400; }
.grand-amount { display: flex; justify-content: center; align-items: baseline; align-self: center; gap: 12px; min-width: 0; line-height: 1.05; color: var(--red); }
.grand-amount output { min-width: 0; white-space: nowrap; font-size: clamp(56px, 10vw, 148px); font-weight: 800; letter-spacing: -.035em; }
.currency { flex: none; font-size: 26px; font-weight: 600; }
.unit { flex: none; font-size: 20px; }
.counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; border-top: 1px solid #e8dfd1; padding-top: 8px; text-align: center; }
.counts > div { min-width: 0; }
.counts span { display: block; font-size: 16px; color: #76634e; white-space: nowrap; }
.counts output { display: block; white-space: nowrap; font-size: 42px; font-weight: 750; line-height: 1.15; color: #9b1730; }
.entry { grid-column: 1 / -1; grid-row: 2; min-height: 0; display: grid; grid-template-rows: 22px minmax(0, 1fr) 20px; }
.entry-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.entry-heading h2 { margin: 0; font-size: 13px; }
.entry-heading p { font-size: 11px; color: #71695e; margin: 0; }
table { width: 100%; height: 100%; border-spacing: 0; table-layout: fixed; background: #fff; border: 1px solid #e2dcd2; border-radius: 6px; overflow: hidden; }
.group-col { width: 8%; }
.money-col { width: 32%; }
thead { height: 26px; }
th { font-size: 11px; font-weight: 600; background: #eee8de; color: #665d51; }
th span { margin-left: 0; }
tbody th { background: #f8f5ef; color: #4c4741; font-size: 16px; font-weight: 750; line-height: 1.1; white-space: nowrap; }
td { padding: 1px 10px; border-top: 1px solid #eeece6; }
tbody th { border-top: 1px solid #eeece6; }
input { display: block; width: 100%; height: clamp(18px, calc(5dvh - 13px), 36px); min-height: 18px; max-height: 36px; border: 1px solid #e2ddd4; border-radius: 3px; background: #fff; color: #4c4741; line-height: 1.05; font-family: inherit; font-size: 15px; font-weight: 600; text-align: right; padding: 0 8px; font-variant-numeric: tabular-nums; }
input::placeholder { color: #a19a90; font-weight: 400; }
input:hover { border-color: #9c8d79; }
input:focus { outline: 2px solid #a57935; outline-offset: 0; background: #fff9eb; }
input[aria-invalid=true] { border-color: var(--red); background: #fff0f3; }
input.high-amount { color: var(--red); font-weight: 750; }
.million th { color: var(--red); }
#validation-status { font-size: 10px; color: #71695e; margin: 3px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#validation-status.error { color: var(--red); }
footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #71695e; font-size: 10px; }
kbd { font: inherit; color: #4c4741; }
.celebration { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); background: #fffdf9; color: var(--red); border: 1px solid #e2b5bd; border-radius: 8px; padding: 10px 20px; box-shadow: 0 3px 14px #9b173018; pointer-events: none; font-weight: 700; z-index: 3; }
.celebration:empty { display: none; }
#fireworks { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
@media (max-height: 700px) {
  .workspace { grid-template-rows: 40px minmax(0, 1fr) 24px; }
  main { grid-template-rows: minmax(0, 1fr) calc(50dvh - 24px); gap: 6px; padding-top: 4px; }
  .summary { padding: 4px 20px 6px; grid-template-rows: 20px 20px minmax(0, 1fr) auto; }
  .summary-heading h1 { font-size: 14px; }
  .amount-label { font-size: 16px; }
  .grand-amount output { font-size: min(10vw, 17vh); }
  .counts { padding-top: 4px; }
  .counts output { font-size: 32px; }
  .counts span { font-size: 14px; }
  .entry { grid-template-rows: 20px minmax(0, 1fr) 18px; }
  thead { height: 24px; }
  input { font-size: 14px; }
}
@media (max-width: 640px) {
  .workspace { padding: 0 10px; grid-template-rows: 42px minmax(0, 1fr) 32px; }
  main { grid-template-rows: minmax(0, 1fr) calc(50dvh - 32px); gap: 6px; padding-top: 5px; }
  .brand { font-size: 13px; gap: 8px; }
  .brand img { width: 62px; }
  .back { font-size: 11px; }
  .summary { padding: 8px 10px; grid-template-rows: 22px 24px minmax(0, 1fr) auto; }
  .summary-heading h1 { font-size: 14px; }
  .summary-heading > span { font-size: 10px; }
  .amount-label { font-size: 17px; }
  .grand-amount { gap: 5px; }
  .grand-amount output { font-size: 16vw; }
  .currency { font-size: 16px; }
  .unit { font-size: 13px; }
  .counts { gap: 8px; padding-top: 8px; }
  .counts span { font-size: 12px; }
  .counts output { font-size: 30px; }
  .entry-heading h2 { font-size: 12px; }
  .entry-heading p { font-size: 9px; }
  .group-col { width: 10%; }
  .money-col { width: 34%; }
  thead { height: 30px; }
  th { font-size: 9px; }
  th span { display: block; margin: 0; }
  tbody th { font-size: 12px; }
  td { padding: 1px 3px; }
  input { height: clamp(17px, calc(5dvh - 14px), 36px); font-size: 13px; padding: 0 3px; min-height: 17px; }
  footer { display: block; padding-top: 2px; font-size: 8px; line-height: 1.6; }
  footer > span { display: block; }
  #validation-status { font-size: 9px; }
  .celebration { font-size: 12px; white-space: nowrap; padding: 8px 12px; }
}

.guide { position: fixed; top: 12px; right: 16px; width: 330px; z-index: 4; padding: 0; }
.guide summary { font-size: 11px; font-weight: 650; color: #76634e; cursor: pointer; }
.guide h2 { font-size: 14px; color: var(--red); margin: 10px 0 5px; }
.guide ol { margin: 0; padding-left: 23px; font-size: 13px; line-height: 1.8; }
.guide li { padding-left: 2px; margin-bottom: 4px; white-space: nowrap; }
.guide dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 8px; row-gap: 6px; margin: 0; font-size: 12px; line-height: 1.8; }
.guide dt { font-weight: 700; margin: 0; }
.guide dd { margin: 0; color: #71695e; white-space: nowrap; }
@media (max-width: 1799px) {
  main { grid-template-columns: minmax(0, 1fr); }
  .guide { position: fixed; top: 10px; right: 12px; z-index: 4; padding: 0; }
  .guide summary { font-size: 11px; }
  .guide-content { position: absolute; right: 0; top: 25px; width: min(340px, calc(100vw - 24px)); max-height: calc(100dvh - 60px); overflow-y: auto; padding: 8px 18px 18px; background: #fffdf9; border: 1px solid #e2dcd2; border-radius: 8px; box-shadow: 0 6px 24px #76634e25; }
  .guide li, .guide dd { white-space: normal; }
  .guide dl { display: block; font-size: 13px; }
  .guide dt { margin-top: 8px; }
}
