/* ==========================================================================
   THEME - shared colour tokens for the Dark and the Light theme.   (loaded FIRST)

   How it works
   - The theme is the data-theme attribute on <html>:  "dark" (the default) or "light".  js/theme.js sets it before the page paints,
     the nav-bar toggle changes it, and the choice is remembered in localStorage ("dp-theme").
   - Every colour in the site's stylesheets is written as  rgb(var(--token))  or  rgba(var(--token), alpha).  A token is just the
     three channels of a colour ("94, 214, 240"), so the alpha / opacity written at the point of use never changes between themes,
     only the colour does.
   - The dark values below are the original dark-fantasy palette, unchanged.  The light values (second block) are the warm
     90s / 2000s afternoon palette.  To restyle a theme, edit only the matching block of this file.
   - Tokens are grouped by ROLE (surfaces, text, lines, primary action, accent, ...), numbered from darkest / dimmest to brightest in
     the dark theme.  The comment after each dark value is its original hex and how many times it is used.
   - Light-only component styling (offset "comic" shadows, outlines) lives in css/theme-light.css (loaded last).
   ========================================================================== */

:root {
  /* ---- the Light palette (defined once, used by the light tokens below) ---- */
  --p-cream: 255, 248, 231;        /* #FFF8E7  Warm Cream      - cards, panels */
  --p-tatami: 244, 230, 200;       /* #F4E6C8  Tatami Beige    - page, wells, inputs */
  --p-apricot: 255, 184, 92;       /* #FFB85C  Golden Apricot  - warm highlights, golden-hour glow */
  --p-terracotta: 232, 111, 72;    /* #E86F48  Terracotta      - primary buttons */
  --p-teal: 59, 142, 165;          /* #3B8EA5  Retro Teal      - secondary buttons, links, selection */
  --p-espresso: 61, 43, 31;        /* #3D2B1F  Espresso Ink    - text, outlines */
  --p-sepia: 122, 92, 67;          /* #7A5C43  Muted Sepia     - secondary text */
  --p-sage: 127, 168, 118;         /* #7FA876  Soft Sage       - success, online */
  --p-indigo: 36, 30, 56;          /* #241E38  Indigo          - special accents (toasts, celebration) */
  --p-violet: 157, 101, 255;       /* #9D65FF  Violet glow     - special accents */
  /* shades derived from the palette for readable text (all >= 4.5:1 on cream and on tatami) */
  --p-sepia-ink: 105, 77, 54;      /* #694D36  Muted Sepia, deepened for small text (>= 5:1 on cream and tatami) */
  --p-ink-deep: 43, 29, 19;        /* #2B1D13  headings */
  --p-brown: 88, 64, 46;           /* #58402E  body-muted text */
  --p-teal-ink: 30, 98, 118;       /* #1E6276  teal for text / links */
  --p-terracotta-deep: 168, 62, 32;/* #A83E20  terracotta borders and text */
  --p-on-primary: 28, 15, 8;       /* #1C0F08  text on a terracotta fill */
  --p-focus: 124, 77, 224;         /* #7C4DE0  keyboard focus ring (violet) */
  --p-gold-ink: 138, 90, 18;       /* #8A5A12  gold as text */
  --p-red-ink: 176, 48, 32;        /* #B03020  error text */
  --p-sage-ink: 62, 110, 56;       /* #3E6E38  success text */
}

