/* B-Affiliate — Liquid Glass tiết chế, kiểu Mail/Reminders (diễn giải web, không phải UI chính thức của Apple) */
:root {
  --canvas: #F5F7FA; --surface: #FFFFFF; --ink: #161719; --muted: #5C626C;
  --hair: rgba(199,204,212,.7); --ctl-border: #8A9099; --action: #0066CC; --accent: #0A84FF;
  --sky: #4F8DFF; --iris: #9B7BFF; --rose: #FF7FB0;
  --success: #1D7F38; --warning: #A65B00; --danger: #C4001A;
  --spring: cubic-bezier(0.32, 0.72, 0, 1); --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 400 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); font-weight: 400; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 16px; height: 16px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: default; }
@supports (corner-shape: squircle) { .list, .glass, .group, .reply { corner-shape: squircle; } }

/* Nền màu nhạt phía trên — để thanh kính có màu bên dưới */
.tint { position: fixed; inset: 0 0 auto 0; height: 200px; z-index: -1; opacity: .3; pointer-events: none;
  background: radial-gradient(40% 120% at 20% 0%, var(--sky), transparent 70%),
              radial-gradient(35% 110% at 55% 0%, var(--rose), transparent 70%),
              radial-gradient(40% 120% at 85% 0%, var(--iris), transparent 70%);
  -webkit-mask-image: linear-gradient(#000, transparent); mask-image: linear-gradient(#000, transparent); }

/* ---------- Kính: chỉ lớp điều hướng ---------- */
.glass { background: rgba(255,255,255,.5);
  -webkit-backdrop-filter: blur(10px) saturate(180%) brightness(1.1); backdrop-filter: blur(10px) saturate(180%) brightness(1.1);
  border: 1px solid rgba(255,255,255,.75);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.85), inset 0 -1px 0 rgba(255,255,255,.3), 0 0 0 .5px rgba(22,23,25,.1), 0 8px 24px rgba(22,23,25,.1); }
.glass.thick { background: rgba(255,255,255,.78); box-shadow: inset 0 1.5px 0 rgba(255,255,255,.95), 0 0 0 .5px rgba(22,23,25,.1), 0 18px 48px rgba(22,23,25,.18); }

.nav { position: fixed; z-index: 50; top: 12px; left: 50%; transform: translateX(-50%); width: min(900px, calc(100% - 24px));
  display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 18px; border-radius: 999px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 14px; }
.nav-status { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 999px; background: rgba(22,23,25,.06); cursor: pointer;
  transition: background .15s, transform .15s var(--bounce); }
.icon-btn:hover { background: rgba(22,23,25,.1); }

/* ---------- Nút ---------- */
.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.35); background: var(--action); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 4px 14px rgba(0,102,204,.25); transition: transform .15s var(--bounce), filter .15s; }
.btn-primary:hover { filter: brightness(1.08); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--hair); background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; color: var(--ink);
  transition: transform .15s var(--bounce), background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--canvas); border-color: var(--ctl-border); }
.btn-text { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 8px; border: 0; background: none; border-radius: 999px;
  color: var(--action); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn-text:hover { text-decoration: underline; }
.btn-text.quiet { color: var(--muted); }
.btn-primary:active, .btn:active, .btn-text:active, .icon-btn:active, .seg button:active, .pill:active { transform: scale(.96); }
.spinner { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .8s linear infinite; }
.nav-status .spinner { display: inline-block; border-color: rgba(22,23,25,.15); border-top-color: var(--accent); }
.busy .spinner { display: inline-block; } .busy .ic { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(22,23,25,.06); }
.seg button { min-height: 36px; padding: 0 16px; border: 0; border-radius: 999px; background: none; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted);
  transition: background .2s, color .2s; }
.seg button[aria-checked="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(22,23,25,.1), 0 2px 8px rgba(22,23,25,.06); }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 0 14px; border-radius: 999px; border: 0; background: rgba(22,23,25,.06);
  cursor: pointer; font-size: 14px; font-weight: 600; }
.pill:hover { background: rgba(22,23,25,.1); }

