/* ============================================================
   Account widget — self-contained Recent drawer + sign-in modal
   + auth pill. Designed to drop into ANY page regardless of that
   page's CSS-variable system: it defines its own `--aw-*` tokens
   (light + dark, keyed off `html.dark`) and prefixes every class
   with `aw-` to avoid collisions.

   Used by the marketing front page (index.html). The app page
   (/start) still uses its own copy in styles.css for now; item 2
   (accounts rethink) is the point to unify them.
   ============================================================ */

.aw-v {
  --aw-panel: #ffffff;
  --aw-bg: #fcfaf6;
  --aw-ink: #1a1815;
  --aw-ink-soft: #4a423a;
  --aw-muted: #837a6e;
  --aw-line: #e8dfd0;
  --aw-accent: #d9683f;
  --aw-accent-ink: #a8482a;
  --aw-accent-soft: #fbe9df;
  --aw-error: #c0392b;
  --aw-shadow: 0 24px 60px rgba(26, 24, 21, .1), 0 4px 12px rgba(26, 24, 21, .05);
}
html.dark .aw-v {
  --aw-panel: #211e17;
  --aw-bg: #16140f;
  --aw-ink: #f1eadc;
  --aw-ink-soft: #c8bfa9;
  --aw-muted: #8a8170;
  --aw-line: #2f2920;
  --aw-accent: #e6855e;
  --aw-accent-ink: #f0976f;
  --aw-accent-soft: #3a2b21;
  --aw-error: #e6785f;
  --aw-shadow: 0 24px 60px rgba(0, 0, 0, .5), 0 4px 12px rgba(0, 0, 0, .3);
}

.aw-hidden { display: none !important; }

/* ---- Nav pieces (Recent button + auth pill) ---- */
.aw-recent-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 14.5px; font-weight: 700; cursor: pointer;
  padding: 8px 14px; border-radius: 999px; border: none;
  background: var(--aw-accent-soft); color: var(--aw-accent-ink);
  transition: background .15s, color .15s;
}
.aw-recent-btn:hover { background: var(--aw-accent); color: #fff; }
.aw-recent-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; }

.aw-pill { position: relative; display: inline-flex; align-items: center; }
.aw-signin-btn,
.aw-user-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
  padding: 8px 14px; border-radius: 999px;
  background: none; border: 1px solid var(--aw-line); color: var(--aw-ink-soft);
  transition: border-color .15s, color .15s, background .15s;
  max-width: 190px;
}
.aw-signin-btn:hover,
.aw-user-btn:hover { border-color: var(--aw-accent); color: var(--aw-ink); }
.aw-user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aw-user-btn svg { width: 12px; height: 12px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; }
.aw-user-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 120;
  background: var(--aw-panel); border: 1px solid var(--aw-line); border-radius: 12px;
  box-shadow: var(--aw-shadow); padding: 6px; min-width: 150px;
}
.aw-user-dropdown button {
  display: block; width: 100%; text-align: left; padding: 9px 12px;
  font: inherit; font-size: 14px; color: var(--aw-ink);
  background: transparent; border: none; border-radius: 8px; cursor: pointer;
}
.aw-user-dropdown button:hover { background: var(--aw-accent-soft); color: var(--aw-accent-ink); }

