/* Avatar Sloppy — follows design/DESIGN.md (Apple design analysis), tokens copied from avatar-critters.
   Single accent Action Blue, no gradients, no shadows on chrome. The only shadow is the
   product-shadow under the generated avatar. */
:root {
  --primary: #0066cc;
  --primary-focus: #0071e3;
  --ink: #1d1d1f;
  --ink-80: #333333;
  --ink-48: #7a7a7a;
  --divider-soft: #f0f0f0;
  --hairline: #e0e0e0;
  --canvas: #ffffff;
  --parchment: #f5f5f7;
  --pearl: #fafafc;
  --tile-1: #272729;

  --r-xs: 5px; --r-sm: 8px; --r-md: 11px; --r-lg: 18px; --r-pill: 9999px;
  --s-xxs: 4px; --s-xs: 8px; --s-sm: 12px; --s-md: 17px; --s-lg: 24px; --s-xl: 32px; --s-xxl: 48px; --s-section: 80px;

  --font-display: "SF Pro Display", system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --font-text: "SF Pro Text", system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --product-shadow: rgba(0, 0, 0, 0.22) 3px 5px 30px 0;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font-family: var(--font-text); font-size: 17px; line-height: 1.47; letter-spacing: -0.374px;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
:focus-visible { outline: 2px solid var(--primary-focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Sub nav (frosted) */
.sub-nav { position: sticky; top: 0; z-index: 10; height: 52px; background: rgba(245, 245, 247, 0.8); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid rgba(0, 0, 0, 0.08); }
.sub-nav__inner { max-width: 1120px; margin: 0 auto; height: 100%; padding: 0 22px; display: flex; align-items: center; justify-content: space-between; gap: var(--s-md); }
.sub-nav__title { font-family: var(--font-display); font-size: 21px; font-weight: 600; line-height: 1.19; letter-spacing: 0.231px; }
.sub-nav__right { display: flex; align-items: center; gap: var(--s-sm); min-width: 0; font-size: 14px; letter-spacing: -0.224px; }
.sub-nav__avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex: none; background: var(--pearl); }
.sub-nav__avatar--initial { display: inline-flex; align-items: center; justify-content: center; font-size: 12px; color: var(--ink-80); border: 1px solid var(--ink-48); }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; }
.btn-google .g-logo { background: #fff; border-radius: 50%; padding: 3px; width: 24px; height: 24px; box-sizing: border-box; }
.btn-google.is-busy { opacity: .6; pointer-events: none; }
.btn-google[disabled] { opacity: .45; cursor: not-allowed; }
.notice { margin-top: var(--s-md); border: 1px dashed var(--ink-48); border-radius: var(--r-md); padding: var(--s-sm) var(--s-md); font-size: 14px; color: var(--ink-80); background: var(--pearl); }
.notice b { display: block; color: var(--ink); margin-bottom: 2px; }
.sub-nav__user { color: var(--ink-48); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Buttons */
.btn { border: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform 0.12s ease; white-space: nowrap; text-decoration: none; }
.btn:active { transform: scale(0.95); }
.btn[disabled] { cursor: not-allowed; background: var(--hairline); color: var(--ink-48); border-color: var(--hairline); }
.btn-primary { background: var(--primary); color: #fff; border-radius: var(--r-pill); padding: 11px 22px; font-size: 17px; }
.btn-secondary { background: transparent; color: var(--primary); border: 1px solid var(--primary); border-radius: var(--r-pill); padding: 11px 22px; font-size: 17px; }
.btn-block { width: 100%; }
.link { color: var(--primary); background: none; border: 0; padding: 0; cursor: pointer; font-size: 14px; letter-spacing: -0.224px; }
.link[disabled] { color: var(--ink-48); cursor: default; }

/* Tiles */
.tile { padding: var(--s-section) 22px; }
.tile--light { background: var(--canvas); }
.tile--parchment { background: var(--parchment); }
.hero { text-align: center; padding-top: 72px; padding-bottom: 56px; }
.hero__title { font-family: var(--font-display); font-size: 56px; font-weight: 600; line-height: 1.07; letter-spacing: -0.28px; margin: 0 auto; max-width: 900px; }
.hero__lead { font-family: var(--font-display); font-size: 28px; font-weight: 400; line-height: 1.14; letter-spacing: 0.196px; margin: var(--s-md) 0 0; }
.studio { padding-top: var(--s-xxl); }
.studio__inner { max-width: 1120px; margin: 0 auto; }

/* Cards */
.card { background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: var(--s-xl); }
.card__eyebrow { font-size: 12px; letter-spacing: -0.12px; color: var(--ink-48); margin: 0 0 var(--s-xxs); }
.card__title { font-family: var(--font-display); font-size: 28px; font-weight: 600; line-height: 1.14; letter-spacing: 0.196px; margin: 0 0 var(--s-xs); }
.card__hint { font-size: 14px; letter-spacing: -0.224px; color: var(--ink-48); margin: 0 0 var(--s-lg); }
.subhead { font-size: 14px; font-weight: 600; line-height: 1.29; letter-spacing: -0.224px; margin: var(--s-lg) 0 var(--s-sm); }

/* Login */
.login { max-width: 440px; margin: 0 auto; }
.field { display: flex; flex-direction: column; gap: var(--s-xs); margin-bottom: var(--s-md); }
.field label { font-size: 14px; font-weight: 600; letter-spacing: -0.224px; }
.input { width: 100%; border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 12px 14px; font-size: 17px; background: var(--canvas); }
.input:focus { outline: 2px solid var(--primary-focus); outline-offset: 0; border-color: transparent; }
.row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-sm); margin-top: var(--s-md); font-size: 14px; letter-spacing: -0.224px; color: var(--ink-48); }

/* Studio grid */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: var(--s-lg); align-items: start; }

/* Dropzone */
.drop { position: relative; display: grid; place-items: center; text-align: center; min-height: 260px; border: 2px dashed var(--hairline); border-radius: var(--r-lg); background: var(--pearl); cursor: pointer; padding: var(--s-lg); transition: border-color 0.15s ease; }
.drop:hover, .drop.is-over { border-color: var(--primary); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop__title { font-family: var(--font-display); font-size: 21px; font-weight: 600; margin: 0 0 var(--s-xxs); }
.drop__hint { font-size: 14px; color: var(--ink-48); letter-spacing: -0.224px; margin: 0; }
.drop__preview { width: 100%; display: flex; gap: var(--s-md); align-items: center; text-align: left; }
.drop__preview img { width: 120px; height: 120px; object-fit: cover; border-radius: var(--r-sm); background: var(--parchment); flex: none; }
.drop__meta { font-size: 14px; letter-spacing: -0.224px; color: var(--ink-80); min-width: 0; }
.drop__meta b { display: block; font-size: 17px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-xs); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--canvas); color: var(--ink); border: 1px solid var(--hairline); border-radius: var(--r-pill); padding: 8px 16px; font-size: 14px; line-height: 1.43; letter-spacing: -0.224px; cursor: pointer; transition: transform 0.12s ease; }
.chip:active { transform: scale(0.95); }
.chip[aria-pressed="true"] { border: 2px solid var(--primary-focus); padding: 7px 15px; font-weight: 600; }
.swatch { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.15); flex: none; }

