/* 品牌色、字型、留白與圓角可從這裡調整。 */
:root {
  --paper: #faf8f4;
  --white: #fffcf9;
  --card: #fffcfa;
  --ink: #332a3b;
  --muted: #645a6a;
  --accent: #694f78;
  --deep: #523760;
  --line: #dcd4db;
  --pale: #f4eff5;
  --lavender: #ece2f2;
  --band: #ede6ed;
  --stamp: #e2d3e9;
  --sand: #f6e7d8;
  --sand-ink: #755238;
  --unpaid-bg: #ffebc8;
  --unpaid-ink: #7b420c;
  --success: #3d614e;
  --error: #96394c;
  --shade: rgba(49,35,57,.36);
  --shadow: 0 18px 64px rgba(51,36,59,.19);
  --header-bg: #fdfbf8;
  --hover: #fcf9fd;
  --focus: #694685;
  --max: 1120px;
  --radius: 19px;
  --serif: "Baskervville","Noto Serif TC","Noto Serif CJK TC","Songti TC","PMingLiU",Georgia,serif;
  --sans: "DM Sans",Inter,"Noto Sans TC","Noto Sans CJK TC","PingFang TC","Microsoft JhengHei",Arial,sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden],.symbols {
  display: none!important;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

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

button,select {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  background: transparent;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.icon {
  height: 20px;
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

#sheet {
  container-type: inline-size;
  max-width: 100%;
  margin: auto;
  background: var(--paper);
  min-height: 80vh;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

body.phone #sheet {
  max-width: 414px;
  box-shadow: 0 0 0 1px var(--line);
}

body.phone {
  background: var(--band);
}

/* App WebView：原生已有頂欄，勿再疊 safe-area；隱藏回首頁 */
body.app-webview .home-link {
  display: none !important;
}
body.app-webview .masthead {
  padding-top: 0 !important;
}
body.app-webview .mast-inner {
  min-height: 48px;
  padding-block: 4px;
}
body.app-webview .hero {
  margin-top: 8px;
}

.wrap {
  width: min(calc(100% - 88px),var(--max));
  margin-inline: auto;
}

.skip {
  position: fixed;
  z-index: 8;
  top: 8px;
  left: 8px;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  background: var(--white);
}

.skip:focus {
  clip-path: none;
  width: auto;
  height: auto;
  padding: 10px;
}

.masthead {
  padding-top: env(safe-area-inset-top);
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
}

.mast-inner,.brand,.home-link,.account,.section-head,.pill,.foot,.dialog-top,.review-inner,.review-controls,.review-brand {
  display: flex;
  align-items: center;
}

.mast-inner,.section-head,.dialog-top,.review-inner {
  justify-content: space-between;
  gap: 16px;
}

.mast-inner {
  min-height: 77px;
}

.brand {
  gap: 12px;
}

.brand img {
  border-radius: 13px;
}

.brand strong,.brand em {
  display: block;
}

.brand strong {
  font: 600 20px/1.2 var(--serif);
  letter-spacing: .04em;
}

.brand em {
  font: italic 12px/1.55 "Kaiti TC","BiauKai","KaiTi",cursive;
  color: var(--accent);
  letter-spacing: .08em;
}

.home-link {
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  min-height: 44px;
}

.home-link .icon {
  width: 16px;
}

.home-link:hover {
  color: var(--deep);
}

.hero {
  display: grid;
  grid-template-columns: 1fr 1.09fr;
  gap: clamp(24px,6vw,78px);
  align-items: center;
  margin: 32px 0 28px;
}

.hero-copy {
  padding: 8px 0;
}

h1,h2,p {
  margin: 0;
}

h1,h2 {
  font-family: var(--serif);
}

h1 {
  font-size: clamp(38px,4.2vw,57px);
  line-height: 1.18;
  font-weight: 600;
  margin: 0 0 10px;
  letter-spacing: .015em;
  text-wrap: balance;
}

html:lang(en) h1 {
  letter-spacing: -.035em;
}

.lede {
  font-size: 17px;
  color: var(--muted);
}

.account {
  margin-top: 20px;
  gap: 8px;
  font-size: .9375rem;
  color: var(--muted);
}

.account span {
  white-space: nowrap;
}

.account b {
  min-width: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.account .icon {
  width: 15px;
  height: 15px;
}

.hero-art {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--lavender);
}

.hero-art img {
  width: 100%;
  height: clamp(190px,18.5vw,244px);
  object-fit: cover;
  object-position: 50% 48%;
  display: block;
}

.gift {
  position: relative;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 22px;
  padding: 19px 27px;
  background: linear-gradient(106deg,var(--lavender),var(--pale));
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.gift .pill::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.stamp,.receipt-icon {
  display: grid;
  place-items: center;
  color: var(--accent);
}

.stamp {
  height: 60px;
  width: 60px;
  border-radius: 50%;
  background: var(--stamp);
  outline: 1px dashed var(--accent);
  outline-offset: -6px;
}

.stamp .icon {
  width: 29px;
  height: 29px;
}

.above {
  font-size: 11px;
  letter-spacing: .1em;
  font-weight: bold;
  color: var(--accent);
  margin-bottom: 1px;
}

.gift h2 {
  font-size: 25px;
  line-height: 1.4;
  font-weight: 600;
}

.gift-copy>p:last-child {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.pill {
  min-height: 44px;
  gap: 10px;
  justify-content: center;
  border-radius: 30px;
  padding: 9px 18px;
  font-weight: 600;
  font-size: 14px;
}

.soft {
  background: var(--white);
  color: var(--deep);
  border: 1px solid var(--line);
}

.primary {
  background: var(--accent);
  color: var(--white);
  border: 1px solid var(--accent);
}

.primary:hover {
  background: var(--deep);
}

.soft:hover {
  border-color: var(--accent);
}

.pill .icon {
  width: 16px;
}

.pill:disabled {
  opacity: .65;
  cursor: wait;
}

.plans {
  margin-top: 34px;
}

.section-head {
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-head h2 {
  font-size: clamp(26px,2.7vw,35px);
  font-weight: 600;
  line-height: 1.25;
}

.grouped-plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr));
  align-items: start;
  gap: 24px;
}

.plan-group {
  min-width: 0;
}

.plan-group-head {
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 10px;
  border-inline-start: 4px solid var(--accent);
  background: var(--pale);
}

.plan-group[data-group="postpaid"] .plan-group-head {
  border-color: var(--sand-ink);
  background: var(--sand);
}

.plan-group-head h3 {
  margin: 0 0 2px;
  font: 650 1.375rem/1.4 var(--serif);
}

.plan-group-head p {
  font-size: .9375rem;
  color: var(--muted);
}

.plan-note {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--sand-ink);
  background: var(--sand);
  padding: 9px 13px;
  border-radius: 10px;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(min(175px,100%),1fr));
  gap: 12px;
}

