:root {
  color-scheme: light;
  --ink: #18271f;
  --muted: #52635a;
  --paper: #f5f6f0;
  --surface: #fff;
  --line: #dce3d9;
  --forest: #102820;
  --deep-forest: #0b1e18;
  --action: #27513e;
  --accent: #d7f68c;
  --focus: #257353;
  --radius: 1rem;
  font: 16px/1.55 Inter, system-ui, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
h1, h2, p { margin: 0; }
h1, h2 { line-height: 1.22; letter-spacing: -.045em; }
h1 { font-size: clamp(1.9rem, 4.7vw, 2.95rem); font-weight: 760; overflow-wrap: anywhere; }
h2 { font-size: 1.35rem; font-weight: 730; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.shell { width: min(100% - 3rem, 72rem); margin-inline: auto; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4.5rem; }
.brand { display: inline-flex; align-items: center; gap: .68rem; text-decoration: none; font-size: 1.29rem; font-weight: 830; line-height: 1; letter-spacing: -.06em; }
.brand-name { display: block; margin-top: .22rem; color: var(--muted); font-size: .65rem; font-weight: 680; letter-spacing: .02em; }
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 2.2rem;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: .65rem;
  background: var(--deep-forest);
}
.brand-mark::before {
  content: "";
  width: 1rem;
  height: .9rem;
  background:
    linear-gradient(var(--accent), var(--accent)) left bottom / 22% 42% no-repeat,
    linear-gradient(var(--accent), var(--accent)) center bottom / 22% 68% no-repeat,
    linear-gradient(var(--accent), var(--accent)) right bottom / 22% 100% no-repeat;
}
.account { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.account-email { max-width: 34vw; color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-account { display: none; }
.skip-link { position: fixed; z-index: 10; top: .7rem; left: .7rem; padding: .7rem 1rem; border-radius: .5rem; background: var(--surface); color: var(--ink); transform: translateY(-180%); }
.skip-link:focus { transform: none; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  min-height: 2.85rem;
  padding: .55rem 1rem;
  border: 1px solid transparent;
  border-radius: .65rem;
  font: inherit;
  font-weight: 680;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease;
}
.primary { background: var(--forest); color: white; }
.primary:hover { background: var(--action); }
.secondary { border-color: var(--line); background: var(--surface); color: var(--ink); }
.secondary:hover { border-color: #9aaea1; background: #f2f6ef; }
.compact { min-height: 2.5rem; white-space: nowrap; font-size: .85rem; }
.accent { background: var(--accent); color: var(--deep-forest); }
.accent:hover { background: #e7ffad; }
.text-link { display: inline-flex; align-items: center; gap: .5rem; color: var(--action); font-weight: 680; text-decoration: none; }
.text-link:hover { text-decoration: underline; text-underline-offset: .24em; }
.chevron { width: .44em; height: .44em; border-top: 1.5px solid; border-right: 1.5px solid; transform: rotate(45deg); }
.chevron.back { transform: rotate(225deg); }
.arrow { position: relative; width: .95rem; height: 1px; background: currentColor; }
.arrow::after { position: absolute; content: ""; top: -.2rem; right: 0; width: .45rem; height: .45rem; border-top: 1px solid; border-right: 1px solid; transform: rotate(45deg); }
.download-mark { position: relative; width: .9rem; height: .95rem; border-bottom: 1.5px solid; }
.download-mark::before { position: absolute; content: ""; top: 0; left: calc(50% - .75px); width: 1.5px; height: .63rem; background: currentColor; }
.download-mark::after { position: absolute; content: ""; top: .28rem; left: .25rem; width: .42rem; height: .42rem; border-right: 1.5px solid; border-bottom: 1.5px solid; transform: rotate(45deg); }

.auth-shell { display: grid; align-items: center; min-height: calc(100svh - 4.5rem); padding-block: 2.4rem; }
.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(100%, 67rem);
  min-height: 29rem;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.65rem;
  background: var(--surface);
  box-shadow: 0 18px 52px -36px #192e235e;
}
.auth-heading, .auth-panel { min-width: 0; padding: clamp(2rem, 5vw, 4rem); }
.auth-heading { display: flex; flex-direction: column; justify-content: center; background: var(--forest); color: #f5ffe4; }
.auth-heading h1 { margin-bottom: .85rem; font-size: clamp(2.1rem, 4.1vw, 3.35rem); word-break: keep-all; }
.auth-intro { color: #d5e1d5; word-break: keep-all; }
.auth-panel { display: grid; place-items: center; }
.auth-content { width: min(100%, 25rem); }
.auth-content > :first-child { margin-top: 0; }
.auth-form { display: grid; gap: 1rem; }
.field { display: grid; gap: .45rem; }
.field label { font-size: .9rem; font-weight: 670; }
.field small { color: var(--muted); font-size: .82rem; }
.field input {
  min-width: 0;
  width: 100%;
  min-height: 3.15rem;
  padding: .66rem .85rem;
  border: 1px solid #aab9ae;
  border-radius: .65rem;
  background: #fdfefb;
  color: var(--ink);
  font: inherit;
}
.field input:hover { border-color: var(--action); }
.auth-form .primary { min-height: 3.2rem; margin-top: .35rem; }
.auth-footer { margin-top: 1.5rem; padding-top: 1.1rem; border-top: 1px solid var(--line); font-size: .88rem; }
.alert { margin-top: 1.25rem; padding: .75rem 1rem; border-radius: .65rem; background: #fff2ef; color: #842b23; font-size: .92rem; }
.auth-form + .alert, .alert + .auth-form { margin-top: 1rem; }

.workspace { padding-block: clamp(2rem, 5vw, 3.65rem) 4rem; }
.page-heading { margin-bottom: 1.5rem; }
.detail-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.breadcrumb { margin-bottom: .95rem; font-size: .88rem; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.error-panel { max-width: 37rem; margin-inline: auto; padding: clamp(1.4rem, 5vw, 2.75rem); }
.error-panel h1 { margin-bottom: 1.35rem; font-size: clamp(1.5rem, 4vw, 2.25rem); word-break: keep-all; }
.empty-state { margin-top: 1.5rem; padding: 1.55rem; color: var(--muted); }

.balance-card {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.3rem;
  min-height: 12.5rem;
  padding: clamp(1.3rem, 4vw, 2.35rem);
  border-radius: 1.2rem;
  background: var(--forest);
  color: white;
}
.balance-main { min-width: 0; }
.balance-main h2 { color: #e0ebdb; font-size: 1rem; letter-spacing: -.02em; font-weight: 640; }
.balance-value {
  margin-top: .55rem;
  color: #f5ffe4;
  font-size: clamp(1.9rem, 5.5vw, 3.35rem);
  font-weight: 740;
  font-variant-numeric: tabular-nums;
  line-height: 1.12;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}
.balance-value .won-fraction { color: #bfd0c2; font-size: .68em; }
.balance-meta { display: flex; align-items: flex-start; flex-direction: column; gap: .55rem; color: #e0ebdb; font-size: .88rem; }
.balance-meta strong { color: #fff; }
.notice {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  margin-top: 1rem;
  padding: .8rem 1rem;
  border: 1px solid #d5dfc4;
  border-radius: .7rem;
  background: #edf3e2;
  color: #2c4438;
  font-size: .9rem;
}
.notice-mark { flex: none; width: .52rem; height: .52rem; margin-top: .44rem; border-radius: 50%; background: #54752f; }

.ledger, .detail-ledger { margin-top: 1.85rem; }
.detail-ledger { display: grid; grid-template-columns: minmax(15rem, 1fr) minmax(0, 2.15fr); gap: 1.1rem; }
.detail-ledger section { min-width: 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .8rem 1rem; min-height: 2.75rem; margin-bottom: .65rem; }
.year-list { display: flex; flex-wrap: wrap; gap: .32rem; }
.year-list a {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: .35rem .75rem;
  border: 1px solid transparent;
  border-radius: .55rem;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 640;
  text-decoration: none;
}
.year-list a:hover { background: #e9eee5; color: var(--ink); }
.year-list a[aria-current="page"] { border-color: #cad8ca; background: var(--surface); color: var(--ink); font-weight: 740; }
.table-wrap { overflow-x: auto; scrollbar-color: #94a89a #eaf0e8; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .92rem; }
th, td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { background: #edf2ea; color: #46584d; font-weight: 650; font-size: .84rem; }
tbody th { font-weight: 670; }
tbody tr:last-child > * { border-bottom: 0; }
tbody tr:hover { background: #f7f9f4; }
th small { display: block; margin-top: .19rem; color: var(--muted); font-size: .78rem; font-weight: 470; overflow-wrap: anywhere; }
.numeric { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.amount { font-weight: 690; }
.won-fraction { color: var(--muted); font-size: .82em; font-weight: 570; }
.action-cell { width: 9rem; text-align: right; white-space: nowrap; }
.action-cell .text-link { min-height: 2rem; font-size: .88rem; }
.track-table { min-width: 36rem; }
.track-table th:first-child, .track-table td:nth-child(2) { min-width: 6.5rem; overflow-wrap: anywhere; }
.scroll-hint { display: none; color: var(--muted); font-size: .78rem; }
.platform-row { position: relative; }
.platform-link { display: inline-flex; align-items: center; gap: .55rem; color: var(--action); text-decoration: none; }
.platform-link::after { position: absolute; inset: 0; content: ""; }
.platform-link:hover { text-decoration: underline; text-underline-offset: .2em; }
.platform-row.platform-selected { background: #e5efde; }
.platform-selected th { box-shadow: inset .2rem 0 var(--action); }
.sort-link { display: inline-flex; align-items: center; justify-content: flex-end; gap: .35rem; min-height: 1.5rem; color: var(--action); text-decoration: none; }
.sort-link:hover { text-decoration: underline; text-underline-offset: .2em; }
.sort-icon { width: .8em; text-align: center; }
.track-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; color: var(--action); font-size: .85rem; font-weight: 680; }
.track-filter span { overflow-wrap: anywhere; }
#tracks-title { scroll-margin-top: 1rem; }

@media (max-width: 39rem) {
  .scroll-hint { display: inline; }
}

@media (max-width: 57rem) {
  .detail-ledger { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 43rem) {
  .shell { width: calc(100% - 2rem); }
  .header-row { min-height: 3.85rem; }
  .auth-shell { display: block; min-height: 0; padding-block: 1rem 2rem; }
  .auth-layout { grid-template-columns: minmax(0, 1fr); min-height: 0; border-radius: 1.15rem; }
  .auth-heading { padding: 1.5rem 1.25rem; }
  .auth-heading h1 { margin-bottom: .55rem; font-size: clamp(1.75rem, 6vw, 2.1rem); }
  .auth-intro { font-size: .9rem; }
  .auth-panel { padding: 1.6rem 1.25rem 1.75rem; }
  .account-email { display: none; }
  .mobile-account { display: block; margin-top: .42rem; color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
  .balance-card { min-height: 0; align-items: flex-start; }
  .balance-meta { gap: .4rem; }
  .balance-meta .button { min-height: 2.65rem; }
  .action-cell { width: auto; }
  th, td { padding-inline: .7rem; }
  .history-table { font-size: .82rem; }
  .history-table th[scope="row"] { min-width: 5.8rem; }
  .action-cell .text-link { font-size: .8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