/* Status */
.error { margin: var(--s-md) 0 0; padding: var(--s-sm) var(--s-md); border-radius: var(--r-md); background: #fff4f4; border: 1px solid #f3c7c7; color: #b3261e; font-size: 14px; letter-spacing: -0.224px; }
.note { font-size: 12px; letter-spacing: -0.12px; color: var(--ink-48); margin: var(--s-sm) 0 0; }

/* Result */
.result__frame { aspect-ratio: 1 / 1; border-radius: var(--r-sm); background: var(--parchment); display: grid; place-items: center; overflow: hidden; margin-bottom: var(--s-md); }
.result__frame.has-image { background: transparent; overflow: visible; }
.result__frame img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: var(--r-sm); box-shadow: var(--product-shadow); }
.result__placeholder { text-align: center; color: var(--ink-48); font-size: 14px; letter-spacing: -0.224px; padding: var(--s-lg); }
.result__placeholder strong { display: block; font-family: var(--font-display); font-size: 21px; color: var(--ink); font-weight: 600; margin-bottom: var(--s-xxs); }
.result__actions { display: flex; flex-direction: column; gap: var(--s-sm); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--hairline); border-top-color: var(--primary); animation: spin 0.9s linear infinite; margin: 0 auto var(--s-sm); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* Footer */
.footer { background: var(--parchment); color: var(--ink-80); padding: 40px 22px 64px; font-size: 12px; letter-spacing: -0.12px; line-height: 1.5; }
.footer__inner { max-width: 1120px; margin: 0 auto; border-top: 1px solid var(--hairline); padding-top: var(--s-lg); }
.footer p { margin: 0 0 var(--s-xs); }
.footer__legal { color: var(--ink-48); }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .hero { padding-top: 48px; padding-bottom: 40px; }
  .hero__title { font-size: 34px; line-height: 1.12; }
  .hero__lead { font-size: 19px; line-height: 1.32; }
  .tile { padding-left: 16px; padding-right: 16px; }
  .card { padding: var(--s-lg) var(--s-md); }
  .card__title { font-size: 24px; }
  .drop__preview img { width: 88px; height: 88px; }
  .sub-nav__user { max-width: 140px; }
}

