/* ============================================================
   SimpGate API — app.css
   Apple-style design system
   ============================================================ */

/* ---- Variables ---- */
:root {
  --blue:           #0071e3;
  --blue-hover:     #0077ed;
  --blue-dark:      #005bbf;
  --bg:             #F8F8F8;
  --white:          #ffffff;
  --text:           #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary:  #aeaeb2;
  --border:         #e5e5ea;
  --danger:         #ff3b30;
  --success:        #34c759;
  --card-radius:    14px;
  --btn-radius:     980px;
  --shadow-card:    0 2px 12px rgba(0, 0, 0, 0.06), 0 0 0 1px var(--border);
  --font:           "PingFang SC", "PingFang TC", "PingFang HK", "Heiti SC", -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --transition:     0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--blue);
  text-decoration: none;
}

button {
  font-family: var(--font);
  cursor: pointer;
}

input, select, textarea {
  font-family: var(--font);
}

/* ---- Mobile warning ---- */
.mobile-warning {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20000;
  background: var(--bg);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  gap: 16px;
}

.mobile-warning .mw-icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 8px;
}

.mobile-warning h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

.mobile-warning p {
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 280px;
}

/* Only the admin table page requires desktop; home, login & user are responsive */
@media (max-width: 768px) {
  #page-admin .mobile-warning {
    display: flex;
  }
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: var(--btn-radius);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
  border: 1.5px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
  user-select: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.btn-primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.btn-primary:active {
  background: #004aad;
}

.btn-secondary {
  background: var(--white);
  color: var(--blue);
  border-color: var(--blue);
}

.btn-secondary:hover {
  background: var(--blue);
  color: #fff;
}

.btn-secondary:active {
  background: var(--blue-dark);
  color: #fff;
}

/* Signed-in (today) state: solid gray, non-interactive */
.btn-signed,
.btn-signed:hover,
.btn-signed:disabled {
  background: #e8e8ed;
  color: #8e8e93;
  border-color: #e8e8ed;
  opacity: 1;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--white);
  color: var(--text);
}

.btn-danger {
  background: var(--white);
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 7px 16px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 17px;
}

/* Arrow icon button (login step button) */
.btn-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--text-tertiary);
  color: #fff;
  border: none;
  flex-shrink: 0;
  transition: background var(--transition), transform 0.12s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.12s ease;
}

.btn-arrow:hover {
  background: var(--blue);
}

.btn-arrow.active {
  background: var(--blue);
}

.btn-arrow svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* ---- Cards ---- */
.card {
  background: var(--white);
  border-radius: var(--card-radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  padding: 24px;
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.card + .card {
  margin-top: 16px;
}

/* ---- Floating label input ---- */
.float-field {
  position: relative;
  width: 100%;
}

.float-field input {
  width: 100%;
  height: 56px;
  padding: 22px 16px 8px;
  font-size: 16px;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--border);
  outline: none;
  transition: border-color var(--transition);
  border-radius: 0;
}

.float-field input::placeholder {
  color: transparent;
}

.float-field input:focus {
  border-bottom-color: var(--blue);
}

.float-field label {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-secondary);
  pointer-events: none;
  transition: top 0.18s ease, font-size 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.float-field input:focus ~ label,
.float-field input:not(:placeholder-shown) ~ label {
  top: 10px;
  transform: none;
  font-size: 11px;
  color: var(--blue);
  font-weight: 500;
}

.float-field input:not(:focus):not(:placeholder-shown) ~ label {
  color: var(--text-tertiary);
}

/* ---- Divider with text ---- */
.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.divider-text span {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ---- Toast notification ---- */
.toast-wrap {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 18px;
  border-radius: var(--btn-radius);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  /* liquid glass */
  background: rgba(28, 28, 32, 0.42);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow:
    0 10px 32px rgba(0, 0, 0, 0.26),
    inset 0 1px 1px rgba(255, 255, 255, 0.38),
    inset 0 -1px 2px rgba(255, 255, 255, 0.08);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.16);
  pointer-events: auto;
  animation: toastIn 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.toast-success { background: rgba(40, 175, 95, 0.40); }
.toast.toast-error   { background: rgba(220, 70, 60, 0.40); }

.toast-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
  margin-left: 1px;
}

.toast.toast-bump { animation: toastBump 0.3s ease; }
.toast.toast-out  { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastBump {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px) scale(0.96); }
}

/* ---- Modal dialog ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 7000;
  /* Glassmorphism: blur + dim the page behind the prompt */
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease forwards;
}

