:root {
  --bg: #ffffff;
  --page: #f5f5f5;
  --text: #171717;
  --muted: #777;
  --line: #eeeeee;
  --card: #ffffff;
  --primary: #4b63ff;
  --purple: #8b5cf6;
  --pink: #ff70a8;
  --orange: #ff9b47;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--page);
}

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

button {
  padding: 0;
  border: 0;
  cursor: pointer;
  background: transparent;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.same-stage {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 24px 10px;
}

.same-phone {
  position: relative;
  width: min(100%, 430px);
  min-height: min(880px, calc(100vh - 48px));
  padding: 12px 16px calc(86px + env(safe-area-inset-bottom));
  background: var(--bg);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.14);
  overflow: hidden;
}

.tool-text-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  margin: 0 -16px 12px;
  padding: 0 16px 8px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.tool-text-nav::-webkit-scrollbar {
  display: none;
}

.tool-text-nav button {
  flex: 0 0 auto;
  color: #111;
  font-size: 16px;
  font-weight: 600;
  line-height: 34px;
}

.tool-text-nav button.is-active {
  color: #111;
  font-weight: 900;
}

.view-page {
  display: grid;
  gap: 14px;
}

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

.haibao-item {
  display: grid;
  gap: 6px;
  width: 100%;
  text-align: left;
}

.haibao-img {
  display: block;
  width: 100%;
  height: 158px;
  object-fit: cover;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.haibao-title {
  display: block;
  padding: 0 2px 2px;
  color: #222;
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
}

.bottom-tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid #f2f2f2;
  background: #fff;
}

.bottom-tabbar button {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  color: #222;
}

.bottom-tabbar button.is-active {
  color: #111;
  font-weight: 700;
}

.bottom-tabbar em {
  font-size: 14px;
  font-style: normal;
  line-height: 18px;
}

.tab-art {
  position: relative;
  width: 28px;
  height: 24px;
  display: block;
}

.tab-create::before,
.tab-create::after {
  content: "";
  position: absolute;
  border-radius: 5px;
  background: currentColor;
}

.tab-create::before {
  left: 4px;
  top: 4px;
  width: 18px;
  height: 14px;
}

.tab-create::after {
  right: 2px;
  top: 1px;
  width: 8px;
  height: 8px;
  opacity: 0.5;
}

.tab-agent::before,
.tab-agent::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: currentColor;
}

.tab-agent::before {
  left: 6px;
  top: 3px;
  width: 16px;
  height: 16px;
}

.tab-agent::after {
  left: 2px;
  bottom: 1px;
  width: 24px;
  height: 8px;
  border-radius: 999px;
  opacity: 0.4;
}

.tab-mine::before,
.tab-mine::after {
  content: "";
  position: absolute;
  left: 50%;
  background: currentColor;
  transform: translateX(-50%);
}

.tab-mine::before {
  top: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.tab-mine::after {
  bottom: 1px;
  width: 22px;
  height: 10px;
  border-radius: 12px 12px 4px 4px;
  opacity: 0.45;
}

.simple-page-title {
  padding: 10px 2px 4px;
  font-size: 22px;
  font-weight: 800;
}

.tool-panel,
.result-card,
.agent-card,
.quota-card,
.auth-form,
.account-summary,
.history-card {
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.tool-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

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

.panel-head p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.panel-head h2 {
  margin: 0;
  font-size: 22px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-actions > span,
.status-pill,
[data-active-tool-cost] {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  background: rgba(75, 99, 255, 0.1);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tool-card {
  min-height: 78px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  padding: 8px;
  border-radius: 12px;
  color: #222;
  text-align: center;
  background: #f7f7f7;
}

.tool-card.is-active,
.tool-card:hover {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--purple));
}

.tool-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--pink), var(--orange));
}

.tool-card.is-active .tool-icon,
.tool-card:hover .tool-icon {
  background: rgba(255, 255, 255, 0.2);
}

.tool-card strong {
  display: block;
  font-size: 12px;
  line-height: 1.2;
}

.tool-card small,
.tool-meta {
  display: none;
}

.composer-form,
.auth-form {
  display: grid;
  gap: 12px;
}

.composer-form label,
.auth-form label {
  display: grid;
  gap: 7px;
  color: #555;
  font-size: 13px;
  font-weight: 700;
}

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

textarea {
  resize: vertical;
}

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

.primary-button,
.soft-button,
.ghost-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--purple));
}

.soft-button {
  color: var(--primary);
  background: rgba(75, 99, 255, 0.1);
}

.ghost-button {
  color: #555;
  background: #f5f5f5;
}

.result-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  box-shadow: none;
  background: #fbfbfb;
}

.result-box {
  min-height: 120px;
  max-height: 320px;
  overflow: auto;
  padding: 12px;
  border: 1px dashed #ddd;
  border-radius: 12px;
  color: #333;
  background: #fff;
  line-height: 1.7;
  white-space: pre-wrap;
}

.result-box img {
  display: block;
  width: 100%;
  border-radius: 12px;
}

.muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.agent-grid,
.history-list,
.account-summary {
  display: grid;
  gap: 10px;
}

.agent-card,
.auth-form,
.history-card,
.account-summary,
.quota-card {
  padding: 14px;
}

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

.agent-card strong {
  font-size: 16px;
}

.agent-card span,
.history-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.agent-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.agent-steps em {
  padding: 5px 8px;
  border-radius: 999px;
  color: #0f766e;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  background: rgba(33, 198, 168, 0.12);
}

.quota-card {
  display: grid;
  gap: 6px;
  color: #fff;
  background: linear-gradient(135deg, #1f2937, #4b63ff);
}

.quota-card span,
.quota-card em {
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-style: normal;
}

.quota-card strong {
  font-size: 30px;
}

.account-summary div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-radius: 12px;
  background: #f7f7f7;
}

.history-card {
  display: grid;
  gap: 12px;
}

.history-list {
  max-height: 420px;
  overflow: auto;
}

.history-item {
  display: grid;
  gap: 7px;
  padding: 12px;
  border-radius: 12px;
  background: #f7f7f7;
}

.history-item strong {
  font-size: 14px;
}

.history-item .ghost-button {
  justify-self: start;
  min-height: 32px;
}

.composer-dialog,
.settings-dialog {
  width: min(410px, calc(100vw - 24px));
  max-height: min(88vh, 820px);
  border: 0;
  border-radius: 18px;
  padding: 0;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.2);
}

.composer-dialog::backdrop,
.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(3px);
}

.composer-dialog .tool-panel {
  max-height: min(88vh, 820px);
  overflow: auto;
  box-shadow: none;
}

.settings-dialog form {
  padding: 18px;
}

.config-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.config-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #f7f7f7;
}

.config-list strong,
.config-list span {
  font-size: 13px;
}

.config-list span {
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 14px;
  color: #fff;
  text-align: center;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.86);
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  transition: 0.18s ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.is-hidden {
  display: none !important;
}

@media (min-width: 760px) {
  .same-stage {
    align-items: center;
  }

  .same-phone {
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    border-radius: 4px;
  }
}

@media (max-width: 520px) {
  .same-stage {
    display: block;
    padding: 0;
    background: #fff;
  }

  .same-phone {
    width: 100%;
    min-height: 100vh;
    box-shadow: none;
  }
}

@media (max-width: 370px) {
  .haibao-img {
    height: 144px;
  }

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

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