/* Random picks (这次随机到) */
.picks { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pick { font-size: 12px; letter-spacing: -0.12px; line-height: 1.4; border: 1px solid var(--hairline); border-radius: var(--r-pill); padding: 3px 10px; background: var(--pearl); color: var(--ink); }
.pick span { color: var(--ink-48); margin-right: 4px; }
.pick--plain { color: var(--ink-48); }
#picks .subhead { margin-top: var(--s-md); }

/* History (生成历史) */
.history { margin-top: var(--s-lg); }
.history__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-md); }
.history__count { font-size: 14px; font-weight: 400; color: var(--ink-48); letter-spacing: -0.224px; margin-left: 6px; }
.history__hint { margin-bottom: var(--s-md); }
.history__empty { font-size: 14px; color: var(--ink-48); margin: 0; padding: var(--s-lg); text-align: center; background: var(--pearl); border-radius: var(--r-md); }
.history__grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--s-md); }
.hcard { display: flex; flex-direction: column; gap: var(--s-xs); min-width: 0; }
.hcard__img { position: relative; display: block; padding: 0; border: 0; background: var(--parchment); border-radius: var(--r-sm); cursor: zoom-in; aspect-ratio: 1 / 1; overflow: hidden; }
.hcard__img > img:first-child { width: 100%; height: 100%; object-fit: cover; display: block; }
.hcard__src { position: absolute; right: 6px; bottom: 6px; width: 30%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: var(--r-xs); border: 2px solid #fff; background: #fff; }
.hcard__meta { font-size: 12px; color: var(--ink-48); display: flex; flex-direction: column; gap: 6px; }
.hcard__meta .pick { font-size: 11px; padding: 2px 8px; }
.hcard__actions { display: flex; gap: var(--s-md); }
.link--danger { color: #b3261e; }
.btn-small { padding: 7px 14px; font-size: 14px; }

/* History detail dialog */
.hdetail { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: var(--s-xl); color: var(--ink); background: var(--canvas); }
.hdetail::backdrop { background: rgba(0, 0, 0, 0.45); }
.hdetail__head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-md); margin-bottom: var(--s-md); }
.hdetail__pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-md); }
.hdetail__pair figure { margin: 0; display: flex; flex-direction: column; gap: var(--s-xs); align-items: flex-start; min-width: 0; }
.hdetail__pair img { width: 100%; max-height: 40vh; aspect-ratio: 1 / 1; object-fit: contain; background: var(--parchment); border-radius: var(--r-sm); }
.hdetail__pair figcaption { font-size: 12px; color: var(--ink-48); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.hdetail__prompt-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-md); }
.hdetail__prompt { margin: 0; max-height: 200px; overflow: auto; white-space: pre-wrap; word-break: break-word; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--pearl); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: var(--s-sm) var(--s-md); }
.hdetail__foot { margin-top: var(--s-md); text-align: right; }
.toast { position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--tile-1); color: #fff; font-size: 14px; padding: 10px 18px; border-radius: var(--r-pill); transition: opacity .2s ease, transform .2s ease; z-index: 100; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 640px) {
  .hdetail { padding: var(--s-lg) var(--s-md); }
  .hdetail__pair { grid-template-columns: 1fr; }
  .history__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
