:root {
  color-scheme: light;
  --ink: #1f2528;
  --muted: #667174;
  --line: #d9dfdc;
  --paper: #fbfbf8;
  --panel: #ffffff;
  --mint: #d6efe6;
  --mint-strong: #178f70;
  --accent-soft: #d6efe6;
  --accent: #178f70;
  --accent-ink: #063f31;
  --accent-line: rgba(23, 143, 112, 0.25);
  --page-wash: rgba(214, 239, 230, 0.82);
  --coral: #ee715f;
  --amber: #f0b94b;
  --blue: #4e7fbf;
  --shadow: 0 18px 60px rgba(44, 56, 52, 0.13);
}

body[data-theme="rose"] {
  --accent-soft: #f8dce2;
  --accent: #b84761;
  --accent-ink: #5d1f32;
  --accent-line: rgba(184, 71, 97, 0.28);
  --page-wash: rgba(248, 220, 226, 0.82);
}

body[data-theme="sky"] {
  --accent-soft: #dcecf8;
  --accent: #356fa6;
  --accent-ink: #14385d;
  --accent-line: rgba(53, 111, 166, 0.26);
  --page-wash: rgba(220, 236, 248, 0.82);
}

body[data-theme="lavender"] {
  --accent-soft: #e8e1f6;
  --accent: #6f5aa8;
  --accent-ink: #33265c;
  --accent-line: rgba(111, 90, 168, 0.26);
  --page-wash: rgba(232, 225, 246, 0.82);
}

body[data-theme="sunset"] {
  --accent-soft: #f8e2cf;
  --accent: #a45f2d;
  --accent-ink: #573014;
  --accent-line: rgba(164, 95, 45, 0.28);
  --page-wash: rgba(248, 226, 207, 0.82);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, var(--page-wash), rgba(255, 255, 255, 0.2) 42%),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans TC",
    "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

code {
  border-radius: 5px;
  background: #eef7f3;
  color: var(--accent);
  padding: 2px 5px;
  font-weight: 800;
}

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

.notice-panel,
.auth-panel {
  padding: 18px;
}

.app-message {
  margin-bottom: 16px;
  border: 1px solid rgba(238, 113, 95, 0.38);
  border-radius: 8px;
  background: #fff4f1;
  color: #8d2e22;
  padding: 12px 14px;
  font-weight: 750;
  line-height: 1.45;
}

.notice-panel {
  margin-top: 28px;
}

.notice-panel p,
.muted-copy,
.helper-text {
  color: var(--muted);
  line-height: 1.55;
}

.auth-layout {
  display: grid;
  min-height: calc(100vh - 64px);
  place-items: center;
}

.auth-panel {
  width: min(520px, 100%);
}

.auth-panel h1 {
  margin-bottom: 12px;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.inline-check input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-actions button,
.account-actions button,
.install-button,
.input-row button {
  min-height: 42px;
  border-radius: 6px;
  font-weight: 900;
}

.auth-actions button:first-child,
.account-actions button:not(.ghost-button) {
  background: var(--ink);
  color: #fff;
}

.auth-actions button:last-child {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent);
}

.auth-form .text-button {
  min-height: 34px;
  justify-self: center;
  background: transparent;
  color: var(--accent);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 0 30px;
}

.topbar-side {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.2rem, 7vw, 5rem);
  line-height: 0.95;
}

.app-title {
  overflow-wrap: anywhere;
}

h2 {
  font-size: 1.2rem;
}

.point-badge {
  display: grid;
  min-width: 128px;
  aspect-ratio: 1;
  place-items: center;
  padding: 14px;
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  box-shadow: var(--shadow);
}

.point-badge span {
  font-size: 3rem;
  font-weight: 900;
  line-height: 0.9;
}

.point-badge small {
  color: var(--accent-ink);
  font-weight: 700;
}

.install-button {
  min-height: 42px;
  border: 1px solid var(--accent-line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--accent);
  font-weight: 900;
  padding: 0 18px;
  box-shadow: 0 8px 28px rgba(44, 56, 52, 0.1);
}

