/* QingNotes — Responsive Editorial Stylesheet
   Paper warmth, deep ink, and warm tin-red accent.
   Zero external dependencies; supports web and in-app views, light & dark modes. */

:root {
  color-scheme: light dark;

  /* Paper & ink palette (light: warm xuan paper & deep ink) */
  --paper: #f7f4ec;
  --paper-raised: #fffdf8;
  --paper-tint: #efeae0;
  --paper-glow: rgb(255 253 247 / 0.72);

  --ink: #22201c;
  --ink-muted: #565149;
  --ink-subtle: #6b655c;

  --line: #ded8cb;
  --line-strong: #c4bcb0;
  --line-subtle: rgb(34 32 28 / 0.085);

  /* Warm tin-red / terracotta accent (WCAG AA contrast verified) */
  --accent: #9b442b;
  --accent-hover: #833620;
  --accent-ink: #8c3b24;
  --accent-soft: #f2e1d7;
  --accent-line: rgb(140 59 36 / 0.42);
  --on-accent: #fffbf6;
  --focus: #8c3b24;

  --shadow-frame:
    0 1px 2px rgb(38 31 22 / 0.08),
    0 14px 36px -10px rgb(38 31 22 / 0.14);
  --shadow-button:
    0 1px 2px rgb(38 31 22 / 0.14),
    inset 0 1px 0 rgb(255 255 255 / 0.18);

  /* Typography & layout */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI",
    system-ui, sans-serif;
  --font-serif: "New York", "Songti SC", "STSong", "Noto Serif CJK SC",
    "Source Han Serif SC", Georgia, "Times New Roman", serif;

  --container: 68rem;
  --measure: 44rem;
  --gutter: clamp(1rem, 4vw, 2.25rem);

  --radius-sm: 8px;
  --radius-md: 12px;
  --fast: 150ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  accent-color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #191715;
    --paper-raised: #22201c;
    --paper-tint: #2b2824;
    --paper-glow: rgb(220 134 102 / 0.06);

    --ink: #f1ece2;
    --ink-muted: #c2bab0;
    --ink-subtle: #9e968b;

    --line: #34312c;
    --line-strong: #4e4942;
    --line-subtle: rgb(241 236 226 / 0.09);

    --accent: #dc8666;
    --accent-hover: #e7997b;
    --accent-ink: #efa98d;
    --accent-soft: #3d2a22;
    --accent-line: rgb(239 169 141 / 0.48);
    --on-accent: #1d1410;
    --focus: #efa98d;

    --shadow-frame:
      0 2px 6px rgb(0 0 0 / 0.42),
      0 18px 42px -10px rgb(0 0 0 / 0.56);
    --shadow-button:
      0 1px 3px rgb(0 0 0 / 0.36),
      inset 0 1px 0 rgb(255 255 255 / 0.16);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --paper: #191715;
  --paper-raised: #22201c;
  --paper-tint: #2b2824;
  --paper-glow: rgb(220 134 102 / 0.06);

  --ink: #f1ece2;
  --ink-muted: #c2bab0;
  --ink-subtle: #9e968b;

  --line: #34312c;
  --line-strong: #4e4942;
  --line-subtle: rgb(241 236 226 / 0.09);

  --accent: #dc8666;
  --accent-hover: #e7997b;
  --accent-ink: #efa98d;
  --accent-soft: #3d2a22;
  --accent-line: rgb(239 169 141 / 0.48);
  --on-accent: #1d1410;
  --focus: #efa98d;

  --shadow-frame:
    0 2px 6px rgb(0 0 0 / 0.42),
    0 18px 42px -10px rgb(0 0 0 / 0.56);
  --shadow-button:
    0 1px 3px rgb(0 0 0 / 0.36),
    inset 0 1px 0 rgb(255 255 255 / 0.16);
}

:root[data-theme="light"] {
  color-scheme: light;
}

