:root {
  --app-max-width: 520px;
  --brand: #0f766e;
  --brand-dark: #0f3f3a;
  --surface: #ffffff;
  --muted-surface: #f8fafc;
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: #f5f7fb;
  color: #1f2933;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f5f7fb;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid #b8c2cf;
  border-radius: 6px;
  background: var(--surface);
  color: #1f2933;
  padding: 0 14px;
  touch-action: manipulation;
}

button.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
  font-weight: 700;
}

button.danger {
  border-color: #c2410c;
  color: #c2410c;
}

button.full {
  width: 100%;
}

.hidden {
  display: none !important;
}

#app {
  min-height: 100vh;
}

.login-view {
  width: min(100%, var(--app-max-width));
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.app-title {
  font-size: 26px;
  font-weight: 800;
  text-align: center;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field span {
  font-size: 14px;
  font-weight: 700;
  color: #344054;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #b8c2cf;
  border-radius: 6px;
  background: var(--surface);
  color: #111827;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

.login-actions {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
}

.status-text,
.sync-status {
  min-height: 22px;
  margin: 0;
  color: #475467;
  font-size: 13px;
}

.main-view {
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.mobile-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--brand-dark);
  color: #ffffff;
  padding: 12px 14px;
  padding-top: max(12px, env(safe-area-inset-top));
}

.mobile-header strong {
  font-size: 18px;
}

.sync-status {
  padding: 10px 14px;
  background: #ccfbf1;
  color: var(--brand-dark);
}

.screen-view {
  width: min(100%, var(--app-max-width));
  margin: 0 auto;
  padding: 14px;
}

.result-box {
  margin-top: 16px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.result-grid div,
.settings-row,
.market-meta {
  border: 1px solid #d7dee8;
  border-radius: 6px;
  background: var(--muted-surface);
  padding: 10px;
}

.result-grid span,
.settings-row span {
  display: block;
  color: #667085;
  font-size: 12px;
}

.result-grid strong,
.settings-row strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.mobile-template-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  align-items: center;
  border: 1px solid #d7dee8;
  border-radius: 6px;
  background: var(--muted-surface);
  padding: 10px;
  margin: 10px 0;
}

.mobile-template-card strong,
.mobile-template-card span {
  display: block;
}

.mobile-template-card span {
  margin-top: 3px;
  color: #667085;
  font-size: 12px;
}

.mobile-template-card button {
  grid-row: span 2;
}

.template-panel {
  border: 1px solid #d7dee8;
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
  margin-bottom: 10px;
}

.template-token-row,
.template-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.template-token-row button {
  min-height: 34px;
  padding: 0 10px;
}

#copy:disabled {
  color: #98a2b3;
}

.details {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.detail-item,
.market-item {
  border: 1px solid #d7dee8;
  border-radius: 6px;
  background: var(--surface);
  padding: 10px;
}

.detail-item strong,
.market-item strong {
  display: block;
  margin-bottom: 4px;
}

.detail-item span,
.market-item span {
  display: block;
  color: #475467;
  font-size: 13px;
  line-height: 1.55;
}

.search {
  margin-bottom: 12px;
}

.market-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

#settings-view button {
  width: 100%;
  margin-top: 10px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 3;
  width: min(100%, var(--app-max-width));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-top: 1px solid #cbd5e1;
  background: var(--surface);
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
}

.bottom-nav .tab {
  border: 0;
  border-radius: 6px;
  background: transparent;
}

.bottom-nav .tab.active {
  background: var(--brand);
  color: #ffffff;
  font-weight: 700;
}
