:root {
  --bg: #f8f2ea;
  --paper: #fffaf4;
  --paper-strong: #fffdf9;
  --ink: #394939;
  --muted: #79736b;
  --line: #eadfd3;
  --green: #3f6553;
  --green-strong: #294c3d;
  --green-soft: #e4ede6;
  --sand: #efe7dc;
  --amber: #d6a450;
  --sky: #dce9ee;
  --rose: #efd9d3;
  --mint: #dcece4;
  --clay: #c28b62;
  --danger: #a54a43;
  --shadow: 0 18px 42px rgba(51, 43, 34, 0.1);
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(214, 164, 80, 0.14), transparent 30%),
    radial-gradient(circle at 92% 18%, rgba(119, 160, 178, 0.16), transparent 32%),
    radial-gradient(circle at 18% 78%, rgba(194, 139, 98, 0.12), transparent 30%),
    linear-gradient(180deg, #fbf7f1 0%, var(--bg) 100%);
  color: var(--ink);
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  width: min(100%, 440px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(30px, env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
  position: relative;
}

.top-menu-bar {
  align-items: center;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  min-height: 44px;
}

.top-menu-title {
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.top-menu-action {
  height: 44px;
  width: 44px;
}

.icon-button,
.text-button,
.pill-button,
.primary-button,
.ghost-button,
.small-icon-button {
  border: 0;
  cursor: pointer;
}

.icon-button,
.small-icon-button {
  align-items: center;
  background: transparent;
  color: var(--ink);
  display: inline-flex;
  justify-content: center;
}

.icon-button {
  border-radius: 50%;
  height: 44px;
  width: 44px;
}

.icon-button svg,
.small-icon-button svg {
  height: 23px;
  width: 23px;
}

.icon-button:active,
.small-icon-button:active {
  background: var(--sand);
}

.screen {
  display: grid;
  gap: 18px;
  padding-top: 5px;
}

.hero-title {
  margin: 6px 0 4px;
  text-align: center;
}

.hero-title h1 {
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.18;
  margin: 0;
}

.hero-title p {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  margin: 0;
}

.card,
.result-strip,
.goal-card,
.settings-summary {
  background: rgba(255, 250, 244, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.settings-summary.is-hourly {
  grid-template-columns: repeat(2, 1fr);
}

.calculator-card {
  padding: 18px;
}

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

.field span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
}

.price-row,
.input-with-select {
  align-items: center;
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1fr 94px;
  overflow: hidden;
}

.price-row input,
.goal-form .field > input,
.input-with-select input,
.plain-input,
.field textarea {
  background: transparent;
  border: 0;
  color: var(--green);
  min-width: 0;
  outline: 0;
  width: 100%;
}

.price-row input {
  font-size: clamp(42px, 14vw, 64px);
  font-weight: 600;
  letter-spacing: 0;
  padding: 18px 8px 18px 18px;
}

.input-with-select input,
.goal-form .field > input,
.plain-input,
.field textarea {
  font-size: 16px;
  padding: 16px;
}

.goal-form .field > input,
.goal-form .input-with-select,
.goal-form .field textarea {
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.goal-form .field > input {
  min-height: 54px;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.goal-form .field > input::placeholder,
.goal-form .field textarea::placeholder {
  color: rgba(121, 115, 107, 0.72);
}

.goal-form .field > input:focus,
.goal-form .field textarea:focus {
  background: #fffefb;
  border-color: rgba(63, 101, 83, 0.42);
  box-shadow:
    0 0 0 4px rgba(63, 101, 83, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.goal-form .input-with-select:focus-within {
  background: #fffefb;
  border-color: rgba(63, 101, 83, 0.42);
  box-shadow:
    0 0 0 4px rgba(63, 101, 83, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

select {
  appearance: none;
  background: var(--sand);
  border: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  height: 100%;
  padding: 0 14px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  margin: 12px 0 16px;
  text-align: center;
}

.primary-button,
.ghost-button,
.pill-button {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-weight: 850;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  width: 100%;
}

.primary-button {
  background: var(--green);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14);
  color: #fff;
}

.primary-button:active {
  background: var(--green-strong);
}

.ghost-button {
  background: var(--sand);
  color: var(--ink);
}

.calculator-cat-note {
  min-height: 220px;
  padding-top: 56px;
  position: relative;
}

.calculator-cat-bubble {
  background: #f2ebe4;
  border-radius: 26px 26px 26px 8px;
  color: #4a433d;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.6;
  left: 10px;
  max-width: 170px;
  padding: 20px 18px;
  position: absolute;
  top: 8px;
  z-index: 1;
}

.calculator-cat-bubble::after {
  border-left: 18px solid transparent;
  border-top: 14px solid #f2ebe4;
  bottom: -10px;
  content: "";
  height: 0;
  position: absolute;
  right: 18px;
  transform: rotate(-10deg);
  width: 0;
}

.settings-cat-note {
  display: grid;
  gap: 6px;
  justify-items: center;
  margin: 28px auto 0;
  min-height: 220px;
  overflow: hidden;
  padding-top: 0;
  width: min(320px, 100%);
}

.settings-cat-bubble {
  background: #f2ebe4;
  border-radius: 26px 26px 26px 8px;
  color: #4a433d;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.6;
  max-width: 190px;
  padding: 20px 18px;
  position: relative;
  z-index: 1;
}

.settings-cat-bubble::after {
  border-left: 18px solid transparent;
  border-top: 14px solid #f2ebe4;
  bottom: -10px;
  content: "";
  height: 0;
  position: absolute;
  right: 18px;
  transform: rotate(-10deg);
  width: 0;
}

.cat-image {
  display: block;
  height: auto;
  max-width: 100%;
  object-fit: contain;
  user-select: none;
}

.cat-calculator {
  margin-inline: auto;
  width: 76%;
}

.cat-settings {
  margin-inline: auto;
  margin-top: -6px;
  width: min(280px, 82vw);
}

.cat-goals {
  width: min(160px, 78vw);
}

.cat-00 {
  width: min(250px, 88vw);
}

.page-end-cat {
  display: flex;
  padding: 18px 0 4px;
  margin-left: 10px;
}

.cat-menu {
  width: 230px;
}

.work-results {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.result-box {
  align-items: center;
  display: grid;
  gap: 8px;
  justify-items: center;
  min-height: 118px;
  padding: 14px 8px;
}

.result-box + .result-box {
  border-left: 1px solid var(--line);
}

.result-box svg {
  color: var(--green);
  height: 27px;
  width: 27px;
}

.result-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}

.result-label {
  font-size: 13px;
  font-weight: 800;
}

.section-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.section-head h2 {
  font-size: 17px;
  margin: 0;
}

.section-head p {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

.goal-results,
.goal-list,
.settings-list {
  display: grid;
  gap: 10px;
}

.goal-list {
  position: relative;
}

.screen:has(.goals-cat-note) {
  padding-bottom: 223px;
}

.goals-cat-note {
  height: 205px;
  left: 50%;
  pointer-events: none;
  position: absolute;
  transform: translateX(-50%);
  top: calc(100% + 18px);
  width: min(286px, 82vw);
}

.goals-cat-bubble {
  background: #f2ebe4;
  border-radius: 22px 22px 6px 22px;
  color: #4a433d;
  font-size: 13px;
  font-weight: 750;
  left: 0;
  line-height: 1.5;
  max-width: 160px;
  padding: 14px 16px;
  position: absolute;
  top: 0;
}

.goals-cat-bubble::after {
  border-left: 12px solid #f2ebe4;
  border-top: 9px solid transparent;
  bottom: -7px;
  content: "";
  height: 0;
  position: absolute;
  right: 16px;
  transform: rotate(12deg);
  width: 0;
}

.goals-cat-note .cat-goals {
  bottom: 0;
  position: absolute;
  right: 0;
}

.goal-card {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 52px 1fr auto;
  min-height: 82px;
  padding: 12px;
}

.goal-icon {
  align-items: center;
  background: #f2ece3;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--green-strong);
  display: inline-flex;
  height: 48px;
  justify-content: center;
  width: 48px;
}

.goal-icon svg {
  height: 25px;
  width: 25px;
}

.goal-main {
  min-width: 0;
}

.goal-main strong {
  display: block;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.goal-main small,
.goal-side small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-top: 3px;
}

.goal-side {
  font-weight: 850;
  text-align: right;
  white-space: nowrap;
}

.meter {
  background: #ebe2d8;
  border-radius: 999px;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
}

.meter span {
  background: var(--green);
  border-radius: inherit;
  display: block;
  height: 100%;
  max-width: 100%;
}

.empty-state {
  align-items: center;
  background: rgba(255, 250, 244, 0.76);
  border: 1px dashed #ddcebf;
  border-radius: 8px;
  display: grid;
  gap: 14px;
  justify-items: center;
  min-height: 220px;
  padding: 28px;
  text-align: center;
}

.empty-state h2 {
  font-size: 18px;
  margin: 0;
}

.empty-state p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.page-intro {
  margin: -8px 0 2px;
  text-align: center;
}

.page-subtitle {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin: 12px 0 0;
  text-align: center;
}

.add-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  display: inline-flex;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.add-button svg {
  height: 24px;
  width: 24px;
}

.goal-item {
  grid-template-columns: 38px 48px 1fr auto;
}

.goal-card:nth-of-type(3n + 1) .goal-icon {
  background: var(--mint);
  color: var(--green-strong);
}

.goal-card:nth-of-type(3n + 2) .goal-icon {
  background: var(--rose);
  color: #7d4f47;
}

.goal-card:nth-of-type(3n + 3) .goal-icon {
  background: var(--sky);
  color: #36546a;
}

.drag-handle {
  align-items: center;
  background: transparent;
  border: 0;
  color: #a49b91;
  cursor: grab;
  display: inline-flex;
  height: 44px;
  justify-content: center;
  touch-action: none;
  width: 32px;
}

.drag-handle svg {
  height: 22px;
  width: 22px;
}

.goal-item.is-dragging {
  opacity: 0.45;
}

.item-actions {
  align-items: center;
  display: flex;
  gap: 2px;
}

.small-icon-button {
  border-radius: 50%;
  height: 38px;
  width: 38px;
}

.danger {
  color: var(--danger);
}

.settings-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.segmented {
  background: #f0e8df;
  border-radius: 999px;
  display: grid;
  gap: 4px;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
}

.segmented button {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 850;
  min-height: 42px;
}

.segmented button.is-active {
  background: var(--green);
  color: #fff;
}

.settings-grid {
  display: grid;
  gap: 14px;
}

.settings-summary {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, 1fr);
  padding: 16px 10px;
  text-align: center;
}

.summary-item strong {
  display: block;
  font-size: 20px;
}

.summary-item span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 750;
  margin-top: 4px;
}

.sheet-backdrop {
  background: rgba(29, 27, 24, 0.34);
  bottom: 0;
  left: max(0px, calc(50% - 220px));
  position: fixed;
  top: 0;
  width: min(100vw, 440px);
  z-index: 40;
}

.side-sheet {
  background: var(--paper-strong);
  border-radius: 0 22px 22px 0;
  bottom: 0;
  box-shadow: 20px 0 54px rgba(35, 30, 24, 0.22);
  clip-path: inset(0 100% 0 0);
  display: flex;
  flex-direction: column;
  left: max(0px, calc(50% - 220px));
  max-width: 360px;
  overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  pointer-events: none;
  position: fixed;
  top: 0;
  transition: clip-path 0.24s ease, visibility 0s linear 0.24s;
  visibility: hidden;
  width: 86vw;
  z-index: 50;
}

.side-sheet.is-open {
  clip-path: inset(0);
  pointer-events: auto;
  transition-delay: 0s;
  visibility: visible;
}

.sheet-header,
.dialog-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.sheet-header h2,
.dialog-header h2 {
  font-size: 22px;
  margin: 0;
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
}

.sheet-header p {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  margin: 6px 0 0;
}

.menu-list {
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
  margin: 24px 0 18px;
  padding: 12px 0;
}

.menu-list button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  font-size: 16px;
  font-weight: 800;
  gap: 14px;
  grid-template-columns: 28px 1fr;
  min-height: 52px;
  padding: 0 10px;
  text-align: left;
}

.menu-list svg {
  height: 24px;
  width: 24px;
}

.menu-footer {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin-top: auto;
}

.goal-dialog {
  background: var(--paper-strong);
  border: 0;
  border-radius: 22px 22px 0 0;
  bottom: 0;
  box-shadow: 0 -20px 54px rgba(35, 30, 24, 0.22);
  color: var(--ink);
  margin: auto auto 0;
  max-height: 94dvh;
  max-width: 440px;
  padding: 0;
  width: 100%;
}

.goal-dialog::backdrop {
  background: rgba(29, 27, 24, 0.34);
}

.goal-form {
  display: grid;
  gap: 18px;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
}

.text-button {
  background: transparent;
  color: var(--green-strong);
  font-weight: 850;
  min-height: 44px;
}

.icon-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, 1fr);
}

.icon-option {
  align-items: center;
  background: #f3ece3;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green-strong);
  display: grid;
  gap: 5px;
  justify-items: center;
  min-height: 72px;
  padding: 8px 4px;
}

.icon-option svg {
  height: 25px;
  width: 25px;
}

.icon-option span {
  color: #5c554e;
  font-size: 10px;
  font-weight: 800;
}

.icon-option.is-active {
  background: var(--green);
  color: #fff;
}

.icon-option.is-active span {
  color: #fff;
}

.setup-warning {
  background: #f6eadc;
  border: 1px solid #e6d1b9;
  border-radius: 8px;
  color: #5a4430;
  display: grid;
  gap: 10px;
  padding: 14px;
}

.setup-warning strong {
  font-size: 15px;
}

@media (min-width: 760px) {
  body {
    align-items: start;
    display: flex;
    justify-content: center;
    padding: 24px;
  }

  .app-shell {
    border: 1px solid var(--line);
    border-radius: 32px;
    box-shadow: 0 24px 80px rgba(48, 40, 31, 0.14);
    min-height: min(860px, calc(100dvh - 48px));
    overflow: hidden;
  }

  .side-sheet {
    bottom: 24px;
    left: calc(50% - 220px);
    top: 24px;
  }

  .sheet-backdrop {
    bottom: 24px;
    left: calc(50% - 220px);
    top: 24px;
  }

}

@media (max-width: 520px) {
  .settings-cat-note {
    gap: 4px;
    margin-top: 24px;
    width: min(300px, calc(100vw - 36px));
  }

  .settings-cat-bubble {
    max-width: min(210px, calc(100vw - 90px));
  }

  .cat-settings {
    width: min(270px, calc(100vw - 54px));
  }
}

@media (max-width: 360px) {
  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

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

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

  .cat-image {
    justify-self: center;
  }

  .work-results,
  .settings-summary {
    grid-template-columns: 1fr;
  }

  .result-box + .result-box {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
