/*
 * DigitalStudio design system — matches MeowSphere (喵友圈).
 * Warm palette: cream page, white cards, orange brand ramp, stone text.
 * Use these tokens and components instead of one-off colours so every page matches.
 *
 * The "webpage colour" setting (/settings/webpage_color) still works: when the
 * user saved custom colours, --webapp-* variables override the defaults below.
 */
:root {
  --brand-50: #fff6ea;
  --brand-100: #ffeacf;
  --brand-200: #ffd3a8;
  --brand-300: #ffb376;
  --brand-500: var(--webapp-btn-color1, #e48233);
  --brand-600: var(--webapp-btn-color2, #ca6719);
  --brand-700: #a24e10;
  --cream: #fef9f1;
  --amber-50: #fffbeb;

  --stone-50: #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-400: #a8a29e;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-700: #44403c;
  --stone-800: #292524;
  --stone-900: #1c1917;

  --ok-bg: #ecfccb;   --ok-fg: #3f6212;
  --info-bg: #e0f2fe; --info-fg: #075985;
  --warn-bg: #fef3c7; --warn-fg: #92400e;
  --bad-bg: #ffe4e6;  --bad-fg: #9f1239;

  --page-bg-1: var(--webapp-bg-color1, var(--cream));
  --page-bg-2: var(--webapp-bg-color2, var(--cream));
  --text: var(--webapp-text-color, var(--stone-800));

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans",
    "Microsoft YaHei", "Noto Sans CJK SC", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --shadow-card: 0 1px 2px rgba(110, 80, 50, 0.06), 0 4px 16px -4px rgba(110, 80, 50, 0.08);
  --shadow-lift: 0 2px 4px rgba(110, 80, 50, 0.06), 0 12px 32px -8px rgba(110, 80, 50, 0.16);

  --radius-sm: 0.75rem;
  --radius: 1rem;
  --radius-lg: 1.5rem;
  --header-h: 3.6rem;
  --content-w: 64rem;
}

*, *::before, *::after { box-sizing: border-box; }
/* The hidden attribute must win over component display rules (.notice, .badge, flex rows...) */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: linear-gradient(180deg, var(--page-bg-1), var(--page-bg-2)) fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--brand-200); color: var(--stone-900); }
:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

h1, h2, h3, h4 { color: var(--stone-900); line-height: 1.25; letter-spacing: -0.01em; }
a { color: var(--brand-700); text-underline-offset: 2px; }
img, video, canvas { max-width: 100%; }

/* Lucide icons (<i data-lucide="..."> becomes <svg class="lucide">) */
svg.lucide { width: 1.15em; height: 1.15em; flex-shrink: 0; stroke-width: 1.9; vertical-align: -0.2em; }

/* ---------- Site shell ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(255, 234, 207, 0.8);
  background: rgba(255, 255, 255, 0.8);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.site-header__inner {
  max-width: var(--content-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  min-height: var(--header-h);
}
.site-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--stone-900);
  text-decoration: none;
}
.site-brand__mark {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  color: #fff;
  background: linear-gradient(135deg, var(--brand-300), var(--brand-500));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.site-brand__mark svg.lucide { width: 1.25rem; height: 1.25rem; stroke-width: 2; }
.site-brand__logo { display: block; width: 2.25rem; height: 2.25rem; flex-shrink: 0; }
.site-footer__brand img { display: block; }
.site-nav {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  font-size: 0.875rem;
  color: var(--stone-600);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}
.site-nav a:hover { background: var(--brand-50); color: var(--stone-900); }
.site-nav a[aria-current="page"] { background: var(--brand-100); color: var(--brand-700); font-weight: 500; }
.site-header__tools { display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }
.site-user {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem 0.25rem 0.25rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--stone-700);
}

.site-user { text-decoration: none; transition: background-color 0.15s; }
.site-user:hover { background: var(--stone-100); color: var(--stone-900); }
@media (max-width: 640px) { .site-user__name { display: none; } }

/* Character avatars (static/js/avatar.js fills [data-avatar]) */
.avatar {
  display: inline-block; flex-shrink: 0; width: 2.5rem; height: 2.5rem; overflow: hidden;
  border-radius: 999px; background: var(--brand-50); vertical-align: middle;
}
.avatar svg { display: block; width: 100%; height: 100%; }
.avatar--sm { width: 1.75rem; height: 1.75rem; }
.avatar--xs { width: 1.25rem; height: 1.25rem; }
.avatar--lg { width: 6rem; height: 6rem; box-shadow: 0 0 0 4px var(--brand-100); }