/* ── Reset & Base ─────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  background-color: var(--paper);
}

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background-color: var(--paper);
  background-image: radial-gradient(75% 420px at 50% 0%, var(--paper-glow), transparent 72%);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  text-autospace: normal;
}

:lang(zh) body,
body:lang(zh) {
  line-height: 1.8;
}

main {
  flex: 1 0 auto;
}

main:focus {
  outline: none;
}

h1,
h2,
h3,
h4,
p,
figure,
ul,
ol {
  margin: 0;
}

img,
svg,
picture {
  display: block;
  max-width: 100%;
}

button,
select,
input {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent-ink);
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1.25px;
  text-decoration-color: var(--accent-line);
  transition: color var(--fast) var(--ease),
    text-decoration-color var(--fast) var(--ease);
}

a:hover {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

/* ── Skip Link ────────────────────────────────────────────────── */

.skip {
  position: fixed;
  inset-block-start: calc(0.75rem + env(safe-area-inset-top, 0px));
  inset-inline-start: calc(0.75rem + env(safe-area-inset-left, 0px));
  z-index: 100;
  padding: 0.6rem 1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-frame);
  transform: translateY(-200%);
  opacity: 0;
  pointer-events: none;
}

.skip:focus,
.skip:focus-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ── Container ────────────────────────────────────────────────── */

.wrap {
  width: min(100%, var(--container));
  margin-inline: auto;
  padding-inline:
    max(var(--gutter), env(safe-area-inset-left, 0px))
    max(var(--gutter), env(safe-area-inset-right, 0px));
}

.wrap .wrap {
  width: 100%;
  padding-inline: 0;
}

body > .wrap {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

body > .wrap > main {
  flex: 1 0 auto;
}

/* ── Header, Brand, Nav, Language Switcher ────────────────────── */

.site-header {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block:
    calc(clamp(0.875rem, 2vw, 1.25rem) + env(safe-area-inset-top, 0px))
    clamp(0.875rem, 2vw, 1.25rem);
  border-bottom: 1px solid var(--line);
}

.site-header > .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.5rem;
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover {
  color: var(--accent-ink);
}

.brand img,
.brand svg {
  width: 1.875rem;
  height: 1.875rem;
  flex: none;
  border-radius: 7px;
  object-fit: contain;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.35rem;
  margin-inline-start: auto;
}

.nav ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.35rem;
  padding: 0;
  list-style: none;
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding-block: 0.25rem;
  color: var(--ink-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1.5px solid transparent;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

.nav a:hover {
  color: var(--ink);
}

.nav a[aria-current="page"],
.nav a.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* Language switcher: supports <a>, <button>, <select>, or container of links */

a.lang,
button.lang {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.35rem;
  padding: 0.3rem 0.78rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--fast) var(--ease),
    border-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}

a.lang:hover,
button.lang:hover {
  background: var(--paper-tint);
  border-color: var(--accent-line);
  color: var(--accent-ink);
}

select.lang {
  appearance: none;
  -webkit-appearance: none;
  min-height: 2.35rem;
  padding: 0.3rem 2rem 0.3rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper-raised)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236b655c' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E")
    no-repeat right 0.55rem center / 1rem;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--fast) var(--ease),
    background-color var(--fast) var(--ease);
}

select.lang:hover {
  border-color: var(--ink-subtle);
  background-color: var(--paper-tint);
}

.lang:not(a):not(button):not(select) {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-tint);
}

.lang:not(a):not(button):not(select) a,
.lang:not(a):not(button):not(select) button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.2rem 0.6rem;
  border: 0;
  border-radius: calc(var(--radius-sm) - 3px);
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}

.lang:not(a):not(button):not(select) a:hover,
.lang:not(a):not(button):not(select) button:hover {
  color: var(--ink);
}

.lang:not(a):not(button):not(select) [aria-current="page"],
.lang:not(a):not(button):not(select) [aria-current="true"],
.lang:not(a):not(button):not(select) [aria-pressed="true"],
.lang:not(a):not(button):not(select) .is-active {
  background: var(--paper-raised);
  color: var(--ink);
  box-shadow: 0 1px 2px rgb(34 32 28 / 0.08);
}

/* ── Hero ─────────────────────────────────────────────────────── */

.hero {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.75rem, 4.5vw, 3.5rem);
  align-items: center;
  padding-block: clamp(2.25rem, 6vw, 4.75rem) clamp(2.25rem, 5vw, 4rem);
}

.hero-copy {
  min-width: 0;
  max-width: 35rem;
}

.hero-copy h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.95rem, 4.2vw, 3.1rem);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-wrap: balance;
}