.install-button[hidden] {
  display: none;
}

.account-panel {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  max-width: min(56vw, 520px);
  color: var(--muted);
  text-align: right;
}

.account-panel .kicker {
  margin-bottom: 2px;
  font-size: 0.68rem;
}

.account-panel .meta {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 850;
  line-height: 1.3;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

select {
  min-height: 42px;
  min-width: 190px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

.tab-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
}

.tab-bar button {
  min-height: 42px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.tab-bar button.active {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 8px 22px rgba(31, 37, 40, 0.12);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.home-grid {
  display: grid;
  grid-template-columns: 300px minmax(280px, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.controls-panel {
  display: grid;
  gap: 18px;
  grid-row: 1 / span 2;
  padding: 18px;
  position: sticky;
  top: 18px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

textarea {
  width: 100%;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-line);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 8px;
}

.point-action-row {
  grid-template-columns: 1fr 82px 82px;
}

button[type="submit"],
.input-row button,
.rule-form button {
  min-height: 44px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.quick-grid button,
.ghost-button,
.segmented-control button,
.gift-actions button,
.rule-card button {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.quick-grid button {
  color: var(--accent);
}

.subtract-grid button,
.subtract-button {
  color: #a8372a;
}

.summary-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.summary-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: #f5f7f4;
  gap: 3px 12px;
}

.summary-card-primary {
  background: color-mix(in srgb, var(--accent-soft) 64%, #ffffff);
  border-color: var(--accent-line);
}

.summary-list dt {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.summary-list dd {
  margin: 0;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  grid-row: 1 / span 2;
}

.summary-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.summary-detail strong {
  color: var(--accent);
}

.summary-action {
  position: relative;
}

.summary-action:not(.is-disabled) {
  cursor: pointer;
}

.summary-action:not(.is-disabled):hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.summary-action:not(.is-disabled)::after {
  content: "查看";
  grid-column: 1 / -1;
  justify-self: start;
  border-radius: 5px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
}

.summary-action.is-disabled {
  opacity: 0.62;
}

.ghost-button {
  color: #a8372a;
}

.account-actions .return-button {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: 0 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.rule-form {
  display: grid;
  grid-template-columns: 86px 1fr 86px 96px 110px;
  gap: 10px;
  padding: 18px;
  align-items: end;
}

.per-point-form {
  grid-template-columns: 1fr 86px 96px 150px;
  border-bottom: 1px solid var(--line);
  background: #fbfdfb;
}

.rule-bulk-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 18px 18px 10px;
  margin-bottom: 8px;
}

.rule-bulk-actions button {
  min-height: 38px;
  border-radius: 6px;
  font-weight: 900;
}

.rules-list,
.gift-list {
  display: grid;
  gap: 10px;
  padding: 0 18px 18px;
}

.rule-card,
.gift-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.rule-card {
  grid-template-columns: 22px 72px 1fr auto;
  align-items: center;
}

.rule-card-fixed {
  grid-template-columns: 72px 1fr auto;
}

.rule-card .rule-check {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.threshold-pill {
  display: grid;
  place-items: center;
  min-height: 52px;
  border-radius: 6px;
  background: #eef7f3;
  color: var(--accent);
  font-weight: 900;
}

.rule-card p,
.gift-card p {
  margin: 0;
}

.meta {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.segmented-control {
  display: flex;
  min-width: 176px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f7f4;
}

.segmented-control button {
  flex: 1;
  min-height: 32px;
  border-color: transparent;
  background: transparent;
}

.segmented-control button.active {
  background: #fff;
  box-shadow: 0 3px 10px rgba(31, 37, 40, 0.08);
}

.gift-card {
  grid-template-columns: auto 1fr;
  align-items: start;
}

.gift-panel {
  grid-column: 2;
}

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

.settings-grid .panel:last-child {
  grid-column: 1 / -1;
}

.settings-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.settings-action-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 8px;
}

.settings-action-row select {
  width: 100%;
}

.settings-action-row button {
  min-height: 42px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.settings-form button,
.settings-wide-button {
  min-height: 44px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.binding-card {
  display: grid;
  gap: 6px;
  margin: 0 18px 18px;
  border-radius: 8px;
  background: #f5f7f4;
  padding: 14px;
}

.binding-card span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.binding-card strong {
  overflow-wrap: anywhere;
}

.settings-wide-button {
  width: calc(100% - 36px);
  margin: 0 18px 18px;
  border: 1px solid var(--line);
  background: #fff;
  color: #a8372a;
}

.danger-button {
  min-height: 42px;
  color: #a8372a;
}

.gift-check {
  width: 24px;
  height: 24px;
  margin-top: 4px;
  accent-color: var(--accent);
}

.gift-main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.gift-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.gift-title-row strong {
  overflow-wrap: anywhere;
  font-size: 1.04rem;
}

.status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.76rem;
  font-weight: 900;
}

.status.pending {
  background: #eaf4ff;
  color: var(--blue);
}

.status.done {
  background: #edf6ec;
  color: var(--accent);
}

.status.expired {
  background: #fff2dc;
  color: #9b5e00;
}

.gift-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gift-info span {
  border-radius: 6px;
  background: #f5f7f4;
  color: var(--muted);
  padding: 7px 9px;
  font-size: 0.84rem;
  font-weight: 750;
}

.gift-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gift-actions button[data-action="extend"] {
  border-color: rgba(240, 185, 75, 0.55);
  color: #8b5707;
}

.calendar-link,
.calendar-button {
  display: inline-grid;
  min-height: 38px;
  place-items: center;
  border: 1px solid rgba(78, 127, 191, 0.45);
  border-radius: 6px;
  background: #fff;
  color: var(--blue);
  padding: 0 12px;
  font-weight: 800;
  text-decoration: none;
}

.calendar-button:disabled {
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(28, 35, 36, 0.36);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(420px, 100%);
  max-width: calc(100vw - 36px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(31, 42, 43, 0.22);
  padding: 24px;
  overflow: hidden;
}

.modal-panel h2 {
  margin: 0 0 10px;
}

.modal-panel label {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  color: var(--muted);
  font-weight: 850;
}

.modal-panel input,
.modal-panel select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.modal-panel input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions-three {
  grid-template-columns: 0.8fr 1.3fr 1.3fr;
}

.modal-actions button {
  min-height: 44px;
  border-radius: 6px;
  font-weight: 900;
}

.modal-actions button:last-child {
  background: var(--ink);
  color: #fff;
}

.rule-card button {
  color: #a8372a;
}

.empty-state {
  display: grid;
  gap: 6px;
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 1.1rem;
}

.completed {
  opacity: 0.66;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 24px, 680px);
    padding-top: 18px;
  }

  .topbar {
    align-items: end;
  }

  .topbar-side {
    align-items: end;
  }

  .account-panel {
    align-items: flex-end;
    flex-direction: column;
    max-width: 100%;
  }

  .account-actions,
  select {
    width: 100%;
  }

  .point-badge {
    min-width: 104px;
  }

  .point-badge span {
    font-size: 2.5rem;
  }

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

  .controls-panel {
    grid-row: auto;
    position: static;
  }

  .gift-panel {
    grid-column: auto;
  }

  .rule-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .rule-form button {
    grid-column: 1 / -1;
  }

  .modal-actions-three {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .topbar > div:first-child {
    grid-column: 1 / -1;
  }

  .topbar-side {
    grid-column: 1 / -1;
    justify-items: stretch;
    width: 100%;
  }

  .account-panel {
    justify-content: flex-start;
    text-align: left;
  }

  .point-badge {
    aspect-ratio: auto;
    width: 100%;
    min-height: 96px;
    border-radius: 8px;
  }

  .install-button {
    justify-self: end;
  }

  .section-heading,
  .gift-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented-control {
    width: 100%;
  }

  .tab-bar {
    position: sticky;
    top: 0;
    z-index: 2;
  }

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