.lang-select {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: var(--stone-500);
}
.lang-select svg.lucide { position: absolute; left: 0.6rem; pointer-events: none; }
.lang-select select {
  appearance: none;
  -webkit-appearance: none;
  height: 2.25rem;
  padding: 0 0.75rem 0 2rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  color: var(--stone-600);
  cursor: pointer;
}
.lang-select select:hover { background: var(--stone-100); color: var(--stone-900); }

.site-main {
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
}
@media (min-width: 640px) { .site-main { padding-top: 2.5rem; } }

.site-footer {
  margin-top: 2rem;
  border-top: 1px solid var(--brand-100);
  background: rgba(255, 255, 255, 0.6);
}
.site-footer__inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--stone-500);
}
.site-footer__brand { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 500; color: var(--stone-700); }
.site-footer__brand svg.lucide { color: var(--brand-500); }
.site-footer__links { display: flex; flex-wrap: wrap; gap: 0.25rem; }

/* ---------- Page hero ---------- */
.page-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--brand-100), var(--brand-50) 55%, var(--amber-50));
  box-shadow: inset 0 0 0 1px var(--brand-100);
  text-align: left;
}
@media (min-width: 640px) { .page-hero { padding: 2rem; } }
.page-hero--lg { padding: 1.75rem; }
@media (min-width: 640px) { .page-hero--lg { padding: 3rem; } }
.page-hero::after {
  /* faint rocket watermark, like MeowSphere's paw print */
  content: "";
  position: absolute;
  right: -1.5rem;
  bottom: -2rem;
  width: 11rem;
  height: 11rem;
  transform: rotate(12deg);
  opacity: 0.07;
  pointer-events: none;
  background: var(--brand-500);
  -webkit-mask: url("../images/hero-mark.svg") center / contain no-repeat;
  mask: url("../images/hero-mark.svg") center / contain no-repeat;
}
/* A hero with the search box must not clip its dropdown: the watermark stays inside instead. */
.page-hero:has(.search-container) { overflow: visible; z-index: 5; }
.page-hero:has(.search-container)::after { right: 0.75rem; bottom: 0.5rem; width: 9rem; height: 9rem; }
/* Title-only heroes: centre the title against the icon */
.page-hero:not(:has(.page-hero__subtitle, .page-hero__actions)) { align-items: center; }
.page-hero__icon {
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.8);
  color: var(--brand-600);
  box-shadow: var(--shadow-card);
}
.page-hero__icon svg.lucide { width: 1.6rem; height: 1.6rem; stroke-width: 1.75; }
.page-hero__icon--logo { padding: 0; overflow: hidden; background: transparent; }
.page-hero__icon--logo img { width: 100%; height: 100%; display: block; }
@media (min-width: 640px) { .page-hero__icon { width: 3.5rem; height: 3.5rem; } }
.page-hero--lg .page-hero__icon { width: 4rem; height: 4rem; }
.page-hero--lg .page-hero__icon svg.lucide { width: 2rem; height: 2rem; }
.page-hero__body { position: relative; min-width: 0; flex: 1; }
.page-hero h1,
.page-hero__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--stone-900);
  text-shadow: none;
}
@media (min-width: 640px) { .page-hero h1, .page-hero__title { font-size: 1.875rem; } }
.page-hero--lg h1 { font-size: 1.875rem; }
@media (min-width: 640px) { .page-hero--lg h1 { font-size: 3rem; } }
.page-hero__subtitle { margin: 0.5rem 0 0; max-width: 42rem; color: var(--stone-600); }
@media (min-width: 640px) { .page-hero__subtitle { font-size: 1.125rem; } }
.page-hero__actions { margin-top: 1.25rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.page-hero__actions:empty { display: none; }

/* ---------- Cards & grids ---------- */
.card {
  border-radius: var(--radius);
  background: #fff;
  padding: 1.25rem;
  box-shadow: var(--shadow-card), inset 0 0 0 1px var(--stone-100);
}
@media (min-width: 640px) { .card { padding: 1.5rem; } }
.card-title, .section-title {
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--stone-900);
}
.section-title { margin-top: 2rem; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--stone-500); }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(13.5rem, 100%), 1fr));
  gap: 0.75rem;
}
.tile {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  background: #fff;
  color: var(--stone-800);
  text-decoration: none;
  font-weight: 500;
  box-shadow: var(--shadow-card), inset 0 0 0 1px var(--stone-100);
  transition: box-shadow 0.2s, transform 0.2s, color 0.2s;
}
.tile:hover { box-shadow: var(--shadow-lift), inset 0 0 0 1px var(--brand-100); transform: translateY(-2px); color: var(--stone-900); background: #fff; }
.tile--danger .tile__icon { background: var(--bad-bg); color: var(--bad-fg); }
.tile--danger:hover { color: var(--bad-fg); }
button.tile { width: 100%; margin: 0; border: 0; font: inherit; font-weight: 500; text-align: left; justify-content: flex-start; cursor: pointer; line-height: inherit; }
div.tile:hover { transform: none; box-shadow: var(--shadow-card), inset 0 0 0 1px var(--stone-100); }
.tile__icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  background: var(--brand-50);
  color: var(--brand-600);
}
.tile__icon svg.lucide { width: 1.3rem; height: 1.3rem; }
.tile__text { min-width: 0; display: flex; flex-direction: column; }
.tile__desc { font-size: 0.8rem; font-weight: 400; color: var(--stone-500); }
.tile__arrow { margin-left: auto; color: var(--stone-300); transition: color 0.2s, transform 0.2s; }
.tile:hover .tile__arrow { color: var(--brand-500); transform: translateX(2px); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn-primary { background: var(--brand-500); color: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06); }
.btn-primary:hover { background: var(--brand-600); color: #fff; }
.btn-primary:active { background: var(--brand-700); }
.btn-secondary { background: #fff; color: var(--stone-700); box-shadow: inset 0 0 0 1px var(--stone-200); }
.btn-secondary:hover { background: var(--stone-50); color: var(--stone-900); }
.btn-ghost { padding: 0.375rem 0.625rem; font-size: 0.875rem; background: transparent; color: var(--stone-500); }
.btn-ghost:hover { background: var(--stone-100); color: var(--stone-800); }
.btn-danger { background: #fff; color: var(--bad-fg); box-shadow: inset 0 0 0 1px #fecdd3; }
.btn-danger:hover { background: var(--bad-bg); }

/* ---------- Forms ---------- */
.input,
input[type="text"], input[type="password"], input[type="email"], input[type="search"],
input[type="number"], input[type="url"], input[type="tel"], input[type="date"], select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--stone-200);
  border-radius: var(--radius-sm);
  background: #fff;
  font: inherit;
  color: var(--stone-900);
  box-shadow: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder, input::placeholder, textarea::placeholder { color: var(--stone-400); opacity: 1; }
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--brand-500);
  outline: none;
  box-shadow: 0 0 0 4px var(--brand-100);
}
input[type="checkbox"], input[type="radio"], input[type="range"], input[type="color"] { accent-color: var(--brand-500); }
label { color: var(--stone-700); font-weight: 500; }

