/* Codex L2M: same colours and controls as boss-timer (dark night + gold), no outside fonts or scripts. */
@font-face { font-family: "Cinzel"; src: url("/fonts/cinzel-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #0b0909; --card: #151112; --card-2: #1e1819; --line: #2f2425; --line-2: #47363a;
  --text: #f2eadf; --muted: #b8a993; --faint: #8f8270; --accent: #e2c27d;
  --g-white: #e9e4da; --g-green: #5fd068; --g-blue: #5aa9ff; --g-other: #ff9a5a;
  --r-vrare: #ff6b4d; --r-rare: #f4c152; --r-easy: #4fd1ae; --r-none: #9a8f84; --r-craft: #b99cff;
  --map-green: #5fd068; --map-red: #ff6b4d;
  --shadow: 0 1px 0 rgba(255, 235, 200, 0.04) inset, 0 18px 40px -22px rgba(0, 0, 0, 0.85);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", "Noto Sans", Roboto, Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Noto Sans", Roboto, Arial, sans-serif;
}
:root[data-theme="light"] {
  --bg: #f2ede5; --card: #fffdf9; --card-2: #f7f1e8; --line: #e3d7c6; --line-2: #cdbca3;
  --text: #20160e; --muted: #5b4c3a; --faint: #76665a; --accent: #9a6a12;
  --g-white: #6d6255; --g-green: #1d8a35; --g-blue: #1f6fd1; --g-other: #c25a12;
  --r-vrare: #b5321b; --r-rare: #8a5a00; --r-easy: #0b7559; --r-none: #6d6255; --r-craft: #6a46c9;
  --map-green: #1d8a35; --map-red: #b5321b;
  --shadow: 0 1px 2px rgba(40, 24, 8, 0.06), 0 12px 26px -18px rgba(40, 24, 8, 0.3);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.boot { padding: 60px 20px; text-align: center; color: var(--muted); }

.wrap { max-width: 1320px; margin: 0 auto; padding: 0 20px 48px; }
.top { display: flex; align-items: center; gap: 16px; padding: 16px 0 14px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 34px; width: auto; }
.brand-sep { width: 1px; height: 30px; background: var(--line-2); }
.brand-txt { display: grid; line-height: 1.15; }
.brand-title { font: 700 21px/1.1 "Cinzel", var(--font-display); letter-spacing: 0.06em; color: var(--accent); text-transform: uppercase; }
.brand-sub { font-size: 12px; color: var(--faint); }
.actions { display: flex; gap: 8px; margin-left: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; min-width: 40px; padding: 0 11px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--muted); }
.btn:hover { background: var(--card-2); color: var(--text); border-color: var(--line-2); }
:root[data-theme="dark"] .ic-sun, :root[data-theme="light"] .ic-moon { display: none; }

.seg { display: inline-flex; gap: 2px; max-width: 100%; padding: 3px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.seg a, .seg button { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; white-space: nowrap; }
.seg a:hover, .seg button:hover { color: var(--text); }
.seg [aria-current="page"], .seg button[aria-pressed="true"] { background: var(--card-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg em { margin-left: 7px; color: var(--faint); font-style: normal; font-weight: 500; font-variant-numeric: tabular-nums; }

.tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.search { position: relative; flex: 1 1 260px; max-width: 420px; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input, .sel, .num, .note-in {
  height: 40px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); padding: 0 12px;
}
.search input { width: 100%; padding-left: 38px; }
.search input::placeholder, .note-in::placeholder { color: var(--faint); }
.search input:focus, .sel:focus, .num:focus, .note-in:focus { outline: none; border-color: var(--accent); }
.sel { max-width: 260px; }
.num { width: 72px; }
.count { color: var(--muted); font-size: 13.5px; margin: 0 0 10px; }
.count b { color: var(--text); }

.card { padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); box-shadow: var(--shadow); }
.card + .card, .sec + .sec { margin-top: 14px; }
.sec-h { display: flex; align-items: baseline; gap: 10px; margin: 22px 0 10px; }
.sec-h h2 { font: 700 17px/1.2 var(--font-display); }
.sec-title { font: 700 17px/1.2 var(--font-display); margin-bottom: 10px; }
.sec-h .cnt { color: var(--faint); font-weight: 600; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.back:hover { color: var(--text); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }

/* codex rows */
.rows { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.row:hover { border-color: var(--line-2); background: var(--card-2); }
.row-name { font-weight: 650; overflow-wrap: anywhere; }
.row-sub { color: var(--muted); font-size: 13.5px; }
.row-icons { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; max-width: 520px; }
.tag { display: inline-block; padding: 0 8px; margin-right: 6px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted); vertical-align: 1px; }
.more { display: block; margin: 14px auto 0; }

/* item icon tile */
.ico { position: relative; display: inline-block; width: 46px; height: 46px; flex: none; border: 2px solid var(--gc, var(--line-2)); border-radius: 9px; overflow: hidden; background: #111; }
.ico img { display: block; width: 100%; height: 100%; }
.ico b { position: absolute; right: 1px; bottom: 0; padding: 0 3px; border-radius: 5px; background: rgba(0, 0, 0, 0.72); color: #fff; font-size: 11.5px; font-weight: 700; line-height: 15px; }
.ico.lg { width: 84px; height: 84px; border-radius: 12px; }
.ico.lg b { font-size: 15px; line-height: 20px; }
.g-white { --gc: var(--g-white); } .g-green { --gc: var(--g-green); } .g-blue { --gc: var(--g-blue); } .g-hue14 { --gc: var(--g-other); }
.gname.g-white { color: var(--g-white); } .gname.g-green { color: var(--g-green); } .gname.g-blue { color: var(--g-blue); } .gname.g-hue14 { color: var(--g-other); }

/* rarity badge */
.rar { display: inline-block; padding: 1px 9px; border: 1px solid var(--rc); border-radius: 999px; color: var(--rc); font-size: 12px; font-weight: 700; white-space: nowrap; }
.r-vrare { --rc: var(--r-vrare); } .r-rare { --rc: var(--r-rare); } .r-easy { --rc: var(--r-easy); }
.r-noclone, .r-nosrc { --rc: var(--r-none); } .r-craft { --rc: var(--r-craft); }

/* detail head */
.head { display: flex; gap: 16px; align-items: center; }
.head h1 { font: 700 24px/1.2 var(--font-display); overflow-wrap: anywhere; }
.head .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; color: var(--muted); }
.reward { margin-top: 8px; font-weight: 600; color: var(--accent); }

/* item tiles in a codex */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.tile { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.tile:hover { border-color: var(--line-2); background: var(--card-2); }
.tile-name { font-weight: 650; }
.tile-sub { font-size: 13px; color: var(--muted); }

/* sources: map first, unfold monsters */
.src { border: 1px solid var(--line); border-radius: 12px; background: var(--card); overflow: hidden; }
.src + .src { margin-top: 8px; }
.src summary { display: flex; gap: 10px; align-items: center; padding: 10px 14px; cursor: pointer; list-style: none; }
.src summary::-webkit-details-marker { display: none; }
.src summary::before { content: "▸"; color: var(--faint); }
.src[open] summary::before { content: "▾"; }
.src summary .grow { flex: 1; font-weight: 650; }
.src ul { padding: 0 14px 10px 36px; display: grid; gap: 3px; }
.src li { color: var(--muted); }
.src.off { opacity: 0.6; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; transform: rotate(45deg); }
.dot.green { background: var(--map-green); } .dot.red { background: var(--map-red); } .dot.none { background: var(--faint); }
.farm { font-size: 12px; font-weight: 700; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--faint); }
.farm.yes { color: var(--r-easy); border-color: var(--r-easy); } .farm.no { color: var(--r-vrare); border-color: var(--r-vrare); }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12.5px; color: var(--faint); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
.table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: var(--card-2); }
.table .n { text-align: right; font-variant-numeric: tabular-nums; }
.table a:hover, .lnk:hover { color: var(--accent); }
.note-in { width: 100%; min-width: 140px; height: 34px; border-radius: 9px; }
.table .sel { height: 34px; border-radius: 9px; }

/* items grid */
.igrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.mon { padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.mon + .mon { margin-top: 8px; }
.mon h3 { font-size: 15px; font-weight: 650; margin-bottom: 6px; }
.mon .row-icons { justify-content: flex-start; max-width: none; }
.set { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; }
.set label { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); white-space: nowrap; }
.set .note-in { width: 320px; }
.hint { margin-top: 8px; font-size: 13px; color: var(--faint); }
.save-state { align-self: center; font-size: 12px; color: var(--faint); white-space: nowrap; }
.save-state.warn { color: var(--r-rare); }
.save-state.bad { color: var(--r-vrare); }
@media (max-width: 640px) { .save-state:not(.warn):not(.bad) { display: none; } }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at 50% 20%, #2a1d14 0%, var(--bg) 65%); }
.login-card { width: min(380px, 100%); display: grid; gap: 12px; padding: 30px 26px; border: 1px solid #5b4630; border-radius: 16px; background: rgba(21, 17, 18, 0.92); box-shadow: 0 30px 60px -30px #000; text-align: center; color: #f2eadf; }
.login-logo { width: 200px; height: auto; margin: 0 auto; }
.login-title { font: 700 26px/1.1 "Cinzel", serif; letter-spacing: 0.12em; color: #e2c27d; text-transform: uppercase; }
.login-sub { color: #b8a993; font-size: 13.5px; margin-bottom: 6px; }
.login-card input { height: 44px; padding: 0 14px; border: 1px solid #5b4630; border-radius: 12px; background: #15130f; color: #f2eadf; }
.login-card input:focus { outline: none; border-color: #e2c27d; box-shadow: 0 0 0 3px rgba(226, 194, 125, 0.16); }
.login-btn { height: 44px; border: 0; border-radius: 12px; background: linear-gradient(#e9cd8c, #b8913f); color: #20160e; font-weight: 700; letter-spacing: 0.04em; }
.login-err { color: #ff8a70; font-weight: 600; font-size: 13.5px; }

@media (max-width: 720px) {
  .wrap { padding: 0 12px 40px; }
  .brand-logo, .brand-sep { display: none; }
  .row { grid-template-columns: 1fr; }
  .row-icons { justify-content: flex-start; }
  .ico { width: 40px; height: 40px; }
  .hide-sm { display: none; }
}