/* ---------- TOKENS: dark values (default), then the light values ---------- */
:root {
  /* Surfaces: panels, cards, wells, inputs (dark tones become cream / tatami) */
  --surf-1: 2, 3, 6;      /* #020306  x4 */
  --surf-2: 3, 5, 8;      /* #030508  x1 */
  --surf-3: 3, 5, 9;      /* #030509  x4 */
  --surf-4: 4, 6, 10;     /* #04060a  x8 */
  --surf-5: 3, 7, 14;     /* #03070e  x1 */
  --surf-6: 5, 7, 10;     /* #05070a  x9 */
  --surf-7: 6, 8, 11;     /* #06080b  x9 */
  --surf-8: 8, 11, 15;    /* #080b0f  x1 */
  --surf-9: 8, 11, 16;    /* #080b10  x1 */
  --surf-10: 8, 11, 17;   /* #080b11  x2 */
  --surf-11: 8, 12, 18;   /* #080c12  x2 */
  --surf-12: 8, 12, 19;   /* #080c13  x1 */
  --surf-13: 10, 13, 19;  /* #0a0d13  x5 */
  --surf-14: 10, 14, 20;  /* #0a0e14  x6 */
  --surf-15: 9, 14, 22;   /* #090e16  x1 */
  --surf-16: 10, 14, 21;  /* #0a0e15  x1 */
  --surf-17: 11, 14, 20;  /* #0b0e14  x2 */
  --surf-18: 11, 15, 21;  /* #0b0f15  x3 */
  --surf-19: 11, 15, 22;  /* #0b0f16  x3 */
  --surf-20: 10, 16, 26;  /* #0a101a  x1 */
  --surf-21: 12, 16, 23;  /* #0c1017  x4 */
  --surf-22: 12, 17, 24;  /* #0c1118  x1 */
  --surf-23: 13, 17, 25;  /* #0d1119  x3 */
  --surf-24: 4, 18, 31;   /* #04121f  x4 */
  --surf-25: 17, 17, 19;  /* #111113  x1 */
  --surf-26: 13, 18, 24;  /* #0d1218  x2 */
  --surf-27: 13, 18, 25;  /* #0d1219  x1 */
  --surf-28: 14, 18, 24;  /* #0e1218  x3 */
  --surf-29: 13, 18, 27;  /* #0d121b  x1 */
  --surf-30: 14, 18, 26;  /* #0e121a  x4 */
  --surf-31: 20, 18, 14;  /* #14120e  x1 */
  --surf-32: 14, 19, 27;  /* #0e131b  x2 */
  --surf-33: 15, 19, 26;  /* #0f131a  x1 */
  --surf-34: 15, 20, 28;  /* #0f141c  x1 */
  --surf-35: 16, 21, 29;  /* #10151d  x1 */
  --surf-36: 17, 22, 33;  /* #111621  x1 */
  --surf-37: 24, 22, 18;  /* #181612  x1 */
  --surf-38: 18, 23, 31;  /* #12171f  x5 */
  --surf-39: 18, 24, 32;  /* #121820  x3 */
  --surf-40: 18, 24, 35;  /* #121823  x2 */
  --surf-41: 25, 24, 27;  /* #19181b  x1 */
  --surf-42: 20, 26, 34;  /* #141a22  x2 */
  --surf-43: 19, 26, 38;  /* #131a26  x1 */
  --surf-44: 20, 27, 38;  /* #141b26  x1 */
  --surf-45: 21, 27, 37;  /* #151b25  x1 */
  --surf-46: 22, 28, 37;  /* #161c25  x1 */
  --surf-47: 21, 28, 40;  /* #151c28  x2 */
  --surf-48: 20, 30, 44;  /* #141e2c  x1 */
  --surf-49: 24, 31, 41;  /* #181f29  x1 */
  --surf-50: 24, 31, 42;  /* #181f2a  x1 */
  --surf-51: 26, 33, 43;  /* #1a212b  x9 */
  --surf-52: 22, 32, 56;  /* #162038  x1 */
  --surf-53: 26, 33, 44;  /* #1a212c  x1 */
  --surf-54: 22, 34, 50;  /* #162232  x1 */
  --surf-55: 26, 34, 48;  /* #1a2230  x3 */
  --surf-56: 26, 36, 51;  /* #1a2433  x1 */
  --surf-57: 24, 38, 54;  /* #182636  x2 */
  --surf-58: 30, 38, 49;  /* #1e2631  x2 */
  --surf-59: 30, 38, 50;  /* #1e2632  x2 */
  --surf-60: 48, 36, 42;  /* #30242a  x2 */
  --surf-61: 30, 40, 58;  /* #1e283a  x4 */
  --surf-62: 27, 40, 70;  /* #1b2846  x1 */
  --surf-63: 27, 42, 69;  /* #1b2a45  x1 */
  --surf-64: 34, 44, 62;  /* #222c3e  x1 */
  --surf-65: 34, 45, 61;  /* #222d3d  x1 */
  --surf-66: 37, 45, 57;  /* #252d39  x1 */
  --surf-67: 30, 46, 62;  /* #1e2e3e  x1 */
  --surf-68: 34, 46, 66;  /* #222e42  x1 */
  --surf-69: 38, 48, 62;  /* #26303e  x5 */
  --surf-70: 40, 50, 64;  /* #283240  x1 */
  --surf-71: 42, 50, 61;  /* #2a323d  x1 */
  --surf-72: 36, 50, 72;  /* #243248  x2 */
  --surf-73: 42, 52, 67;  /* #2a3443  x1 */
  --surf-74: 42, 52, 70;  /* #2a3446  x1 */
  --surf-75: 43, 53, 67;  /* #2b3543  x1 */
  --surf-76: 34, 54, 87;  /* #223657  x1 */
  --surf-77: 40, 56, 80;  /* #283850  x1 */
  --surf-78: 47, 59, 80;  /* #2f3b50  x1 */
  --surf-79: 43, 66, 104; /* #2b4268  x1 */
  --surf-80: 58, 70, 86;  /* #3a4656  x2 */
  --surf-81: 60, 70, 120; /* #3c4678  x1 */
  --surf-82: 53, 82, 127; /* #35527f  x1 */

  /* Text (headings, body, muted) */
  --txt-1: 93, 105, 119;  /* #5d6977  x1 */
  --txt-2: 108, 120, 134; /* #6c7886  x2 */
  --txt-3: 111, 127, 148; /* #6f7f94  x1 */
  --txt-4: 111, 128, 150; /* #6f8096  x1 */
  --txt-5: 115, 129, 147; /* #738193  x4 */
  --txt-6: 127, 141, 160; /* #7f8da0  x4 */
  --txt-7: 127, 144, 166; /* #7f90a6  x1 */
  --txt-8: 141, 144, 152; /* #8d9098  x1 */
  --txt-9: 131, 148, 170; /* #8394aa  x3 */
  --txt-10: 135, 148, 166; /* #8794a6  x1 */
  --txt-11: 142, 155, 171; /* #8e9bab  x8 */
  --txt-12: 140, 157, 178; /* #8c9db2  x14 */
  --txt-13: 140, 160, 190; /* #8ca0be  x2 */
  --txt-14: 167, 159, 141; /* #a79f8d  x1 */
  --txt-15: 147, 161, 179; /* #93a1b3  x1 */
  --txt-16: 143, 162, 186; /* #8fa2ba  x1 */
  --txt-17: 147, 163, 184; /* #93a3b8  x13 */
  --txt-18: 147, 164, 186; /* #93a4ba  x8 */
  --txt-19: 154, 168, 187; /* #9aa8bb  x2 */
  --txt-20: 154, 169, 188; /* #9aa9bc  x1 */
  --txt-21: 159, 176, 197; /* #9fb0c5  x1 */
  --txt-22: 159, 176, 198; /* #9fb0c6  x2 */
  --txt-23: 170, 183, 200; /* #aab7c8  x2 */
  --txt-24: 174, 185, 199; /* #aeb9c7  x1 */
  --txt-25: 174, 187, 208; /* #aebbd0  x1 */
  --txt-26: 170, 188, 214; /* #aabcd6  x1 */
  --txt-27: 180, 193, 210; /* #b4c1d2  x1 */
  --txt-28: 182, 195, 212; /* #b6c3d4  x1 */
  --txt-29: 185, 198, 216; /* #b9c6d8  x1 */
  --txt-30: 197, 207, 219; /* #c5cfdb  x15 */
  --txt-31: 197, 209, 224; /* #c5d1e0  x1 */
  --txt-32: 199, 209, 222; /* #c7d1de  x3 */
  --txt-33: 211, 213, 218; /* #d3d5da  x1 */
  --txt-34: 213, 221, 232; /* #d5dde8  x4 */
  --txt-35: 219, 227, 238; /* #dbe3ee  x7 */
  --txt-36: 223, 228, 236; /* #dfe4ec  x1 */
  --txt-37: 219, 229, 242; /* #dbe5f2  x3 */
  --txt-38: 223, 231, 242; /* #dfe7f2  x1 */
  --txt-39: 228, 233, 240; /* #e4e9f0  x9 */
  --txt-40: 230, 235, 242; /* #e6ebf2  x2 */
  --txt-41: 233, 237, 243; /* #e9edf3  x3 */
  --txt-42: 238, 242, 248; /* #eef2f8  x20 */
  --txt-43: 238, 243, 250; /* #eef3fa  x12 */
  --txt-44: 241, 244, 248; /* #f1f4f8  x14 */
  --txt-45: 242, 246, 252; /* #f2f6fc  x1 */
  --txt-46: 255, 255, 255; /* #ffffff  x14 */

  /* Lines and tints: borders, dividers, hover washes */
  --wash-1: 91, 106, 124; /* #5b6a7c  x1 */
  --wash-2: 86, 112, 150; /* #567096  x2 */
  --wash-3: 40, 120, 190; /* #2878be  x1 */
  --wash-4: 142, 155, 171; /* #8e9bab  x2 */
  --wash-5: 140, 157, 178; /* #8c9db2  x2 */
  --wash-6: 140, 160, 190; /* #8ca0be  x41 */
  --wash-7: 150, 172, 205; /* #96accd  x2 */
  --wash-8: 150, 175, 210; /* #96afd2  x38 */
  --wash-9: 180, 195, 216; /* #b4c3d8  x1 */
  --wash-10: 185, 200, 220; /* #b9c8dc  x1 */
  --wash-11: 190, 205, 225; /* #becde1  x13 */
  --wash-12: 200, 214, 235; /* #c8d6eb  x10 */
  --wash-13: 207, 216, 230; /* #cfd8e6  x2 */
  --wash-14: 255, 255, 255; /* #ffffff  x42 */

  /* Shadow colour (the alpha is scaled by --shade-k so light shadows stay soft) */
  --shade-1: 0, 0, 0;     /* #000000  x70 */
  --shade-2: 9, 12, 17;   /* #090c11  x1 */
  --shade-3: 10, 13, 19;  /* #0a0d13  x2 */
  --shade-4: 18, 23, 31;  /* #12171f  x1 */

  /* Inner highlights (alpha scaled by --hi-k) */
  --hi-1: 140, 160, 190;  /* #8ca0be  x2 */
  --hi-2: 190, 205, 225;  /* #becde1  x1 */
  --hi-3: 200, 214, 235;  /* #c8d6eb  x2 */
  --hi-4: 255, 255, 255;  /* #ffffff  x30 */

  /* Primary action fills, gradients and hovers (cyan -> terracotta) */
  --pri-fill-1: 24, 90, 118; /* #185a76  x1 */
  --pri-fill-2: 14, 122, 150; /* #0e7a96  x4 */
  --pri-fill-3: 16, 134, 165; /* #1086a5  x1 */
  --pri-fill-4: 15, 137, 168; /* #0f89a8  x3 */
  --pri-fill-5: 24, 149, 179; /* #1895b3  x1 */
  --pri-fill-6: 24, 150, 184; /* #1896b8  x1 */
  --pri-fill-7: 47, 159, 200; /* #2f9fc8  x1 */
  --pri-fill-8: 31, 167, 200; /* #1fa7c8  x1 */
  --pri-fill-9: 47, 180, 214; /* #2fb4d6  x3 */
  --pri-fill-10: 63, 183, 224; /* #3fb7e0  x10 */
  --pri-fill-11: 60, 192, 226; /* #3cc0e2  x1 */
  --pri-fill-12: 82, 196, 234; /* #52c4ea  x1 */
  --pri-fill-13: 82, 197, 236; /* #52c5ec  x1 */
  --pri-fill-14: 94, 214, 240; /* #5ed6f0  x6 */
  --pri-fill-15: 127, 216, 255; /* #7fd8ff  x2 */
  --pri-fill-16: 111, 220, 243; /* #6fdcf3  x1 */
  --pri-fill-17: 111, 224, 245; /* #6fe0f5  x10 */
  --pri-fill-18: 143, 227, 245; /* #8fe3f5  x4 */
  --pri-fill-19: 132, 232, 249; /* #84e8f9  x1 */
  --pri-fill-20: 138, 234, 248; /* #8aeaf8  x1 */
  --pri-fill-21: 155, 235, 255; /* #9bebff  x1 */
  --pri-fill-22: 166, 236, 250; /* #a6ecfa  x1 */

  /* Primary action borders */
  --pri-line-1: 94, 214, 240; /* #5ed6f0  x5 */
  --pri-line-2: 127, 227, 247; /* #7fe3f7  x1 */
  --pri-line-3: 160, 225, 255; /* #a0e1ff  x5 */
  --pri-line-4: 190, 238, 255; /* #beeeff  x1 */

  /* Primary action glows */
  --pri-glow-1: 24, 150, 184; /* #1896b8  x4 */
  --pri-glow-2: 60, 150, 240; /* #3c96f0  x2 */
  --pri-glow-3: 40, 170, 210; /* #28aad2  x2 */
  --pri-glow-4: 60, 170, 245; /* #3caaf5  x1 */
  --pri-glow-5: 94, 214, 240; /* #5ed6f0  x3 */
  --pri-glow-6: 127, 216, 255; /* #7fd8ff  x2 */

  /* Text on a primary fill */
  --onfill-1: 4, 18, 31;  /* #04121f  x9 */
  --onfill-2: 4, 34, 43;  /* #04222b  x4 */
  --onfill-3: 6, 34, 43;  /* #06222b  x1 */
  --onfill-4: 255, 255, 255; /* #ffffff  x5 */

  /* Accent text and links (cyan -> teal) */
  --cy-text-1: 14, 95, 120; /* #0e5f78  x1 */
  --cy-text-2: 14, 122, 150; /* #0e7a96  x1 */
  --cy-text-3: 79, 157, 255; /* #4f9dff  x1 */
  --cy-text-4: 47, 180, 214; /* #2fb4d6  x1 */
  --cy-text-5: 159, 194, 255; /* #9fc2ff  x2 */
  --cy-text-6: 94, 214, 240; /* #5ed6f0  x7 */
  --cy-text-7: 143, 210, 228; /* #8fd2e4  x1 */
  --cy-text-8: 127, 216, 255; /* #7fd8ff  x1 */
  --cy-text-9: 169, 219, 232; /* #a9dbe8  x1 */
  --cy-text-10: 127, 227, 247; /* #7fe3f7  x2 */
  --cy-text-11: 143, 227, 245; /* #8fe3f5  x4 */
  --cy-text-12: 181, 227, 239; /* #b5e3ef  x1 */
  --cy-text-13: 191, 233, 244; /* #bfe9f4  x1 */
  --cy-text-14: 190, 235, 248; /* #beebf8  x1 */
  --cy-text-15: 207, 234, 245; /* #cfeaf5  x1 */
  --cy-text-16: 191, 243, 255; /* #bff3ff  x1 */
  --cy-text-17: 201, 243, 255; /* #c9f3ff  x1 */
  --cy-text-18: 201, 244, 251; /* #c9f4fb  x1 */
  --cy-text-19: 241, 251, 255; /* #f1fbff  x1 */

  /* Accent borders and rules */
  --cy-line-1: 111, 171, 232; /* #6fabe8  x1 */
  --cy-line-2: 159, 194, 255; /* #9fc2ff  x9 */
  --cy-line-3: 94, 214, 240; /* #5ed6f0  x57 */
  --cy-line-4: 127, 216, 255; /* #7fd8ff  x27 */
  --cy-line-5: 127, 227, 247; /* #7fe3f7  x12 */
  --cy-line-6: 190, 215, 255; /* #bed7ff  x1 */

  /* Accent tints and selected backgrounds */
  --cy-wash-1: 24, 90, 118; /* #185a76  x1 */
  --cy-wash-2: 24, 92, 120; /* #185c78  x1 */
  --cy-wash-3: 20, 96, 128; /* #146080  x2 */
  --cy-wash-4: 20, 100, 130; /* #146482  x1 */
  --cy-wash-5: 30, 110, 150; /* #1e6e96  x1 */
  --cy-wash-6: 14, 122, 150; /* #0e7a96  x1 */
  --cy-wash-7: 40, 120, 160; /* #2878a0  x1 */
  --cy-wash-8: 24, 150, 184; /* #1896b8  x13 */
  --cy-wash-9: 79, 157, 255; /* #4f9dff  x7 */
  --cy-wash-10: 159, 194, 255; /* #9fc2ff  x5 */
  --cy-wash-11: 94, 214, 240; /* #5ed6f0  x53 */
  --cy-wash-12: 127, 216, 255; /* #7fd8ff  x9 */

  /* Accent glows and rings (box-shadow) */
  --cy-glow-1: 30, 120, 150; /* #1e7896  x1 */
  --cy-glow-2: 40, 120, 230; /* #2878e6  x1 */
  --cy-glow-3: 24, 140, 180; /* #188cb4  x1 */
  --cy-glow-4: 24, 150, 184; /* #1896b8  x13 */
  --cy-glow-5: 30, 150, 190; /* #1e96be  x2 */
  --cy-glow-6: 79, 157, 255; /* #4f9dff  x5 */
  --cy-glow-7: 40, 170, 210; /* #28aad2  x12 */
  --cy-glow-8: 80, 170, 250; /* #50aafa  x1 */
  --cy-glow-9: 120, 170, 255; /* #78aaff  x2 */
  --cy-glow-10: 130, 180, 255; /* #82b4ff  x2 */
  --cy-glow-11: 159, 194, 255; /* #9fc2ff  x5 */
  --cy-glow-12: 94, 214, 240; /* #5ed6f0  x33 */
  --cy-glow-13: 127, 216, 255; /* #7fd8ff  x9 */
  --cy-glow-14: 190, 235, 255; /* #beebff  x1 */

  /* Keyboard focus ring */
  --focus-1: 159, 194, 255; /* #9fc2ff  x17 */
  --focus-2: 207, 224, 255; /* #cfe0ff  x1 */

  /* Gold: medals, host crown, Best badge (same in both themes where not listed in light) */
  --gold-1: 201, 164, 92; /* #c9a45c  x18 */
  --gold-2: 229, 181, 96; /* #e5b560  x1 */
  --gold-3: 232, 196, 90; /* #e8c45a  x2 */
  --gold-4: 227, 201, 135; /* #e3c987  x3 */
  --gold-5: 230, 205, 142; /* #e6cd8e  x1 */
  --gold-6: 255, 200, 110; /* #ffc86e  x2 */
  --gold-7: 255, 226, 160; /* #ffe2a0  x3 */
  --gold-8: 239, 231, 212; /* #efe7d4  x3 */
  --gold-9: 255, 240, 200; /* #fff0c8  x1 */
  --gold-10: 255, 246, 214; /* #fff6d6  x5 */

  /* Gold text */
  --gold-text-1: 125, 90, 64; /* #7d5a40  x1 */
  --gold-text-2: 138, 85, 48; /* #8a5530  x1 */
  --gold-text-3: 169, 135, 54; /* #a98736  x1 */
  --gold-text-4: 200, 137, 93; /* #c8895d  x1 */
  --gold-text-5: 201, 146, 106; /* #c9926a  x1 */
  --gold-text-6: 201, 164, 92; /* #c9a45c  x4 */
  --gold-text-7: 230, 205, 142; /* #e6cd8e  x2 */
  --gold-text-8: 255, 207, 153; /* #ffcf99  x2 */
  --gold-text-9: 243, 223, 166; /* #f3dfa6  x1 */
  --gold-text-10: 239, 231, 212; /* #efe7d4  x2 */
  --gold-text-11: 246, 239, 222; /* #f6efde  x2 */

  /* Red tints (errors, remove, leave) */
  --red-1: 224, 80, 74;   /* #e0504a  x1 */
  --red-2: 255, 52, 42;   /* #ff342a  x1 */
  --red-3: 226, 118, 110; /* #e2766e  x1 */
  --red-4: 255, 107, 90;  /* #ff6b5a  x2 */
  --red-5: 255, 120, 110; /* #ff786e  x2 */
  --red-6: 255, 130, 120; /* #ff8278  x1 */
  --red-7: 255, 138, 125; /* #ff8a7d  x2 */
  --red-8: 255, 140, 140; /* #ff8c8c  x1 */
  --red-9: 255, 150, 120; /* #ff9678  x1 */
  --red-10: 255, 150, 140; /* #ff968c  x2 */
  --red-11: 255, 190, 182; /* #ffbeb6  x1 */
  --red-12: 255, 201, 195; /* #ffc9c3  x1 */

  /* Solid red fills */
  --red-solid-1: 160, 0, 20; /* #a00014  x1 */
  --red-solid-2: 165, 36, 36; /* #a52424  x3 */
  --red-solid-3: 185, 43, 43; /* #b92b2b  x1 */
  --red-solid-4: 190, 40, 40; /* #be2828  x1 */
  --red-solid-5: 205, 14, 28; /* #cd0e1c  x1 */
  --red-solid-6: 190, 60, 60; /* #be3c3c  x2 */
  --red-solid-7: 208, 64, 58; /* #d0403a  x1 */

  /* Red / error text */
  --red-text-1: 109, 31, 39; /* #6d1f27  x1 */
  --red-text-2: 255, 138, 128; /* #ff8a80  x1 */
  --red-text-3: 255, 141, 131; /* #ff8d83  x1 */
  --red-text-4: 217, 163, 163; /* #d9a3a3  x1 */
  --red-text-5: 215, 169, 169; /* #d7a9a9  x2 */
  --red-text-6: 255, 179, 170; /* #ffb3aa  x1 */
  --red-text-7: 255, 180, 172; /* #ffb4ac  x2 */
  --red-text-8: 255, 180, 173; /* #ffb4ad  x1 */
  --red-text-9: 255, 208, 208; /* #ffd0d0  x1 */
  --red-text-10: 255, 210, 204; /* #ffd2cc  x1 */
  --red-text-11: 255, 217, 213; /* #ffd9d5  x3 */
  --red-text-12: 244, 233, 232; /* #f4e9e8  x1 */

  /* Dark red */
  --red-dark: 42, 8, 6;   /* #2a0806  x1 */

  /* Success / online (green -> sage) */
  --green-1: 114, 196, 147; /* #72c493  x3 */
  --green-2: 127, 209, 160; /* #7fd1a0  x2 */
  --green-3: 110, 224, 154; /* #6ee09a  x4 */

  /* Success text */
  --green-text: 143, 214, 168; /* #8fd6a8  x1 */

  /* Dark text used on bright fills (medals, gold) */
  --ink-dark-1: 5, 7, 10; /* #05070a  x1 */
  --ink-dark-2: 10, 13, 19; /* #0a0d13  x1 */
  --ink-dark-3: 4, 18, 31; /* #04121f  x1 */
  --ink-dark-4: 17, 17, 19; /* #111113  x1 */
  --ink-dark-5: 28, 24, 16; /* #1c1810  x2 */
}