/* ---------- Tables ---------- */
.table-wrap, .table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-card), inset 0 0 0 1px var(--stone-100);
}
table { width: 100%; border-collapse: collapse; font-size: 0.925rem; color: var(--stone-700); background: transparent; }
th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--stone-500);
  background: var(--stone-50);
  border-bottom: 1px solid var(--stone-200);
}
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--stone-100); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--brand-50); }

/* ---------- Badges, empty states, alerts ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--stone-100);
  color: var(--stone-600);
}
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-info { background: var(--info-bg); color: var(--info-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge-bad { background: var(--bad-bg); color: var(--bad-fg); }

.empty-state {
  padding: 3rem 1.5rem;
  border: 2px dashed var(--brand-200);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.6);
  text-align: center;
  color: var(--stone-500);
}
.empty-state svg.lucide { display: block; margin: 0 auto 0.75rem; width: 2.5rem; height: 2.5rem; color: var(--brand-300); stroke-width: 1.5; }

.notice {
  display: flex;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--brand-50);
  color: var(--stone-700);
  box-shadow: inset 0 0 0 1px var(--brand-100);
}

.notice svg.lucide { margin-top: 0.15rem; color: var(--brand-600); }
.notice--error { background: var(--bad-bg); color: var(--bad-fg); box-shadow: none; }
.notice--error svg.lucide { color: var(--bad-fg); }
.flash-list { display: grid; gap: 0.5rem; margin-bottom: 1rem; }

/* Back button: a light pill above the page hero (templates/partials/back.html), unlike the action buttons */
.back-bar { margin-top: 1.25rem; margin-bottom: 0.75rem; }
@media (min-width: 640px) { .back-bar { margin-top: 2rem; } }
.back-bar + .page-hero, .back-bar + script + .page-hero { margin-top: 0 !important; }
a.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.9rem 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--brand-50);
  color: var(--brand-700);
  box-shadow: inset 0 0 0 1px var(--brand-100);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s, box-shadow 0.15s;
}
a.back-link:hover { background: var(--brand-100); color: var(--brand-700); box-shadow: inset 0 0 0 1px var(--brand-200); }
a.back-link svg.lucide { width: 1rem; height: 1rem; transition: transform 0.15s; }
a.back-link:hover svg.lucide { transform: translateX(-2px); }
a.back-link--top { margin: 0 0 0.75rem; }