/* ---------- Trang chính ---------- */
.main { max-width: 860px; margin: 0 auto; padding: 88px 20px 48px; }
.today { display: flex; align-items: center; gap: 10px; margin: 8px 0 20px; font-size: 15px; color: var(--muted); }
.today b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.ring { width: 26px; height: 26px; transform: rotate(-90deg); flex: none; }
.ring circle { fill: none; stroke-width: 4; stroke: rgba(22,23,25,.1); }
.ring #ring-val { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 94.25; stroke-dashoffset: 94.25; transition: stroke-dashoffset .5s var(--spring); }
.progress { margin: -8px 0 20px; padding: 14px 18px; border-radius: 20px; }
.prog-head { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.prog-head .spinner { display: inline-block; border-color: rgba(22,23,25,.15); border-top-color: var(--accent); }
.prog-head .muted { font-size: 14px; font-variant-numeric: tabular-nums; }
.bar { height: 6px; margin: 12px 0; border-radius: 999px; background: rgba(22,23,25,.08); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .6s var(--spring); }
.prog-steps { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.prog-steps li { display: flex; align-items: center; gap: 6px; }
.prog-steps .dot { width: 8px; height: 8px; margin: 0 4px; border-radius: 50%; border: 1.5px solid currentColor; opacity: .6; }
.prog-steps .done { color: var(--success); } .prog-steps .done .ic { width: 16px; height: 16px; }
.prog-steps .now { color: var(--ink); font-weight: 600; } .prog-steps .now .dot { background: var(--accent); border-color: var(--accent); opacity: 1; }
.alert { margin: -8px 0 16px; padding: 10px 14px; border-radius: 14px; background: rgba(196,0,26,.08); color: var(--danger); font-size: 14px; font-weight: 600; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.filters { display: flex; gap: 8px; align-items: center; }

/* Danh sách (nội dung đặc) */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: 20px; border: 1px solid var(--hair);
  box-shadow: 0 1px 2px rgba(22,23,25,.06); overflow: hidden; }
.item { position: relative; border-top: 1px solid var(--hair); transition: background .15s, opacity .25s, transform .3s var(--spring); }
.item:first-child { border-top: 0; }
.item-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 20px; cursor: pointer; }
.item:hover .item-row { background: #FAFBFC; }
.item.sel .item-row { background: rgba(10,132,255,.06); }
.item.sel::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.item.leaving { opacity: 0; transform: translateX(24px); }
.title { margin: 0; font-size: 15px; font-weight: 500; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.open .title { display: none; }
.meta { margin-top: 2px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; }
.meta .go { color: var(--success); font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.meta .go::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.side { display: flex; align-items: center; gap: 8px; }
.score { font-size: 15px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 28px; text-align: right; }
.quick { opacity: 0; transition: opacity .15s; }
.item:hover .quick, .item.sel .quick { opacity: 1; }
.open .quick { display: none; }

/* Chi tiết: các bước */
.detail { display: none; padding: 0 20px 20px; }
.open .detail { display: block; animation: reveal .3s var(--spring); }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } }
.full { margin: 0 0 6px; font-size: 16px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
mark { background: rgba(10,132,255,.13); color: var(--ink); border-radius: 3px; padding: 0 1px; }
.why { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.why .warn { color: var(--warning); font-weight: 600; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.step { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; align-items: start; }
.step-n { display: grid; place-items: center; width: 24px; height: 24px; margin-top: 8px; border-radius: 50%; background: rgba(22,23,25,.07);
  font-size: 12px; font-weight: 700; color: var(--muted); }
.step-body { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 40px; }
.reply { width: 100%; padding: 12px 14px; border-radius: 14px; background: var(--canvas); font-size: 15px; line-height: 1.5; }
.ph { padding: 0 4px; border-radius: 4px; background: rgba(10,132,255,.14); font-weight: 600; }
.empty { padding: 56px 24px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }
.hint { margin: 14px 4px 0; font-size: 12px; color: var(--muted); }
kbd { font: 600 11px var(--font); padding: 1px 5px; border-radius: 5px; border: 1px solid #C7CCD4; background: var(--surface); }

/* ---------- Lớp nổi ---------- */
.pop { position: fixed; z-index: 90; border-radius: 22px; padding: 8px; min-width: 220px; max-height: 60vh; overflow-y: auto;
  transform-origin: var(--ox, top left); animation: grow .3s var(--spring); }
.no-scan .scan-only, .progress[hidden], .pop[hidden], .sheet[hidden], .scrim[hidden], .toast[hidden], .sheet-pane[hidden] { display: none; }
.pop.closing { animation: shrink .18s var(--spring) forwards; }
@keyframes grow { from { opacity: 0; transform: scale(.7); } }
@keyframes shrink { to { opacity: 0; transform: scale(.7); } }
.menu .menu-title { font-size: 12px; color: var(--muted); padding: 6px 12px 4px; font-weight: 600; }
.menu button { display: flex; width: 100%; align-items: center; min-height: 44px; padding: 0 12px; border: 0; border-radius: 14px; background: none;
  cursor: pointer; font-size: 15px; font-weight: 600; text-align: left; }
.menu button:hover, .menu button:focus-visible { background: rgba(22,23,25,.07); }
.menu button[aria-checked="true"] { background: rgba(10,132,255,.14); }

.scrim { position: fixed; inset: 0; z-index: 70; background: rgba(22,23,25,.28); animation: fade .25s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; z-index: 80; top: 72px; left: 50%; transform: translateX(-50%); width: min(720px, calc(100% - 24px)); max-height: calc(100vh - 96px);
  border-radius: 30px; padding: 16px; display: flex; flex-direction: column; animation: sheetIn .4s var(--spring); }
@keyframes sheetIn { from { opacity: 0; transform: translate(-50%, 16px) scale(.98); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-pane { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: hidden; }
.group { background: var(--surface); border-radius: 18px; border: 1px solid var(--hair); }
.group.scroll { overflow: auto; max-height: 56vh; }
.cell { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 0 16px; border-top: 1px solid var(--hair); font-size: 15px; }
.cell:first-child { border-top: 0; }
.note { margin: 0 6px; font-size: 13px; color: var(--muted); }
.seg.small { align-self: flex-start; }
.logic { padding: 4px 20px 8px; }
.logic section { padding: 14px 0; border-top: 1px solid var(--hair); }
.logic section:first-child { border-top: 0; }
.logic h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 15px; font-weight: 700; }
.logic h3 .step-n { margin: 0; }
.logic p { margin: 6px 0 0 34px; font-size: 14px; line-height: 1.55; color: var(--ink); }
.logic i { font-style: normal; color: var(--muted); }
.logic .rubric { margin: 8px 0 0 34px; width: calc(100% - 34px); }
.logic .rubric td { padding: 7px 10px; font-size: 14px; vertical-align: top; }
.logic .rubric td:first-child { white-space: nowrap; width: 1%; font-weight: 600; }
.logic .formula { font-weight: 600; font-size: 15px; padding: 10px 14px; border-radius: 12px; background: var(--canvas); display: inline-block; }
.stepper { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(22,23,25,.06); }
.stepper button { width: 34px; height: 34px; border-radius: 999px; border: 0; background: var(--surface); cursor: pointer; font-size: 17px; box-shadow: 0 1px 2px rgba(22,23,25,.1); }
.stepper output { min-width: 30px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.toggle { width: 50px; height: 30px; border-radius: 999px; border: 0; padding: 3px; background: rgba(22,23,25,.18); cursor: pointer; transition: background .25s; flex: none; }
.toggle span { display: block; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(22,23,25,.2); transition: transform .35s var(--bounce); }
.toggle[aria-checked="true"] { background: var(--accent); }
.toggle[aria-checked="true"] span { transform: translateX(20px); }
.kw-add { display: flex; gap: 8px; }
.kw-add input { flex: 1; min-width: 0; min-height: 44px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--ctl-border); background: var(--surface);
  font: 400 15px var(--font); color: var(--ink); }
.kw-add input:focus { outline: none; border-color: transparent; box-shadow: 0 0 0 3px var(--accent); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { position: sticky; top: 0; background: var(--surface); text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 14px; white-space: nowrap; }
td { padding: 8px 14px; border-top: 1px solid var(--hair); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.text { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td a { color: var(--action); text-decoration: none; } td a:hover { text-decoration: underline; }
.status { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; white-space: nowrap; }
.status.replied { color: var(--success); } .status.skipped { color: var(--muted); }
.toast { position: fixed; z-index: 95; left: 50%; bottom: 20px; transform: translateX(-50%); border-radius: 999px; padding: 4px 6px 4px 20px;
  display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; animation: rise .35s var(--spring); white-space: nowrap; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 20px); } }

/* ---------- Responsive, a11y ---------- */
@media (max-width: 700px) {
  .main { padding: 76px 12px 32px; }
  .nav-status, .hint { display: none; }
  .quick { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media (prefers-reduced-transparency: reduce) { .glass, .glass.thick { background: rgba(255,255,255,.94); backdrop-filter: none; -webkit-backdrop-filter: none; } }
@media (prefers-contrast: more) { .glass, .glass.thick { background: #fff; backdrop-filter: none; border: 1px solid var(--ink); } }