.modal {
  /* frosted glass card */
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  padding: 28px 28px 24px;
  max-width: 400px;
  width: 90%;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.22),
    inset 0 1px 1px rgba(255, 255, 255, 0.85);
  animation: scaleIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.modal-body {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

/* ============================================================
   PAGE TRANSITION — JIEJOE-style vertical column wave wipe
   ============================================================ */

.page-transition {
  position: fixed;
  inset: 0;
  /* Above the toast (8000) so the wipe covers any lingering toast on navigation. */
  z-index: 9000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  background: transparent;
}

/* horizontal bands stacked top-to-bottom, sliding in from the left */
.transition-col {
  position: relative;
  flex: 1 1 0;
  width: 100%;
  background: #030303;
  /* extend 1px top & bottom so adjacent bands overlap — no sub-pixel seams */
  box-shadow: 0 1px 0 0 #030303, 0 -1px 0 0 #030303;
  transform: translateX(-101%);
}

/* thin glowing blue leading edge on the right of each band */
.transition-col::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 2px;
  background: #0071e3;
  box-shadow:
    0 0 12px 1px rgba(0, 113, 227, 0.85),
    0 0 26px 3px rgba(0, 113, 227, 0.4);
  opacity: 0;
}

.page-transition.is-active,
.page-transition.is-entering {
  visibility: visible;
}

/* ---- boot: arriving mid-transition, columns already covering ---- */
html.transition-boot body { background: #030303; }

html.transition-boot .home-hero,
html.transition-boot .inner-content,
html.transition-boot .login-container,
html.transition-boot .error-content {
  opacity: 0;
}

html.transition-boot .page-transition { visibility: visible; }
html.transition-boot .transition-col { transform: translateX(0); }

/* ---- page surface fade ---- */
.is-page-exiting .home-hero,
.is-page-exiting .inner-content,
.is-page-exiting .login-container,
.is-page-exiting .error-content {
  animation: pageSurfaceOut 700ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.is-page-entering .home-hero,
.is-page-entering .inner-content,
.is-page-entering .login-container,
.is-page-entering .error-content {
  animation: pageSurfaceIn 760ms cubic-bezier(0.16, 1, 0.3, 1) 140ms both;
}

/* ---- EXIT: bands sweep right to cover screen ---- */
.page-transition.is-active .transition-col {
  animation: colCover 560ms cubic-bezier(0.76, 0, 0.24, 1) forwards;
}
.page-transition.is-active .transition-col::after {
  animation: colEdge 560ms cubic-bezier(0.76, 0, 0.24, 1) forwards;
}

/* ---- ENTER: bands continue right to reveal new page ---- */
.page-transition.is-entering .transition-col {
  transform: translateX(0);
  animation: colReveal 560ms cubic-bezier(0.76, 0, 0.24, 1) forwards;
}
.page-transition.is-entering .transition-col::after {
  animation: colEdge 560ms cubic-bezier(0.76, 0, 0.24, 1) forwards;
}

/* staggered delays — top-to-bottom wave */
.page-transition .transition-col:nth-child(1),
.page-transition .transition-col:nth-child(1)::after { animation-delay: 0ms; }
.page-transition .transition-col:nth-child(2),
.page-transition .transition-col:nth-child(2)::after { animation-delay: 70ms; }
.page-transition .transition-col:nth-child(3),
.page-transition .transition-col:nth-child(3)::after { animation-delay: 140ms; }
.page-transition .transition-col:nth-child(4),
.page-transition .transition-col:nth-child(4)::after { animation-delay: 210ms; }
.page-transition .transition-col:nth-child(5),
.page-transition .transition-col:nth-child(5)::after { animation-delay: 280ms; }
.page-transition .transition-col:nth-child(6),
.page-transition .transition-col:nth-child(6)::after { animation-delay: 350ms; }

@keyframes colCover {
  from { transform: translateX(-101%); }
  to   { transform: translateX(0); }
}

@keyframes colReveal {
  from { transform: translateX(0); }
  to   { transform: translateX(101%); }
}

@keyframes colEdge {
  0%   { opacity: 0; }
  35%  { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes pageSurfaceOut {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-10px) scale(0.975); }
}

@keyframes pageSurfaceIn {
  0%   { opacity: 0; transform: translateY(10px) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}


/* ============================================================
   HOMEPAGE
   ============================================================ */

#page-home {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.home-hero {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(32px, 5vh, 60px) 0 clamp(14px, 2.5vh, 28px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: hidden;
  background: var(--bg);
}

.home-hero h1 {
  margin: 0;
  font-size: clamp(3.2rem, 8vw, 5.7rem);
  font-weight: 700;
  letter-spacing: 0;
  color: var(--text);
  line-height: 1.02;
}

.home-hero .subtitle,
#homeSubtitle {
  margin: 10px 0 0;
  max-width: 680px;
  color: var(--text-secondary);
  font-size: clamp(1.1rem, 2.2vw, 1.6rem);
  line-height: 1.24;
  font-weight: 400;
  min-height: 1.5em;
}

.home-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 20px;
}

