/* Shared look for the static pages and the pattern gallery – the same colors, top bar and cards as the app (style.css). */
:root {
  --bg: #FFF8F4;
  --surface: #FFFFFF;
  --text: #2B2230;
  --muted: #7A6E80;
  --line: #EFE3E6;
  /* As in the app: white text on --accent and --accent-text as text on the background have a contrast of at least 4.5:1. */
  --accent: #D1345A;
  --accent-ink: #FFFFFF;
  --accent-text: #D1345A;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(60, 20, 40, .08);
  color-scheme: light;
}
/* Dark theme: following the system or chosen in the app's menu (data-theme from theme.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #19141C;
    --surface: #241E28;
    --text: #F4ECF2;
    --muted: #A99DAF;
    --line: #3A3140;
    --accent-text: #F06A8C;
    --shadow: 0 2px 10px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #19141C;
  --surface: #241E28;
  --text: #F4ECF2;
  --muted: #A99DAF;
  --line: #3A3140;
  --accent-text: #F06A8C;
  --shadow: 0 2px 10px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  -webkit-tap-highlight-color: transparent;
}

/* The top bar as in the app: logo and name (to the app) and a button – the content has the same width as the page. */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, calc((100% - 720px) / 2 + 16px)) 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
@media (orientation: landscape) and (max-height: 500px) { .top { position: static; } }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); font-size: 1.15rem; font-weight: 700; text-decoration: none; }
.brand img { width: 36px; height: 36px; flex: none; }
.top-cta {
  flex: none; padding: 8px 16px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: .95rem; text-decoration: none;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(40px + env(safe-area-inset-bottom));
}
/* The content in a card like the app's (the gallery's overview sits directly on the background – the patterns are cards themselves). */
article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px 6px;
}
article.plain { background: none; border: 0; box-shadow: none; padding: 4px 0 0; }
.back { display: inline-block; margin-bottom: 10px; color: var(--accent-text); font-weight: 600; text-decoration: none; }
h1 { font-size: 1.55rem; line-height: 1.2; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 26px 0 6px; }
.muted { color: var(--muted); margin: 0 0 16px; }
a { color: var(--accent-text); }
ul, ol { padding-left: 1.2em; }
li { margin: 5px 0; }
li::marker { color: var(--accent-text); }
ol > li::marker { font-weight: 700; }
table { width: 100%; border-collapse: collapse; margin: 12px 0 4px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-size: .9rem; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
/* The invitation to open the app: tinted in the app's color. */
.box {
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 24px 0 8px;
}
.box p { margin: 4px 0; }
.box .cta { margin-top: 6px; }
footer { margin-top: 24px; padding: 12px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
article.plain footer { margin-top: 32px; }
.small { font-size: .9rem; }

.colors { list-style: none; padding: 0; margin: 16px 0 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.colors li { display: flex; align-items: center; gap: 8px; margin: 0; padding: 6px 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.colors li::marker { content: none; }
.colors b { font-variant-numeric: tabular-nums; }
/* The bead as in the app (.bead in style.css): round with a hole in the middle. */
.bead {
  --c: #ccc;
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle, var(--bg) 0 26%, var(--c) 28%);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, .18), inset 0 3px 5px rgba(255, 255, 255, .35), 0 0 0 1px rgba(0, 0, 0, .08);
}
.bead.small { width: 26px; height: 26px; }
/* Transparent beads (CLEAR_CODES in db.js) are shown semi-transparent as in the app. */
.bead.clear { opacity: .55; }
/* The color chart on /colors: cards as in the app's color chart (.swatches in style.css). */
.color-chart { list-style: none; padding: 0; margin: 16px 0 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.color-chart li {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; margin: 0;
  padding: 10px 6px; text-align: center; background: var(--bg); border-radius: 14px;
}
.color-chart li::marker { content: none; }
.color-chart b { margin-top: 4px; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.color-chart span:last-child { width: 100%; font-size: .8rem; line-height: 1.2; overflow-wrap: anywhere; }
/* The pattern gallery (/patterns, gallery.js) */
.motifs { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.motifs li { margin: 0; }
.motifs a { display: flex; flex-direction: column; gap: 2px; height: 100%; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); text-decoration: none; }
.motifs a:hover b { color: var(--accent-text); }
.motifs img { width: 100%; height: 110px; object-fit: contain; border-radius: 8px; background: #EEEAE4; margin-bottom: 4px; }
.motifs b { overflow-wrap: anywhere; }
.motifs span { color: var(--muted); font-size: .85rem; }
/* Search and categories in the gallery */
.motif-search { margin: 16px 0 10px; }
.motif-search .search-row { display: flex; gap: 8px; }
.motif-search .filter-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 8px; }
.plain[aria-busy="true"] .motifs { opacity: .55; transition: opacity .2s; }
.motif-search select { max-width: 100%; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; }
.motif-search .check { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; }
.motif-search input { flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; }
.motif-search button { padding: 10px 18px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chips a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font-size: .9rem; text-decoration: none; }
.chips a[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.more { margin: 0 0 8px; font-weight: 600; }
/* The pattern can be zoomed and dragged around (pages.js): the picture is moved/scaled with transform inside the frame. */
.motif-zoom { position: relative; width: fit-content; max-width: 100%; margin: 8px 0 4px; border-radius: 12px; overflow: hidden; touch-action: pan-x pan-y; user-select: none; -webkit-user-select: none; }
.motif-zoom.zoomed { touch-action: none; cursor: grab; }
.motif-zoom.dragging { cursor: grabbing; }
img.motif { display: block; max-width: 100%; height: auto; transform-origin: 0 0; image-rendering: pixelated; -webkit-user-drag: none; }
.motif-tools { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; }
.motif-tools button { width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--text); font-size: 1.2rem; line-height: 1; cursor: pointer; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.motif-tools button:disabled { opacity: .4; cursor: default; }
.colors .count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.pager { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.report { margin: 16px 0; }
.report .link { padding: 0; border: 0; background: none; color: var(--accent-text); font: inherit; text-decoration: underline; cursor: pointer; }
.cta { display: inline-block; padding: 10px 20px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; }
/* Cookie banner (analytics.js) – as in the app */
.cookie-banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 50;
  max-width: 560px; margin: 0 auto; padding: 12px 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 2px 10px rgba(60, 20, 40, .12);
  font-size: .9rem; line-height: 1.45;
}
.cookie-banner p { margin: 0 0 10px; }
.cookie-btns { display: flex; gap: 8px; }
.cookie-btns button { flex: 1; border: 0; border-radius: 999px; padding: 10px; font: inherit; font-weight: 600; background: var(--accent); color: #fff; }
