:root {
  --ink: #1a1f1c;
  --muted: #7a847e;
  --line: #e8eeea;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --accent: #1b7a55;
  --accent-soft: #e8f5ef;
  --accent-press: #146344;
  --danger: #c0392b;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(720px 420px at 50% -18%, rgba(27, 122, 85, 0.16), transparent 68%),
    linear-gradient(180deg, #eaf1ec 0%, #f4f7f5 48%, #eef1f2 100%);
}

.app-shell {
  width: min(390px, 100%);
  height: 100dvh;
  margin: 0 auto;
  padding:
    max(1rem, env(safe-area-inset-top))
    0.75rem
    max(1rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top {
  padding: 0.25rem 0.2rem 0.9rem;
  text-align: center;
}

.sub {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.main {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.form,
.success {
  background: var(--surface);
  border-radius: 18px;
  padding: 0.2rem 1rem 1.2rem;
  box-shadow: 0 8px 28px rgba(20, 40, 30, 0.06);
  animation: rise 0.32s ease both;
}

.form.is-hidden,
.success.is-hidden {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.row {
  display: grid;
  grid-template-columns: 4.2rem 1fr;
  align-items: center;
  gap: 0.55rem;
  min-height: 3.4rem;
  border-bottom: 1px solid var(--line);
}

.row.is-hidden {
  display: none;
}

.label {
  font-size: 0.95rem;
  font-weight: 500;
}

.row input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  padding: 0.75rem 0;
}

.row input::placeholder {
  color: #b3bbb6;
}

.row-body {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.row-body input {
  flex: 1;
  min-width: 0;
}

.link-btn {
  flex-shrink: 0;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
  padding: 0.35rem 0;
  white-space: nowrap;
  cursor: pointer;
}

.link-btn:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.captcha-hit {
  flex-shrink: 0;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  line-height: 0;
}

#captcha-img {
  height: 38px;
  width: auto;
  max-width: 118px;
  display: block;
  background: #f7faf8;
}

.msg {
  min-height: 1.3rem;
  margin: 0.9rem 0 0.95rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.msg.is-error {
  color: var(--danger);
}

.msg.is-ok {
  color: var(--accent);
}

#android-id {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.device-auth-reopen {
  display: block;
  width: 100%;
  margin: 0 0 0.75rem;
  text-align: center;
  padding: 0.45rem 0;
}

.device-auth-reopen.is-hidden {
  display: none;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.auth-modal.is-hidden {
  display: none;
}

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 28, 22, 0.45);
  animation: authFade 0.2s ease both;
}

.auth-modal-sheet {
  position: relative;
  z-index: 1;
  width: min(340px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 1rem 1rem 1.1rem;
  box-shadow: 0 18px 48px rgba(12, 24, 18, 0.22);
  display: grid;
  gap: 0.75rem;
  animation: authPop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

.auth-modal-sheet.is-busy {
  pointer-events: none;
  opacity: 0.72;
}

.auth-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.auth-modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.auth-modal-close {
  appearance: none;
  border: none;
  background: #eef2ef;
  color: var(--muted);
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.auth-modal-hint {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.device-auth-hit {
  position: relative;
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  background: #f7faf8;
  cursor: crosshair;
  overflow: hidden;
  line-height: 0;
}

#device-auth-img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: top;
  user-select: none;
  -webkit-user-drag: none;
}

.device-auth-mark {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 2px solid #e74c3c;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95);
  pointer-events: none;
  z-index: 2;
  animation: authMark 0.18s ease both;
}

.device-auth-mark.is-hidden {
  display: none;
}

.auth-modal-meta {
  margin: 0;
  min-height: 1.2rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.auth-modal-meta.is-error {
  color: var(--danger);
}

.auth-modal-meta.is-ok {
  color: var(--accent);
}

.auth-modal-confirm {
  width: 100%;
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.8rem 1rem;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 650;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

.auth-modal-confirm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.auth-modal-confirm:not(:disabled):active {
  background: var(--accent-press);
}

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

@keyframes authPop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes authMark {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.btn-login,
.btn-again {
  width: 100%;
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.95rem 1rem;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.btn-login {
  color: #fff;
  background: var(--accent);
}

.btn-login:active {
  transform: scale(0.985);
  background: var(--accent-press);
}

.btn-login:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.success {
  padding-top: 1.15rem;
}

.success-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 700;
}

.success-badge::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--accent);
}

.result {
  margin: 0 0 1rem;
  display: grid;
  gap: 0.8rem;
}

.result div {
  display: grid;
  gap: 0.2rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
}

.result div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.result dt {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.result dd {
  margin: 0;
  font-size: 0.95rem;
  word-break: break-all;
}

.result dd.emphasis {
  font-family: ui-monospace, "Cascadia Code", monospace;
  color: var(--accent);
  font-weight: 650;
  font-size: 1.02rem;
}

.btn-again {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.history {
  margin-top: 1rem;
  padding-top: 0.4rem;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.history-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
  padding: 0 0.15rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.text-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0 0.1rem 0.25rem;
  display: grid;
  gap: 0.55rem;
  align-content: start;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.history-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(20, 40, 30, 0.06);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.history-list li:active {
  transform: scale(0.99);
  background: #fff;
}

.history-list .num {
  font-size: 0.95rem;
  font-weight: 650;
}

.history-list .aid-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.history-list .aid {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.75rem;
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Code", monospace;
  word-break: break-all;
}

.history-list .aid-copy {
  flex: 0 0 auto;
  appearance: none;
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  cursor: pointer;
}

.history-list .aid-copy.is-copied {
  background: var(--accent);
  color: #fff;
}

.history-list .meta {
  font-size: 0.72rem;
  color: var(--muted);
}

.history-empty {
  margin: 0;
  padding: 0.9rem 0.85rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.history-empty.is-hidden {
  display: none;
}

/* ---- slider captcha ---- */
.slider-stage {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 10px;
  background: #eef2f0;
  user-select: none;
  touch-action: none;
  min-height: 120px;
}
.slider-stage img#slider-bg {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: top;
}
.slider-stage img#slider-piece {
  position: absolute;
  top: 0;
  left: 0;
  /* 宽高由 JS 按原图像素比例相对背景缩放，勿写死百分比 */
  width: auto;
  height: auto;
  max-width: none;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
  visibility: hidden;
}
.slider-stage img#slider-piece.is-ready {
  visibility: visible;
}
.slider-bar {
  position: relative;
  margin-top: 0.75rem;
  height: 40px;
  border-radius: 20px;
  background: #eef2f0;
  border: 1px solid var(--line);
  overflow: hidden;
  user-select: none;
  touch-action: none;
}
.slider-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--accent-soft);
}
.slider-bar-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  pointer-events: none;
}
.slider-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 56px;
  height: 34px;
  border-radius: 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(20, 40, 30, 0.12);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 0.75rem;
  letter-spacing: 1px;
  cursor: grab;
  z-index: 2;
}
.slider-knob:active {
  cursor: grabbing;
}
.slider-bar.is-ok .slider-bar-fill {
  background: #d7f0e4;
}
.slider-bar.is-fail .slider-bar-fill {
  background: #f8e0dd;
}
