:root {
  --blue: #0078d4;
  --blue-hover: #106ebe;
  --blue-disabled: #bfd6f3;
  --text: #242424;
  --text-2: #666;
  --text-3: #767676;
  --border: #e6e6e6;
  --border-2: #dfe1e5;
  --hover: #f3f3f3;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .07);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #fff;
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ================= 登录闸门 ================= */
.gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #e8f2fd 0%, #ffffff 55%, #f7f9fc 100%);
  z-index: 50;
}

.gate-card {
  width: 380px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .10);
  padding: 40px 36px 28px;
  text-align: center;
}

.gate-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.gate-title { font-size: 26px; font-weight: 600; margin: 0 0 6px; letter-spacing: -.2px; }
.gate-sub { color: var(--text-2); font-size: 13px; margin: 0 0 24px; line-height: 1.6; }
.gate-input-wrap { margin-bottom: 12px; }

.gate input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 0 14px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
}
.gate input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 120, 212, .12); }

.gate-btn {
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.gate-btn:hover { background: var(--blue-hover); }
.gate-btn:disabled { background: var(--blue-disabled); cursor: default; }

.gate-error { color: #c42b1c; font-size: 12.5px; min-height: 18px; margin: 10px 0 0; }
.gate-foot { color: #9b9b9b; font-size: 11.5px; margin: 18px 0 0; }

/* ================= 顶栏（极简） ================= */
.appbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid #ededed;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-b { font-size: 26px; font-weight: 700; color: var(--blue); line-height: 1; letter-spacing: -.5px; }
.brand-name { font-size: 15px; font-weight: 600; color: #333; }

.signout {
  height: 32px;
  padding: 0 14px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.signout:hover { background: var(--hover); }

/* ================= 主体 ================= */
.main { max-width: 860px; margin: 0 auto; padding: 0 24px 80px; }

.hero {
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  margin: 40px 0 24px;
  letter-spacing: -.2px;
}

/* ================= 输入卡片 ================= */
.composer {
  position: relative;
  background: #fff;
  border: 1px solid #ececec;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 18px 20px 14px;
  transition: box-shadow .2s;
}
.composer:focus-within { box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 12px 32px rgba(0,0,0,.10); }

.composer-main { display: flex; }

.prompt {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  padding: 8px 2px 4px;
  min-height: 84px;
  max-height: 260px;
  background: transparent;
}
.prompt::placeholder { color: var(--text-3); }

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.ratio-wrap { position: relative; }

.ratio-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.ratio-btn:hover { background: var(--hover); }

.ratio-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  min-width: 190px;
  background: #fff;
  border: 1px solid #eaeaea;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
  padding: 6px;
  z-index: 20;
}
.ratio-item {
  display: flex;
  width: 100%;
  gap: 6px;
  align-items: center;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.ratio-item span { color: var(--text-2); }
.ratio-item:hover { background: var(--hover); }
.ratio-item.selected { background: #eef5fd; font-weight: 600; }
.ratio-item.selected::after { content: "✓"; margin-left: auto; color: var(--blue); font-weight: 700; }

.generate {
  min-width: 86px;
  height: 40px;
  border: none;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.generate:hover:not(:disabled) { background: var(--blue-hover); }
.generate:disabled { background: var(--blue-disabled); cursor: default; }

/* ================= 生成动画 ================= */
.generating {
  position: relative;
  height: 140px;
  border-radius: 10px;
  overflow: hidden;
  background: #f5f8fd;
  display: grid;
  place-items: center;
}
.gen-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, #eef3fb 20%, #f8fbff 40%, #eef3fb 60%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.gen-center { position: relative; text-align: center; }
.gen-spinner {
  width: 26px; height: 26px; margin: 0 auto 10px;
  border: 3px solid #cfe1f7; border-top-color: var(--blue);
  border-radius: 50%; animation: spin .9s infinite linear;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gen-label { font-size: 14px; font-weight: 600; color: #1b4b7d; }
.gen-bar { width: 240px; height: 4px; margin: 10px auto 0; background: #dbe8f8; border-radius: 2px; overflow: hidden; }
.gen-bar i { display: block; width: 0%; height: 100%; background: var(--blue); transition: width .4s ease; }

/* ================= 结果 ================= */
.results { margin-top: 30px; }
.results-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.results-title { font-size: 16px; font-weight: 600; }
.results-meta { font-weight: 400; color: var(--text-2); font-size: 12.5px; margin-left: 8px; }

.ghost-btn {
  height: 34px; padding: 0 14px;
  border: 1px solid #d9d9d9; border-radius: 6px;
  background: #fff; font-family: inherit; font-size: 13px; cursor: pointer;
}
.ghost-btn:hover { background: var(--hover); }

.result-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.result-tile {
  position: relative; border-radius: 12px; overflow: hidden;
  background: #f3f3f3; aspect-ratio: var(--ar, 3 / 2);
}
.result-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }

.result-actions {
  position: absolute; inset: auto 0 0 0;
  display: flex; gap: 8px; justify-content: flex-end; padding: 10px;
  background: linear-gradient(to top, rgba(0,0,0,.45), rgba(0,0,0,0));
  opacity: 0; transition: opacity .15s;
}
.result-tile:hover .result-actions { opacity: 1; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.94); display: grid; place-items: center;
  cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.icon-btn:hover { background: #fff; }

.results-prompt { margin-top: 12px; color: var(--text-2); font-size: 13px; line-height: 1.6; word-break: break-word; }

/* ================= Toast ================= */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #323232; color: #fff; padding: 12px 18px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  z-index: 60; max-width: 80vw;
}

/* ================= 响应式 ================= */
@media (max-width: 720px) {
  .appbar { padding: 0 14px; }
  .main { padding: 0 14px 60px; }
  .hero { font-size: 18px; margin: 24px 0 16px; }
  .composer { padding: 14px 14px 10px; }
  .result-grid { grid-template-columns: 1fr; }
}
