:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #132033;
  --muted: #667085;
  --line: #dbe3ef;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --blue: #2563eb;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --soft: #eef5ff;
  --shadow: 0 14px 34px rgba(15, 23, 42, .09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .58;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .13);
}

label span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.hidden {
  display: none !important;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, .88), rgba(15, 118, 110, .82)),
    linear-gradient(135deg, #0f172a, #155e75);
}

.auth-panel {
  width: min(100%, 420px);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #0f766e;
  color: #fff;
  font-weight: 800;
  font-size: 24px;
}

.auth-panel h1,
.topbar h1,
.section-head h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.auth-panel h1 {
  margin-top: 14px;
  font-size: 26px;
}

.auth-panel p {
  margin: 8px 0 18px;
  color: var(--muted);
  line-height: 1.7;
}

.stack {
  display: grid;
  gap: 12px;
}

.captcha-row {
  display: grid;
  grid-template-columns: 1fr 132px;
  gap: 10px;
  align-items: end;
}

.captcha-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.captcha-button img {
  width: 100%;
  height: 44px;
  object-fit: cover;
  display: block;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 72px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  background: #0f172a;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .18);
}

.topbar h1 {
  font-size: 19px;
  font-weight: 760;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 12px;
  color: rgba(255, 255, 255, .66);
}

.top-actions,
.action-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.content {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: 16px;
}

.screen {
  display: none;
}

.screen.active {
  display: grid;
  gap: 14px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.section-head h2 {
  font-size: 21px;
}

.section-head p,
.panel p,
.helper {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.panel,
.item-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(15, 23, 42, .05);
}

.panel {
  padding: 14px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.panel h3 {
  font-size: 16px;
}

.primary,
.soft,
.ghost,
.icon-button {
  min-height: 40px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.primary {
  padding: 0 14px;
  color: var(--primary-ink);
  background: var(--primary);
}

.primary.success {
  background: var(--green);
}

.soft {
  padding: 0 12px;
  color: #19416f;
  background: var(--soft);
  border: 1px solid #c9ddff;
}

.soft.accent {
  color: #0f5d70;
  background: #e8f8fb;
  border-color: #bdebf2;
}

.ghost {
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.icon-button {
  width: 40px;
  padding: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.topbar .icon-button {
  color: #fff;
  background: rgba(255, 255, 255, .09);
  border-color: rgba(255, 255, 255, .18);
}

.wide {
  width: 100%;
}

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

.form-grid.compact {
  align-items: end;
}

.span-2 {
  grid-column: span 2;
}

.check-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

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

.check-row span {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.2;
}

.card-list {
  display: grid;
  gap: 10px;
}

.item-card {
  padding: 13px;
  display: grid;
  gap: 10px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 720;
  line-height: 1.55;
  word-break: break-word;
}

.card-meta,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
}

.chip.green {
  color: #047857;
  background: #e8f8f0;
}

.chip.red {
  color: #b91c1c;
  background: #fee2e2;
}

.chip.amber {
  color: #b45309;
  background: #fff7ed;
}

.muted {
  color: var(--muted);
}

.status-line {
  min-height: 24px;
  color: #334155;
  font-size: 13px;
  line-height: 1.55;
}

.inline-message {
  margin-top: 10px;
  min-height: 20px;
  color: #334155;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.inline-message.error {
  color: var(--red);
}

.inline-message.success {
  color: var(--green);
}

.qr-box {
  width: min(100%, 260px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin: 8px auto 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-section {
  margin-top: 12px;
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metric-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-row strong {
  display: block;
  margin-top: 2px;
  font-size: 16px;
}

.rank-select {
  width: 22px;
  min-height: 22px;
  flex: 0 0 22px;
  margin-top: 2px;
}

.result-image {
  width: 78px;
  height: 78px;
  flex: 0 0 78px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.rank-main {
  min-width: 0;
  flex: 1 1 auto;
}

.rewrite-box {
  padding: 10px;
  border-radius: var(--radius);
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  color: #334155;
  font-size: 13px;
  line-height: 1.6;
}

.copy-block {
  width: 100%;
  min-height: 88px;
  padding: 10px;
  border-radius: var(--radius);
  background: #0f172a;
  color: #e5e7eb;
  white-space: pre-wrap;
  overflow: auto;
  font-size: 12px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.tab-btn {
  min-height: 54px;
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
  display: grid;
  place-items: center;
  gap: 2px;
}

.tab-btn i {
  font-size: 19px;
}

.tab-btn span {
  font-size: 12px;
}

.tab-btn.active {
  color: var(--primary);
  background: #e7f7f4;
}

.toast-host {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 40;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 11px 12px;
  border-radius: var(--radius);
  color: #fff;
  background: #0f172a;
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.45;
}

.toast.success {
  background: #047857;
}

.toast.error {
  background: #b91c1c;
}

@media (min-width: 700px) {
  .content {
    padding: 22px;
  }

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

@media (max-width: 390px) {
  .content {
    padding: 12px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .section-head,
  .metric-row {
    display: grid;
  }

  .action-strip > button {
    flex: 1 1 auto;
  }
}