:root[data-theme="light"] {
  /* Surfaces: panels, cards, wells, inputs (dark tones become cream / tatami) */
  --surf-1: 239, 224, 190;
  --surf-2: 241, 226, 194;
  --surf-3: 241, 226, 194;
  --surf-4: 241, 227, 195;
  --surf-5: 242, 228, 196;
  --surf-6: 242, 228, 197;
  --surf-7: 243, 229, 199;
  --surf-8: 245, 232, 204;
  --surf-9: 245, 232, 205;
  --surf-10: 245, 232, 205;
  --surf-11: 245, 233, 206;
  --surf-12: 245, 233, 206;
  --surf-13: 246, 234, 208;
  --surf-14: 246, 235, 209;
  --surf-15: 246, 235, 209;
  --surf-16: 246, 235, 210;
  --surf-17: 246, 235, 210;
  --surf-18: 247, 236, 211;
  --surf-19: 247, 236, 211;
  --surf-20: 247, 236, 213;
  --surf-21: 247, 236, 213;
  --surf-22: 248, 237, 214;
  --surf-23: 248, 237, 215;
  --surf-24: 248, 237, 215;
  --surf-25: 248, 238, 215;
  --surf-26: 248, 238, 216;
  --surf-27: 248, 238, 216;
  --surf-28: 248, 238, 216;
  --surf-29: 248, 238, 216;
  --surf-30: 248, 238, 216;
  --surf-31: 248, 238, 217;
  --surf-32: 249, 239, 217;
  --surf-33: 249, 239, 218;
  --surf-34: 249, 239, 219;
  --surf-35: 250, 240, 220;
  --surf-36: 250, 241, 222;
  --surf-37: 250, 241, 222;
  --surf-38: 250, 242, 223;
  --surf-39: 251, 242, 224;
  --surf-40: 251, 243, 224;
  --surf-41: 251, 243, 225;
  --surf-42: 252, 244, 226;
  --surf-43: 252, 244, 226;
  --surf-44: 253, 245, 227;
  --surf-45: 253, 245, 227;
  --surf-46: 253, 245, 228;
  --surf-47: 253, 245, 228;
  --surf-48: 254, 247, 229;
  --surf-49: 255, 247, 230;
  --surf-50: 255, 247, 230;
  --surf-51: 255, 248, 232;
  --surf-52: 255, 248, 232;
  --surf-53: 255, 248, 232;
  --surf-54: 255, 248, 232;
  --surf-55: 255, 248, 232;
  --surf-56: 255, 249, 233;
  --surf-57: 255, 249, 234;
  --surf-58: 255, 249, 234;
  --surf-59: 255, 249, 234;
  --surf-60: 255, 249, 235;
  --surf-61: 255, 249, 235;
  --surf-62: 255, 249, 235;
  --surf-63: 255, 249, 236;
  --surf-64: 255, 250, 236;
  --surf-65: 255, 250, 237;
  --surf-66: 255, 250, 237;
  --surf-67: 255, 250, 237;
  --surf-68: 255, 250, 237;
  --surf-69: 255, 250, 238;
  --surf-70: 255, 250, 238;
  --surf-71: 255, 250, 238;
  --surf-72: 255, 250, 238;
  --surf-73: 255, 250, 239;
  --surf-74: 255, 250, 239;
  --surf-75: 255, 250, 239;
  --surf-76: 255, 251, 240;
  --surf-77: 255, 251, 241;
  --surf-78: 255, 251, 242;
  --surf-79: 255, 252, 244;
  --surf-80: 255, 252, 245;
  --surf-81: 255, 252, 246;
  --surf-82: 255, 253, 248;
  /* Text (headings, body, muted) */
  --txt-1: var(--p-sepia-ink);
  --txt-2: var(--p-sepia-ink);
  --txt-3: var(--p-sepia-ink);
  --txt-4: var(--p-sepia-ink);
  --txt-5: var(--p-sepia-ink);
  --txt-6: var(--p-sepia-ink);
  --txt-7: var(--p-sepia-ink);
  --txt-8: var(--p-sepia-ink);
  --txt-9: var(--p-sepia-ink);
  --txt-10: var(--p-sepia-ink);
  --txt-11: var(--p-sepia-ink);
  --txt-12: var(--p-sepia-ink);
  --txt-13: var(--p-sepia-ink);
  --txt-14: var(--p-sepia-ink);
  --txt-15: var(--p-sepia-ink);
  --txt-16: var(--p-sepia-ink);
  --txt-17: var(--p-sepia-ink);
  --txt-18: var(--p-sepia-ink);
  --txt-19: var(--p-sepia-ink);
  --txt-20: var(--p-sepia-ink);
  --txt-21: var(--p-brown);
  --txt-22: var(--p-brown);
  --txt-23: var(--p-brown);
  --txt-24: var(--p-brown);
  --txt-25: var(--p-brown);
  --txt-26: var(--p-brown);
  --txt-27: var(--p-brown);
  --txt-28: var(--p-brown);
  --txt-29: var(--p-espresso);
  --txt-30: var(--p-espresso);
  --txt-31: var(--p-espresso);
  --txt-32: var(--p-espresso);
  --txt-33: var(--p-espresso);
  --txt-34: var(--p-espresso);
  --txt-35: var(--p-espresso);
  --txt-36: var(--p-espresso);
  --txt-37: var(--p-espresso);
  --txt-38: var(--p-espresso);
  --txt-39: var(--p-ink-deep);
  --txt-40: var(--p-ink-deep);
  --txt-41: var(--p-ink-deep);
  --txt-42: var(--p-ink-deep);
  --txt-43: var(--p-ink-deep);
  --txt-44: var(--p-ink-deep);
  --txt-45: var(--p-ink-deep);
  --txt-46: var(--p-ink-deep);
  /* Lines and tints: borders, dividers, hover washes */
  --wash-1: var(--p-sepia);
  --wash-2: var(--p-sepia);
  --wash-3: var(--p-sepia);
  --wash-4: var(--p-sepia);
  --wash-5: var(--p-sepia);
  --wash-6: var(--p-sepia);
  --wash-7: var(--p-sepia);
  --wash-8: var(--p-sepia);
  --wash-9: var(--p-espresso);
  --wash-10: var(--p-espresso);
  --wash-11: var(--p-espresso);
  --wash-12: var(--p-espresso);
  --wash-13: var(--p-espresso);
  --wash-14: var(--p-espresso);
  /* Shadow colour (the alpha is scaled by --shade-k so light shadows stay soft) */
  --shade-1: var(--p-espresso);
  --shade-2: var(--p-espresso);
  --shade-3: var(--p-espresso);
  --shade-4: var(--p-espresso);
  /* Inner highlights (alpha scaled by --hi-k) */
  --hi-1: 255, 253, 246;
  --hi-2: 255, 253, 246;
  --hi-3: 255, 253, 246;
  --hi-4: 255, 253, 246;
  /* Primary action fills, gradients and hovers (cyan -> terracotta) */
  --pri-fill-1: 196, 78, 44;
  --pri-fill-2: 207, 88, 52;
  --pri-fill-3: 212, 92, 56;
  --pri-fill-4: 213, 93, 57;
  --pri-fill-5: 218, 98, 61;
  --pri-fill-6: 219, 99, 62;
  --pri-fill-7: 223, 103, 65;
  --pri-fill-8: 226, 105, 67;
  --pri-fill-9: 231, 110, 71;
  --pri-fill-10: var(--p-terracotta);
  --pri-fill-11: 234, 115, 76;
  --pri-fill-12: 235, 118, 79;
  --pri-fill-13: 236, 118, 79;
  --pri-fill-14: 239, 126, 86;
  --pri-fill-15: 240, 129, 89;
  --pri-fill-16: 240, 129, 89;
  --pri-fill-17: 241, 132, 92;
  --pri-fill-18: 243, 136, 96;
  --pri-fill-19: 244, 138, 98;
  --pri-fill-20: 245, 140, 100;
  --pri-fill-21: 245, 143, 103;
  --pri-fill-22: 246, 144, 104;
  /* Primary action borders */
  --pri-line-1: var(--p-terracotta-deep);
  --pri-line-2: var(--p-terracotta-deep);
  --pri-line-3: var(--p-terracotta-deep);
  --pri-line-4: var(--p-terracotta-deep);
  /* Primary action glows */
  --pri-glow-1: var(--p-terracotta);
  --pri-glow-2: var(--p-terracotta);
  --pri-glow-3: var(--p-terracotta);
  --pri-glow-4: var(--p-terracotta);
  --pri-glow-5: var(--p-terracotta);
  --pri-glow-6: var(--p-terracotta);
  /* Text on a primary fill */
  --onfill-1: var(--p-on-primary);
  --onfill-2: var(--p-on-primary);
  --onfill-3: var(--p-on-primary);
  --onfill-4: var(--p-on-primary);
  /* Accent text and links (cyan -> teal) */
  --cy-text-1: var(--p-teal-ink);
  --cy-text-2: var(--p-teal-ink);
  --cy-text-3: var(--p-teal-ink);
  --cy-text-4: var(--p-teal-ink);
  --cy-text-5: var(--p-teal-ink);
  --cy-text-6: var(--p-teal-ink);
  --cy-text-7: var(--p-teal-ink);
  --cy-text-8: var(--p-teal-ink);
  --cy-text-9: var(--p-teal-ink);
  --cy-text-10: var(--p-teal-ink);
  --cy-text-11: var(--p-teal-ink);
  --cy-text-12: var(--p-teal-ink);
  --cy-text-13: var(--p-teal-ink);
  --cy-text-14: var(--p-teal-ink);
  --cy-text-15: var(--p-teal-ink);
  --cy-text-16: var(--p-teal-ink);
  --cy-text-17: var(--p-teal-ink);
  --cy-text-18: var(--p-teal-ink);
  --cy-text-19: var(--p-teal-ink);
  /* Accent borders and rules */
  --cy-line-1: var(--p-teal);
  --cy-line-2: var(--p-teal);
  --cy-line-3: var(--p-teal);
  --cy-line-4: var(--p-teal);
  --cy-line-5: var(--p-teal);
  --cy-line-6: var(--p-teal);
  /* Accent tints and selected backgrounds */
  --cy-wash-1: var(--p-teal);
  --cy-wash-2: var(--p-teal);
  --cy-wash-3: var(--p-teal);
  --cy-wash-4: var(--p-teal);
  --cy-wash-5: var(--p-teal);
  --cy-wash-6: var(--p-teal);
  --cy-wash-7: var(--p-teal);
  --cy-wash-8: var(--p-teal);
  --cy-wash-9: var(--p-teal);
  --cy-wash-10: var(--p-teal);
  --cy-wash-11: var(--p-teal);
  --cy-wash-12: var(--p-teal);
  /* Accent glows and rings (box-shadow) */
  --cy-glow-1: var(--p-teal);
  --cy-glow-2: var(--p-teal);
  --cy-glow-3: var(--p-teal);
  --cy-glow-4: var(--p-teal);
  --cy-glow-5: var(--p-teal);
  --cy-glow-6: var(--p-teal);
  --cy-glow-7: var(--p-teal);
  --cy-glow-8: var(--p-teal);
  --cy-glow-9: var(--p-teal);
  --cy-glow-10: var(--p-teal);
  --cy-glow-11: var(--p-teal);
  --cy-glow-12: var(--p-teal);
  --cy-glow-13: var(--p-teal);
  --cy-glow-14: var(--p-teal);
  /* Keyboard focus ring */
  --focus-1: var(--p-focus);
  --focus-2: var(--p-focus);
  /* Gold text */
  --gold-text-1: var(--p-gold-ink);
  --gold-text-2: var(--p-gold-ink);
  --gold-text-3: var(--p-gold-ink);
  --gold-text-4: var(--p-gold-ink);
  --gold-text-5: var(--p-gold-ink);
  --gold-text-6: var(--p-gold-ink);
  --gold-text-7: var(--p-gold-ink);
  --gold-text-8: var(--p-gold-ink);
  --gold-text-9: var(--p-gold-ink);
  --gold-text-10: var(--p-gold-ink);
  --gold-text-11: var(--p-gold-ink);
  /* Red tints (errors, remove, leave) */
  --red-1: 204, 66, 46;
  --red-2: 204, 66, 46;
  --red-3: 204, 66, 46;
  --red-4: 204, 66, 46;
  --red-5: 204, 66, 46;
  --red-6: 204, 66, 46;
  --red-7: 204, 66, 46;
  --red-8: 204, 66, 46;
  --red-9: 204, 66, 46;
  --red-10: 204, 66, 46;
  --red-11: 204, 66, 46;
  --red-12: 204, 66, 46;
  /* Red / error text */
  --red-text-1: var(--p-red-ink);
  --red-text-2: var(--p-red-ink);
  --red-text-3: var(--p-red-ink);
  --red-text-4: var(--p-red-ink);
  --red-text-5: var(--p-red-ink);
  --red-text-6: var(--p-red-ink);
  --red-text-7: var(--p-red-ink);
  --red-text-8: var(--p-red-ink);
  --red-text-9: var(--p-red-ink);
  --red-text-10: var(--p-red-ink);
  --red-text-11: var(--p-red-ink);
  --red-text-12: var(--p-red-ink);
  /* Success / online (green -> sage) */
  --green-1: var(--p-sage);
  --green-2: var(--p-sage);
  --green-3: var(--p-sage);
  /* Success text */
  --green-text: var(--p-sage-ink);
}