.stack > * + * { margin-top: 1rem; }
.muted { color: var(--stone-500); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Desktop: the header (capped at the content width) also holds search, language, account and admin, so the nav drops its icons. */
@media (min-width: 901px) {
  .site-nav { gap: 0.1rem; }
  .site-nav a { padding: 0.375rem 0.6rem; }
  .site-nav a svg.lucide { display: none; }
}
/* Phones and portrait tablets: the nav moves to its own full-width, swipeable row
   (with a fade on the right edge) so every section stays visible. */
@media (max-width: 900px) {
  :root { --header-h: 6rem; }
  .site-header__inner { flex-wrap: wrap; row-gap: 0.15rem; padding-bottom: 0.35rem; }
  .site-header__tools { margin-left: auto; }
  .site-nav {
    order: 3; flex: 1 0 100%;
    margin: 0 -1rem; padding: 0 1rem;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 2rem), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 2rem), transparent);
  }
  .site-nav a { padding: 0.45rem 0.8rem; }
}
@media (max-width: 640px) {
  .site-brand__name { display: none; }
  .lang-select select { max-width: 7.5rem; text-overflow: ellipsis; }
  .site-header__inner { gap: 0.5rem; padding-left: 0.75rem; padding-right: 0.75rem; }
  .site-nav { margin: 0 -0.75rem; padding: 0 0.75rem; }
  /* Tables scroll sideways instead of squashing every cell into a column of single characters. */
  .table-wrap th, .table-wrap td, .table-container th, .table-container td { padding: 0.6rem 0.75rem; white-space: nowrap; }
  .table-wrap .cell-text { min-width: 14rem; white-space: pre-wrap; }
}

