:root {
  --ground: #f7f4ee;
  --surface: #fffcf7;
  --surface-2: #f1ece4;
  --hairline: rgba(40, 36, 28, 0.1);
  --text: #1c1b19;
  --text-2: #5c574e;
  --text-3: #8a8478;
  --accent: #0f8f86;
  --accent-soft: #e5f6f4;
  --accent-border: rgba(15, 143, 134, 0.35);
  --danger: #c45c5c;
  --warn: #b8892d;
  --ok: #2f9e6b;
  --font: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  padding:
    max(8px, env(safe-area-inset-top))
    14px
    max(8px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-align: center;
}

.nav {
  width: 100%;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  text-align: left;
}

.mark {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}

.nav-copy {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.product {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.product-sub {
  font-size: 10px;
  color: var(--text-3);
  line-height: 1.2;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 10px;
  flex-shrink: 0;
}

.status-pill .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-3);
}

.status-pill.pending .dot { background: var(--warn); }
.status-pill.ok .dot { background: var(--ok); }
.status-pill.error .dot { background: var(--danger); }
.status-pill.loading .dot {
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.stage {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.hero {
  flex: 0 0 auto;
  width: 100%;
}

.hero .kicker {
  margin: 0 0 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  margin: 0;
  font-size: clamp(20px, 5.6vw, 26px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.hero .lede {
  margin: 4px auto 0;
  max-width: 28em;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-2);
}

.command {
  width: 100%;
  flex: 0 0 auto;
  text-align: left;
}

.field-label {
  display: block;
  margin: 0 0 4px 2px;
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
}

.command-row {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  overflow: hidden;
}

.command-row:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.prefix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-right: 1px solid var(--hairline);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-2);
}

.phone-input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 0 8px;
}

.phone-input::placeholder {
  color: var(--text-3);
  letter-spacing: 0;
  font-weight: 400;
}

.primary-btn {
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-left: 1px solid var(--hairline);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.panel {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  overflow: hidden;
}

.panel-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-2);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.panel-name {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

.ghost-btn {
  height: 26px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}

.ghost-btn:hover:not(:disabled) {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}

.ghost-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.code-box {
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.code-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.code-main {
  font-family: var(--mono);
  font-size: clamp(22px, 6.5vw, 30px);
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--text-3);
  word-break: break-all;
  line-height: 1.15;
}

.code-main.ready { color: var(--text); }

.code-sub {
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-2);
  max-width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta-list {
  flex: 0 0 auto;
  margin: 0;
  border-top: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.meta-item {
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.meta-item + .meta-item {
  border-left: 1px solid var(--hairline);
}

.meta-item dt {
  margin: 0;
  font-size: 10px;
  color: var(--text-3);
}

.meta-item dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hint {
  flex: 0 0 auto;
  margin: 0;
  width: 100%;
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-3);
  min-height: 1.2em;
}

/* Short screens: tighten without dropping titles */
@media (max-height: 700px) {
  .hero .lede { font-size: 11px; }
  .phone-input,
  .primary-btn { height: 40px; }
  .code-main { font-size: 22px; }
  .meta-item { padding: 6px; }
}

@media (max-height: 620px) {
  .hero .kicker { display: none; }
  .product-sub { display: none; }
  .shell { gap: 6px; }
  .code-sub { -webkit-line-clamp: 1; }
}

/* Wider phones / tablet */
@media (min-width: 640px) {
  .shell {
    max-width: 520px;
    padding: 20px 20px;
    gap: 12px;
  }

  .hero h1 { font-size: 28px; }
  .hero .lede { font-size: 13px; margin-top: 8px; }

  .phone-input,
  .primary-btn { height: 46px; font-size: 14px; }

  .primary-btn { padding: 0 16px; }

  .code-main { font-size: 34px; }
  .code-sub { font-size: 13px; -webkit-line-clamp: 3; }
  .meta-item dd { font-size: 13px; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  .status-pill.loading .dot { animation: none; }
}
