/* =========================================================
   Exam Hub — high-end, minimal design system
   Inspired by emilkowalski/skills aesthetic
   ========================================================= */
:root {
  --bg: #FBFAF8;
  --bg-grad-1: #F4F2FF;
  --bg-grad-2: #FFF7F0;
  --surface: #FFFFFF;
  --surface-2: #F6F5F2;
  --border: #E8E6E1;
  --border-strong: #D9D6CF;
  --text: #1B1A18;
  --muted: #6F6D68;
  --faint: #9C9A93;
  --accent: #5B5BD6;
  --accent-2: #8B5CF6;
  --accent-soft: #EEEDFF;
  --amber: #D97706;
  --amber-soft: #FEF3E2;
  --green: #15803D;
  --green-soft: #E7F6EC;
  --red: #DC2626;
  --red-soft: #FDECEC;
  --code-bg: #0F1117;
  --code-text: #E6E8F0;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(20,18,15,.05), 0 1px 3px rgba(20,18,15,.04);
  --shadow-md: 0 4px 12px -2px rgba(20,18,15,.08), 0 2px 6px -2px rgba(20,18,15,.05);
  --shadow-lg: 0 18px 40px -12px rgba(40,30,80,.18), 0 8px 20px -10px rgba(20,18,15,.10);
  --maxw: 1120px;
  --nav-h: 64px;
  --font: "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------- Background ambience ---------- */
.bg-ambient {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 50% at 12% 0%, var(--bg-grad-1) 0%, transparent 60%),
    radial-gradient(55% 45% at 100% 8%, var(--bg-grad-2) 0%, transparent 55%);
  opacity: .9;
}

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 22px;
  background: rgba(251,250,248,.78);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav .brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.nav .brand .logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff; font-size: 15px; box-shadow: var(--shadow-sm);
}
.nav .links { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav .links a {
  padding: 7px 12px; border-radius: 9px; font-size: 13.5px; color: var(--muted); font-weight: 500;
  transition: background .15s, color .15s;
}
.nav .links a:hover { background: var(--surface-2); color: var(--text); }
.nav .links a.active { color: var(--accent); background: var(--accent-soft); }
.nav-toggle { display: none; margin-left: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; width: 38px; height: 38px; font-size: 18px; cursor: pointer; }

/* ---------- Layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }
.section { padding: 56px 0; }
.section-sm { padding: 30px 0; }

/* ---------- Hero ---------- */
.hero { padding: 70px 0 36px; text-align: center; }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  padding: 6px 13px; border-radius: 999px; margin-bottom: 22px;
}
.hero h1 {
  font-size: clamp(34px, 6vw, 58px); line-height: 1.05; letter-spacing: -.03em; margin: 0 0 18px;
  font-weight: 800;
}
.hero h1 .grad {
  background: linear-gradient(120deg, var(--accent), var(--accent-2) 55%, var(--amber));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { font-size: clamp(15px, 2.2vw, 19px); color: var(--muted); max-width: 680px; margin: 0 auto; }
.hero .cta { margin-top: 30px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 11px 18px; border-radius: 11px; font-weight: 600; font-size: 14px;
  border: 1px solid transparent; transition: transform .12s, box-shadow .15s, background .15s;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: var(--shadow-md); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-amber { background: var(--amber); color: #fff; }
.btn-amber:hover { transform: translateY(-2px); }

/* ---------- Cards grid ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm);
  transition: transform .18s cubic-bezier(.2,.7,.3,1), box-shadow .18s, border-color .18s;
  display: flex; flex-direction: column; gap: 12px; overflow: hidden;
}
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius); pointer-events: none;
  background: linear-gradient(180deg, rgba(91,91,214,.05), transparent 40%);
  opacity: 0; transition: opacity .2s;
}
.card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.card:hover::after { opacity: 1; }
.card .tag {
  align-self: flex-start; font-size: 11.5px; font-weight: 600; letter-spacing: .03em;
  padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.card .tag.amber { background: var(--amber-soft); color: var(--amber); }
.card h3 { margin: 2px 0 0; font-size: 19px; letter-spacing: -.01em; }
.card p { margin: 0; color: var(--muted); font-size: 13.8px; flex: 1; }
.card .meta { display: flex; gap: 14px; font-size: 12px; color: var(--faint); flex-wrap: wrap; }
.card .meta span { display: inline-flex; align-items: center; gap: 5px; }
.card .go { margin-top: 4px; font-weight: 600; color: var(--accent); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Section heading ---------- */
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.sec-head h2 { font-size: clamp(24px, 3.4vw, 32px); letter-spacing: -.02em; margin: 0; }
.sec-head p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- Tutorial page layout ---------- */
.tut-hero { padding: 40px 0 18px; }
.tut-hero .crumbs { font-size: 13px; color: var(--faint); margin-bottom: 14px; }
.tut-hero .crumbs a:hover { color: var(--accent); }
.tut-hero h1 { font-size: clamp(26px, 4vw, 40px); letter-spacing: -.025em; margin: 0 0 10px; }
.tut-hero p { color: var(--muted); max-width: 760px; margin: 0; font-size: 15px; }

.layout { display: grid; grid-template-columns: 240px 1fr; gap: 34px; align-items: start; padding-bottom: 60px; }
.sidebar { position: sticky; top: calc(var(--nav-h) + 20px); display: flex; flex-direction: column; gap: 6px; }
.sidebar .s-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 6px 10px; }
.sidebar a {
  padding: 10px 13px; border-radius: 11px; font-size: 14px; font-weight: 500; color: var(--muted);
  display: flex; align-items: center; gap: 10px; border: 1px solid transparent; transition: .15s;
}
.sidebar a .ic { width: 22px; text-align: center; }
.sidebar a:hover { background: var(--surface-2); color: var(--text); }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); border-color: #DCDAFF; font-weight: 600; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel-pad { padding: 26px; }
.panel-head { padding: 18px 26px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; display: flex; align-items: center; gap: 9px; }
.panel-head .hint { font-size: 12.5px; color: var(--faint); }

.tabpane { display: none; }
.tabpane.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Document (memo) inline via Shadow DOM ---------- */
.memo-host {
  display: block; min-height: 200px;
  /* the original memo styles live inside the shadow root */
}
.memo-bar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.memo-bar .dot { width: 9px; height: 9px; border-radius: 50%; background: #ff6058; }
.memo-bar .dot.y { background: #ffbd2e; } .memo-bar .dot.g { background: #29c840; }
.memo-bar .url { margin-left: 8px; }
.memo-bar .spacer { flex: 1; }
.memo-switch { display: inline-flex; gap: 4px; background: #fff; border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.memo-switch button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; font-size: 12.5px; cursor: pointer; color: var(--muted); font-weight: 500; }
.memo-switch button.active { background: var(--accent); color: #fff; }

/* ---------- Code block ---------- */
.code-block { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid #20232b; background: var(--code-bg); }
.code-block .ch { display: flex; align-items: center; gap: 8px; padding: 9px 14px; background: #161922; border-bottom: 1px solid #23262f; }
.code-block .ch .fname { font-size: 12.5px; color: #b9bdc9; font-family: var(--mono); }
.code-block .ch .lang { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #6c7283; border: 1px solid #2a2e39; padding: 1px 7px; border-radius: 6px; }
.copy-btn { margin-left: auto; background: #23262f; border: 1px solid #2f333f; color: #cdd2de; font-size: 12px; padding: 4px 11px; border-radius: 7px; cursor: pointer; transition: .15s; }
.copy-btn:hover { background: #2c303b; color: #fff; }
.copy-btn.ok { background: var(--green); border-color: var(--green); color: #fff; }
.code-block pre { margin: 0; padding: 16px 18px; overflow: auto; max-height: 460px; }
.code-block code { font-family: var(--mono); font-size: 13px; color: var(--code-text); white-space: pre; line-height: 1.55; }

.note { display: flex; gap: 11px; padding: 13px 16px; border-radius: var(--radius-sm); font-size: 13.5px; margin: 16px 0; }
.note .ni { flex: none; font-size: 16px; line-height: 1.4; }
.note.info { background: #EEF4FF; border: 1px solid #D6E4FF; color: #1e3a8a; }
.note.warn { background: var(--amber-soft); border: 1px solid #F6D9A8; color: #7c4a03; }
.note.ok { background: var(--green-soft); border: 1px solid #BFE6CB; color: #14532d; }

/* ---------- Viewer (docx / pdf) ---------- */
.viewer {
  border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2);
}
.viewer .vbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.viewer .vbar .spacer { flex: 1; }
.viewer .vbody { padding: 0; }
.viewer iframe { width: 100%; height: 760px; border: 0; background: #fff; }
.docx-render { padding: 26px 30px; background: #fff; min-height: 400px; max-height: 820px; overflow: auto; font-size: 15px; line-height: 1.7; }
.docx-render h1, .docx-render h2, .docx-render h3 { line-height: 1.3; margin: 1.1em 0 .5em; }
.docx-render img { max-width: 100%; border-radius: 8px; margin: 10px 0; }
.docx-render table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13.5px; }
.docx-render th, .docx-render td { border: 1px solid #d8d8d8; padding: 7px 10px; }
.docx-render th { background: #f3f3f3; }
.docx-loading { padding: 50px; text-align: center; color: var(--muted); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin 1s linear infinite; vertical-align: -6px; margin-right: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Download cards ---------- */
.dl-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.dl-card { display: flex; align-items: center; gap: 14px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); transition: .15s; }
.dl-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.dl-card .ico { width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg,#1f2230,#2c3142); color: #fff; display: grid; place-items: center; font-size: 20px; flex: none; }
.dl-card .info { flex: 1; min-width: 0; }
.dl-card .info .nm { font-weight: 600; font-size: 14.5px; word-break: break-all; }
.dl-card .info .sz { font-size: 12.5px; color: var(--faint); }
.dl-card .dl-btn { flex: none; background: var(--accent); color: #fff; padding: 9px 15px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.dl-card .dl-btn:hover { background: var(--accent-2); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); padding: 34px 0 46px; color: var(--faint); font-size: 13px; }
.footer .wrap { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; align-items: center; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; flex-direction: row; flex-wrap: wrap; }
  .sidebar .s-label { width: 100%; }
  .sidebar a { flex: 1 1 auto; justify-content: center; }
  .dl-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .grid { grid-template-columns: 1fr; }
  .nav .links { display: none; position: absolute; top: var(--nav-h); right: 12px; left: 12px; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 8px; box-shadow: var(--shadow-lg); }
  .nav .links.open { display: flex; }
  .nav-toggle { display: block; }
  .memo-host { min-height: 120px; }
}
