* { box-sizing: border-box; }

:root {
  --ink: #4a3424;
  --muted: #7a624c;
  --line: #e6d3b6;
  --coral: #de6a48;
  --gold: #f2c15c;
  --gold-mid: #e89a2e;
  --gold-deep: #b86a16;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  background: #7ea8be;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* Avoid a second full-screen filtered image on iOS's small graphics budget. */
@supports (-webkit-touch-callout: none) {
  @media (pointer: coarse) { .ambient { display: none; } }
}

@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

.ambient {
  position: fixed;
  inset: -10%;
  background: url("/auth-assets/login-bg.jpg?v=4") center / cover no-repeat;
  filter: blur(32px) saturate(1.12);
  transform: scale(1.08);
}

.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(28, 48, 62, .22);
}

.stage {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  max-width: calc(100vh * 9 / 16);
  margin: 0 auto;
  overflow: hidden;
  box-shadow: 0 0 72px rgba(16, 28, 36, .38);
}

@supports (height: 100dvh) {
  .stage { max-width: calc(100dvh * 9 / 16); }
}

.bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 16%;
}

.shade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 58%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(62, 46, 30, .12) 28%,
    rgba(42, 30, 20, .42) 100%
  );
}

.frame {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: max(3.2vh, env(safe-area-inset-top, 0px)) 5.5% max(2.4vh, env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
  overflow-y: auto;
}

.logo {
  display: block;
  width: min(78%, 22rem);
  margin: 0 0 clamp(16px, 3.6vh, 36px);
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .22));
  pointer-events: none;
}

.panel {
  width: min(100%, 26rem);
  margin: 0 auto;
  padding: clamp(14px, 2.4vh, 20px) clamp(14px, 3.2vw, 18px) 14px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 252, 246, .94), rgba(255, 243, 226, .9));
  border: 1px solid rgba(255, 255, 255, .72);
  box-shadow: 0 16px 40px rgba(40, 28, 16, .22);
  backdrop-filter: blur(14px);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(236, 220, 196, .7);
}

.tab {
  flex: 1;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}

.tab.active {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 6px 14px rgba(222, 106, 72, .28);
}

.field {
  display: block;
  margin-bottom: 11px;
}

.field span {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  color: var(--muted);
}

.field input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .88);
  font-size: 15px;
  color: var(--ink);
}

.field input:focus {
  outline: 2px solid #f0b27a;
  border-color: var(--coral);
}

.hidden { display: none; }

.remember {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 4px 2px 13px;
  font-size: 13px;
  color: var(--muted);
}

.forgot {
  border: 0;
  padding: 0;
  background: transparent;
  color: #b86a16;
  font-size: 13px;
  cursor: pointer;
}

.forgot:hover { color: var(--coral); }

.captcha-field { margin-bottom: 11px; }

.field .captcha-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}

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

.captcha-img {
  flex: 0 0 128px;
  width: 128px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffaf3;
  cursor: pointer;
  overflow: hidden;
}

.captcha-img img {
  display: block;
  width: 128px;
  height: 42px;
}

body[data-page="register"] .logo,
body[data-page="reset"] .logo {
  width: min(62%, 16rem);
  margin-bottom: 12px;
}

body[data-page="register"] .field,
body[data-page="reset"] .field,
body[data-page="register"] .captcha-field,
body[data-page="reset"] .captcha-field {
  margin-bottom: 8px;
}

.remember label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.start {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 24px;
  background: linear-gradient(180deg, var(--gold), var(--gold-mid));
  color: #5a3208;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--gold-deep);
}

.start:hover { filter: brightness(1.03); }
.start:active { transform: translateY(2px); box-shadow: 0 4px 0 var(--gold-deep); }
.start:disabled { opacity: .65; cursor: wait; }

.message {
  min-height: 1.3em;
  margin: 10px 0 0;
  text-align: center;
  font-size: 13px;
  color: #b42318;
}

.message.ok { color: #2f7d3a; }

.version {
  margin: clamp(12px, 2.4vh, 22px) 0 0;
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, .9);
  text-shadow: 0 1px 3px rgba(0, 0, 0, .45);
}

.panel h2 {
  margin: 2px 0 4px;
  font-size: 20px;
  text-align: center;
}

.sub {
  margin: 0 0 12px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.server-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(46vh, 360px);
  overflow: auto;
}

.server-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .72);
}

.server-card strong { font-size: 16px; }
.server-card p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.badges { display: flex; gap: 6px; margin-top: 6px; }
.badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: #f3e2c4;
  color: #8a5a22;
  font-size: 11px;
}
.badge.hot { background: #f8d7cf; color: #b42318; }
.badge.ok { background: #d9f0dc; color: #2f7d3a; }

.enter {
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--gold), var(--gold-mid));
  color: #5a3208;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--gold-deep);
}
.enter:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.linkish {
  display: block;
  width: 100%;
  margin-top: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.linkish.hidden { display: none; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.stats div {
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .72);
  font-size: 12px;
  color: var(--muted);
}
.stats strong { display: block; margin-top: 4px; color: var(--ink); font-size: 18px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions button, .row-actions button {
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--gold), var(--gold-mid));
  color: #5a3208;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
}
.row-actions { display: flex; gap: 8px; margin-top: 12px; }
.row-actions .minor, button.minor {
  background: #efe4d4;
  color: var(--ink);
  box-shadow: none;
}
.log-list { max-height: 180px; overflow: auto; margin: 8px 0 0; padding: 0; list-style: none; }
.log-list li { padding: 6px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.log-list b { color: var(--ink); }

@media (max-height: 740px) {
  .logo { width: min(64%, 16rem); margin-bottom: 14px; }
}

@media (max-height: 620px) {
  .logo { width: min(52%, 13rem); margin-bottom: 10px; }
  .tabs { margin-bottom: 8px; }
  .field { margin-bottom: 7px; }
  .start { height: 42px; }
}

@media (orientation: landscape) and (max-height: 560px) {
  .stage {
    width: 100%;
    max-width: 52rem;
    height: 100%;
  }
  .frame {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
    gap: 16px 28px;
    padding: 16px 4%;
  }
  .logo {
    width: min(34%, 14rem);
    margin: 0;
  }
  .panel {
    width: min(420px, 48%);
  }
  .version {
    width: 100%;
    margin-top: 0;
  }
}