/* ==========================================================================
   Non-colour theme settings and whole-page backgrounds
   ========================================================================== */
:root {
  color-scheme: dark;
  --shade-k: 1;      /* how strong drop shadows are (1 = as designed for the dark theme) */
  --hi-k: 1;         /* how strong the thin inner highlights are */
}
:root[data-theme="light"] {
  color-scheme: light;
  --shade-k: 0.42;
  --hi-k: 5;
}

/* ==========================================================================
   THEME TOGGLE (nav bar) - a compact sun / moon switch.  Sits in .nav-right beside the profile.
   Visual size 54 x 30; the button itself is 44px tall so it stays an easy touch target.
   ========================================================================== */
.theme-toggle {
  /* dark (default) */
  --tt-track: rgba(26, 33, 43, 0.9); --tt-line: rgba(150, 175, 210, 0.38); --tt-line-hi: rgba(190, 205, 225, 0.55); --tt-inset: rgba(0, 0, 0, 0.35);
  --tt-knob: #26303e; --tt-knob-line: rgba(94, 214, 240, 0.7); --tt-knob-shadow: 0 0 10px rgba(94, 214, 240, 0.28), 0 1px 2px rgba(0, 0, 0, 0.4);
  --tt-sun: #8c9db2; --tt-moon: #5ed6f0; --tt-sun-k: #ffb85c; --tt-moon-k: #5ed6f0; --tt-focus: #7fe3f7;
  appearance: none; -webkit-appearance: none; flex: 0 0 auto; position: relative;
  box-sizing: border-box; width: 58px; height: 44px; margin: 0; padding: 0; border: 0; background: none; cursor: pointer;
  display: inline-grid; place-items: center; -webkit-tap-highlight-color: transparent; border-radius: 999px;
}
:root[data-theme="light"] .theme-toggle {
  --tt-track: linear-gradient(90deg, #ffd9a0, #ffe9c4); --tt-line: rgb(61, 43, 31); --tt-line-hi: rgb(61, 43, 31); --tt-inset: rgba(122, 92, 67, 0.25);
  --tt-knob: #fff8e7; --tt-knob-line: rgb(61, 43, 31); --tt-knob-shadow: 1px 2px 0 rgba(61, 43, 31, 0.9);
  --tt-sun: #b86a1a; --tt-moon: #7a5c43; --tt-sun-k: #e86f48; --tt-moon-k: #3b8ea5; --tt-focus: #7c4de0;
}
.theme-toggle .tt-track {
  position: relative; box-sizing: border-box; display: block; width: 54px; height: 30px; border-radius: 999px;
  border: 1px solid var(--tt-line); background: var(--tt-track);
  box-shadow: inset 0 1px 3px var(--tt-inset);
  transition: background-color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}
.theme-toggle:hover .tt-track { border-color: var(--tt-line-hi); }
.theme-toggle .tt-ico {
  position: absolute; top: 50%; width: 16px; height: 16px; margin-top: -8px; display: block; transition: opacity 0.3s ease, transform 0.45s cubic-bezier(.3, 1.4, .5, 1), color 0.3s ease;
}
.theme-toggle .tt-sun  { left: 6px;  color: var(--tt-sun); }
.theme-toggle .tt-moon { right: 6px; color: var(--tt-moon); }
.theme-toggle .tt-knob {
  position: absolute; top: 3px; left: 3px; box-sizing: border-box; width: 22px; height: 22px; border-radius: 50%;
  background: var(--tt-knob); border: 1px solid var(--tt-knob-line); box-shadow: var(--tt-knob-shadow);
  transform: translateX(24px); transition: transform 0.4s cubic-bezier(.3, 1.3, .5, 1), background-color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}
/* dark: the knob sits over the moon (the moon is "on"); light: it slides over the sun */
:root[data-theme="dark"] .theme-toggle .tt-moon { opacity: 0; transform: rotate(-40deg) scale(.6); }
:root[data-theme="light"] .theme-toggle .tt-sun { opacity: 0; transform: rotate(90deg) scale(.6); }
:root[data-theme="light"] .theme-toggle .tt-knob { transform: translateX(0); }
.theme-toggle .tt-knob .tt-ico { left: 50%; right: auto; top: 50%; margin: -8px 0 0 -8px; }
.theme-toggle .tt-knob .tt-moon-k { color: var(--tt-moon-k); }
.theme-toggle .tt-knob .tt-sun-k { color: var(--tt-sun-k); }
:root[data-theme="dark"] .theme-toggle .tt-knob .tt-sun-k { opacity: 0; transform: rotate(-90deg) scale(.5); }
:root[data-theme="light"] .theme-toggle .tt-knob .tt-moon-k { opacity: 0; transform: rotate(90deg) scale(.5); }
.theme-toggle:active .tt-knob { width: 26px; }
:root[data-theme="light"] .theme-toggle:active .tt-knob { width: 26px; }
:root[data-theme="dark"] .theme-toggle:active .tt-knob { transform: translateX(20px); }
.theme-toggle:focus-visible { outline: 2px solid var(--tt-focus) !important; outline-offset: 0 !important; }

@media (max-width: 400px) { .theme-toggle { width: 50px; } .theme-toggle .tt-track { width: 46px; height: 28px; } .theme-toggle .tt-knob { width: 20px; height: 20px; transform: translateX(18px); } :root[data-theme="light"] .theme-toggle .tt-knob { transform: translateX(0); } .theme-toggle .tt-ico { width: 14px; height: 14px; margin-top: -7px; } .theme-toggle .tt-knob .tt-ico { margin: -7px 0 0 -7px; } :root[data-theme="dark"] .theme-toggle:active .tt-knob { transform: translateX(16px); } .theme-toggle:active .tt-knob { width: 24px; } }
@media (max-width: 340px) { .theme-toggle { width: 46px; } .theme-toggle .tt-track { width: 42px; } .theme-toggle .tt-knob { transform: translateX(14px); } :root[data-theme="dark"] .theme-toggle:active .tt-knob { transform: translateX(12px); } .theme-toggle .tt-sun { left: 5px; } .theme-toggle .tt-moon { right: 5px; } }

/* switching: the whole page cross-fades (View Transitions) ... */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.15s; animation-timing-function: ease; }
/* while the snapshot cross-fade runs, element transitions are switched off so they do not overlap it (class added by js/theme.js only for the
   duration of the transition); the toggle and everything inside it are excluded, so its knob / icon animations still play */
:root.theme-vt *:not(.theme-toggle):not(.theme-toggle *),
:root.theme-vt *:not(.theme-toggle):not(.theme-toggle *)::before,
:root.theme-vt *:not(.theme-toggle):not(.theme-toggle *)::after { transition: none !important; }
/* ... or, where that is not available, colours fade through this temporary class */
:root.theme-fade *, :root.theme-fade *::before, :root.theme-fade *::after {
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, fill 0.15s ease, stroke 0.15s ease, opacity 0.15s ease !important;
}
@media (prefers-reduced-motion: reduce) {
  .theme-toggle .tt-track, .theme-toggle .tt-ico, .theme-toggle .tt-knob { transition: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