/* Language toggle — small liquid-glass pill, fixed top-right. Kept below the
   page-transition wipe (9000) and toast (8000) so the black wipe covers it when
   leaving the homepage; it's only needed on the (desktop) homepage anyway. */
.lang-toggle {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 200;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.75);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78) 0%, rgba(255, 255, 255, 0.42) 60%, rgba(255, 255, 255, 0.55) 100%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.06),
    inset 0 1px 1px rgba(255, 255, 255, 0.9);
  transition: color 0.2s ease, box-shadow 0.3s ease,
              transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lang-toggle:hover {
  transform: translateY(-2px) scale(1.06);
  color: var(--blue);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.1),
    0 0 18px 2px rgba(255, 255, 255, 0.9),
    inset 0 1px 2px rgba(255, 255, 255, 1);
}

.lang-toggle:active {
  transform: translateY(0) scale(0.96);
}

/* every language toggle holds the translate glyph, centered */
[data-lang-toggle] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
[data-lang-toggle] svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* language dropdown menu (opened by the translate icon) */
.sg-lang-menu {
  position: fixed;
  z-index: 9500;
  min-width: 132px;
  padding: 6px;
  border-radius: 14px;
  display: none;
  flex-direction: column;
  gap: 2px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.8));
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.14),
    inset 0 1px 1px rgba(255, 255, 255, 0.9);
}
.sg-lang-menu.open {
  display: flex;
  animation: sgLangIn 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sg-lang-item {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  text-align: left;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.sg-lang-item:hover {
  background: rgba(0, 0, 0, 0.05);
}
.sg-lang-item.active {
  color: var(--blue);
  font-weight: 600;
}
@keyframes sgLangIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- AI chat ---- */
#page-chat {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.chat-wrap {
  width: min(820px, calc(100% - 32px));
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 20px;
}
.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px 4px 20px;
}
.chat-empty {
  margin: auto;
  color: var(--text-tertiary);
  text-align: center;
  font-size: 15px;
}
.chat-msg {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.chat-msg.ai {
  align-self: flex-start;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}
.chat-msg.thinking { color: var(--text-tertiary); }
.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 10px 12px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05);
}
.chat-input {
  flex: 1;
  border: 0;
  resize: none;
  outline: none;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  max-height: 140px;
  background: transparent;
  color: var(--text);
}
.chat-send {
  flex-shrink: 0;
  align-self: stretch;
}

/* ---- admin AI config form ---- */
.ai-form {
  display: flex;
  flex-direction: column;
  max-width: 560px;
}
.ai-form .label-sm {
  margin-top: 14px;
}
.ai-form .ai-field {
  width: 100%;
  margin-top: 6px;
}
.ai-form .ai-token-status {
  margin-top: 8px;
  color: var(--text-tertiary);
}

/* Phone showcase — a single static product image, no entrance animation. */
.home-product {
  width: min(900px, 100%);
  margin: clamp(16px, 2.5vh, 34px) auto 0;
  display: flex;
  justify-content: center;
  overflow: visible;
  pointer-events: none;
}

.home-product-img {
  display: block;
  width: auto;
  height: auto;
  /* The image background is already #F8F8F8 (= page bg), so NO drop-shadow — a
     filter shadow would outline the opaque rectangle and create a visible seam.
     The phones' own baked-in shadow provides the depth. Capped by vh so it never
     grows tall enough to push the 备案 footer off the first screen. */
  max-width: 100%;
  max-height: min(62vh, 660px);
  object-fit: contain;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

#page-login {
  background: var(--white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.login-back-btn {
  position: absolute;
  top: 20px;
  left: 24px;
  z-index: 10;
}

.login-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 24px 60px;
}

.login-box {
  width: 100%;
  max-width: 420px;
}

.login-box h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 32px;
  text-align: center;
}

.login-step {
  margin-bottom: 0;
}

.login-step-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.login-step-row .float-field {
  flex: 1;
}

/* ---- Apple Store style combined login box ---- */
.apple-login-box {
  border: 1px solid #c7c7cc;
  border-radius: 12px;
  background: var(--white);
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

/* Apple blue focus ring on the whole box when any field is focused */
.apple-login-box:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18);
}

