:root {
  color-scheme: dark;
  /* ---- All colours are variables. Shared ones here; each palette (data-theme on <html>) below sets the rest.
          v1 = dark only; v2 can add a light palette as another [data-theme] block. ---- */
  --ok: #62d4a0; --ok-bg: rgba(98, 212, 160, .13);
  --warn: #f0b45a; --warn-bg: rgba(240, 180, 90, .14);
  --bad: #f28e84; --bad-bg: rgba(242, 142, 132, .15); --bad-line: rgba(242, 142, 132, .45);
  --tip: #e8ebf4; --tip-ink: #0c1328;
  --on-color: #fff; --discord: #5865f2; --brand-ig: #8446cc;
  --scrim: rgba(3, 5, 12, .66); --shadow: rgba(0, 0, 0, .45); --shadow-badge: rgba(0, 0, 0, .5);
  --page: #06080e; --demo-bar: #04060b; --demo-ink: #e8eaf3; --demo-ctl: #151b2e; --demo-line: #2f3858; --phone-frame: #03040a;
  --radius: 14px;
}
:root {
  /* v1 base (decided 2025-11-25): black background + charcoal card. Accent sets A/B/C below only change the highlight colours. */
  --bg: #08090c; --bg2: #101218; --card: #15171c; --card2: #1d1f26; --surface: #242830; --field: #060709; --line: #2f343f; --track: #2b2f39;
  --ink: #e8ebed; --muted: #8e99a2; --edge: rgba(255, 255, 255, .06);
}
/* Accent set D (designed freely for this black + charcoal base, brand colours not required):
   champagne for actions, a rich gold only for value (CHP hexagon, class), a cool periwinkle for progress as the contrast "pop". */
:root[data-theme="d"] {
  --accent: #e6d3a3; --accent-hi: #f3e6c4; --accent-ink: #231b08; --accent-deep: #b59d66;
  --accent-soft: rgba(230, 211, 163, .13); --accent-line: rgba(230, 211, 163, .38);
  --accent2: #e8b23c; --gold-hi: #ffdc7a; --gold-lo: #b9811c; --gold-ink: #2a1c03; --gold-text: #f0cf82;
  --gold-soft: rgba(232, 178, 60, .1); --gold-line: rgba(232, 178, 60, .45);
  --bar-lv: #8d9bff; --bar-lv-lo: #6272e8;
}
/* Accent set A: Gold */
:root[data-theme="a"] {
  --accent: #d4b25c; --accent-hi: #e8cb78; --accent-ink: #241a04; --accent-deep: #a98a3a;
  --accent-soft: rgba(212, 178, 92, .14); --accent-line: rgba(212, 178, 92, .4);
  --accent2: #e2b94a; --gold-hi: #f6dd8c; --gold-lo: #b88a26; --gold-ink: #2b1f04; --gold-text: #ecd08a;
  --gold-soft: rgba(226, 185, 74, .1); --gold-line: rgba(226, 185, 74, .45);
  --bar-lv: #7d93d6; --bar-lv-lo: #566cb0;
}
/* Accent set B: Teal (gold only on the CHP hexagon) */
:root[data-theme="b"] {
  --accent: #3fb3a2; --accent-hi: #58c9b8; --accent-ink: #04201c; --accent-deep: #2a8577;
  --accent-soft: rgba(63, 179, 162, .15); --accent-line: rgba(63, 179, 162, .4);
  --accent2: #d9b45c; --gold-hi: #f0d58b; --gold-lo: #aa8530; --gold-ink: #2a1f06; --gold-text: #e6c77a;
  --gold-soft: rgba(217, 180, 92, .1); --gold-line: rgba(217, 180, 92, .45);
  --bar-lv: #3fb3a2; --bar-lv-lo: #2a8577;
}
/* Accent set C: Champagne */
:root, :root[data-theme="c"] {
  --accent: #dcc593; --accent-hi: #eddab0; --accent-ink: #2a2008; --accent-deep: #b39a63;
  --accent-soft: rgba(220, 197, 147, .14); --accent-line: rgba(220, 197, 147, .4);
  --accent2: #e0c488; --gold-hi: #f7e9c6; --gold-lo: #b79a58; --gold-ink: #2c2108; --gold-text: #ecd7a4;
  --gold-soft: rgba(224, 196, 136, .1); --gold-line: rgba(224, 196, 136, .45);
  --bar-lv: #8f7fe6; --bar-lv-lo: #6b5bc2;
}

/* Accent sets E-J (more candidates on the same black + charcoal base) */
:root[data-theme="e"] {
  --accent: #8fc3ff; --accent-hi: #b4d7ff; --accent-ink: #07162b; --accent-deep: #5a8fd0;
  --accent-soft: rgba(143,195,255, .14); --accent-line: rgba(143,195,255, .4);
  --accent2: #c9d3e0; --gold-hi: #f4f7fb; --gold-lo: #8c98ab; --gold-ink: #101722; --gold-text: #d8e0ec;
  --gold-soft: rgba(201,211,224, .1); --gold-line: rgba(201,211,224, .45);
  --bar-lv: #5fd7c8; --bar-lv-lo: #36a89b;
}
:root[data-theme="f"] {
  --accent: #eab0a0; --accent-hi: #f6cdc1; --accent-ink: #2a1410; --accent-deep: #b87f70;
  --accent-soft: rgba(234,176,160, .14); --accent-line: rgba(234,176,160, .4);
  --accent2: #e29a82; --gold-hi: #ffcfba; --gold-lo: #b5654c; --gold-ink: #2b120a; --gold-text: #f2b9a6;
  --gold-soft: rgba(226,154,130, .1); --gold-line: rgba(226,154,130, .45);
  --bar-lv: #b9a3ff; --bar-lv-lo: #8e76e8;
}
:root[data-theme="g"] {
  --accent: #b79cff; --accent-hi: #cfbcff; --accent-ink: #190d38; --accent-deep: #8466e0;
  --accent-soft: rgba(183,156,255, .14); --accent-line: rgba(183,156,255, .4);
  --accent2: #b48bff; --gold-hi: #e2cfff; --gold-lo: #7a52e0; --gold-ink: #170a33; --gold-text: #d3bcff;
  --gold-soft: rgba(180,139,255, .1); --gold-line: rgba(180,139,255, .45);
  --bar-lv: #ff9ec7; --bar-lv-lo: #e0699f;
}
:root[data-theme="h"] {
  --accent: #ffa066; --accent-hi: #ffbf94; --accent-ink: #2a1204; --accent-deep: #d0703a;
  --accent-soft: rgba(255,160,102, .14); --accent-line: rgba(255,160,102, .4);
  --accent2: #ff9448; --gold-hi: #ffc38a; --gold-lo: #d4601c; --gold-ink: #2b1103; --gold-text: #ffc194;
  --gold-soft: rgba(255,148,72, .1); --gold-line: rgba(255,148,72, .45);
  --bar-lv: #6fb6ff; --bar-lv-lo: #4a8fe0;
}
:root[data-theme="i"] {
  --accent: #5fdcae; --accent-hi: #8aecc8; --accent-ink: #04201a; --accent-deep: #34a67f;
  --accent-soft: rgba(95,220,174, .14); --accent-line: rgba(95,220,174, .4);
  --accent2: #e0c488; --gold-hi: #f7e9c6; --gold-lo: #b79a58; --gold-ink: #2c2108; --gold-text: #ecd7a4;
  --gold-soft: rgba(224,196,136, .1); --gold-line: rgba(224,196,136, .45);
  --bar-lv: #7fb0ff; --bar-lv-lo: #5688e0;
}
:root[data-theme="j"] {
  --accent: #efece4; --accent-hi: #fbf9f3; --accent-ink: #1d1a14; --accent-deep: #b5b0a2;
  --accent-soft: rgba(239,236,228, .14); --accent-line: rgba(239,236,228, .4);
  --accent2: #e9e3d3; --gold-hi: #fffdf6; --gold-lo: #a9a291; --gold-ink: #1d1a14; --gold-text: #efe9d9;
  --gold-soft: rgba(233,227,211, .1); --gold-line: rgba(233,227,211, .45);
  --bar-lv: #9aa7c4; --bar-lv-lo: #6f7d9e;
}

