:root {
  color-scheme: light;
  font-family: Geist, "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  --ink: #163336;
  --bg: #f4f7f4;
  --deep: #112f33;
  --accent: #176451;
  --soft: #e1f4ec;
  --surface: #eef6f2;
  --mint: #a1ebc7;
  --mint-hover: #b6f2d5;
  --muted: #4c6666;
  --line: #d5e2df;
  --shadow: 0 10px 32px #1738310d;
  --ease-out: cubic-bezier(.2,.7,.2,1);
  color: var(--ink);
  background: var(--bg);
  accent-color: var(--accent);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(ellipse at 75% 0%, #dbf2e8, transparent 560px);
}
main {
  width: min(100% - max(28px,env(safe-area-inset-left) + env(safe-area-inset-right) + 24px), 600px);
  margin: 0 auto;
  padding: max(clamp(18px, 6vh, 56px),env(safe-area-inset-top) + 8px) 0 32px;
}
h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: clamp(23px, 5vw, 30px); font-weight: 750; line-height: 1.2; }
h2 { font-size: 18px; }

.page-header, .dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  min-height: 108px;
  padding: 20px clamp(16px, 4vw, 26px);
  border: 1px solid #294d4d;
  border-radius: 22px;
  color: #effbf7;
  background: linear-gradient(116deg, var(--deep) 25%, #1b514c);
  box-shadow: 0 12px 32px #112f3324;
}
.page-header::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: radial-gradient(circle at 89% 0%, #a1ebc732 0, transparent 54%),
    repeating-radial-gradient(circle at 91% -36%, #bbffe120 0 1px, transparent 1px 25px);
}
.page-header h1 { display: flex; align-items: center; gap: 11px; }
.service-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--mint);
  color: var(--deep);
}
.service-mark::before {
  content: "";
  width: 13px;
  height: 19px;
  border: 2px solid currentColor;
  border-radius: 4px;
}
.service-mark::after {
  content: "";
  position: absolute;
  bottom: 11px;
  width: 5px;
  height: 1.5px;
  border-radius: 1px;
  background: currentColor;
}
.page-header .secondary {
  min-height: 42px;
  border-color: #a1ebc76b;
  background: #ffffff14;
  color: #effbf7;
}
.page-header .secondary:hover { background: #ffffff24; }

nav {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 4px;
  padding: 5px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 2px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}
nav a:is([aria-current],:hover) { background: var(--soft); color: var(--accent); }
.tab-icon { display: inline-block; position: relative; width: 18px; height: 18px; flex: none; }
.tab-icon::before, .tab-icon::after { content: ""; position: absolute; border-radius: 3px; }
.tab-card::before { inset: 3px 0; border: 1.5px solid currentColor; }
.tab-card::after { inset: 7px 2px auto; height: 1.5px; background: currentColor; }
.tab-order::before { inset: 0 2px; border: 1.5px solid currentColor; }
.tab-order::after { inset: 5px 6px auto; height: 1.5px; background: currentColor; box-shadow: 0 4px currentColor; }
.tab-phone::before { inset: 0 3px; border: 1.5px solid currentColor; }
.tab-phone::after { inset: auto 7px 4px; height: 1.5px; background: currentColor; }

.panel, dialog {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
}
.panel { margin-top: 16px; padding: clamp(16px, 4vw, 28px); box-shadow: var(--shadow); }
form { display: grid; gap: 16px; }
.redeem-devices { display: grid; gap: 10px; min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.redeem-devices legend { font-weight: 650; }
.redeem-devices summary { cursor: pointer; color: var(--accent); }
.redeem-devices details > label { margin-top: 10px; }
.renew-choices { display: grid; gap: 6px; max-height: 220px; overflow: auto; }
.renew-choices label { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-weight: 400; }
.renew-choices input[type="checkbox"] { flex: none; width: 18px; min-height: 18px; }
#renew-device-message { color: var(--muted); overflow-wrap: anywhere; }
label { display: grid; gap: 7px; font-weight: 600; }
input, textarea, select, button { font: inherit; }
input, textarea, select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfefc;
  color: var(--ink);
  font-weight: 400;
}
textarea { resize: vertical; }
:is(button,nav a) { touch-action: manipulation; }
input::placeholder, textarea::placeholder { color: #637875; }
input:is(:focus-visible), select:is(:focus-visible), textarea:is(:focus-visible) {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #17645123;
}
button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 650;
  cursor: pointer;
}
.primary { background: var(--mint); color: #173831; border-color: #8ed9b3; box-shadow: 0 3px 8px #17645118; }
.primary:hover { background: var(--mint-hover); }
.secondary { border-color: var(--line); background: #fff; color: var(--accent); }
.secondary:hover { background: var(--soft); }
button:disabled { opacity: .6; cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.page-header :focus-visible { outline-color: var(--mint); }

.notice {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--accent);
  overflow-wrap: anywhere;
}
.notice.error { background: #fff0ee; color: #922718; }
.result {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.result p, .result li { line-height: 1.55; }
.result dl, #contact-details { display: grid; gap: 9px; }
.result dl > div, #contact-details > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 10px; }
.result dt, #contact-details dt { color: var(--muted); }
.result dd, #contact-details dd { min-width: 0; overflow-wrap: anywhere; }
.result ul { display: grid; gap: 6px; margin: 0; padding-inline-start: 22px; }
.result button { justify-self: start; }
.device-help { color: var(--muted); line-height: 1.55; margin-bottom: 16px; }
.device-card { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.device-card h3 { margin: 0; font-size: 16px; }
.shop-claim-form { margin-top: 16px; }
.shop-device-choices { min-width: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; }
.shop-device-choices legend { padding-inline: 4px; color: var(--muted); }
.shop-device-choices label { grid-template-columns: auto 1fr; align-items: center; min-height: 46px; padding: 6px; }
.shop-device-choices label + label { border-top: 1px solid var(--line); }
.shop-device-choices input { width: 19px; min-height: 19px; accent-color: var(--accent); }
.shop-device-choices small { display: block; color: var(--muted); font-weight: 400; }
#shop-claim-result a { color: var(--accent); }

dialog {
  width: min(100% - 32px, 440px);
  max-height: 86vh;
  max-height: 86dvh;
  padding: 20px;
  color: inherit;
  box-shadow: 0 24px 68px #112f3340;
  overscroll-behavior: contain;
}
dialog::backdrop { background: #112f3370; }
#contact-details { margin-top: 14px; }
#contact-details button { min-height: 34px; padding: 4px 9px; }
#contact-details a { color: var(--accent); }
#contact-message { margin-top: 8px; color: var(--muted); }

@keyframes portal-arrive {
  from { opacity: .5; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}
@keyframes portal-sheet-arrive {
  from { opacity: .75; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}
@keyframes portal-backdrop-arrive { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: no-preference) {
  :is(button, nav a) {
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 180ms ease, transform 150ms var(--ease-out);
  }
  :is(button:not(:disabled), nav a):active { transform: scale(.965); }
  .panel:not([hidden]), .result:not([hidden]), form#query, dialog[open] {
    animation: portal-arrive 240ms var(--ease-out) both;
  }
  dialog[open]::backdrop { animation: portal-backdrop-arrive 180ms ease both; }
}
@media (max-width: 640px) {
  main {
    padding-top: max(18px,env(safe-area-inset-top) + 8px);
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }
  .page-header { min-height: 92px; padding-block: 16px; }
  .page-header .secondary { font-size: 14px; padding-inline: 10px; }
  nav {
    position: fixed;
    z-index: 2;
    inset: auto max(10px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));
    width: min(100% - 20px, 510px);
    margin: 0 auto;
    border-radius: 19px;
    background: #fffffff5;
    box-shadow: 0 8px 32px #112f3324;
  }
  nav a { flex-direction: column; gap: 3px; min-height: 49px; border-radius: 13px; font-size: 12px; }
  dialog {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    max-height: 84vh;
    max-height: 84dvh;
    margin: 0;
    padding: 18px max(16px,env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left));
    border-radius: 22px 22px 0 0;
  }
  #contact-details button { min-height: 44px; }
  @media (prefers-reduced-motion: no-preference) {
    dialog[open] { animation-name: portal-sheet-arrive; }
  }
}