/* ---- Recent drawer ---- */
.aw-backdrop {
  position: fixed; inset: 0; background: rgba(45, 33, 18, .4); z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.aw-backdrop.aw-open { opacity: 1; pointer-events: auto; }
.aw-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 400px; max-width: 88vw;
  background: var(--aw-panel); border-right: 1px solid var(--aw-line);
  box-shadow: var(--aw-shadow); z-index: 210;
  display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform .3s cubic-bezier(.4, 0, .2, 1);
}
.aw-drawer.aw-open { transform: translateX(0); }
.aw-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--aw-line); flex-shrink: 0;
}
.aw-drawer-head h2 { font-size: 17px; font-weight: 800; color: var(--aw-ink); margin: 0; }
.aw-icon-btn {
  width: 34px; height: 34px; border-radius: 999px; border: none; cursor: pointer;
  background: none; color: var(--aw-muted); display: grid; place-items: center;
}
.aw-icon-btn:hover { background: var(--aw-bg); color: var(--aw-ink); }
.aw-icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.aw-drawer-body { padding: 14px 16px; overflow-y: auto; }
.aw-recent-item {
  display: flex; align-items: center; gap: 13px; min-width: 0;
  background: var(--aw-panel); border: 1px solid var(--aw-line);
  border-radius: 16px; padding: 12px 14px; margin-bottom: 9px;
  text-decoration: none; color: inherit; transition: border-color .14s;
}
.aw-recent-item:hover { border-color: var(--aw-accent); }
.aw-recent-thumb {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: var(--aw-accent-soft); color: var(--aw-accent);
  display: grid; place-items: center;
}
.aw-recent-thumb svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
/* Series cover thumbnail (replaces the book icon when a chapter resolves). */
.aw-recent-cover { width: 44px; height: 60px; border-radius: 8px; flex-shrink: 0; overflow: hidden; background: var(--aw-accent-soft); }
.aw-recent-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aw-recent-meta { flex: 1; min-width: 0; }
.aw-recent-title {
  font-size: 14px; font-weight: 700; color: var(--aw-ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere;
}
/* Chinese name + pinyin aid line under the English title. */
.aw-recent-cn { font-size: 12px; color: var(--aw-ink-soft); margin-top: 2px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aw-recent-py { color: var(--aw-muted); }
.aw-recent-sub { font-size: 12px; color: var(--aw-muted); }
.aw-recent-chap { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .01em; color: #fff; background: var(--aw-accent); border-radius: 5px; padding: 1px 7px; margin-right: 6px; }
.aw-recent-level { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .01em; color: var(--aw-accent); background: var(--aw-accent-soft); border-radius: 5px; padding: 1px 6px; margin-right: 6px; }
.aw-recent-del { width: 28px; height: 28px; flex-shrink: 0; border-radius: 999px; background: none; border: none; color: var(--aw-muted); font-size: 16px; cursor: pointer; }
.aw-recent-del:hover { color: var(--aw-error); }
.aw-drawer-empty { text-align: center; color: var(--aw-muted); font-size: 13px; font-weight: 600; padding: 36px 12px; }
.aw-claim-banner {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  background: var(--aw-accent-soft); border: 1px solid var(--aw-accent);
  border-radius: 14px; padding: 11px 13px; margin-bottom: 12px;
  font-size: 12.5px; font-weight: 600; color: var(--aw-ink);
}
.aw-claim-banner button {
  flex-shrink: 0; background: var(--aw-accent); color: #fff; border: none; border-radius: 999px;
  padding: 7px 13px; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.aw-claim-banner button:hover { filter: brightness(1.06); }
.aw-drawer-status { font-size: 12px; color: var(--aw-muted); line-height: 1.45; padding: 0 2px 12px; }

/* ---- Sign-in modal ---- */
.aw-modal-backdrop {
  position: fixed; inset: 0; z-index: 220;
  background: rgba(26, 24, 21, .5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.aw-modal {
  background: var(--aw-panel); border-radius: 20px; box-shadow: var(--aw-shadow);
  width: 100%; max-width: 400px; padding: 28px 26px; text-align: center;
}
.aw-modal-icon {
  width: 52px; height: 52px; border-radius: 15px; margin: 0 auto 16px;
  background: var(--aw-accent-soft); color: var(--aw-accent); display: grid; place-items: center;
}
.aw-modal-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.aw-modal-title { font-size: 20px; font-weight: 800; color: var(--aw-ink); margin: 0 0 8px; }
.aw-modal-sub { font-size: 14px; color: var(--aw-muted); line-height: 1.5; margin: 0 0 20px; }
.aw-modal .aw-email-echo { color: var(--aw-ink); font-weight: 700; }
.aw-btn-primary {
  display: block; width: 100%; padding: 12px 16px; margin-top: 10px;
  background: var(--aw-accent); color: #fff; border: none; border-radius: 14px;
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; transition: background .15s;
}
.aw-btn-primary:hover { background: var(--aw-accent-ink); }
.aw-btn-primary:disabled { opacity: .6; cursor: default; }
.aw-btn-secondary {
  display: block; width: 100%; padding: 12px 16px; margin-top: 10px;
  background: none; color: var(--aw-ink-soft); border: 1px solid var(--aw-line); border-radius: 14px;
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: border-color .15s;
}
.aw-btn-secondary:hover { border-color: var(--aw-accent); }
.aw-btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px 16px;
  background: var(--aw-panel); color: var(--aw-ink);
  border: 1.5px solid var(--aw-line); border-radius: 14px;
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; transition: border-color .15s;
}
.aw-btn-google:hover { border-color: var(--aw-accent); }
.aw-cancel {
  display: block; width: 100%; margin-top: 14px; padding: 6px;
  background: none; border: none; color: var(--aw-muted);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.aw-cancel:hover { color: var(--aw-ink); }
.aw-input {
  width: 100%; padding: 12px 14px; margin-bottom: 10px;
  background: var(--aw-bg); color: var(--aw-ink);
  border: 1.5px solid var(--aw-line); border-radius: 12px;
  font: inherit; font-size: 15px; text-align: center;
}
.aw-input:focus { outline: none; border-color: var(--aw-accent); }
.aw-divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--aw-muted); font-size: 13px; }
.aw-divider::before, .aw-divider::after { content: ""; flex: 1; height: 1px; background: var(--aw-line); }
.aw-error { color: var(--aw-error); font-size: 13px; font-weight: 600; margin-bottom: 10px; }

/* ---- Responsive: keep Recent + auth compact on phones ---- */
@media (max-width: 560px) {
  .aw-recent-btn .aw-label { display: none; }
  .aw-recent-btn { padding: 9px; }
  .aw-signin-btn, .aw-user-btn { font-size: 14px; padding: 8px 12px; max-width: 130px; }
}