/* OTP section: collapsed initially, silky reveal/retract via grid-template-rows.
   Animating 0fr -> 1fr gives buttery-smooth auto-height with no magic numbers. */
.apple-otp-wrap {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.44s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.34s ease;
}

.apple-otp-wrap.show {
  grid-template-rows: 1fr;
  opacity: 1;
}

.apple-otp-inner {
  overflow: hidden;
  min-height: 0;
  transform: translateY(-6px);
  transition: transform 0.44s cubic-bezier(0.22, 1, 0.36, 1);
}

.apple-otp-wrap.show .apple-otp-inner {
  transform: translateY(0);
}

.apple-field {
  position: relative;
}

.apple-field input {
  width: 100%;
  height: 58px;
  padding: 24px 18px 8px;
  font-size: 16px;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  border-radius: 0;
}

.apple-field.has-action input {
  padding-right: 60px;
}

.apple-field input::placeholder {
  color: transparent;
}

.apple-field label {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-secondary);
  pointer-events: none;
  transition: top 0.16s ease, font-size 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.apple-field input:focus ~ label,
.apple-field input:not(:placeholder-shown) ~ label {
  top: 11px;
  transform: none;
  font-size: 11px;
  color: var(--text-tertiary);
}

.apple-field-divider {
  height: 1px;
  background: #c7c7cc;
  margin: 0;
}

.apple-field .btn-arrow {
  position: absolute;
  right: 14px;
  top: 50%;
  margin-top: -15px;            /* centered (30px button); margin keeps transform free */
  width: 30px;
  height: 30px;
  border: 1.5px solid #c7c7cc;  /* gray ring */
  background: transparent;       /* transparent center */
  color: #8e8e93;               /* gray arrow */
  transition: border-color var(--transition),
              color var(--transition),
              margin-top 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.12s cubic-bezier(0.4, 0, 0.2, 1);
}

/* While the user is typing (label floated up), drop the button down to follow the text */
.apple-field input:focus ~ .btn-arrow,
.apple-field input:not(:placeholder-shown) ~ .btn-arrow {
  margin-top: -6px;
}

.apple-field .btn-arrow svg {
  width: 15px;
  height: 15px;
}

/* ready state: blue ring + blue arrow, center stays transparent */
.apple-field .btn-arrow:hover,
.apple-field .btn-arrow.active {
  border-color: var(--blue);
  color: var(--blue);
  background: transparent;
}

/* Apple-style tactile press: sink down a touch + slight shrink */
.apple-field .btn-arrow:active,
.apple-field .btn-arrow.pressed {
  transform: translateY(3px) scale(0.9);
}

.login-error {
  font-size: 13px;
  color: var(--danger);
  margin-top: 10px;
  min-height: 18px;
  text-align: center;
}

.qr-area {
  margin-top: 28px;
  text-align: center;
}

.qr-frame {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 200px;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  margin-bottom: 12px;
}

.qr-frame canvas,
.qr-frame img {
  width: 180px;
  height: 180px;
  display: block;
}