/* ---- Whole-theme skins (demo bar "Whole theme"): background + card + accents together. v1 stays dark only. ---- */
:root[data-skin="1"] {
  --bg: #0b0814; --bg2: #130e23; --card: #1a1428; --card2: #221a34; --surface: #292040; --field: #090610;
  --line: #352851; --track: #30254a; --edge: rgba(255, 255, 255, .06); --ink: #ebe9f2; --muted: #aea6bf;
  --accent: #b79cff; --accent-hi: #d8caff; --accent-ink: #0e091b; --accent-deep: #8053f6;
  --accent-soft: rgba(183,156,255, .14); --accent-line: rgba(183,156,255, .4);
  --accent2: #b48bff; --gold-hi: #deccff; --gold-lo: #7c34ff; --gold-ink: #0f091b; --gold-text: #ceb3ff;
  --gold-soft: rgba(180,139,255, .1); --gold-line: rgba(180,139,255, .45);
  --bar-lv: #22c9b2; --bar-lv-lo: #14917f;   /* Crypto Hiroba green (level bar) */
  --bar-cl-lo: #f2b01a; --bar-cl-hi: #ffd957;   /* Crypto Hiroba yellow, #ffcb31 in the middle (class bar) */
}
:root[data-skin="2"] {
  --bg: #050b16; --bg2: #091327; --card: #0f1c33; --card2: #132441; --surface: #172b4f; --field: #040911;
  --line: #1d3662; --track: #1b325a; --edge: rgba(255, 255, 255, .06); --ink: #e9ecf2; --muted: #a6afbf;
  --accent: #5cc8ff; --accent-hi: #8ad7ff; --accent-ink: #09151b; --accent-deep: #17a8f3;
  --accent-soft: rgba(92,200,255, .14); --accent-line: rgba(92,200,255, .4);
  --accent2: #4fb6f0; --gold-hi: #9ad5f6; --gold-lo: #1290d6; --gold-ink: #09141b; --gold-text: #7ec9f4;
  --gold-soft: rgba(79,182,240, .1); --gold-line: rgba(79,182,240, .45);
  --bar-lv: #ff8f7a; --bar-lv-lo: #ff5b3d;
}
:root[data-skin="3"] {
  --bg: #0e0709; --bg2: #1c0e12; --card: #231117; --card2: #2f171f; --surface: #3b1d27; --field: #0a0506;
  --line: #4c2532; --track: #45222e; --edge: rgba(255, 255, 255, .06); --ink: #f2e9ec; --muted: #bfa6ae;
  --accent: #e8c27a; --accent-hi: #efd4a1; --accent-ink: #1b1509; --accent-deep: #d4a03d;
  --accent-soft: rgba(232,194,122, .14); --accent-line: rgba(232,194,122, .4);
  --accent2: #e8b94f; --gold-hi: #f1d697; --gold-lo: #c6911a; --gold-ink: #1b1509; --gold-text: #eecb7c;
  --gold-soft: rgba(232,185,79, .1); --gold-line: rgba(232,185,79, .45);
  --bar-lv: #e66f8a; --bar-lv-lo: #dd3b60;
}
:root[data-skin="4"] {
  --bg: #0a0b0d; --bg2: #131519; --card: #17191d; --card2: #1f2227; --surface: #272a31; --field: #07080a;
  --line: #32363f; --track: #2e3239; --edge: rgba(255, 255, 255, .06); --ink: #e9ecf2; --muted: #a6aebf;
  --accent: #bfe84e; --accent-hi: #ceed77; --accent-ink: #161b09; --accent-deep: #97c123;
  --accent-soft: rgba(191,232,78, .14); --accent-line: rgba(191,232,78, .4);
  --accent2: #bfe84e; --gold-hi: #d9f196; --gold-lo: #98c61a; --gold-ink: #161b09; --gold-text: #cfee7b;
  --gold-soft: rgba(191,232,78, .1); --gold-line: rgba(191,232,78, .45);
  --bar-lv: #7fb0ff; --bar-lv-lo: #428aff;
}
:root[data-skin="5"] {
  --bg: #0d0907; --bg2: #1a120e; --card: #1f1612; --card2: #2a1e19; --surface: #36261f; --field: #090605;
  --line: #463128; --track: #3f2d25; --edge: rgba(255, 255, 255, .06); --ink: #f2ebe9; --muted: #bfaea6;
  --accent: #e39a5f; --accent-hi: #eab386; --accent-ink: #1b1109; --accent-deep: #c4702c;
  --accent-soft: rgba(227,154,95, .14); --accent-line: rgba(227,154,95, .4);
  --accent2: #e08a45; --gold-hi: #ecb68b; --gold-lo: #b15f1d; --gold-ink: #1b1109; --gold-text: #e7a571;
  --gold-soft: rgba(224,138,69, .1); --gold-line: rgba(224,138,69, .45);
  --bar-lv: #5fc9b8; --bar-lv-lo: #3bb09d;
}
:root[data-skin="6"] {
  --bg: #070b1a; --bg2: #0b122a; --card: #121a36; --card2: #162043; --surface: #1b2751; --field: #060915;
  --line: #213064; --track: #1f2c5c; --edge: rgba(255, 255, 255, .06); --ink: #e9ebf2; --muted: #a6acbf;
  --accent: #ff7f6e; --accent-hi: #ffa89c; --accent-ink: #1b0b09; --accent-deep: #f44028;
  --accent-soft: rgba(255,127,110, .14); --accent-line: rgba(255,127,110, .4);
  --accent2: #ff8a78; --gold-hi: #ffd1ca; --gold-lo: #ff3f21; --gold-ink: #1b0b09; --gold-text: #ffb6ab;
  --gold-soft: rgba(255,138,120, .1); --gold-line: rgba(255,138,120, .45);
  --bar-lv: #7fb2ff; --bar-lv-lo: #428dff;
}
:root[data-skin="7"] {
  --bg: #04100f; --bg2: #08201e; --card: #0c2523; --card2: #103230; --surface: #15403c; --field: #030b0a;
  --line: #1b534f; --track: #184c47; --edge: rgba(255, 255, 255, .06); --ink: #e9f2f1; --muted: #a6bfbd;
  --accent: #e6cf9a; --accent-hi: #efe0bf; --accent-ink: #1b1509; --accent-deep: #d0ad5f;
  --accent-soft: rgba(230,207,154, .14); --accent-line: rgba(230,207,154, .4);
  --accent2: #e0c488; --gold-hi: #f1e4c9; --gold-lo: #cea243; --gold-ink: #1b1509; --gold-text: #ebd8b0;
  --gold-soft: rgba(224,196,136, .1); --gold-line: rgba(224,196,136, .45);
  --bar-lv: #3fd0bd; --bar-lv-lo: #29a998;
}
:root[data-skin="8"] {
  --bg: #0f0710; --bg2: #1c0d1e; --card: #26142a; --card2: #311a36; --surface: #3c2042; --field: #0b050c;
  --line: #4c2853; --track: #45244d; --edge: rgba(255, 255, 255, .06); --ink: #f0e9f2; --muted: #baa6bf;
  --accent: #f0b2a6; --accent-hi: #f7d4cd; --accent-ink: #1b0c09; --accent-deep: #de7a67;
  --accent-soft: rgba(240,178,166, .14); --accent-line: rgba(240,178,166, .4);
  --accent2: #eba08f; --gold-hi: #f7dad4; --gold-lo: #de6245; --gold-ink: #1b0c09; --gold-text: #f3c5ba;
  --gold-soft: rgba(235,160,143, .1); --gold-line: rgba(235,160,143, .45);
  --bar-lv: #b9a3ff; --bar-lv-lo: #8a66ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--page); display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* demo bar (mockup only) */
#demo-bar { background: var(--demo-bar); color: var(--demo-ink); font-size: 13px; padding: 6px 12px; flex: none; }
#demo-bar summary { cursor: pointer; font-weight: 600; }
#demo-body { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 8px 0 4px; }
#demo-body label { display: flex; align-items: center; gap: 6px; }
#demo-body select, #demo-body button { background: var(--demo-ctl); color: var(--demo-ink); border: 1px solid var(--demo-line); border-radius: 6px; padding: 3px 8px; }
#demo-body .note { opacity: .7; }

#stage { flex: 1; min-height: 0; display: flex; justify-content: center; }
#app { container-type: inline-size; position: relative; width: 100%; height: 100%; background: var(--bg); overflow: hidden; display: flex; flex-direction: column; }
#app.phone { width: 390px; max-width: 100%; margin: 12px 0; height: calc(100% - 24px); border-radius: 28px; border: 8px solid var(--phone-frame); }

/* header */
#top { flex: none; display: flex; align-items: center; gap: 14px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
#top .brand { font-weight: 700; margin-right: auto; }
#body { flex: 1; min-height: 0; display: flex; }
#screen { flex: 1; min-width: 0; overflow-y: auto; padding: 24px 20px 48px; }
.wrap { max-width: 880px; margin: 0 auto; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.muted { color: var(--muted); font-size: 13px; }

/* buttons & inputs */
.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 10px 18px; font-weight: 600; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.link { display: inline-block; text-decoration: none; }
input[type=text], textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--field); }
label.field { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 6px; }
.err { color: var(--bad); font-size: 13px; margin-top: 6px; }
.okmsg { color: var(--ok); font-size: 13px; margin-top: 6px; }

/* login */
.login { text-align: center; max-width: 440px; margin: 8vh auto 0; }
.login h1 { font-size: min(28px, calc((100cqi - 32px) / 14.5)); } /* keeps "Crypto Hiroba Member Portal" on one line */
.login > .btn { margin: 20px 0 14px; }
.login .btn:not(.ghost) { background: var(--discord); color: var(--on-color); padding: 12px 24px; }
.login .row .btn { margin: 0; padding: 12px 24px; }

