:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d9e0e7;
  --primary: #e3253c;
  --primary-dark: #bd1f31;
  --accent: #1f8a9e;
  --ok: #147a4a;
  --warn: #b42318;
  --shadow: 0 8px 24px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.auth-view,
.main-view {
  width: 100%;
  max-width: 720px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px calc(74px + env(safe-area-inset-bottom));
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 2px 18px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.25;
}

h2 {
  font-size: 18px;
}

.eyebrow,
.brand-row p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel,
.redeem-panel,
.config-form {
  padding: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 2px 14px;
}

.content {
  padding-bottom: 8px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 2px 10px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
}

.field span,
.toggle-row span {
  color: var(--muted);
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--text);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

textarea {
  min-height: 82px;
  padding: 9px 11px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 138, 158, 0.12);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toggle-row {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  padding: 0;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.text-btn {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 700;
}

.primary-btn {
  width: 100%;
  background: var(--primary);
  color: #ffffff;
}

.primary-btn:active {
  background: var(--primary-dark);
}

.secondary-btn {
  width: 100%;
  margin-top: 10px;
  background: #eef7f9;
  color: var(--accent);
}

.ghost-btn,
.text-btn {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
}

.text-btn {
  min-height: 34px;
  color: var(--accent);
}

.form-message {
  min-height: 20px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.form-message.ok {
  color: var(--ok);
}

.form-message.error {
  color: var(--warn);
}

.profile-panel {
  padding: 4px 14px;
  margin-bottom: 12px;
}

.profile-line {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.profile-line:last-child {
  border-bottom: 0;
}

.profile-line span {
  color: var(--muted);
  font-size: 13px;
}

.profile-line strong {
  text-align: right;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 720px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  background: rgba(244, 246, 248, 0.96);
  border-top: 1px solid var(--line);
}

.nav-btn {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--muted);
  font-weight: 700;
}

.nav-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: #fff5f6;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom));
  width: min(92vw, 420px);
  transform: translateX(-50%);
  padding: 11px 14px;
  border-radius: 7px;
  background: rgba(31, 41, 51, 0.94);
  color: #ffffff;
  text-align: center;
  font-size: 14px;
  z-index: 20;
}

@media (min-width: 680px) {
  .auth-view,
  .main-view {
    padding-top: 28px;
  }

  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .field-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .profile-line {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 9px 0;
  }

  .profile-line strong {
    text-align: left;
  }
}