.qr-status {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.qr-hint {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ============================================================
   USER PAGE
   ============================================================ */

#page-user {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   ADMIN PAGE
   ============================================================ */

#page-admin {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Shared inner-page layout ---- */
.inner-header {
  background: #fbfbfd;
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.inner-header-spacer {
  flex: 1;
}

.inner-content {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 32px 80px;
  flex: 1 0 auto;            /* fill height so the footer sits at the bottom */
}

.inner-content.wide {
  max-width: 1100px;
}

.page-heading h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 6px;
}

.page-heading p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

/* Token display */
.token-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 16px;
}

.token-value {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  word-break: break-all;
  flex: 1;
  letter-spacing: 0.01em;
}

.quota-number {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  margin: 4px 0 20px;
}

/* ---- User page: mobile adaptation ---- */
@media (max-width: 768px) {
  .inner-header {
    padding: 0 14px;
    gap: 8px;
  }

  .inner-content {
    padding: 28px 16px 60px;
  }

  .page-heading h1 {
    font-size: 28px;
  }

  .page-heading p {
    margin-bottom: 24px;
  }

  #page-user .card {
    padding: 18px 16px;
  }

  /* token: stack value above a right-aligned copy button for easy tapping */
  .token-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .token-row .btn {
    align-self: flex-end;
  }

  /* keep the captcha widget from overflowing narrow cards */
  #captcha-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---- Admin table ---- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--card-radius);
  border: 1px solid var(--border);
  background: var(--white);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead tr {
  background: #fafafa;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: #fafafa;
}

.data-table .mono {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.badge-yes { background: #e8f9ee; color: #1a8a3a; }
.badge-no  { background: #f2f2f7; color: var(--text-secondary); }

/* Inline edit form */
.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-input {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  outline: none;
  min-width: 100px;
  transition: border-color var(--transition);
}

.inline-input:focus {
  border-color: var(--blue);
}

/* ============================================================
   ERROR PAGES (404 / 403)
   ============================================================ */

#page-error {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.error-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto;              /* center vertically, leaving the footer at the bottom */
  padding: 40px 24px;
  text-align: center;
}

.error-code {
  font-size: 96px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
  margin-bottom: 8px;
}

.error-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.error-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ============================================================
   SITE FOOTER (ICP / 公安备案)
   ============================================================ */
.site-footer {
  display: flex;
  justify-content: center;
  width: 100%;
  flex-shrink: 0;            /* never get squeezed in flex-column layouts */
  margin-top: auto;          /* stick to the bottom when content is short */
  padding: 26px 16px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-secondary);
  background: transparent;
}

/* Liquid-glass capsule */
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 12px;
  max-width: 900px;
  padding: 11px 24px;
  border-radius: 980px;
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0.32) 58%, rgba(255, 255, 255, 0.46) 100%);
  -webkit-backdrop-filter: blur(24px) saturate(200%) brightness(1.07);
  backdrop-filter: blur(24px) saturate(200%) brightness(1.07);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow:
    0 6px 22px rgba(0, 0, 0, 0.07),
    inset 0 1.5px 1px rgba(255, 255, 255, 0.95),
    inset 0 -6px 14px rgba(255, 255, 255, 0.30);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Homepage: the phone showcase emerges from the hero bottom; pull the footer
   up so the glass pill nestles right under the phones (no empty seam). */
#page-home .site-footer {
  margin-top: 0;
  padding-top: 16px;
}

/* hover → the glass capsule lifts and lights up. A plain white glow is
   invisible against the near-white page, so the visible cues are the lift +
   deeper drop shadow + a brighter, whiter glass; the white halo is the accent. */
/* static glass capsule — gentle brighten on hover, no movement/bounce */
.footer-inner:hover {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86) 0%, rgba(255, 255, 255, 0.48) 60%, rgba(255, 255, 255, 0.6) 100%);
  border-color: rgba(255, 255, 255, 0.95);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.09),
    inset 0 1.5px 2px rgba(255, 255, 255, 1),
    inset 0 -6px 14px rgba(255, 255, 255, 0.35);
}

.footer-link {
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color 0.18s ease;
  white-space: nowrap;
}

.footer-link:hover {
  color: var(--blue);
}

.footer-separator {
  color: var(--border);
}

.footer-copyright {
  color: var(--text-tertiary);
  white-space: nowrap;
}

.site-name {
  font-weight: 500;
}

.police-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.police-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  vertical-align: middle;
}

@media (max-width: 768px) {
  .site-footer {
    padding: 20px 16px;
  }
  .footer-inner {
    flex-direction: column;
    gap: 5px;
    padding: 14px 22px;
    border-radius: 18px;     /* rounded card when stacked */
  }
  .footer-separator {
    display: none;          /* cleaner stacked layout on mobile */
  }
}

/* ============================================================
   UTILITIES
   ============================================================ */

.section-gap {
  margin-top: 28px;
}

.label-sm {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.text-sm { font-size: 13px; }
.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

.flex-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.flex-wrap {
  flex-wrap: wrap;
}

.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

/* Spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(0,113,227,0.2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Captcha container */
#captcha-container {
  margin: 16px 0;
}

/* ============================================================
   RESPONSIVE — home & login adapt to mobile (like reference 图2)
   ============================================================ */
@media (max-width: 768px) {
  .home-hero {
    width: calc(100% - 32px);
    padding-top: 44px;
  }

  .home-hero h1 {
    font-size: clamp(2.6rem, 13vw, 3.6rem);
  }

  .home-hero .subtitle,
  #homeSubtitle {
    font-size: clamp(1rem, 4.4vw, 1.25rem);
    padding: 0 8px;
  }

  /* center the showcase image and size it to the viewport */
  .home-product {
    width: 100%;
    margin-top: clamp(28px, 7vh, 64px);
  }

  .home-product-img {
    max-width: 100%;
    max-height: 42vh;
  }

  /* login box adapts */
  .login-container {
    padding: 72px 20px 48px;
  }

  .login-box h2 {
    font-size: 24px;
  }

  .login-back-btn {
    top: 14px;
    left: 14px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