/* mypage */
.profile { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.profile .who { flex: 1 1 90px; min-width: 0; }
/* Class: the most prominent item at the top (bigger than Balance and Level) */
.class-badge { margin-left: auto; font-size: 24px; font-weight: 800; line-height: 1.2; color: var(--accent2-ink); background: var(--accent2); border-radius: 14px; padding: 10px 18px; box-shadow: 0 2px 8px var(--shadow); text-wrap: balance; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 22px; flex: none; }
.profile .name { font-size: 20px; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; } /* Balance and Level side by side; wraps when narrow */
.stat { background: var(--surface); border-radius: 12px; padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 18px; font-weight: 700; margin-top: 2px; }
.bar { margin-top: 14px; }
.bar .track { height: 10px; background: var(--track); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 99px; }
.bar .fill.class { background: var(--accent2); }
.pending { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.pending b { font-size: 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.acct { padding: 10px 0; border-bottom: 1px solid var(--line); }
.acct:last-child { border: 0; }
.acct .lbl { font-size: 13px; color: var(--muted); }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.hist li:last-child { border: 0; }
.hist .completed { color: var(--ok); font-weight: 600; }
.hist .failed { color: var(--bad); font-weight: 600; }

/* mission cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.mcard { position: relative; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-height: 120px; width: 100%; display: flex; flex-direction: column; gap: 8px; transition: transform .1s, box-shadow .1s; overflow: hidden; }
.mcard:hover { transform: translateY(-2px); box-shadow: 0 6px 18px var(--shadow); }
.mcard .t { font-weight: 700; line-height: 1.3; }
.mcard .meta { margin-top: auto; display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.mcard .chp { color: var(--accent); font-weight: 700; }
.mcard .body { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.mcard.dim .body { opacity: .28; }
.mcard.dim { background: var(--field); }
.mcard .big { position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; font-weight: 800; letter-spacing: .02em; pointer-events: none; }
.mcard .big.in_review { color: var(--warn); }
.mcard .big.completed { color: var(--ok); }
.mcard .small { align-self: flex-start; font-size: 12px; font-weight: 700; color: var(--bad); background: var(--bad-bg); border-radius: 99px; padding: 2px 10px; }
.mcard.failed { border-color: var(--bad-line); }

/* detail panel */
#scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .25s; }
#panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(480px, 100%); background: var(--card); box-shadow: -8px 0 30px var(--shadow); transform: translateX(105%); transition: transform .28s ease; overflow-y: auto; padding: 20px; }
#app.open #scrim { opacity: 1; pointer-events: auto; }
#app.open #panel { transform: none; }
#panel h2 { font-size: 22px; margin: 6px 0 12px; }
.sec { margin-top: 18px; }
.sec h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 0 0 6px; }
.sec ol { margin: 0; padding-left: 20px; line-height: 1.45; }
.sec li { margin-bottom: 6px; }
.banner { border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-top: 12px; }
.banner.in_review { background: var(--warn-bg); color: var(--warn); }
.banner.completed { background: var(--ok-bg); color: var(--ok); }
.banner.failed { background: var(--bad-bg); color: var(--bad); }
.banner b { display: block; margin-bottom: 2px; }
.preview { max-width: 100%; max-height: 180px; border-radius: 10px; margin-top: 10px; border: 1px solid var(--line); }
.form { margin-top: 20px; padding-top: 6px; border-top: 1px solid var(--line); }
.register { text-align: center; }

#toast { position: absolute; left: 50%; bottom: 20px; transform: translate(-50%, 30px); background: var(--tip); color: var(--tip-ink); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; max-width: 90%; z-index: 5; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* narrow (phone) layout: based on the app's own width, so the Phone toggle works too */
@container (max-width: 640px) {
  #top { padding: 10px 12px; flex-wrap: wrap; gap: 6px 8px; }
  #top .brand { font-size: 14px; flex-basis: 100%; }
  #screen { padding: 16px 12px 40px; }
  h1 { font-size: 20px; }
  .class-badge { font-size: 20px; padding: 8px 14px; }
  .grid { grid-template-columns: 1fr; }
  #panel { width: 100%; }
  .profile .name { font-size: 18px; }
}

/* Line breaking. text-wrap is ignored by browsers that don't support it (the text just wraps as before). */
#top, #screen, #panel, #toast { white-space: pre-line; overflow-wrap: break-word; } /* "\n" in the text files becomes a line break */
h1, h2, h3, .brand, .btn, .stat .v, .mcard .t, .mcard .big, .banner b, .acct .lbl { text-wrap: balance; }
p, li, .muted, .banner, .sec div, .hist li, .pending div { text-wrap: pretty; }
.login h1, .banner { text-wrap: balance; }
.login p { text-wrap: pretty; }

/* Social Accounts (inside the profile card, under Upcoming CHP) */
.social { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.sa-head { position: relative; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sa-title { font-weight: 700; font-size: 16px; }
.help-btn { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; line-height: 1; padding: 0; }
.help-pop { display: none; position: absolute; z-index: 3; top: 30px; left: 0; width: min(340px, calc(100cqi - 72px)); background: var(--tip); color: var(--tip-ink); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.5; white-space: pre-line; box-shadow: 0 6px 20px var(--shadow); text-wrap: pretty; }
.sa-head.open .help-pop { display: block; }
@media (hover: hover) { .help-btn:hover + .help-pop { display: block; } }
.acct { padding: 6px 0; border: 0; }
.acct-row { display: flex; align-items: center; gap: 8px; }
.ico { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 15px; color: var(--on-color); }
.ico.x { border: 1px solid var(--line); }
.ico { overflow: hidden; }
.ico img { display: block; width: 100%; height: 100%; object-fit: cover; transform: scale(1.05); }
.ico svg { display: block; width: 22px; height: 22px; }
.acct-input, .acct-text { flex: 1; min-width: 0; }
.acct-text { padding: 10px 2px; line-height: 20px; font-size: 16px; overflow-wrap: anywhere; }
.acct-text.empty { color: var(--muted); }
.acct-btns { flex: none; display: flex; gap: 6px; }
.acct-row .btn { flex: none; padding: 10px 14px; }
@container (max-width: 360px) {
  .acct-row { gap: 6px; }
  .ico { width: 34px; height: 34px; font-size: 13px; }
  .acct-input { padding: 10px 8px; font-size: 14px; }
  .acct-row .btn { padding: 10px 10px; }
}

/* Navigation: sidebar (wide) / bottom tab bar (narrow) */
#side { flex: none; width: 200px; background: var(--card); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
#side a { color: var(--muted); text-decoration: none; padding: 10px 12px; border-radius: 10px; font-size: 15px; }
#side a:hover { background: var(--surface); }
#side a.on { color: var(--accent); background: var(--accent-soft); font-weight: 700; }
#side a.logout { margin-top: auto; }
#tabs { display: none; flex: none; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#tabs a { flex: 1; text-align: center; padding: 16px 8px 14px; color: var(--muted); text-decoration: none; font-size: 14px; border-top: 3px solid transparent; margin-top: -1px; }
#tabs a.on { color: var(--accent); font-weight: 700; border-top-color: var(--accent); }
#app.no-nav #side, #app.no-nav #tabs { display: none !important; }
.btn.mypage-logout { display: none; margin-top: 28px; width: 100%; text-align: center; }
.login .btn.link { padding: 10px 18px; }
@container (max-width: 640px) {
  #side { display: none; }
  #tabs { display: flex; }
  .btn.mypage-logout { display: block; }
  #toast { bottom: 76px; }
}

/* PC width: the name box (and the plain text) is fixed to fit an @username of up to 15 characters; Edit sits right next to it, the rest stays empty */
@container (min-width: 641px) {
  .acct-row { justify-content: flex-start; }
  .acct-row .acct-input, .acct-row .acct-text { flex: 0 1 calc(17ch + 28px); }   /* may shrink a little so Save / Cancel stay on the same line as the box */
}
/* Very narrow (about 320px): while editing, Save / Cancel drop to their own line so the box keeps a usable width */
@container (max-width: 360px) {
  .acct-row.editing { flex-wrap: wrap; }
  .acct-row.editing .acct-input { flex: 1 1 140px; }
  .acct-row.editing .acct-btns { flex-basis: 100%; justify-content: flex-end; }
}

/* X and Instagram as a left / right split on wide screens: two equal columns, so whatever happens in the left one
   (Edit, Save/Cancel, errors) can never move the right one. In a column, Save/Cancel wrap to the next line if they don't fit.
   Below the wide threshold they stack vertically (and always on phones). */
.acct-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px 36px; }
.acct-list .acct { min-width: 0; }
@container (min-width: 1000px) {
  .acct-list { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}

/* Mission History table */
.hist-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 14px; }
.hist-table th { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; padding: 0 8px 8px; border-bottom: 1px solid var(--line); }
.hist-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
.hist-table tr:last-child td { border-bottom: 0; }
.hist-table .c-mission { width: 44%; }
.hist-table .c-status { width: 22%; font-weight: 600; white-space: nowrap; }
.hist-table .c-chp { width: 17%; white-space: nowrap; }
.hist-table .c-date { width: 17%; white-space: nowrap; }
.hist-table td, .hist-table th { text-align: center; }
.hist-table th.c-mission, .hist-table td.c-mission { text-align: left; }
.hist-table .c-status.completed { color: var(--ok); }
.hist-table .c-status.failed { color: var(--bad); }
.hist-table .c-status.in_review { color: var(--warn); }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.pager .btn { padding: 4px 14px; font-size: 18px; line-height: 1.2; }
/* Page controls: text only (no boxes). Dim numbers, ‹ › arrows, the current page white with a thin underline. Click targets stay about 32px. */
.pager { gap: 2px; flex-wrap: wrap; }
.pager .btn, .pager .pg { min-width: 32px; height: 32px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; box-shadow: none; color: var(--muted); font: inherit; font-size: 14px; line-height: 32px; font-variant-numeric: tabular-nums; cursor: pointer; }
.pager .btn { font-size: 18px; }
.pager .btn:hover:not(:disabled), .pager .pg:hover { background: transparent; color: var(--ink); }
.pager .btn:disabled { opacity: .35; cursor: default; }
.pager .pg.on { color: #fff; font-weight: 600; cursor: default; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }
.pager .pg-gap { color: var(--muted); font-size: 14px; min-width: 20px; text-align: center; opacity: .7; }
.pager-text { font-variant-numeric: tabular-nums; min-width: 64px; text-align: center; }
@container (max-width: 640px) {
  .hist-table { font-size: 12.5px; }
  .hist-table th { font-size: 11px; padding: 0 4px 6px; }
  .hist-table td { padding: 8px 4px; }
  .hist-table .c-mission { width: 35%; }
  .hist-table .c-status { width: 28%; font-size: 12px; }
  .hist-table .c-chp { width: 17%; }
  .hist-table .c-date { width: 20%; }
}

/* Editing on wide screens: Save / Cancel stay on the same line as the box (compact buttons), so nothing jumps down when Edit is pressed */
@container (min-width: 361px) {
  .ico { width: 36px; height: 36px; }
  .acct-row.editing { flex-wrap: nowrap; }
  .acct-row.editing .acct-btns { gap: 4px; }
  .acct-row.editing .acct-btns .btn { padding: 10px 10px; }
}

/* Edit / Save / Cancel in Social Accounts: smaller buttons */
.acct-row .acct-btns .btn { padding: 6px 12px; font-size: 13px; font-weight: 600; border-radius: 8px; }
.acct-row.editing .acct-btns .btn { padding: 6px 10px; }

/* Mission History: width cap on wide screens (table and pager together), year in the date only when wide */
.hist-box { max-width: 760px; margin: 0 auto; }
.hist-table .d-short { display: none; }
.hist-table .c-date { width: 20%; }
.hist-table .c-mission { width: 40%; }
@container (max-width: 640px) {
  .hist-table .d-full { display: none; }
  .hist-table .d-short { display: inline; }
}

@container (max-width: 640px) {
  .hist-table { font-size: 12px; }
  .hist-table td, .hist-table th { padding-left: 3px; padding-right: 3px; }
  .hist-table .c-mission { width: 37%; }
  .hist-table .c-status { width: 27%; }
  .hist-table .c-chp { width: 16%; }
  .hist-table .c-date { width: 20%; }
}

/* Missions: category sections, 2 cards per row on wide screens, 1 on narrow; icon / CHP badge / Failed label sit on the card edge */
.cat { margin-top: 30px; }
.cat-title { margin: 0 0 22px; }
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 34px 20px; }
.mcard { overflow: visible; padding: 28px 16px 30px; min-height: 130px; }
.mcard .meta { justify-content: flex-start; }
.cat-ico { position: absolute; top: -16px; left: 14px; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--on-color); font-weight: 800; font-size: 13px; letter-spacing: .02em; border: 2px solid var(--bg); box-shadow: 0 2px 6px var(--shadow); object-fit: contain; }
.chp-badge { position: absolute; left: 50%; bottom: -15px; transform: translateX(-50%); white-space: nowrap; background: var(--accent2); color: var(--accent2-ink); font-weight: 800; font-size: 15px; line-height: 1; padding: 8px 16px; border-radius: 99px; border: 2px solid var(--bg); box-shadow: 0 2px 8px var(--shadow-badge); }
.mcard .small { position: absolute; left: 50%; top: -12px; transform: translateX(-50%); white-space: nowrap; align-self: auto; border: 2px solid var(--bg); background: var(--bad-bg); }
.mcard.dim .cat-ico, .mcard.dim .chp-badge { opacity: .4; }
@container (max-width: 640px) {
  .grid { grid-template-columns: minmax(0, 1fr); gap: 36px; }
}

/* Card tweaks: the deadline sits right under the title; the CHP badge is a hexagon (still over the bottom edge).
   Hexagon = a ring (page colour) + a filled inner hexagon, both clipped; the shadow is a drop-shadow on the wrapper so the clip doesn't cut it. */
.mcard { min-height: 118px; }
.mcard .meta { margin-top: 8px; }
.chp-badge { background: none; border: 0; border-radius: 0; box-shadow: none; padding: 0; filter: drop-shadow(0 2px 4px var(--shadow-badge)); }
.chp-hex { display: block; padding: 2px; background: var(--bg); clip-path: polygon(0 50%, 11px 0, calc(100% - 11px) 0, 100% 50%, calc(100% - 11px) 100%, 11px 100%); }   /* hexagon: side points ~115deg, other corners ~122deg; between the first sharp version and the narrow one */
.chp-hex-in { display: block; padding: 9px 21px; background: var(--accent2); color: var(--accent2-ink); clip-path: polygon(0 50%, 10px 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 10px 100%); }

/* ---- premium finish (shared by all palettes): depth, thin edges, restrained accent ---- */
#app { background-color: var(--bg); background-image: radial-gradient(140% 55% at 50% 0%, var(--bg2), var(--bg) 70%); }
.card, .mcard { background-color: var(--card); background-image: linear-gradient(180deg, var(--card2), var(--card)); box-shadow: inset 0 1px 0 var(--edge); }
.mcard:hover { box-shadow: inset 0 1px 0 var(--edge), 0 8px 20px var(--shadow); }
.mcard.dim { background-color: var(--field); background-image: none; box-shadow: none; }
.btn { background-image: linear-gradient(180deg, var(--accent-hi), var(--accent)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28); }
.btn.ghost { background-image: none; box-shadow: none; }
.login .btn:not(.ghost) { background-image: none; }
.class-badge { background: var(--gold-soft); color: var(--gold-text); border: 1px solid var(--gold-line); box-shadow: none; font-weight: 700; letter-spacing: .02em; }
.bar .track { height: 6px; }
.bar .fill { background: linear-gradient(90deg, var(--bar-lv-lo), var(--bar-lv)); }
.bar .fill.class { background: linear-gradient(90deg, var(--bar-cl-lo, var(--gold-lo)), var(--bar-cl-hi, var(--gold-hi))); }
.chp-hex-in { background-color: var(--accent2); background-image: linear-gradient(180deg, var(--gold-hi), var(--accent2) 52%, var(--gold-lo)); color: var(--gold-ink); }
.avatar { background: linear-gradient(135deg, var(--accent-hi), var(--accent-deep)); }

/* ---- design polish (Violet noir) ---- */
/* In review / Completed: a label "stamp" that covers the faded text beneath it instead of overlapping it */
.mcard .big > span { background: var(--card); border: 1px solid currentColor; border-radius: 99px; padding: 5px 20px; font-size: 17px; letter-spacing: .04em; box-shadow: 0 4px 14px var(--shadow); white-space: nowrap; }
/* Balance and Level: values sit on the same line even though only Balance has a small label */
.stat { display: flex; flex-direction: column; justify-content: flex-end; }
/* History table: header cells keep the small header size (the status column rule used to enlarge "Status") */
.hist-table th.c-status, .hist-table th.c-chp, .hist-table th.c-date { font-size: 12px; font-weight: 600; }
@container (max-width: 640px) { .hist-table th.c-status, .hist-table th.c-chp, .hist-table th.c-date { font-size: 11px; } }
/* Class badge: on narrow screens it takes its own row at full width instead of hanging at the right */
/* top class labels (Colonel and above Lt General / Major General): gloss on the upper half, soft glow (inline), Major General's holographic colours flow slowly */
.class-badge.cb-top { position: relative; isolation: isolate; }
.class-badge.cb-top::before { content: ""; position: absolute; inset: 0 0 50% 0; border-radius: 13px 13px 0 0; background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(255,255,255,.06)); z-index: -1; pointer-events: none; }
.class-badge.cb-holo { background-size: 200% 100% !important; background-repeat: repeat-x !important; animation: cb-holo 7s linear infinite; }
@keyframes cb-holo { from { background-position: 0 50%; } to { background-position: 200% 50%; } }
@media (prefers-reduced-motion: reduce) { .class-badge.cb-holo { animation: none; } }
@container (max-width: 520px) { .class-badge { margin-left: 0; width: 100%; text-align: center; } }
/* Keyboard focus, current-page marker, reduced motion */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=text]:focus, textarea:focus { border-color: var(--accent-line); }
#side a.on { box-shadow: inset 3px 0 0 var(--accent); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.cat-ico svg { display: block; width: 22px; height: 22px; }
.cat-ico { box-shadow: 0 2px 6px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .3); }
.cat-ico { overflow: hidden; }
.cat-ico img { display: block; width: 100%; height: 100%; object-fit: cover; transform: scale(1.05); }

