:root {
  --ink: #222222;
  --muted: #717171;
  --paper: #f7f7f7;
  --card: #ffffff;
  --line: #dddddd;
  --green: #ff385c;
  --green-soft: #e8f3ee;
  --green-deep: #222222;
  --terracotta: #ff385c;
  --peach: #fff0f3;
  --amber: #9a670e;
  --amber-soft: #fff0cf;
  --blue: #4e7485;
  --blue-soft: #e8f1f5;
  --shadow: 0 3px 14px rgba(0, 0, 0, 0.06);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(63, 114, 91, 0.28);
  outline-offset: 3px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--green);
  font-weight: 700;
}

.brand > span:last-child {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 18px;
  letter-spacing: 0.08em;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
}

.contract-chip {
  padding: 8px 13px;
  border: 1px solid #ffc4ce;
  border-radius: 999px;
  color: #c41d3d;
  background: var(--peach);
  font-size: 12px;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding: 32px 0 30px;
}

.intro {
  display: block;
  padding: 6px 4px 12px;
}

.eyebrow,
.step-label {
  margin: 0 0 9px;
  color: var(--terracotta);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 900px;
  margin-bottom: 10px;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.18;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
  letter-spacing: -0.03em;
}

.intro-copy {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.control-card,
.calendar-card,
.adjust-card,
.breakdown-card,
.source-card {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.text-button {
  padding: 8px 0;
  border: 0;
  color: var(--green);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
}

.control-grid {
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 1.25fr 1.15fr;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field > span:first-child,
fieldset legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.field select,
.input-shell {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #ffffff;
}

.field select {
  padding: 0 42px 0 14px;
}

.input-shell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
}

.input-shell > span {
  color: var(--muted);
}

.input-shell input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 600;
}

.rule-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.rule-strip > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.rule-strip strong {
  color: var(--ink);
}

.rule-dot,
.legend-swatch,
.mini-icon {
  display: inline-block;
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.rule-dot.regular,
.mini-icon.regular {
  background: #3f7d62;
}

.rule-dot.holiday,
.mini-icon.holiday {
  background: var(--amber);
}

.rule-dot.spring,
.mini-icon.spring {
  background: var(--terracotta);
}

.mini-icon.paid {
  border: 2px solid var(--amber);
  background: transparent;
}

.result-card {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 32px;
  padding: 28px;
  border-radius: 18px;
  color: #ffffff;
  background: #222222;
  box-shadow: var(--shadow);
}

.result-main {
  display: grid;
  align-content: center;
  justify-items: start;
}

.result-kicker,
.result-note,
.result-metrics span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.result-amount {
  margin: 5px 0 8px;
  font-family: "DM Mono", monospace;
  font-size: clamp(36px, 5vw, 52px);
  font-weight: 500;
  letter-spacing: -0.06em;
}

.result-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: stretch;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 16px;
}

.share-trigger {
  min-height: 40px;
  margin-top: 18px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  color: #ffffff;
  background: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.share-trigger:hover {
  background: #e92048;
}

.result-metrics > div {
  display: grid;
  align-content: center;
  gap: 7px;
  min-height: 104px;
  padding: 18px;
}

.result-metrics > div + div {
  border-left: 1px solid rgba(255, 255, 255, 0.13);
}

.result-metrics strong {
  font-family: "DM Mono", monospace;
  font-size: 17px;
}

.calendar-heading {
  align-items: end;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

.legend-swatch.work {
  background: var(--green-soft);
}

.legend-swatch.holiday {
  background: var(--amber-soft);
}

.legend-swatch.rest {
  background: var(--blue-soft);
}

.notice {
  margin: -8px 0 22px;
  padding: 12px 15px;
  border: 1px solid #ead7aa;
  border-radius: 12px;
  color: #7c5a23;
  background: #fff7e3;
  font-size: 12px;
  line-height: 1.6;
}

.calendar {
  min-width: 720px;
}

.calendar-scroll {
  max-width: 100%;
  overflow-x: auto;
  padding: 3px;
}

.weekday {
  float: left;
  width: calc(100% / 7);
  padding: 4px 10px 12px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.calendar-days {
  clear: both;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.day-cell {
  position: relative;
  display: grid;
  align-content: space-between;
  min-height: 100px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--ink);
  text-align: left;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

button.day-cell:hover {
  border-color: rgba(37, 51, 45, 0.23);
  box-shadow: 0 8px 20px rgba(60, 57, 45, 0.08);
  transform: translateY(-2px);
}

.day-cell.is-work {
  background: var(--green-soft);
}

.day-cell.is-holiday {
  background: var(--amber-soft);
}

.day-cell.is-rest {
  background: var(--blue-soft);
}

.day-cell.is-blank {
  min-height: 100px;
  border: 1px dashed rgba(115, 104, 82, 0.1);
  background: rgba(247, 243, 234, 0.26);
}

.day-cell.is-selected {
  border-color: var(--green-deep);
  box-shadow: 0 0 0 2px rgba(41, 79, 62, 0.13);
}

.day-number {
  font-family: "DM Mono", monospace;
  font-size: 17px;
}

.day-label {
  max-width: 100%;
  overflow: hidden;
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-badge {
  position: absolute;
  top: 10px;
  right: 9px;
  padding: 3px 6px;
  border-radius: 999px;
  color: #fffaf1;
  background: rgba(37, 51, 45, 0.65);
  font-size: 9px;
}

.calendar-help {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.selected-date {
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--green-deep);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 600;
}

.adjust-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 92px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(247, 243, 234, 0.45);
}

.adjust-empty[hidden] {
  display: none;
}

.adjust-empty span {
  font-size: 24px;
}

.adjust-empty p {
  margin: 0;
  font-size: 13px;
}

.adjust-controls {
  display: grid;
  grid-template-columns: 1.25fr 0.9fr;
  gap: 22px;
}

.adjust-controls[hidden] {
  display: none;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset legend {
  margin-bottom: 9px;
}

.segmented {
  display: grid;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f7f7f7;
}

.segmented.four {
  grid-template-columns: repeat(4, 1fr);
}

.segmented.three {
  grid-template-columns: repeat(3, 1fr);
}

.segmented button {
  min-height: 40px;
  padding: 7px 9px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
}

.segmented button.is-active {
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.adjust-explanation {
  grid-column: 1 / -1;
  margin: -5px 0 0;
  padding: 12px 14px;
  border-left: 3px solid var(--green);
  color: #6f2836;
  background: var(--peach);
  font-size: 12px;
  line-height: 1.65;
}

.formula-box {
  display: grid;
  grid-template-columns: 1fr auto 0.85fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 22px;
  border-radius: 16px;
  color: #f9f5ec;
  background: #222222;
}

.formula-box > div {
  display: grid;
  gap: 7px;
}

.formula-box span {
  color: rgba(249, 245, 236, 0.6);
  font-size: 11px;
}

.formula-box code {
  overflow-wrap: anywhere;
  font-family: "DM Mono", monospace;
  font-size: 14px;
}

.formula-operator {
  font-family: "DM Mono", monospace;
  font-size: 20px !important;
}

.formula-total {
  padding-left: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
}

.formula-total code {
  color: #ff9daf;
  font-size: 21px;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 28px;
  margin-top: 20px;
}

.breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.breakdown-row > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.breakdown-row > span:last-child {
  font-family: "DM Mono", monospace;
  white-space: nowrap;
}

.logic-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  margin-top: 22px;
  padding: 17px 18px;
  border-radius: 13px;
  background: var(--peach);
}

.logic-note strong {
  color: #9f1834;
  font-size: 12px;
}

.logic-note p {
  margin: 0;
  color: #713b46;
  font-size: 12px;
  line-height: 1.65;
}

.source-card {
  display: grid;
  grid-template-columns: 0.55fr 1.4fr auto;
  align-items: center;
  gap: 30px;
  box-shadow: none;
}

.source-card h2 {
  font-size: 20px;
}

.source-card > p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.source-links {
  display: grid;
  justify-items: start;
  gap: 9px;
}

.source-links a {
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.source-links a:hover {
  text-decoration: underline;
}

.share-dialog {
  width: min(920px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

.share-dialog::backdrop {
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(3px);
}

.share-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 0;
}

.share-dialog-copy {
  margin: 6px 24px 18px;
  color: var(--muted);
  font-size: 13px;
}

.dialog-close {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #ffffff;
  font-size: 12px;
  font-weight: 600;
}

.share-preview {
  max-height: calc(100vh - 250px);
  padding: 18px;
  overflow: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #eeeeee;
}

.share-preview canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 3px 16px rgba(0, 0, 0, 0.1);
}

.share-status {
  min-height: 20px;
  margin: 12px 24px 0;
  color: var(--muted);
  font-size: 12px;
}

.share-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 24px 22px;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--green);
  color: #ffffff;
  background: var(--green);
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #ffffff;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 4px 50px;
  color: var(--muted);
  font-size: 11px;
}

footer p {
  margin: 0;
}

@media (max-width: 900px) {
  .control-grid {
    grid-template-columns: 1fr 1fr;
  }

  .result-card {
    grid-template-columns: 1fr;
  }

  .adjust-controls {
    grid-template-columns: 1fr;
  }

  .source-card {
    grid-template-columns: 1fr 1.7fr;
  }

  .source-links {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 24px, 1180px);
  }

  .topbar {
    min-height: 64px;
  }

  .contract-chip {
    display: none;
  }

  main {
    gap: 14px;
    padding-top: 22px;
  }

  .intro {
    padding-bottom: 8px;
  }

  h1 {
    font-size: 32px;
  }

  .control-card,
  .calendar-card,
  .adjust-card,
  .breakdown-card,
  .source-card,
  .result-card {
    padding: 21px;
    border-radius: 18px;
  }

  .section-heading {
    margin-bottom: 20px;
  }

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

  .result-metrics {
    grid-template-columns: 1fr;
  }

  .result-metrics > div {
    min-height: 72px;
  }

  .result-metrics > div + div {
    border-top: 1px solid rgba(255, 255, 255, 0.13);
    border-left: 0;
  }

  .calendar-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .legend {
    justify-content: flex-start;
  }

  .segmented.four {
    grid-template-columns: 1fr 1fr;
  }

  .selected-date {
    max-width: 48%;
    text-align: right;
  }

  .formula-box {
    grid-template-columns: 1fr;
  }

  .formula-operator {
    display: none;
  }

  .formula-total {
    padding: 14px 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    border-left: 0;
  }

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

  .logic-note {
    grid-template-columns: 1fr;
  }

  .source-card {
    grid-template-columns: 1fr;
  }

  .source-links {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .share-dialog {
    width: calc(100% - 16px);
    max-height: calc(100vh - 16px);
    border-radius: 16px;
  }

  .share-dialog-header {
    padding: 18px 18px 0;
  }

  .share-dialog-copy {
    margin: 5px 18px 14px;
  }

  .share-preview {
    max-height: calc(100vh - 270px);
    padding: 10px;
  }

  .share-status {
    margin-right: 18px;
    margin-left: 18px;
  }

  .share-dialog-actions {
    padding-right: 18px;
    padding-left: 18px;
  }

  .primary-button,
  .secondary-button {
    flex: 1;
  }

  footer {
    flex-direction: column;
    line-height: 1.7;
  }
}

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