.plan {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 17px 16px;
  background: var(--card);
  transition: border-color .15s,background .15s,transform .15s;
}

.plan:hover,.plan:focus-visible {
  border-color: var(--accent);
  background: var(--hover);
  transform: translateY(-2px);
}

.plan-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 7px;
  min-height: 22px;
  margin-bottom: 8px;
  padding-right: 13px;
}

.plan-name {
  font-weight: 650;
  font-size: 14px;
  color: var(--accent);
  overflow-wrap: anywhere;
}

.best-rate {
  border-color: var(--accent);
}

.value-label {
  color: var(--deep);
  background: var(--lavender);
  border-radius: 20px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 650;
  line-height: 1.4;
}

.plan-description {
  display: block;
  color: var(--muted);
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.plan-price,.money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.plan-price {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.12;
  font-size: clamp(27px,2.5vw,35px);
  letter-spacing: -.03em;
}

.plan-price small {
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: 0;
  margin-right: 3px;
  font-weight: 600;
}

.call-time {
  display: flex;
  align-items: center;
  gap: 5px;
  border-top: 1px solid var(--line);
  width: 100%;
  padding-top: 10px;
  margin-top: 15px;
  color: var(--muted);
  font-size: 13px;
}

.call-time .icon {
  width: 15px;
  height: 15px;
}

.card-arrow {
  position: absolute;
  top: 15px;
  right: 13px;
  color: var(--accent);
  width: 15px;
  height: 15px;
}

/* 同時展開兩種付款方式，金額與通話時間靠同一條線，方便逐列比較。 */
.plan-group .plan-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.plan-group .plan {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 16px;
  grid-template-areas: "name price arrow" "copy time arrow";
  grid-template-rows: auto auto;
  align-items: center;
  gap: 3px 10px;
  padding: 14px 16px;
}

.plan-group .plan-heading {
  grid-area: name;
  padding: 0;
  margin: 0;
  min-height: 0;
}

.plan-group .plan-name {
  font-size: 1rem;
  color: var(--ink);
}

.plan-group .value-label {
  font-size: .8125rem;
}

.plan-group .plan-price {
  grid-area: price;
  justify-self: end;
  font-size: 1.625rem;
}

.plan-group .plan-price small {
  font-size: .875rem;
}

.plan-group .plan-description {
  grid-area: copy;
  margin: 0;
  align-self: start;
  font-size: .875rem;
}

.plan-group .call-time {
  grid-area: time;
  justify-self: end;
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: .9375rem;
  white-space: nowrap;
}

.plan-group .card-arrow {
  grid-area: arrow;
  position: static;
}

.history {
  margin: 22px 0 0;
}

.history button {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
}

.history button:hover {
  border-color: var(--accent);
}

.receipt-icon {
  width: 37px;
  height: 37px;
  border-radius: 11px;
  background: var(--pale);
  flex: none;
}

.history-copy {
  flex: 1;
}

.history-copy strong,.history-copy small {
  display: block;
}

.history-copy strong {
  font-size: 15px;
}

.history-copy small {
  color: var(--muted);
  font-size: 12px;
}

.arrow {
  color: var(--accent);
}

.foot {
  gap: 9px;
  justify-content: center;
  color: var(--muted);
  padding: 22px 0 max(24px,env(safe-area-inset-bottom));
  font: 13px var(--serif);
}

.sound {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 18px;
}

.sound i {
  width: 2px;
  height: 5px;
  background: var(--accent);
  border-radius: 4px;
}

.sound i:nth-child(2),.sound i:nth-child(4) {
  height: 10px;
}

.sound i:nth-child(3) {
  height: 15px;
}

#stateMessage:not(:empty) {
  padding: 12px 0;
}