/* ---- Icon colour sets for the lower categories (demo bar "Icon colors"; Follow / Event / X / Instagram unchanged) ---- */
:root[data-icons="1"] { --ic-cex-a: #2fe0c6; --ic-cex-b: #12a58f; --ic-cex-ink: #04231d; --ic-camp-a: #c7acff; --ic-camp-b: #8059ee; --ic-camp-ink: #170a33; --ic-trade-a: #ffdc5e; --ic-trade-b: #f2b01a; --ic-trade-ink: #3a2603; --ic-purch-a: #ffa070; --ic-purch-b: #e5603a; --ic-purch-ink: #2d0e04;  --ic-event-a: #6fd0ff; --ic-event-b: #2f8fe3; --ic-event-ink: #06223a; }
:root[data-icons="2"] { --ic-trade-a: #ffd75e; --ic-trade-b: #e8a31c; --ic-trade-ink: #3a2603; --ic-purch-a: #f3e2bb; --ic-purch-b: #c9ad78; --ic-purch-ink: #2e2410;  --ic-event-a: #ff7a8a; --ic-event-b: #d63a56; --ic-event-ink: #2d0508; --ic-cex-a: #ff936e; --ic-cex-b: #e8603c; --ic-cex-ink: #2d0e04; --ic-camp-a: #ffb04e; --ic-camp-b: #ec8a1c; --ic-camp-ink: #2d1604; }
:root[data-icons="3"] { --ic-trade-a: #4fe0c8; --ic-trade-b: #1fa78f; --ic-trade-ink: #04231d; --ic-purch-a: #9ff0b8; --ic-purch-b: #47b974; --ic-purch-ink: #052311;  --ic-event-a: #6b9bff; --ic-event-b: #3a63e6; --ic-event-ink: #04142e; --ic-cex-a: #62bdff; --ic-cex-b: #2d8fe0; --ic-cex-ink: #04142e; --ic-camp-a: #55dcec; --ic-camp-b: #20a8c4; --ic-camp-ink: #03222d; }
:root[data-icons="4"] { --ic-cex-a: #2fe0c6; --ic-cex-b: #12a58f; --ic-cex-ink: #04231d; --ic-trade-a: #ffdc5e; --ic-trade-b: #f2b01a; --ic-trade-ink: #3a2603; --ic-event-a: #8aa0ff; --ic-event-b: #5a63ee; --ic-event-ink: #0a0d33; --ic-camp-a: #c7acff; --ic-camp-b: #8059ee; --ic-camp-ink: #170a33; --ic-purch-a: #ff9ec4; --ic-purch-b: #d8478a; --ic-purch-ink: #33061b; }
:root[data-icons="5"] { --ic-cex-a: #2fe0c6; --ic-cex-b: #12a58f; --ic-cex-ink: #04231d; --ic-trade-a: #ffdc5e; --ic-trade-b: #f2b01a; --ic-trade-ink: #3a2603; --ic-event-a: #ff8fa0; --ic-event-b: #d9435f; --ic-event-ink: #2d0508; --ic-camp-a: #ffa24a; --ic-camp-b: #e8791a; --ic-camp-ink: #2d1604; --ic-purch-a: #f3e2bb; --ic-purch-b: #c9ad78; --ic-purch-ink: #2e2410; }
:root[data-icons="6"] { --ic-cex-a: #2fe0c6; --ic-cex-b: #12a58f; --ic-cex-ink: #04231d; --ic-trade-a: #ffdc5e; --ic-trade-b: #f2b01a; --ic-trade-ink: #3a2603; --ic-event-a: #6b9bff; --ic-event-b: #3a63e6; --ic-event-ink: #04142e; --ic-camp-a: #c7acff; --ic-camp-b: #8059ee; --ic-camp-ink: #170a33; --ic-purch-a: #ff9ec4; --ic-purch-b: #d8478a; --ic-purch-ink: #33061b; }
:root[data-icons="7"] { --ic-cex-a: #2fe0c6; --ic-cex-b: #12a58f; --ic-cex-ink: #04231d; --ic-trade-a: #ffdc5e; --ic-trade-b: #f2b01a; --ic-trade-ink: #3a2603; --ic-event-a: #ff7ac8; --ic-event-b: #c93a9a; --ic-event-ink: #2e0420; --ic-camp-a: #c7acff; --ic-camp-b: #8059ee; --ic-camp-ink: #170a33; --ic-purch-a: #ff9a82; --ic-purch-b: #e0583c; --ic-purch-ink: #2d0e04; }
:root[data-icons="8"] { --ic-cex-a: #2fe0c6; --ic-cex-b: #12a58f; --ic-cex-ink: #04231d; --ic-trade-a: #ffdc5e; --ic-trade-b: #f2b01a; --ic-trade-ink: #3a2603; --ic-event-a: #b8c9f0; --ic-event-b: #7f93c4; --ic-event-ink: #0c1530; --ic-camp-a: #c7acff; --ic-camp-b: #8059ee; --ic-camp-ink: #170a33; --ic-purch-a: #f3e2bb; --ic-purch-b: #c9ad78; --ic-purch-ink: #2e2410; }
:root[data-icons="9"] { --ic-cex-a: #2fe0c6; --ic-cex-b: #12a58f; --ic-cex-ink: #04231d; --ic-trade-a: #ffdc5e; --ic-trade-b: #f2b01a; --ic-trade-ink: #3a2603; --ic-event-a: #6fd0ff; --ic-event-b: #2f8fe3; --ic-event-ink: #06223a; --ic-camp-a: #ffa24a; --ic-camp-b: #e8791a; --ic-camp-ink: #2d1604; --ic-purch-a: #ff9ec4; --ic-purch-b: #d8478a; --ic-purch-ink: #33061b; }
/* demo bar only: long option labels must not widen the page on phones */
#demo-body label { max-width: 100%; min-width: 0; }
#demo-body select { max-width: 100%; min-width: 0; text-overflow: ellipsis; }

/* Balance and Level: no small label; the value is centered in its tile */
.stat { align-items: center; justify-content: center; text-align: center; padding: 16px 14px; }
.stat .v { font-size: 22px; margin-top: 0; }

/* Image drop zone: dashed frame; highlights while a file is dragged over it. The drop hint is hidden on touch devices (no dragging there). */
.dropzone { border: 2px dashed var(--line); border-radius: 14px; padding: 16px; text-align: center; transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.dropzone .drop-text { display: none; font-weight: 600; margin-bottom: 10px; }
.dropzone.over .drop-text { color: var(--accent-hi); }
@media (hover: hover) and (pointer: fine) { .dropzone .drop-text { display: block; } }
.dropzone .preview { display: block; margin-left: auto; margin-right: auto; }

/* Post URL shown as a plain text link (X / Instagram "Complete" missions) */
.post-link { display: block; color: var(--accent-hi); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; word-break: break-all; margin: 4px 0; white-space: normal; }
.post-link:hover { color: var(--accent); }

/* Complete button after pressing: grey, not clickable, label "In review" */
.btn.inrev, .btn.inrev:disabled { background: var(--surface); color: var(--muted); border: 1px solid var(--line); box-shadow: none; opacity: 1; cursor: default; }

/* Admin: new mission form (mockup of this one screen only) */
.admin-form .af-field { margin-bottom: 4px; }
.admin-form input[type=number], .admin-form input[type=datetime-local], .admin-form select, .admin-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--field); color: var(--ink); font: inherit; }
.admin-form input[type=datetime-local] { color-scheme: dark; }
.admin-form input:focus, .admin-form select:focus, .admin-form textarea:focus { border-color: var(--accent-line); outline: none; }
.admin-form textarea { resize: vertical; }
.admin-form .af-check { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; }
.admin-form .af-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.admin-form .err { min-height: 0; }
.admin-form .af-dl { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.admin-form .af-dl input[type=datetime-local] { flex: 1 1 200px; min-width: 0; width: auto; }
.admin-form .af-tz { display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto; font-size: 12px; color: var(--muted); }
.admin-form .af-tz select { width: auto; min-width: 90px; }
.admin-form .af-tz select { max-width: 100%; }
.admin-form .af-dl .af-tz { flex: 1 1 170px; }

/* Submitted (in review): image / text are shown read-only */
.preview-ph { width: 100%; max-width: 320px; height: 180px; background: linear-gradient(135deg, var(--surface), var(--card2)); }
.submitted-text { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--field); overflow-wrap: anywhere; }

/* Missions title row with the admin-only "New mission" button */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.title-row { margin-bottom: 16px; }
.title-row h1 { margin: 0; }
/* Admin: New mission. Three input cards + a live preview: side by side on wide screens, stacked on narrow ones (preview under the inputs) */
.wrap.admin-form { max-width: 1100px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; grid-template-areas: "form" "preview" "actions"; }
.admin-grid > .ac-col { grid-area: form; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.admin-grid > .ac-preview { grid-area: preview; min-width: 0; }
.admin-grid > .af-actions { grid-area: actions; margin-top: 0; }
.ac h3 { margin: 0 0 4px; font-size: 16px; }
.ac-prev-h { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.ac-preview .post-link { cursor: default; text-decoration: underline; }
@container (min-width: 1000px) {
  .admin-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "form preview" "actions preview"; align-items: start; }
  .admin-grid > .ac-preview { position: sticky; top: 0; }
}

.admin-form .af-steps { display: flex; flex-direction: column; gap: 8px; }
.admin-form .af-step { display: flex; gap: 8px; align-items: stretch; }
.admin-form .af-step input { flex: 1 1 auto; min-width: 0; }
.admin-form .af-step .btn, .admin-form .af-add { flex: 0 0 auto; }
.admin-form .af-add { align-self: flex-start; }
.step-note { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0 10px; padding: 10px 12px; border: 1px solid var(--warn); background: var(--warn-bg); border-radius: 10px; color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.5; }
.step-note-ic { flex: 0 0 20px; width: 20px; height: 20px; margin-top: 1px; color: var(--warn); }
.step-note-tx { min-width: 0; overflow-wrap: anywhere; }
.submitted-row { display: flex; gap: 10px; align-items: flex-start; }
.submitted-row .submitted-text { flex: 1 1 auto; min-width: 0; word-break: break-all; }
.submitted-row .copy-btn { flex: 0 0 auto; }
.hist-table tr.tap { cursor: pointer; }
.hist-table tr.tap:hover td { background: var(--accent-soft, rgba(255,255,255,.04)); }
.hist-table tr.tap:focus-visible { outline: 2px solid var(--accent-line); outline-offset: -2px; }
.hist-link { display: flex; align-items: baseline; justify-content: flex-start; gap: 6px; text-align: left; }
.hist-link .hist-t { min-width: 0; }
.hist-link .chev { color: var(--accent); font-size: 1.2em; font-weight: 700; line-height: 1; flex: 0 0 auto; align-self: center; }
.hist-link { align-items: center; }

/* Admin: left-menu group (PC), phone page switcher, Review / Manage Missions cards */
#side .side-sep { height: 1px; background: var(--line); margin: 12px 6px 8px; flex: none; }
#side .side-head { padding: 4px 12px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
#side a.sub { padding-left: 28px; font-size: 14px; }
.admin-tabs { display: none; gap: 6px; margin-bottom: 14px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.admin-tabs a { flex: 1; text-align: center; padding: 9px 8px; border-radius: 9px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.admin-tabs a.on { background: var(--accent-soft); color: var(--accent); }
@container (max-width: 640px) { .admin-tabs { display: flex; } }
.wrap.admin-wrap { max-width: 900px; }
.rv-filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.rv-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); flex: 1 1 180px; min-width: 0; }
.rv-filters select { width: 100%; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--field); color: var(--ink); padding: 10px 12px; font-size: 14px; }
.rv-list { display: flex; flex-direction: column; gap: 12px; }
.rv { padding: 14px 16px; }
.rv-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.rv-head b { min-width: 0; overflow-wrap: anywhere; }
.rv-st { flex: none; font-size: 13px; font-weight: 700; }
.rv-st.in_review { color: var(--warn); } .rv-st.completed { color: var(--ok); } .rv-st.failed { color: var(--bad); }
.rv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 16px; }
.rv-f { min-width: 0; font-size: 14px; }
.rv-v { overflow-wrap: anywhere; }
.rv-text { overflow-wrap: anywhere; word-break: break-all; }
.rv .preview-ph { max-width: 160px; height: 90px; border-radius: 8px; }
.rv-reveal { margin-top: 6px; padding: 4px 10px; font-size: 13px; }
.rv-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.rv-reason { margin-top: 12px; }
.rv-reason textarea { width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 10px; background: var(--field); color: var(--ink); padding: 10px 12px; font-size: 14px; resize: vertical; }
.rv-judged { margin-top: 10px; font-size: 13px; }

/* Manage Missions: tables by category (Active / Ended tabs) */
.mm-tabs { display: flex; gap: 6px; margin: 0 0 14px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; max-width: 320px; }
.mm-tab { flex: 1; font: inherit; font-size: 14px; font-weight: 600; padding: 9px 8px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.mm-tab.on { background: var(--accent-soft); color: var(--accent); }
@container (max-width: 640px) { .mm-tabs { max-width: none; } }   /* phone width: the three tabs fill the row, each the same width */
.wrap.admin-wide { max-width: 1000px; }
.mm-cat { margin-bottom: 10px; }
.mm-card { padding: 6px 12px; overflow: hidden; }
.mm-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 14px; }
.mm-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: bottom; }
.mm-table td { padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
.mm-table tr:last-child td { border-bottom: 0; }
.mm-table .c-title { width: 32%; }
.mm-table .c-chp { width: 11%; }
.mm-table .c-dl { width: 19%; }
.mm-table .c-n { width: 11%; text-align: right; }
.mm-table th.c-n { text-align: right; }
.mm-table .c-act { width: 16%; text-align: right; }
.mm-table.ended .c-title { width: 40%; } .mm-table.ended .c-chp { width: 16%; } .mm-table.ended .c-dl { width: 26%; } .mm-table.ended .c-n { width: 18%; }
.mm-table .c-act .btn { padding: 5px 10px; font-size: 13px; margin: 2px 0 2px 4px; }
.mm-confirm td { background: var(--accent-soft); }
@container (max-width: 640px) {
  /* phone: still a table (same columns and header), but each row is two lines: the title on top, the figures and buttons under it */
  .wrap.admin-wide { padding-left: 12px; padding-right: 12px; }
  .mm-card { padding: 2px 8px; }
  .mm-table, .mm-table thead, .mm-table tbody { display: block; }
  .mm-table { font-size: 12.5px; }
  .mm-table tr { display: grid; grid-template-columns: 21% 19% 21% 13% 1fr; column-gap: 4px; align-items: center; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .mm-table.ended tr { grid-template-columns: 24% 44% 1fr; }
  .mm-table tr:last-child { border-bottom: 0; }
  .mm-table th, .mm-table td { width: auto !important; border: 0; padding: 0; text-align: left; overflow-wrap: normal; word-break: normal; }
  .mm-table th.c-title { display: none; }
  .mm-table thead tr { padding: 8px 0 6px; border-bottom: 1px solid var(--line); }
  .mm-table th { font-size: 10px; align-self: end; hyphens: none; }
  .mm-table td.c-title { grid-column: 1 / -1; font-weight: 600; margin-bottom: 6px; overflow-wrap: anywhere; }
  .mm-table .c-n, .mm-table th.c-n { text-align: left; }
  .mm-table td.c-n { padding-left: 2px; }
  .mm-table td.c-act { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
  .mm-table .c-act .btn { display: block; box-sizing: border-box; padding: 4px 2px; font-size: 11px; margin: 0; text-align: center; overflow-wrap: normal; word-break: normal; line-height: 1.15; }
  .mm-table .mm-confirm { display: block; }
  .mm-table .mm-confirm td { display: block; padding: 8px; border-radius: 8px; }
}
.af-help { font-size: 12px; margin: -2px 0 8px; }
.af-sub { margin: -8px 0 12px; }

/* Manage Missions / Review alignment: text left, numbers (and their headers) right, buttons at the right end; drag handle */
.mm-table .c-chp, .mm-table th.c-chp, .mm-table .c-n, .mm-table th.c-n { text-align: right; }
.mm-table .c-title, .mm-table .c-dl, .mm-table th.c-dl { text-align: left; }
.mm-table .c-act { text-align: right; }
.mm-grip { display: inline-block; width: 28px; margin-right: 6px; text-align: center; font-size: 20px; line-height: 1; color: var(--muted); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 6px; padding: 4px 0; vertical-align: middle; }
.mm-grip:hover, .mm-grip:focus-visible { color: var(--accent); background: var(--accent-soft); outline: none; }
.mm-t { vertical-align: middle; }
.mm-table tr.dragging td { background: var(--accent-soft); }
.mm-table tr.dragging { position: relative; z-index: 2; }
.mm-table tr[data-id] { transition: transform .12s; }
.mm-table tr.dragging { transition: none; }
.rv-actions { justify-content: flex-end; }
.rv-judged { text-align: left; }
.mm-table.active .c-title { width: 29%; } .mm-table.active .c-chp { width: 10%; } .mm-table.active .c-dl { width: 16%; } .mm-table.active .c-n { width: 9%; } .mm-table.active .c-act { width: 18%; }
.mm-table.ended .c-title { width: 36%; } .mm-table.ended .c-chp { width: 14%; } .mm-table.ended .c-dl { width: 20%; } .mm-table.ended .c-n { width: 15%; }
@container (max-width: 640px) {
  .mm-table.active tr { grid-template-columns: 16% 19% 18% 13% 11% 1fr; }
  .mm-table th { font-size: 9.5px; }
  .mm-table.ended tr { grid-template-columns: 19% 29% 20% 1fr; }
  .mm-table .c-chp, .mm-table th.c-chp, .mm-table .c-n, .mm-table th.c-n { text-align: right; }
  .mm-table td.c-title { display: flex; align-items: center; text-align: left; }
  .mm-table .c-dl { padding-left: 6px; text-align: left; }
  .mm-table th.c-dl { padding-left: 6px; text-align: left; }
  .mm-table .c-n { padding-right: 2px; }
  .mm-table td.c-act { align-items: flex-end; }
  .mm-grip { width: 30px; margin-right: 4px; flex: none; }
}
@container (max-width: 360px) { .mm-table th { font-size: 9px; } }
@container (max-width: 640px) { .mm-table tr { row-gap: 0; } .mm-table td.c-title { margin-bottom: 2px; } }

/* Manage Missions: row opens the detail panel; handle in its own left column; CHP / deadline centred */
.mm-table tr.mm-open { cursor: pointer; }
.mm-table tr.mm-open:hover td { background: var(--accent-soft); }
.mm-table tr.mm-open:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.mm-table .c-chp, .mm-table th.c-chp, .mm-table .c-dl, .mm-table th.c-dl { text-align: center; }
.mm-table .c-grip { width: 44px; padding-left: 0; padding-right: 0; text-align: center; }
.mm-table.active .c-grip { width: 44px; } .mm-table.active .c-title { width: 31%; } .mm-table.active .c-chp { width: 12%; } .mm-table.active .c-dl { width: 17%; } .mm-table.active .c-n { width: 10%; }
.mm-grip { margin-right: 0; }
#panel .af-actions { display: flex; gap: 10px; margin-top: 20px; }
.af-end { margin-left: auto; }
.mm-confirm-box { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); }
@container (max-width: 640px) {
  .mm-table.active tr { grid-template-columns: 30px 15% 21% 19% 15% 1fr; }
  .mm-table.active td.c-grip { grid-row: 1 / span 2; grid-column: 1; align-self: start; display: block; }
  .mm-table.active th.c-grip { display: block; }
  .mm-table.active td.c-title { grid-column: 2 / -1; }
  .mm-table .c-chp, .mm-table th.c-chp, .mm-table .c-dl, .mm-table th.c-dl { text-align: center; padding-left: 0; }
  .mm-table .mm-grip { width: 30px; margin: 0; }
  .mm-table td.c-title { display: block; }
}
@container (max-width: 640px) { .mm-table tr.mm-open:hover td { background: none; } .mm-table tr.mm-open:hover { background: var(--accent-soft); border-radius: 8px; } }
@container (max-width: 640px) {
  .mm-table.active tr { grid-template-columns: 30px 18% 13% 11% 15% 1fr; }
  .mm-table.ended tr { grid-template-columns: 20% 16% 22% 1fr; }
  .mm-table .c-dl, .mm-table th.c-dl { padding-left: 0; padding-right: 0; }
}

/* Manage Missions: vertical dividers (Title | Completed / In Review / Failed | CHP / Deadline) and a tighter CHP-Deadline gap */
.mm-table.active .c-title, .mm-table.ended .c-title { width: auto; }
.mm-table.active .c-n, .mm-table.ended .c-n { width: 9%; }
.mm-table.active .c-chp { width: 96px; } .mm-table.active .c-dl { width: 150px; }
.mm-table.ended .c-chp { width: 96px; } .mm-table.ended .c-dl { width: 110px; }
.mm-table.active .c-n:nth-child(3), .mm-table.ended .c-n:nth-child(2), .mm-table .c-chp { border-left: 1px solid var(--line); }
.mm-table .c-chp, .mm-table .c-dl { padding-left: 4px; padding-right: 4px; }
@container (max-width: 640px) {
  .mm-table.active .c-n:nth-child(3), .mm-table.ended .c-n:nth-child(2) { border-left: 0; }   /* phone: Title sits on its own line, so only the CHP divider */
  .mm-table.active tr { grid-template-columns: 30px 18% 13% 11% 14% 1fr; }
  .mm-table .c-chp, .mm-table th.c-chp { border-left: 1px solid var(--line); }
  .mm-table.active .c-chp, .mm-table.ended .c-chp, .mm-table.active .c-dl, .mm-table.ended .c-dl { width: auto; }
}
@container (max-width: 640px) { .mm-table.active tr { grid-template-columns: 30px 17% 13% 11% 16% 1fr; } .mm-table .c-chp { padding-left: 2px; padding-right: 2px; } }
@container (max-width: 640px) { .mm-table.active tr { grid-template-columns: 30px 18% 12% 11% 15% 1fr; } }
@container (max-width: 640px) { .mm-table.active tr { grid-template-columns: 30px 18% 11% 11% 16% 1fr; } }
@container (max-width: 360px) { .mm-table.active tr { grid-template-columns: 28px 18% 12% 11% 16% 1fr; column-gap: 2px; } .mm-table.active .mm-grip { width: 28px; } }

/* vertical dividers removed (not wanted) */
.mm-table.active .c-n:nth-child(3), .mm-table.ended .c-n:nth-child(2), .mm-table .c-chp, .mm-table th.c-chp { border-left: 0 !important; }
.mm-table.active .c-dl { width: 170px; } .mm-table.ended .c-dl { width: 120px; }
@container (max-width: 640px) { .mm-table.active .c-dl, .mm-table.ended .c-dl { width: auto; } }

/* spacing: Failed ↔ CHP wider, CHP ↔ Deadline tighter */
.mm-table.active .c-n:nth-child(5), .mm-table.ended .c-n:nth-child(3) { padding-right: 22px; }
.mm-table.active .c-dl { width: 142px; } .mm-table.ended .c-dl { width: 104px; }
.mm-table .c-chp { padding-left: 2px; padding-right: 2px; }
@container (max-width: 640px) {
  .mm-table.active .c-n:nth-child(5), .mm-table.ended .c-n:nth-child(3) { padding-right: 0; }
  .mm-table.active tr { grid-template-columns: 30px 18% 12% 12% 17% 1fr; }
  .mm-table.ended tr { grid-template-columns: 20% 16% 24% 1fr; }
  .mm-table .c-dl, .mm-table th.c-dl { width: auto; text-align: left; padding-left: 0; }
}
@container (max-width: 360px) { .mm-table.active tr { grid-template-columns: 28px 18% 12% 12% 17% 1fr; } }
@container (max-width: 640px) {
  .mm-table.active tr { grid-template-columns: 30px 18% 12% 11% 16% 1fr; }
  .mm-table.ended tr { grid-template-columns: 20% 16% 22% 1fr; }
  .mm-table .c-dl, .mm-table th.c-dl { text-align: center; }
}
@container (max-width: 360px) { .mm-table.active tr { grid-template-columns: 28px 18% 12% 11% 16% 1fr; column-gap: 2px; } }

/* ===== Manage Missions: PC keeps the table; phone = a two-line list per mission (no header row) ===== */
.dl-short { display: none; }
@container (max-width: 640px) {
  .dl-full { display: none; } .dl-short { display: inline; }
  .mm-table thead { display: none; }
  .mm-table tbody { display: block; }
  .mm-table tr, .mm-table.active tr, .mm-table.ended tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 12px; position: relative; padding: 10px 0 10px 36px; grid-template-columns: none; }
  .mm-table tr.mm-open { padding-left: 36px; }
  .mm-table.ended tr { padding-left: 4px; }
  .mm-table td { display: block; width: auto !important; border: 0 !important; padding: 0 !important; text-align: left !important; white-space: nowrap; font-size: 12.5px; color: var(--muted); }
  .mm-table td.c-title { flex: 0 0 100%; white-space: normal; font-size: 14px; font-weight: 600; color: var(--ink); margin: 0; overflow-wrap: anywhere; }
  .mm-table td.c-grip { position: absolute; left: 0; top: 6px; width: 30px !important; }
  .mm-table .mm-grip { width: 30px; margin: 0; }
  .mm-table td.c-chp, .mm-table td.c-n { color: var(--muted); }
  .mm-table td[data-label]::before { content: attr(data-label) " "; }
  .mm-table td.c-dl { color: var(--ink); }
  .mm-table td.c-n, .mm-table td.c-chp { color: var(--ink); }
  .mm-table td[data-label]::before { color: var(--muted); }
}
.mm-table td.mm-br { display: none; }
@container (max-width: 640px) {
  /* line 2: CHP, deadline / end date; line 3: the counts (a fixed break so the wrap is never in the middle of a group) */
  .mm-table td.c-chp { order: 1; } .mm-table td.c-dl { order: 2; }
  .mm-table td.mm-br { display: block; order: 3; flex: 0 0 100%; height: 0; }
  .mm-table td.c-n { order: 4; }
}

/* Select boxes in the Admin forms / Review filters: one look, the arrow sits inside the right edge, centred vertically */
.admin-form select, .rv-filters select {
  -webkit-appearance: none; appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1.5 1.5 6 6l4.5-4.5' fill='none' stroke='%23a79fc4' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 12px 8px;
  cursor: pointer; text-overflow: ellipsis;
}
.admin-form select:disabled { cursor: default; opacity: .7; }
.admin-form .af-tz select { padding-right: 36px; background-position: right 12px center; }
.admin-form .af-tz select { background-position: right 14px center; padding-right: 38px; }

/* ===== Manage Missions phone: every mission is a card (look of the member Missions cards) ===== */
.ph-only { display: none; }
@container (max-width: 640px) {
  .pc-only { display: none; } .ph-only { display: inline; }
  .mm-card { background: none !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; overflow: visible; }
  .mm-table tbody { display: flex; flex-direction: column; gap: 12px; }
  .mm-table tr, .mm-table.active tr, .mm-table.ended tr {
    background-color: var(--card); background-image: linear-gradient(180deg, var(--card2), var(--card));
    border: 1px solid var(--line) !important; border-radius: var(--radius); box-shadow: inset 0 1px 0 var(--edge);
    padding: 14px 14px 12px 50px; row-gap: 8px; column-gap: 10px; align-items: center;
  }
  .mm-table.ended tr { padding: 14px 14px 12px; }
  .mm-table tr:last-child { border-bottom: 1px solid var(--line) !important; }
  .mm-table tr.mm-open:hover { background-color: var(--card2); border-radius: var(--radius); }
  .mm-table tr.dragging { box-shadow: 0 8px 22px var(--shadow); }
  .mm-table td.c-grip { top: 50%; left: 8px; transform: translateY(-50%); }
  .mm-table td.c-title { font-size: 15px; font-weight: 700; line-height: 1.3; margin-bottom: 4px; }
  .mm-table td.c-chp { flex: 0 0 auto; }
  .mm-table td.c-dl { margin-left: auto; text-align: right !important; font-size: 13px; color: var(--muted); }
  .mm-table .chp-hex { display: inline-block; vertical-align: middle; }
  .mm-table .chp-hex-in { padding: 5px 13px; font-size: 13px; font-weight: 800; white-space: nowrap; }
  .mm-table td.c-n { font-size: 12.5px; }
}
@container (min-width: 340px) and (max-width: 640px) {
  .mm-table.ended tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
  .mm-table.ended tr { padding: 12px; column-gap: 8px; }
}
@container (min-width: 340px) and (max-width: 640px) {
  .mm-table.ended .chp-hex-in { padding: 4px 8px; font-size: 12px; }
  .mm-table.ended td.c-dl { font-size: 12px; }
  .mm-table.ended tr { padding: 12px 10px; column-gap: 6px; }
}

/* ===== Manage Missions phone, redo: plain, readable cards (admin page: legibility first, no decoration) ===== */
@container (max-width: 640px) {
  .mm-table tbody, .mm-table.ended tbody { display: flex; flex-direction: column; gap: 10px; grid-template-columns: none; }
  .mm-table tr, .mm-table.active tr, .mm-table.ended tr {
    background-color: var(--card); background-image: none; box-shadow: none;
    border: 1px solid var(--line) !important; border-radius: 12px;
    padding: 14px 14px 14px 56px; row-gap: 12px; column-gap: 12px; align-items: center;
  }
  .mm-table.ended tr { padding: 14px; }
  .mm-table tr.mm-open:hover { background-color: var(--card2); }
  .mm-table td.c-grip { left: 6px; width: 44px !important; display: flex; justify-content: center; }
  .mm-table .mm-grip { width: 36px; font-size: 22px; padding: 10px 0; }
  .mm-table td.c-title { font-size: 16px; font-weight: 700; line-height: 1.35; margin: 0; color: var(--ink); }
  .mm-table .chp-hex, .mm-table .chp-hex-in { display: inline; padding: 0; background: none !important; clip-path: none; filter: none; box-shadow: none; }
  .mm-table .chp-hex-in { color: var(--accent); font-size: 15px; font-weight: 700; }
  .mm-table td.c-dl { margin-left: auto; font-size: 14px; color: var(--muted); }
  .mm-table td.mm-br { display: block; flex: 0 0 100%; height: 1px; background: var(--line); margin: -2px 0; }
  .mm-table td.c-n { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 17px; font-weight: 700; color: var(--ink); }
  .mm-table td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
}
@container (min-width: 340px) and (max-width: 640px) {
  .mm-table.ended tbody { display: flex; flex-direction: column; gap: 10px; }
  .mm-table.ended tr { padding: 14px; column-gap: 12px; }
  .mm-table.ended .chp-hex-in { font-size: 15px; padding: 0; }
  .mm-table.ended td.c-dl { font-size: 14px; }
}

/* ===== Manage Missions phone, adjust: white CHP / deadline, smaller type (all below the title size), Ended in a single row ===== */
@container (max-width: 640px) {
  .mm-table td.c-title { font-size: 14px; line-height: 1.35; }
  .mm-table .chp-hex-in { color: var(--ink); font-size: 13px; font-weight: 700; }
  .mm-table td.c-dl { color: var(--ink); font-size: 12.5px; }
  .mm-table td.c-n { font-size: 13px; }
  .mm-table td[data-label]::before { font-size: 11px; }
  .mm-table tr, .mm-table.active tr { padding-left: 52px; row-gap: 10px; }
  .mm-table .mm-grip { width: 36px; }
  .mm-table td.c-grip { width: 40px !important; }
  /* Ended: title on top, then CHP / end date / Completed / Failed side by side */
  .mm-table.ended tr { justify-content: space-between; row-gap: 8px; column-gap: 8px; padding: 12px 14px; }
  .mm-table.ended td.mm-br { display: none; }
  .mm-table.ended td.c-dl { margin-left: 0; }
  .mm-table.ended td.c-chp, .mm-table.ended td.c-dl, .mm-table.ended td.c-n { flex: 0 0 auto; }
  .mm-table.ended td.c-n { flex-direction: row; align-items: baseline; gap: 4px; }
  .mm-table.ended td[data-label]::before { display: inline; }
}
@container (min-width: 340px) and (max-width: 640px) {
  .mm-table.ended .chp-hex-in { font-size: 13px; }
  .mm-table.ended td.c-dl { font-size: 12.5px; }
}

/* Ended phone: same order as the PC table (Completed, Failed, CHP, End Date); the four values share one size and weight, only the labels are smaller and grey */
@container (max-width: 640px) {
  .mm-table.ended td.c-n { order: 1; font-size: 13px; font-weight: 600; }
  .mm-table.ended td.c-chp { order: 3; }
  .mm-table.ended td.c-dl { order: 4; font-size: 13px; font-weight: 600; color: var(--ink); }
  .mm-table.ended .chp-hex-in { font-size: 13px; font-weight: 600; }
}
@container (min-width: 340px) and (max-width: 640px) {
  .mm-table.ended .chp-hex-in { font-size: 13px; font-weight: 600; }
  .mm-table.ended td.c-dl { font-size: 13px; }
}
@container (max-width: 640px) { .mm-table.ended tr { padding: 12px; column-gap: 4px; } .mm-table.ended td[data-label]::before { margin-right: 0; } .mm-table.ended td.c-n { gap: 3px; } }

/* Active phone: the deadline starts at the same left edge as the 2nd count column (CHP = column 1), left-aligned */
@container (max-width: 640px) {
  .mm-table.active td.c-chp { flex: 1 1 0; min-width: max-content; }
  .mm-table.active td.c-dl { flex: 2 1 0; min-width: 0; margin-left: 0; text-align: left !important; }
}
@container (max-width: 640px) { .mm-table.active td.c-chp { flex: 0 0 calc((100% - 24px) / 3); min-width: max-content; } .mm-table.active td.c-dl { flex: 1 1 0; } }
/* phone: CHP and deadline are the same kind of information, so the same size and weight (Active and Ended) */
@container (max-width: 640px) { .mm-table .chp-hex-in, .mm-table td.c-dl { font-size: 13px; font-weight: 600; color: var(--ink); } }
.card.ac[hidden] { display: none; }

/* Admin form: CHP = plain digits box (no spinner); deadline = own calendar; time zone box the same height and type size as the deadline box */
.admin-form input.num { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--field); color: var(--ink); font: inherit; }
.admin-form .af-dl { align-items: flex-end; gap: 10px; }
.admin-form .af-dl .dt { position: relative; flex: 1 1 200px; min-width: 0; }
.admin-form .dt-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; height: 44px; box-sizing: border-box; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--field); color: var(--ink); font: inherit; font-size: 16px; text-align: left; cursor: pointer; }
.admin-form .dt-field:focus-visible, .admin-form .dt.open .dt-field { border-color: var(--accent-line); outline: none; }
.admin-form .dt-text.empty { color: var(--muted); }
.admin-form .dt-ico { display: inline-flex; color: var(--muted); flex: none; }
.admin-form .dt-field:hover .dt-ico { color: var(--accent); }
.admin-form .dt.off .dt-field { opacity: .55; cursor: default; }
.admin-form .af-tz select { height: 44px; box-sizing: border-box; font-size: 16px; padding-top: 0; padding-bottom: 0; width: 100%; }
.admin-form .af-dl .af-tz { flex: 1 1 190px; }
.dt-pop { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: max(100%, 280px); max-width: min(340px, calc(100vw - 24px)); box-sizing: border-box; padding: 12px; background-color: var(--card); background-image: linear-gradient(180deg, var(--card2), var(--card)); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 14px 34px var(--shadow); white-space: normal; }
.dt-pop[hidden] { display: none; }
.dt-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dt-title { font-weight: 700; font-size: 15px; }
.dt-nav { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer; }
.dt-nav:hover { background: var(--accent-soft); color: var(--accent); }
.dt-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.dt-wd span { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.dt-day { aspect-ratio: 1 / 1; min-height: 32px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; padding: 0; }
.dt-day:hover { background: var(--accent-soft); }
.dt-day.out { color: var(--muted); opacity: .55; }
.dt-day.today { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.dt-day.sel, .dt-day.sel:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink, #16062a); font-weight: 700; opacity: 1; }
.dt-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.dt-time { display: flex; align-items: center; gap: 4px; margin-right: auto; }
.admin-form .dt-sel { width: auto; min-width: 0; height: 36px; padding: 0 28px 0 10px; font-size: 14px; background-position: right 9px center; }
.dt-btn { padding: 7px 12px; font-size: 14px; }
.dt-day { aspect-ratio: auto; height: 34px; min-height: 0; }
.dt-pop { padding: 10px; }
.dt-wd span { padding: 2px 0 4px; }
.dt-foot { flex-wrap: wrap; }
@media (max-width: 420px) { .dt-time { flex: 0 0 100%; margin-right: 0; } .dt-btn { flex: 1 1 0; } }
.af-pub { flex: 0 0 100%; }
.af-pub:empty { display: none; }
.af-pub .mm-confirm-box { margin-top: 4px; }
.pub-sum { margin-top: 8px; display: grid; gap: 2px; font-size: 14px; overflow-wrap: anywhere; }
.af-pub .rv-actions { margin-top: 10px; }
.af-pfx { display: flex; align-items: center; gap: 10px; }
.af-pfx > span { white-space: nowrap; font-weight: 600; color: var(--muted, #a9a3c4); }
.af-pfx > input { flex: 1 1 0; min-width: 0; }
.rv-filters .rv-search { flex: 2 1 220px; }
.rv-filters input[type=search] { width: 100%; max-width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 10px; background: var(--field); color: var(--ink); padding: 10px 12px; font-size: 14px; }
@container (max-width: 640px) { .rv-filters { flex-direction: column; } .rv-filters label, .rv-filters .rv-search { flex: 0 0 auto; width: 100%; } .rv-filters .rv-search > span { display: none; } }
.rv-filters .rv-search { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
.rv-sbox { position: relative; min-width: 0; }
.rv-sfield { display: flex; align-items: center; min-height: 42px; box-sizing: border-box; border: 1px solid var(--line); border-radius: 10px; background: var(--field); padding: 4px 8px; gap: 6px; flex-wrap: wrap; cursor: text; }
.rv-sfield:focus-within { border-color: var(--accent); }
.rv-tags { display: contents; }
.rv-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; min-width: 0; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--ink); font-size: 13px; }
.rv-chip-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-chip-x { all: unset; cursor: pointer; width: 20px; height: 20px; line-height: 20px; text-align: center; border-radius: 50%; font-size: 16px; color: var(--muted); flex: 0 0 auto; }
.rv-chip-x:hover, .rv-chip-x:focus-visible { background: rgba(255,255,255,.12); color: var(--ink); }
.rv-sin { flex: 1 1 120px; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; padding: 6px 4px; }
.rv-pop { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--card, #241d38); box-shadow: 0 8px 24px rgba(0,0,0,.4); padding: 6px; }
.rv-pop[hidden] { display: none; }
.rv-pop-g { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 6px 8px 2px; }
.rv-pop-i { all: unset; display: block; box-sizing: border-box; width: 100%; padding: 8px; border-radius: 8px; font-size: 14px; color: var(--ink); cursor: pointer; overflow-wrap: anywhere; }
.rv-pop-i:hover, .rv-pop-i:focus-visible { background: var(--accent-soft); }
.rv-sfield .rv-sin, .rv-sfield .rv-sin:focus, .rv-sfield .rv-sin:focus-visible { outline: 0 !important; box-shadow: none !important; border: 0 !important; background: transparent !important; }
/* Admin Review detail panel */
.rv-open { cursor: pointer; }
.rv-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rvp-who { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; min-width: 0; }
.rvp-who-t { min-width: 0; overflow-wrap: anywhere; }
.rvp-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; min-width: 0; }
.rvp-row > div:first-child { flex: 0 0 auto; }
.rvp-row > div:last-child { min-width: 0; text-align: right; overflow-wrap: anywhere; }
.rvp-text { padding: 8px 10px; border-radius: 8px; background: var(--field); overflow-wrap: anywhere; white-space: pre-wrap; margin-top: 4px; }
.rvp-thumb { display: block; width: 100%; max-width: 200px; height: 120px; object-fit: cover; border-radius: 8px; cursor: zoom-in; }
.rvp-thumb.sm { max-width: 90px; height: 54px; }
.rvp-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rvp-det { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.rvp-det > summary { cursor: pointer; font-weight: 600; }
.rvp-hist { padding: 8px 0; border-top: 1px solid var(--line); margin-top: 8px; font-size: 13px; display: grid; gap: 6px; }
.rvp-bar { position: sticky; bottom: -20px; margin: 18px -20px -20px; padding: 12px 20px 16px; background: var(--card); border-top: 1px solid var(--line); z-index: 2; }
.rvp-bar textarea { width: 100%; box-sizing: border-box; }
.zoom-ov { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.85); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.zoom-ov img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.zoom-ph { width: min(480px, 100%); height: 300px; border-radius: 10px; background: linear-gradient(135deg, var(--surface), var(--card2)); }
#panel.rvp { display: flex; flex-direction: column; }
#panel.rvp > * { flex: 0 0 auto; }
#panel.rvp > .btn { align-self: flex-start; }
#panel.rvp > .rvp-bar { margin-top: auto; align-self: stretch; }
.rvp-bar .rv-actions { margin: 0; padding: 0; }
.rv-mc { display: inline-flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.rv-mk { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 1px 5px; border-radius: 4px; background: var(--accent-soft); color: var(--ink); align-self: center; margin-right: -4px; }
.rvp-reason { display: flex; gap: 8px; align-items: baseline; margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.05); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.rvp-reason-l { flex: 0 0 auto; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
/* Review list: compact rows */
.rv { padding: 10px 14px; }
.rv-head { margin-bottom: 6px; }
.rv-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 14px; }
@container (max-width: 640px) { .rv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rv-f { font-size: 13px; line-height: 1.35; }
.rv-lab { font-size: 11px; }
.rv-line { display: flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.rv-line .rv-mk { flex: 0 0 auto; margin-right: 0; }
.rv-av { width: 20px; height: 20px; font-size: 11px; flex: 0 0 auto; }
.rv .rv-text { word-break: normal; overflow-wrap: anywhere; white-space: pre-wrap; }
.rv .rv-actions { margin-top: 8px; gap: 6px; }
.rv .rv-actions .btn { padding: 5px 12px; font-size: 13px; min-height: 0; }
.rv-judged { margin-top: 6px; font-size: 11px; opacity: .85; }
.rv-acct { font-size: 12px; }
.rvp-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#panel.rvp > .rvp-top { align-self: stretch; }
.rvp-st { font-size: 22px; font-weight: 800; line-height: 1.1; text-align: right; overflow-wrap: anywhere; }
/* Review list: phone layout, pager, phone judge buttons */
.rv-left, .rv-right { display: contents; }
.rv-pager { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 8px 0 4px; }
.rv-pg { min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--field); color: var(--ink); font-size: 14px; cursor: pointer; }
.rv-pg.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.rv-pg:disabled { opacity: .35; cursor: default; }
@container (max-width: 640px) {
  .rv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .rv-left, .rv-right { display: grid; gap: 6px; align-content: start; min-width: 0; }
  .rv-user { font-size: 12px; }
  .rvp-bar .rv-actions { flex-wrap: nowrap; gap: 6px; }
  .rvp-bar .rv-actions .btn { flex: 1 1 0; min-width: 0; padding: 7px 6px; font-size: 12px; white-space: nowrap; }
}
@container (max-width: 640px) { .rv-left { gap: 0; } }
@container (max-width: 640px) {
  .rv > .rv-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .rv > .rv-actions .btn { width: 100%; min-width: 0; padding: 7px 6px; white-space: nowrap; }
}

/* Manage Missions: "Draft" tag next to a mission that members cannot see yet */
.mm-unpub { display: inline-block; margin-left: 8px; padding: 1px 8px; font-size: 12px; font-weight: 600; border-radius: 999px; background: var(--accent-soft); color: var(--accent); vertical-align: middle; }
.mm-live { font-size: 12px; font-weight: 400; margin-top: 2px; }

/* Schedule pop-up (New / Edit Mission): small dialog with Publish Date + Time Zone */
.sch-ov { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; }
.sch-box { width: 100%; max-width: 420px; box-sizing: border-box; padding: 18px; border-radius: 16px; background-color: var(--card); border: 1px solid var(--line); box-shadow: 0 14px 34px var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.sch-box h2 { margin: 0; font-size: 18px; }
.sch-box p { margin: 0; }
.sch-box .sch-f { flex: none; width: 100%; }
.sch-box .sch-f .dt { position: relative; }
.sch-box .rv-actions { display: flex; gap: 8px; }

/* Edit / New Mission buttons: one row, same size on every screen; End Mission sits at the far right */
.admin-form .af-actions { display: block; }
.af-row { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; max-width: 540px; }   /* buttons share the row evenly; capped so they never stretch across a wide screen */
.af-row .btn { flex: 1 1 auto; min-width: 0; padding: 9px 12px; font-size: 13px; line-height: 1.2; white-space: nowrap; }
.af-conf:not(:empty) { margin-top: 10px; }
/* Unpublish and End Mission close things down, so they get a warning tone of their own */
.af-row .btn.af-close { background: var(--bad-bg); color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad-line); }
.af-row .btn.af-close:hover { background: rgba(242, 142, 132, .25); }
.af-line { display: contents; }
/* phone: two lines of equal-size buttons (Publish, Schedule / Save as Draft, Cancel, End Mission) */
@container (max-width: 520px) {
  .af-row { flex-direction: column; align-items: stretch; gap: 8px; max-width: none; }
  .af-line { display: flex; gap: 8px; }
  .af-row .btn { flex: 1 1 0; padding: 11px 4px; font-size: 14px; }   /* equal widths inside each line */
}

/* Manage Missions > Drafts on a phone: a card like Ended; state tag at the top right, name on the first line,
   CHP and deadline on the second, Publish at the bottom right (Draft rows only) */
@container (max-width: 640px) {
  .mm-table.drafts tr, .mm-table.drafts tr.mm-open { padding: 14px; row-gap: 10px; column-gap: 14px; align-items: center; justify-content: flex-start; }
  .mm-table.drafts td.c-title { padding-right: 92px !important; }
  .mm-table.drafts .mm-unpub { position: absolute; top: 14px; right: 14px; margin: 0; }
  .mm-table.drafts td.mm-br { display: none; }
  .mm-table.drafts td.c-chp, .mm-table.drafts td.c-dl { flex: 0 0 auto; margin-left: 0; font-size: 13px; font-weight: 600; color: var(--ink); }
  .mm-table.drafts td.c-dl[data-label]::before { display: inline; margin-right: 6px; font-size: 11px; font-weight: 400; color: var(--muted); }
  .mm-table.drafts td.c-act { display: block; flex: 0 0 auto; order: 3; margin-left: auto; }
  .mm-table.drafts td.c-act:empty { display: none; }
  .mm-table.drafts .c-act .btn { display: inline-block; padding: 8px 22px; font-size: 13px; line-height: 1.2; }
}