/* Download lists (templates/partials/file_list.html) */
.file-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.6rem; }
.file-row {
  display: flex; align-items: center; gap: 0.85rem; margin: 0; padding: 0.85rem 1rem;
  border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-card), inset 0 0 0 1px var(--stone-100);
}
.file-row__icon { display: grid; place-items: center; flex-shrink: 0; width: 2.5rem; height: 2.5rem; border-radius: var(--radius-sm); background: var(--brand-50); color: var(--brand-600); }
.file-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.file-row__name { color: var(--stone-900); font-weight: 600; overflow-wrap: anywhere; }
.file-row__meta { font-size: 0.8rem; color: var(--stone-500); }
.file-row__btn { flex-shrink: 0; white-space: nowrap; }
.file-list__empty {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin: 0; padding: 1.5rem 1rem;
  border-radius: var(--radius); border: 2px dashed var(--brand-200); color: var(--stone-500); font-size: 0.9rem;
}
@media (max-width: 480px) {
  .file-row { flex-wrap: wrap; }
  .file-row__btn { flex: 1 0 100%; }
}

/* ---------- Search (static/js/search.js) ---------- */
.search-results { list-style: none; margin: 0; padding: 0.35rem; }
.search-results li { margin: 0; padding: 0; background: none; border: 0; }
.search-item {
  display: flex; align-items: center; gap: 0.85rem; min-height: 3.4rem; padding: 0.6rem 0.8rem; border-radius: var(--radius-sm);
  color: var(--stone-800); text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.search-item:hover, .search-item.is-active { background: var(--brand-50); color: var(--stone-900); }
.search-item.is-active { box-shadow: inset 0 0 0 1px var(--brand-200); }
.search-item__icon { display: grid; place-items: center; flex-shrink: 0; width: 2.4rem; height: 2.4rem; border-radius: 0.7rem; background: var(--brand-50); color: var(--brand-600); }
.search-item.is-active .search-item__icon, .search-item:hover .search-item__icon { background: #fff; }
.search-item__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.search-item__icon svg.lucide { width: 1.25rem; height: 1.25rem; }
.search-item__title { font-size: 1rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item__title mark { background: none; color: var(--brand-700); font-weight: 700; padding: 0; }
.search-item__section { font-size: 0.82rem; color: var(--stone-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-group { display: flex; align-items: center; justify-content: space-between; padding: 0.55rem 0.65rem 0.25rem !important; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--stone-400); }
.search-results .search-group__action, .search-results .search-group__action:hover {
  min-height: 0; margin: 0; padding: 0.1rem 0.4rem; border: 0; border-radius: 0.4rem; background: none; box-shadow: none;
  font: inherit; font-size: 0.75rem; text-transform: none; letter-spacing: 0; color: var(--brand-700); cursor: pointer; transform: none;
}
.search-results .search-group__action:hover { background: var(--brand-50); }
.search-empty { padding: 0.9rem 0.75rem !important; color: var(--stone-500); font-size: 0.9rem; text-align: center; }

.search-dialog {
  width: min(44rem, calc(100% - 2rem)); max-height: min(85vh, 46rem); margin: 10vh auto auto; padding: 0; border: 0;
  border-radius: var(--radius-lg); background: #fff; color: var(--stone-800); overflow: hidden;
  box-shadow: 0 24px 60px rgba(28, 25, 23, 0.25), inset 0 0 0 1px var(--stone-100);
}
.search-dialog[open] { display: flex; flex-direction: column; }
.search-dialog::backdrop { background: rgba(28, 25, 23, 0.35); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.search-dialog__field { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.75rem 0.6rem 1rem; border-bottom: 1px solid var(--stone-100); color: var(--stone-400); }
.search-dialog__field svg.lucide { width: 1.25rem; height: 1.25rem; }
.search-dialog__field input { flex: 1; min-width: 0; border: 0; box-shadow: none; padding: 0.65rem 0; background: transparent; font-size: 1.15rem; }
.search-dialog__field input:focus { box-shadow: none; outline: none; }
.search-dialog__field input::-webkit-search-cancel-button { display: none; }
.search-dialog .search-dialog__close {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem; min-height: 0; margin: 0; padding: 0; border: 0;
  border-radius: 999px; background: transparent; color: var(--stone-500); box-shadow: none; cursor: pointer;
}
.search-dialog .search-dialog__close:hover { background: var(--stone-100); color: var(--stone-800); transform: none; }
.search-dialog .search-results { overflow-y: auto; flex: 1; }
.search-dialog__hint { margin: 0; padding: 0.5rem 1rem; border-top: 1px solid var(--stone-100); font-size: 0.75rem; color: var(--stone-400); }
html.search-open { overflow: hidden; }
@media (pointer: coarse) { .search-dialog__hint { display: none; } }
@media (max-width: 640px) {
  .search-dialog { width: calc(100% - 1.5rem); margin-top: 0.75rem; max-height: calc(100svh - 1.5rem); border-radius: var(--radius); }
}

/* Header that slides away on scroll (site-shell.js adds the class on narrow screens). */
.site-header { transition: transform 0.25s ease; }
.site-header--away { transform: translateY(-100%); }

/* ---------- Phones: denser, app-like layout ---------- */
@media (max-width: 640px) {
  .site-main { padding-top: 1rem; padding-bottom: 2rem; }
  .back-bar { margin-top: 0.85rem; margin-bottom: 0.6rem; }
  .page-hero { gap: 0.85rem; margin-bottom: 1.1rem; padding: 1.1rem 1.15rem; border-radius: var(--radius); }
  .page-hero--lg { padding: 1.35rem 1.15rem; }
  .page-hero::after { width: 8rem; height: 8rem; }
  .page-hero__icon { width: 2.6rem; height: 2.6rem; }
  .page-hero__icon svg.lucide { width: 1.35rem; height: 1.35rem; }
  .page-hero--lg .page-hero__icon { width: 3.25rem; height: 3.25rem; }
  .page-hero h1, .page-hero__title { font-size: 1.3rem; line-height: 1.3; }
  .page-hero--lg h1 { font-size: 1.6rem; }
  .page-hero__subtitle { margin-top: 0.3rem; font-size: 0.9rem; line-height: 1.55; }
  .page-hero__actions { margin-top: 0.9rem; }
  /* large hero (home): logo + title on one line, subtitle and search box use the full width */
  .page-hero--lg { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 0.85rem; }
  .page-hero--lg .page-hero__body { display: contents; }
  .page-hero--lg .page-hero__subtitle, .page-hero--lg .page-hero__actions { grid-column: 1 / -1; }
  .page-hero--lg .page-hero__subtitle { margin-top: 0.6rem; }
  .page-hero__actions .search-container { flex: 1 0 100%; }
  .page-hero__actions .search-container input { width: 100%; }
  .section-title { margin-top: 1.4rem; margin-bottom: 0.6rem; }
  .card { padding: 1.1rem; }

  /* Tiles: two per row, icon above the label */
  .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .tile-grid > .tile {
    position: relative; flex-direction: column; align-items: flex-start; justify-content: flex-start;
    gap: 0.55rem; min-height: 6.25rem; padding: 0.9rem; font-size: 0.925rem; line-height: 1.35;
  }
  .tile-grid > .tile .tile__text { overflow-wrap: anywhere; }
  .tile-grid > .tile .tile__desc { display: none; }
  .tile-grid > .tile .tile__arrow { position: absolute; top: 0.8rem; right: 0.7rem; width: 1rem; height: 1rem; }
}
@media (max-width: 340px) { .tile-grid { grid-template-columns: 1fr; } }

/* Touch screens: press feedback instead of hover effects that stick after a tap */
@media (hover: none) {
  .tile:hover { transform: none; box-shadow: var(--shadow-card), inset 0 0 0 1px var(--stone-100); }
  .tile:hover .tile__arrow { transform: none; color: var(--stone-300); }
  .tile:active { transform: scale(0.98); background: var(--brand-50); }
  .btn:active { transform: scale(0.97); }
}

/* Touch screens: 16px form text stops iOS zooming in on focus; no grey tap flash. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
a, button, summary, label, .tile { -webkit-tap-highlight-color: transparent; }
@media (pointer: coarse) {
  input, select, textarea, .lang-select select { font-size: 16px; }
  .btn { min-height: 2.5rem; }
}

/* Motion: hover transitions only, no page animations. Everything is switched off when the
   visitor asks for less motion (OS setting, or the switch in Display Settings -> html.reduce-motion). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}
html.reduce-motion { scroll-behavior: auto; }