.hero-copy p {
  margin-top: 1.15rem;
  font-size: clamp(1rem, 1.35vw, 1.1rem);
  line-height: 1.78;
  color: var(--ink-muted);
  max-width: 34em;
  text-wrap: pretty;
}

/* Screenshot container: never clips or crops important content on any screen */

.hero-image {
  min-width: 0;
  width: 100%;
  margin: 0;
}

img.hero-image,
.hero-image img {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  box-shadow: var(--shadow-frame);
}

.hero-image figcaption {
  margin-top: 0.7rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--ink-subtle);
}

/* ── Actions & Buttons ────────────────────────────────────────── */

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.secondary {
  color: var(--ink-muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.65rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-button);
  transition: background-color var(--fast) var(--ease),
    border-color var(--fast) var(--ease),
    color var(--fast) var(--ease),
    transform var(--fast) var(--ease);
}

.button:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
  text-decoration: none;
}

.button:active {
  transform: translateY(1px);
}

.button.secondary {
  background: var(--paper-raised);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: none;
}

.button.secondary:hover {
  background: var(--paper-tint);
  border-color: var(--ink-subtle);
  color: var(--ink);
}

/* ── Features (Editorial Columns, No Card Stacking) ───────────── */

.features {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.75rem, 3vw, 2.75rem);
  padding-block: clamp(2.25rem, 5vw, 3.75rem) clamp(2.75rem, 6vw, 4.5rem);
  border-top: 1px solid var(--line);
}

.feature {
  min-width: 0;
  padding: 0;
}

.feature::before {
  content: "";
  display: block;
  width: 1.75rem;
  height: 2px;
  margin-bottom: 0.9rem;
  border-radius: 2px;
  background: var(--accent);
}

.feature h2,
.feature h3 {
  font-family: var(--font-serif);
  font-size: 1.18rem;
  line-height: 1.38;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 0.6rem;
  text-wrap: balance;
}

.feature p {
  font-size: 0.96875rem;
  line-height: 1.78;
  color: var(--ink-muted);
  text-wrap: pretty;
}

/* ── Legal & Support Document Layout ──────────────────────────── */

.document {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-block: clamp(2rem, 5vw, 3.75rem) clamp(2.75rem, 6vw, 4.75rem);
}

.wrap.document {
  max-width: calc(var(--measure) + 4.5rem);
}

.document-header {
  padding-bottom: clamp(1.25rem, 3vw, 1.75rem);
  margin-bottom: clamp(1.65rem, 3.5vw, 2.35rem);
  border-bottom: 1px solid var(--line);
}

.document-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4.2vw, 2.5rem);
  line-height: 1.24;
  font-weight: 600;
  letter-spacing: -0.018em;
  color: var(--ink);
  text-wrap: balance;
}

.document-header p {
  margin-top: 0.75rem;
  font-size: 1rem;
  line-height: 1.72;
  color: var(--ink-muted);
  max-width: 40em;
  text-wrap: pretty;
}

.document section + section {
  margin-top: clamp(1.6rem, 3.2vw, 2.25rem);
  padding-top: clamp(1.5rem, 3vw, 2rem);
  border-top: 1px solid var(--line-subtle);
}

.document h2 {
  font-family: var(--font-serif);
  font-size: clamp(1.16rem, 2vw, 1.32rem);
  line-height: 1.38;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 0.65rem;
  text-wrap: balance;
}

.document h3 {
  font-size: 1.02rem;
  line-height: 1.45;
  font-weight: 600;
  color: var(--ink);
  margin: 1.25rem 0 0.45rem;
}

.document p {
  margin-bottom: 0.85rem;
  color: var(--ink);
  text-wrap: pretty;
  overflow-wrap: break-word;
}

.document p:last-child {
  margin-bottom: 0;
}

.document ul,
.document ol {
  margin: 0.65rem 0 0.85rem;
  padding-inline-start: 1.4rem;
}

.document li + li {
  margin-top: 0.45rem;
}

.document a {
  overflow-wrap: anywhere;
}

/* ── Footer ───────────────────────────────────────────────────── */

.site-footer {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block:
    clamp(1.5rem, 3.5vw, 2.25rem)
    calc(clamp(1.5rem, 3.5vw, 2.25rem) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  color: var(--ink-subtle);
  font-size: 0.875rem;
  line-height: 1.6;
}

.site-footer > .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block: 0;
}

