* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f6f9;
  color: #151923;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

#app {
  max-width: 720px;
  min-height: 100vh;
  margin: 0 auto;
  background: #f7f8fb;
  padding-bottom: 76px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  background: rgba(247, 248, 251, 0.96);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid #e8ebf1;
}

.brand {
  font-size: 22px;
  font-weight: 800;
  color: #b8122b;
}

.subbrand,
.muted {
  color: #7b8494;
  font-size: 12px;
}

.icon-btn,
.text-btn {
  background: #ffffff;
  color: #b8122b;
  border: 1px solid #edf0f5;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
}

main {
  padding: 12px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 8px;
  margin-bottom: 12px;
}

.search-row input {
  border: 1px solid #e2e6ee;
  background: #ffffff;
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}

.search-row button,
#askAiBtn {
  background: #b8122b;
  color: #ffffff;
  border-radius: 10px;
}

.market-strip,
.market-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.market-card,
.news-card,
.quote-row,
.ai-panel,
.profile-card,
.discover-card,
.simple-list,
.breaking {
  background: #ffffff;
  border: 1px solid #e8ebf1;
  border-radius: 10px;
}

.market-card {
  padding: 10px;
}

.market-name {
  font-size: 12px;
  color: #5d6675;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.market-price {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 800;
}

.up {
  color: #d51f35;
}

.down {
  color: #11885b;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 2px 8px;
  font-size: 17px;
  font-weight: 800;
}

.section-title.compact {
  margin-top: 18px;
}

.breaking {
  padding: 10px;
}

.breaking-list {
  display: grid;
  gap: 8px;
}

.flash-item {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 8px;
  align-items: start;
  padding: 6px 0;
  border-top: 1px solid #f0f2f6;
  background: transparent;
  text-align: left;
}

.flash-item:first-child {
  border-top: 0;
}

.flash-time {
  color: #b8122b;
  font-size: 12px;
  font-weight: 700;
}

.flash-title {
  font-size: 14px;
  line-height: 1.45;
}

.channels {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 8px;
}

.channel {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  background: #ffffff;
  color: #4e5868;
  border: 1px solid #e6eaf1;
}

.channel.active {
  background: #b8122b;
  color: #ffffff;
}

.news-list,
.quote-list {
  display: grid;
  gap: 10px;
}

.news-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px;
}

.news-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.45;
}

.news-summary {
  margin-top: 7px;
  color: #596273;
  font-size: 13px;
  line-height: 1.55;
}

.news-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  color: #9299a6;
  font-size: 12px;
}

.quote-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  text-align: left;
  padding: 12px;
}

.quote-code {
  margin-top: 3px;
  color: #88909e;
  font-size: 12px;
}

.quote-price {
  text-align: right;
  font-weight: 800;
}

.ai-panel {
  padding: 12px;
}

.ai-panel textarea {
  width: 100%;
  min-height: 118px;
  resize: vertical;
  border: 1px solid #e1e5ed;
  border-radius: 10px;
  padding: 10px;
  outline: none;
}

#askAiBtn {
  width: 100%;
  margin-top: 10px;
  padding: 11px 14px;
}

.ai-answer {
  margin-top: 12px;
  background: #ffffff;
  border: 1px solid #e8ebf1;
  border-radius: 10px;
  padding: 12px;
  color: #394253;
  line-height: 1.65;
  white-space: pre-wrap;
}

.discover-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.discover-card {
  min-height: 72px;
  padding: 14px;
  text-align: left;
  font-weight: 800;
  color: #273044;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: #b8122b;
  color: #ffffff;
  font-weight: 900;
}

.profile-name {
  font-weight: 900;
}

.simple-list {
  display: grid;
  gap: 1px;
  margin-top: 12px;
  overflow: hidden;
}

.simple-list a,
.simple-list button {
  display: block;
  width: 100%;
  padding: 14px;
  background: #ffffff;
  color: #202838;
  text-align: left;
  text-decoration: none;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(720px, 100%);
  transform: translateX(-50%);
  background: #ffffff;
  border-top: 1px solid #e5e8ee;
  padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
}

.tab {
  background: transparent;
  color: #717b8d;
  padding: 8px 0;
  border-radius: 10px;
  font-size: 13px;
}

.tab.active {
  color: #b8122b;
  font-weight: 800;
  background: #fff1f3;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(13, 20, 31, 0.45);
}

.modal-card {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(720px, 100%);
  max-height: 86vh;
  overflow: auto;
  transform: translateX(-50%);
  margin: 0;
  background: #ffffff;
  border-radius: 18px 18px 0 0;
  padding: 18px 16px 28px;
}

.close {
  float: right;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #f0f2f6;
  font-size: 22px;
}

.modal-title {
  margin: 6px 38px 8px 0;
  font-size: 20px;
  line-height: 1.45;
}

.modal-content {
  color: #30394b;
  line-height: 1.8;
  white-space: pre-wrap;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.modal-actions button {
  padding: 11px 12px;
  border-radius: 10px;
  background: #f2f4f8;
}

.modal-actions button.primary {
  background: #b8122b;
  color: #ffffff;
}

@media (max-width: 420px) {
  .brand {
    font-size: 20px;
  }

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