.status-note,.error-text,.demo-hint {
  font-size: 14px;
}

.error-text {
  color: var(--error);
}

.error-text:not(:empty) {
  margin-top: 12px;
}

.status-note {
  padding: 12px 0;
}

.inline-action {
  min-height: 44px;
  text-decoration: underline;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
}

dialog {
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 23px 25px 25px;
  width: min(460px,calc(100% - 28px));
  max-height: 84vh;
  max-height: 84dvh;
  overflow: auto;
  background: var(--white);
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: var(--shade);
}

body:has(dialog[open]) {
  overflow: hidden;
}

.dialog-top .x {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent);
  margin: -9px -10px 0 0;
}

.x:hover {
  background: var(--pale);
}

dialog h2 {
  font-size: 27px;
  line-height: 1.35;
  margin: 13px 0;
  font-weight: 600;
}

.dialog-copy {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.7;
}

.actions {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.pay-methods {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.pay-methods > .fine {
  margin: 0 0 2px;
}

.pay-methods .pill[data-pay="WeiXin"] {
  background: #07c160;
  color: #fff;
}

.pay-methods .pill[data-pay="Credit"] {
  background: #2563eb;
  color: #fff;
}

.pay-methods .pill[data-pay="ApplePay"] {
  background: #111;
  color: #fff;
}

.details {
  border-top: 1px solid var(--line);
  margin: 12px 0;
}

.details div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}

.details dt {
  color: var(--muted);
  font-size: 13px;
}

.details dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
}

.details .total {
  color: var(--accent);
  font-size: 20px;
}

.fine,.demo-hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 7px;
}

.field {
  display: block;
  margin: 17px 0 4px;
  font-size: 14px;
  font-weight: bold;
}

.field-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  font-size: 16px;
  padding: 12px;
}

.orders {
  list-style: none;
  margin: 0;
  padding: 0;
}

.orders li {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

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

.order-line b {
  min-width: 0;
  overflow-wrap: anywhere;
}

.order-status {
  flex: none;
  font-size: .875rem;
  font-weight: 650;
  line-height: 1.45;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--band);
}

.order-status[data-status="paid"] {
  color: var(--deep);
  background: var(--pale);
}

.order-status[data-status="pending"] {
  color: var(--unpaid-ink);
  background: var(--unpaid-bg);
}

.review {
  background: var(--band);
  color: var(--deep);
  border-bottom: 1px solid var(--line);
}

.review-inner {
  width: min(calc(100% - 40px),var(--max));
  margin: auto;
  min-height: 42px;
  flex-wrap: wrap;
  gap: 2px 10px;
}

.review-brand {
  font-size: 12px;
  gap: 8px;
  font-weight: 650;
}

.review-brand:before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 100%;
  background: var(--accent);
}

.review-controls {
  gap: 8px;
}

.review-controls select {
  max-width: 100%;
  border: 0;
  background: transparent;
  font-size: 12px;
  min-height: 42px;
  padding: 3px;
  color: var(--deep);
}