.site-footer nav,
.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1.25rem;
  padding: 0;
  list-style: none;
}

.site-footer a {
  color: var(--ink-muted);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.site-footer a:hover {
  color: var(--accent-ink);
  text-decoration: underline;
}

/* ── Responsive Breakpoints ───────────────────────────────────── */

@media (max-width: 40rem) {
  .site-header {
    row-gap: 0.6rem;
  }

  .brand {
    order: 1;
  }

  .lang {
    order: 2;
    margin-inline-start: auto;
  }

  .nav {
    order: 3;
    flex-basis: 100%;
    margin-inline-start: 0;
    padding-top: 0.5rem;
    border-top: 1px solid var(--line-subtle);
    gap: 0.25rem 1rem;
  }

  .nav a {
    min-height: 2.35rem;
  }

  .actions {
    gap: 0.65rem;
  }

  .actions .button {
    flex: 1 1 auto;
  }

  .feature + .feature {
    padding-top: 1.5rem;
    border-top: 1px solid var(--line-subtle);
  }
}

@media (min-width: 52rem) {
  .features {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 56rem) {
  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.18fr);
    gap: clamp(2.25rem, 4.5vw, 4rem);
  }
}

/* ── Accessibility & Print Preferences ────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: #a79f92;
    --line-strong: #6e675e;
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --line: #686259;
      --line-strong: #9c9489;
    }
  }

  a {
    text-decoration-thickness: 1.75px;
    text-decoration-color: currentColor;
  }
}

@media (forced-colors: active) {
  .button,
  .button.secondary,
  a.lang,
  button.lang,
  select.lang,
  img.hero-image,
  .hero-image img {
    border: 1px solid CanvasText;
    box-shadow: none;
  }

  .feature::before {
    background: CanvasText;
  }
}

@media print {
  :root {
    --paper: #ffffff;
    --paper-raised: #ffffff;
    --ink: #000000;
    --ink-muted: #222222;
    --ink-subtle: #444444;
    --line: #cccccc;
    --line-subtle: #dddddd;
    --accent-ink: #000000;
  }

  body {
    background: #ffffff;
    color: #000000;
  }

  .skip,
  .nav,
  .lang,
  .actions {
    display: none !important;
  }

  .site-header,
  .site-footer {
    border-color: #cccccc;
  }

  .document {
    max-width: none;
    padding-block: 1rem;
  }

  .hero-image img,
  img.hero-image {
    box-shadow: none;
    border-color: #cccccc;
  }
}

/* Intrinsic language menu works offline and with scripting disabled. */
details.lang:not(a):not(button):not(select) { position: relative; display: block; padding: 0; border: 0; background: transparent; }
.lang summary { cursor: pointer; padding: .45rem .65rem; border: 1px solid var(--line); border-radius: .4rem; font-size: .95rem; }
.language-list { position: absolute; inset: calc(100% + .35rem) 0 auto auto; z-index: 5; min-width: 9rem; padding: .35rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--paper-raised); box-shadow: var(--shadow-frame); }
.lang .language-list a { display: block; min-height: 2.5rem; text-align: start; padding: .45rem .65rem; white-space: nowrap; }
.lang .language-list a[aria-current] { font-weight: 700; color: var(--accent-ink); }
.nav a[aria-current] { text-decoration: underline; text-underline-offset: .35em; }
.document.wrap { width: min(100%, 49rem); margin-inline: auto; }
.document section { padding-block: .35rem; }
.document .contact { margin-block: 2rem 0; }
.library-view { max-width: 54rem; margin: clamp(2rem,5vw,4rem) auto; }
.library-view img { width: 100%; height: auto; border-radius: .65rem; border: 1px solid var(--line); }
.site-footer .foot, .foot div { display: flex; align-items: baseline; flex-wrap: wrap; gap: .6rem 1.25rem; }
.site-footer .foot { justify-content: space-between; }
@media (max-width: 44rem) {
  .site-header .bar { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .25rem 1rem; }
  .site-header .brand { grid-column: 1; grid-row: 1; }
  .site-header details { grid-column: 2; grid-row: 1; justify-self: end; }
  .site-header .nav { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; overflow-wrap: anywhere; }
}
