:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --text: #1b1c22;
  --muted: #5d6070;
  --line: #e2e3ea;
  --accent: #5b5fd6;
  --accent-soft: #ececfb;
  --warn-bg: #fff6dc;
  --warn-line: #e8c55a;
  --danger: #c93a3a;
  --danger-bg: #fdecec;
  --code-bg: #eef0f4;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1014;
    --surface: #17181e;
    --text: #e8e9ee;
    --muted: #a0a3b1;
    --line: #2a2c35;
    --accent: #8f92f0;
    --accent-soft: #23244a;
    --warn-bg: #2d2611;
    --warn-line: #8a6d1d;
    --danger: #f08080;
    --danger-bg: #331a1c;
    --code-bg: #23252d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Language: both texts are in the page; the one not chosen is hidden. */
html[data-lang="vi"] body [lang="en"],
html[data-lang="en"] body [lang="vi"] { display: none !important; }

header.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
header.top .brand { font-weight: 700; color: var(--text); text-decoration: none; }
header.top .brand small { font-weight: 400; color: var(--muted); margin-left: 6px; }
header.top .spacer { flex: 1; }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--bg); }
.lang-switch button {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 4px 12px; border-radius: 999px; cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { background: var(--accent); color: #fff; }

main { max-width: 860px; margin: 0 auto; padding: 24px 16px 80px; min-width: 0; }
h1 { font-size: 30px; line-height: 1.25; margin: 8px 0 8px; }
h2 { font-size: 23px; margin: 48px 0 12px; padding-top: 8px; border-top: 1px solid var(--line); }
h3 { font-size: 19px; margin: 36px 0 8px; }
h3.group-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent);
  margin: 44px 0 0; padding-bottom: 6px; border-bottom: 2px solid var(--accent-soft);
}
h3.feature-group { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 8px; }
h4 { font-size: 19px; margin: 28px 0 8px; }

/* Sidebar: every feature, by group. Only on wide screens; narrow ones keep the contents box. */
.sidebar { display: none; }
@media (min-width: 1100px) {
  .layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); }
  .sidebar {
    display: block; position: sticky; top: 53px; align-self: start;
    height: calc(100vh - 53px); overflow-y: auto;
    padding: 20px 12px 40px 16px; border-right: 1px solid var(--line); background: var(--surface);
    font-size: 14px;
  }
  .sidebar a {
    display: block; padding: 4px 10px; border-radius: 6px; color: var(--text); text-decoration: none; line-height: 1.4;
  }
  .sidebar a:hover { background: var(--accent-soft); }
  .sidebar a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .sidebar .side-group { margin: 16px 0 2px; }
  .sidebar .side-group a, .sidebar a.side-top {
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  }
  .sidebar a.side-top { margin: 4px 0; }
  .sidebar a.side-top:last-child { margin-top: 16px; }
  nav.toc { display: none; }
}
p, ul, ol { margin: 8px 0; }
li { margin: 4px 0; }
a { color: var(--accent); }
.lead { color: var(--muted); font-size: 17px; }
b.ui, .ui {
  font-weight: 600;
  background: var(--accent-soft);
  padding: 0 5px;
  border-radius: 4px;
  overflow-wrap: anywhere;
}
kbd {
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px;
}

nav.toc { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 20px; margin: 20px 0; }
nav.toc ol { margin: 0; padding-left: 20px; }

/* Feature list */
ul.features { list-style: none; padding: 0; display: grid; gap: 8px; }
ul.features li {
  margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
}
ul.features li a { font-weight: 600; text-decoration: none; }
ul.features li a:hover { text-decoration: underline; }

/* A task: steps beside its screenshots (stacked on narrow screens) */
.task { display: grid; grid-template-columns: minmax(320px, 1fr) auto; gap: 20px; align-items: start; }
.task > .text { min-width: 0; }
.shots { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; max-width: 464px; }
figure { margin: 0; }
figure img {
  display: block; border-radius: 14px; border: 1px solid var(--line);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .12); background: #000;
}
figure.phone img { width: 220px; height: auto; }
figure.wide { margin: 16px 0; }
figure.wide img { width: 100%; height: auto; border-radius: 10px; }
figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; max-width: 220px; }
figure.wide figcaption { max-width: none; }
@media (max-width: 720px) {
  .task { grid-template-columns: minmax(0, 1fr); }
  .shots { justify-content: flex-start; max-width: none; }
  figure.phone img { width: min(220px, 70vw); }
}

/* Optional feature: a small icon; its note shows on hover or focus (a tap on touch screens). */
.opt {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; font-size: 11px; line-height: 1; vertical-align: 2px;
  background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 50%; cursor: help;
}
h4 .opt { vertical-align: 3px; }
.opt::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 6px); right: -8px; z-index: 20;
  width: max-content; max-width: 220px; padding: 6px 10px; border-radius: 6px;
  background: var(--text); color: var(--bg);
  font: 600 12px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-transform: none; letter-spacing: 0; white-space: normal;
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .12s;
}
.opt:hover::after, .opt:focus::after { opacity: 1; visibility: visible; }
.opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.note {
  background: var(--surface); border-left: 4px solid var(--accent); border-radius: 6px; padding: 8px 14px; margin: 12px 0;
}
.warn { background: var(--warn-bg); border-left: 4px solid var(--warn-line); border-radius: 6px; padding: 8px 14px; margin: 12px 0; }
.danger { background: var(--danger-bg); border-left: 4px solid var(--danger); border-radius: 6px; padding: 8px 14px; margin: 12px 0; }

ul.rules { padding-left: 20px; }
ul.rules li { margin: 8px 0; }
.back { font-size: 13px; margin-top: 8px; }

/* Landing page */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 24px; }
.cards a {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px;
  color: var(--text); text-decoration: none;
}
.cards a:hover { border-color: var(--accent); }
.cards strong { display: block; font-size: 19px; color: var(--accent); margin-bottom: 6px; }
footer { color: var(--muted); font-size: 13px; margin-top: 48px; }
/* In the sidebar the note hangs under the whole link, so it stays inside the sidebar. */
.sidebar a { position: relative; }
.sidebar .opt { position: static; }
.sidebar .opt::after { left: 10px; right: auto; max-width: 200px; }