.demo-tools {
  width: min(calc(100% - 36px),var(--max));
  border-top: 1px solid var(--line);
  margin: 0 auto 16px;
  color: var(--muted);
  font-size: 12px;
}

.demo-tools summary {
  cursor: pointer;
  padding: 12px 0;
  min-height: 44px;
}

.demo-tools button {
  margin-inline-end: 12px;
  color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* 四張美元方案在平板上排成兩列，方便逐欄比較。 */
@container (min-width:741px) and (max-width:960px) {
  #planGroups > .plan-grid:has(> .plan:nth-child(4):last-child) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container (max-width:740px) {
  .wrap {
    width: min(calc(100% - 40px),620px);
  }
  /* 手機／窄屏：無需「回到首頁」（App 有原生返回；官網小屏也顯冗餘） */
  .home-link {
    display: none;
  }
  .masthead {
    padding-top: max(0px, env(safe-area-inset-top));
  }
  .mast-inner {
    min-height: 52px;
    padding-block: 6px;
  }
  .brand img {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }
  .brand strong {
    font-size: 17px;
  }
  .brand em {
    font-size: 11px;
  }
  .hero {
    gap: 20px;
    grid-template-columns: 1fr .9fr;
    margin: 12px 0 16px;
  }
  .hero-art img {
    height: 164px;
  }
  .hero h1 {
    font-size: 32px;
  }
  .lede {
    font-size: 14px;
  }
  .account {
    margin-top: 12px;
  }
  .gift {
    gap: 12px;
    padding: 15px 17px;
    grid-template-columns: 45px 1fr auto;
  }
  .stamp {
    height: 43px;
    width: 43px;
  }
  .stamp .icon {
    width: 22px;
  }
  .gift h2 {
    font-size: 21px;
  }
  .gift .pill {
    font-size: 12px;
    padding: 7px 12px;
  }
  .plan-grid {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  .section-head h2 {
    font-size: 27px;
  }
  .plans {
    margin-top: 26px;
  }
  .plan-price {
    font-size: 27px;
  }
}

@container (max-width:525px) {
  .wrap {
    width: calc(100% - 28px);
  }
  .mast-inner {
    min-height: 48px;
    padding-block: 4px;
  }
  .hero {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 8px 0 12px;
  }
  .hero-copy {
    padding: 0;
  }
  .hero h1 {
    font-size: 30px;
    margin: 0 0 2px;
  }
  .hero-art {
    border-radius: 14px;
  }
  .hero-art img {
    height: 120px;
    object-position: 50% 42%;
  }
  .account {
    margin-top: 9px;
  }
  .gift {
    grid-template-columns: 42px 1fr;
    gap: 8px 12px;
    padding: 13px 15px;
    border-radius: 15px;
  }
  .gift .pill {
    grid-column: 2;
    justify-self: start;
    min-height: 44px;
  }
  .gift-copy>p:last-child {
    font-size: 12px;
  }
  .section-head {
    gap: 12px;
  }
  .plan-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .plan {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto 16px;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 0 9px;
    padding: 12px 14px;
    border-radius: 13px;
  }
  .plan-heading {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
    padding: 0;
    min-height: 0;
  }
  .plan-name, .plan-description {
    font-size: 12px;
  }
  .plan-description {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: 4px;
  }
  .plan-price {
    grid-column: 1;
    grid-row: 2;
    font-size: 25px;
  }
  .plan-price small {
    font-size: 12px;
  }
  .call-time {
    grid-column: 2;
    grid-row: 1/3;
    border: 0;
    padding: 0;
    margin: 0;
    white-space: nowrap;
    font-size: 12px;
  }
  .card-arrow {
    position: static;
    grid-row: 1/3;
    grid-column: 3;
  }
  .history {
    margin-top: 16px;
  }
  .history button {
    padding: 12px;
    gap: 10px;
  }
  .foot {
    padding-top: 18px;
  }
}

/* 視口兜底：部分 WebView 對 container query 支援不穩時仍隱藏回首頁 */
@media (max-width: 740px) {
  .home-link {
    display: none !important;
  }
}

@media(max-width:460px) {
  .review-inner {
    width: calc(100% - 28px);
  }
  .review-controls {
    gap: 2px;
  }
  .review-controls select {
    font-size: 11px;
  }
  .review-brand {
    font-size: 11px;
  }
  .review-brand:before {
    display: none;
  }
  dialog {
    padding: 18px 18px max(20px,env(safe-area-inset-bottom));
  }
}

body.phone dialog {
  max-width: 382px;
}

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