:root {
  --bg: #ffffff; --panel: #ffffff; --soft: #f5f6fa; --ink: #18192b; --muted: #6a6f85; --line: #e6e8f0;
  --brand: #6d4ae8; --brand-2: #ff6b9a; --brand-ink: #fff; --mark: #fff2a8;
  --danger: #d93025; --ok: #1f9d55; --radius: 12px; --shadow: 0 1px 2px rgba(20,20,60,.06), 0 8px 24px -12px rgba(20,20,60,.18);
  /* current label colour (set inline per element) */
  --lc: #6d4ae8; --lc-bg: #efeafd;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; max-width: 100%; overflow-x: hidden; }
*, *::before, *::after { min-width: 0; }
img, svg, video { max-width: 100%; }
.field .v, .quote .qb, .r-title, .r-snip, .d-head h2, .card .t, .lrow-top input { overflow-wrap: anywhere; word-break: break-word; }
body { font: 15px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 3px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
kbd { font: 12px/1 Inter, sans-serif; border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; color: var(--muted); background: #fff; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; letter-spacing: -.2px; white-space: nowrap; min-width: 0; }
.brand-name { overflow: hidden; text-overflow: ellipsis; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 800;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: var(--shadow); }
.searchwrap { flex: 1; display: flex; align-items: center; gap: 8px; max-width: 720px; margin: 0 auto; background: var(--soft); border: 1.5px solid transparent; border-radius: 999px; padding: 6px 14px; transition: .15s; }
.searchwrap:focus-within { background: #fff; border-color: var(--brand); box-shadow: 0 0 0 4px #6d4ae822; }
.search-ico { color: var(--muted); font-size: 18px; }
#q { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 4px 0; font-size: 15px; }
#q::-webkit-search-cancel-button { cursor: pointer; }
.actions { display: flex; gap: 8px; align-items: center; }
.inline { display: inline; margin: 0; }
.actions { position: relative; }
.burger { font-size: 18px; line-height: 1; padding: 7px 12px; }
.menu { position: absolute; top: calc(100% + 8px); right: 0; width: 240px; background: #fff; border: 1.5px solid var(--line); border-radius: 14px; box-shadow: 0 18px 40px -12px rgba(20,20,60,.3); padding: 6px; z-index: 30; }
.menu-user { font-size: 12px; color: var(--muted); padding: 8px 12px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px; }
.menu-item:hover { background: var(--soft); }
.menu-item.danger { color: var(--danger); }
.menu .inline { display: block; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }

.btn { padding: 8px 14px; border: 1.5px solid var(--line); background: #fff; border-radius: 999px; cursor: pointer; white-space: nowrap; font-weight: 600; font-size: 14px; transition: .12s; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: #5b3bd0; color: #fff; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn.icon { padding: 8px 11px; }
.btn.lc { background: var(--lc-bg); color: var(--lc); border-color: transparent; }

/* ---------- pills ---------- */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--lc-bg);
  background: var(--lc-bg); color: var(--lc); font-weight: 600; font-size: 14px; cursor: pointer; transition: .12s; user-select: none; }
.pill:hover { border-color: var(--lc); }
.pill.active { background: var(--lc); color: #fff; border-color: var(--lc); }
.pill .n { font-size: 12px; font-weight: 700; background: rgba(255,255,255,.7); color: var(--lc); padding: 1px 7px; border-radius: 999px; }
.pill.active .n { background: rgba(255,255,255,.25); color: #fff; }
.pills.big .pill { padding: 12px 18px; font-size: 15px; border-radius: 14px; }
.pills.big .pill .n { font-size: 13px; }
.chip { display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--lc-bg); color: var(--lc); }
.chip.q { background: var(--soft); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }

/* review list */
#results li { position: relative; padding-right: 44px; }
.star { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent; color: #c2c6d1; font-size: 19px; cursor: pointer; line-height: 1; }
.star:hover { background: #fff6d6; color: #d99a00; }
.star.on { color: #d99a00; }
.btn.review-on { background: #fff6d6; color: #a87400; border-color: transparent; }
.stat-review { cursor: pointer; }

/* label manager */
.lrows { display: grid; gap: 8px; }
.lrow { border: 1.5px solid var(--line); border-left: 5px solid var(--lc); border-radius: 10px; padding: 10px 12px; }
.lrow-top { display: flex; align-items: center; gap: 8px; }
.modal-card .lrow-top input[type=text] { flex: 1; min-width: 0; border: 1.5px solid transparent; background: var(--lc-bg); color: var(--lc); font-weight: 700; padding: 7px 10px; border-radius: 8px; margin: 0; }
.modal-card .lrow-top input[type=text]:focus { border-color: var(--lc); background: #fff; outline: none; box-shadow: none; }
.lrow-bottom { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.modal-card .lrow-bottom select { width: auto; margin: 0; padding: 5px 8px; font-size: 13px; }
.lcount { font-size: 13px; flex: 1; }
.lbtns { display: flex; gap: 4px; }
.lrow .swatch { margin: 0; flex-shrink: 0; }

/* ---------- home ---------- */
.home { max-width: 1100px; margin: 0 auto; padding: 36px 24px 80px; }
.hero { text-align: center; margin-bottom: 36px; }
.hero h1 { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin: 0 0 18px; }
.stats { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.stat { min-width: 150px; padding: 14px 20px; border-radius: 14px; background: var(--soft); text-align: left; }
.stat b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.5px; color: var(--lc); }
.stat span { font-size: 13px; color: var(--muted); font-weight: 500; }
.block { margin-top: 34px; }
.block.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; }
.block-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.block-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; }
.block-head .muted { font-size: 13px; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.card { padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; border-left: 4px solid var(--lc); transition: .12s; background: #fff; }
.card:hover { box-shadow: var(--shadow); border-color: var(--line); border-left-color: var(--lc); }
.card .t { font-weight: 600; }
.card .m { font-size: 13px; color: var(--muted); margin-top: 2px; }
.quick { display: grid; gap: 8px; }
.quick-btn { text-align: left; padding: 12px 14px; border: 1.5px solid var(--line); background: #fff; border-radius: var(--radius); cursor: pointer; display: grid; gap: 2px; transition: .12s; }
.quick-btn:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.quick-btn b { font-weight: 700; }
.quick-btn span { font-size: 13px; color: var(--muted); }

/* ---------- browse ---------- */
.browse { display: flex; flex-direction: column; height: calc(100vh - 57px); }
.pillbar { display: flex; align-items: center; gap: 16px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: #fff; }
.pillbar .pills { flex: 1; flex-wrap: nowrap; overflow-x: auto; padding: 2px 0; scrollbar-width: thin; }
.scope { display: flex; gap: 12px; font-size: 13px; white-space: nowrap; color: var(--muted); flex-shrink: 0; background: var(--soft); padding: 6px 12px; border-radius: 999px; }
.scope label { cursor: pointer; display: flex; align-items: center; gap: 4px; }
.scope input { accent-color: var(--brand); }
.split { display: grid; grid-template-columns: 400px 1fr; flex: 1; min-height: 0; }
.results { border-right: 1px solid var(--line); overflow-y: auto; background: #fff; }
.results-head { padding: 12px 20px; font-size: 13px; color: var(--muted); font-weight: 500; position: sticky; top: 0; background: #fff; border-bottom: 1px solid var(--line); z-index: 1; }
#results { list-style: none; margin: 0; padding: 8px; display: grid; gap: 6px; }
#results li { padding: 12px 14px; border-radius: var(--radius); cursor: pointer; border: 1.5px solid transparent; border-left: 4px solid var(--lc); transition: .12s; }
#results li:hover { background: var(--soft); }
#results li.active { background: var(--lc-bg); border-color: var(--lc-bg); border-left-color: var(--lc); }
#results li.muted { border: 0; cursor: default; padding: 24px; text-align: center; }
.r-title { font-weight: 600; line-height: 1.35; }
.r-meta { font-size: 13px; color: var(--muted); margin-top: 1px; }
.r-snip { font-size: 13px; margin-top: 6px; color: var(--ink); line-height: 1.45; }
.r-snip .where { color: var(--muted); font-style: italic; }
#results .chips { margin-top: 7px; }

.detail { overflow-y: auto; padding: 0 0 80px; background: #fff; }
.empty { color: var(--muted); padding: 80px 40px; text-align: center; }
.d-band { padding: 22px 32px 18px; background: var(--lc-bg); border-bottom: 1px solid var(--line); }
.d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.d-head h2 { margin: 0 0 4px; font-size: 22px; line-height: 1.3; font-weight: 800; letter-spacing: -.3px; }
.d-head .sub { color: var(--muted); font-weight: 500; }
.d-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.d-band .chips { margin-top: 10px; }
.d-body { padding: 8px 32px 0; }
.field { margin-top: 20px; }
.field .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--lc); font-weight: 700; margin-bottom: 4px; }
.field .v { white-space: pre-wrap; line-height: 1.6; }
.field .v:empty::before { content: "—"; color: var(--muted); }

.quotes { margin: 28px 32px 0; padding-top: 20px; border-top: 1px solid var(--line); }
.quotes h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 0 0 10px; font-weight: 700; }
.quote { border-left: 4px solid var(--lc); background: var(--soft); padding: 12px 14px; margin-bottom: 8px; border-radius: 0 var(--radius) var(--radius) 0; }
.quote .qb { white-space: pre-wrap; line-height: 1.55; }
.quote .qm { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.quote .qm .btns { display: flex; gap: 4px; }
.quote .btn.small { background: #fff; }
.addquote { margin-top: 12px; padding: 12px; border: 1.5px dashed var(--line); border-radius: var(--radius); }
.addquote textarea { width: 100%; min-height: 70px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.row input[type=text] { flex: 1; min-width: 120px; }

/* ---------- forms ---------- */
form.edit { padding: 22px 32px; }
form.edit label, .modal-card label { display: block; margin-top: 14px; font-size: 13px; color: var(--muted); font-weight: 600; }
form.edit input[type=text], form.edit textarea, .modal-card input[type=text], .modal-card input[type=password],
.addquote input[type=text], .addquote textarea, .modal-card select {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; margin-top: 4px; font-weight: 400; color: var(--ink); outline: none; }
form.edit input:focus, form.edit textarea:focus, .modal-card input:focus, .addquote textarea:focus, .addquote input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px #6d4ae822; }
form.edit textarea { min-height: 84px; resize: vertical; }
.labelpick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.labelpick label { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-size: 14px; color: var(--lc); background: #fff;
  border: 1.5px solid var(--lc-bg); padding: 5px 12px; border-radius: 999px; cursor: pointer; font-weight: 600; }
.labelpick label:has(input:checked) { background: var(--lc); color: #fff; border-color: var(--lc); }
.labelpick input[type=checkbox] { display: none; }
.formbar { display: flex; gap: 8px; margin-top: 20px; }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(24,25,43,.45); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; backdrop-filter: blur(2px); }
.modal-card { position: relative; background: #fff; border-radius: 16px; padding: 22px 26px; width: min(660px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 30px 60px -20px rgba(0,0,0,.4); }
.modal-x { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--soft); color: var(--ink); font-size: 16px; cursor: pointer; z-index: 1; }
.modal-x:hover { background: var(--line); }
.modal-foot { position: sticky; bottom: -22px; margin: 18px -26px -22px; padding: 12px 26px; background: #fff; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
.modal-card h2 { margin: 0 0 8px; font-size: 18px; font-weight: 800; }
.modal-card table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.modal-card td, .modal-card th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.modal-card th { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { background: none; border: 0; padding: 8px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; background: var(--lc); vertical-align: middle; margin-right: 6px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 18px; border-radius: 999px; z-index: 30; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); }
.alert { background: #fdecea; color: var(--danger); padding: 9px 12px; border-radius: 10px; margin: 10px 0; font-size: 14px; }

/* ---------- login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; background: linear-gradient(135deg, #f3efff, #ffeef4); }
.login-card { background: #fff; padding: 30px 34px; border-radius: 18px; width: min(390px, 100%); box-shadow: 0 30px 60px -25px rgba(60,40,120,.35); }
.login-card h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.3px; }
.login-card label { display: block; margin-top: 14px; font-size: 13px; color: var(--muted); font-weight: 600; }
.login-card input[type=text], .login-card input:not([type]), .login-card input[type=password] {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; margin-top: 4px; font-weight: 400; outline: none; }
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px #6d4ae822; }
.login-card .check { display: flex; gap: 6px; align-items: center; color: var(--ink); font-weight: 500; }
.login-card .btn { width: 100%; margin-top: 18px; padding: 11px; border-radius: 10px; }
.cf-turnstile { margin-top: 14px; }

/* ---------- responsive ---------- */
.backbtn { display: none; margin: 12px 0 0 16px; }
@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
  .detail { display: none; }
  body.show-detail .results { display: none; }
  body.show-detail .detail { display: block; }
  .backbtn { display: inline-block; }
  .block.two { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  body { font-size: 15px; }
  /* top bar: brand + actions on one row, search full width below */
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .brand { order: 1; flex: 1; min-width: 0; }
  .brand-name { font-size: 15px; }
  .actions { order: 2; margin-left: auto; gap: 6px; }
  .actions .btn { padding: 8px 12px; }
  .searchwrap { order: 3; flex-basis: 100%; max-width: none; margin: 0; }
  .searchwrap kbd { display: none; }
  /* home */
  .home { padding: 20px 16px 60px; }
  .hero { margin-bottom: 24px; }
  .hero h1 { font-size: 22px; margin-bottom: 14px; }
  .stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { min-width: 0; padding: 12px 10px; text-align: center; }
  .stat b { font-size: 22px; }
  .stat span { font-size: 12px; }
  .block { margin-top: 26px; }
  .pills.big { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .pills.big .pill { justify-content: space-between; align-items: center; min-height: 58px; padding: 8px 14px; font-size: 14px; border-radius: 12px; white-space: normal; text-align: left; line-height: 1.2; }
  .pills.big .pill .n { flex-shrink: 0; margin-left: 8px; }
  .quick { grid-template-columns: repeat(2, 1fr); }
  .quick-btn { padding: 12px; }
  .quick-btn span { display: none; }
  .card { padding: 12px; }
  /* browse */
  .browse { height: auto; min-height: calc(100vh - 110px); }
  .pillbar { padding: 10px 14px; gap: 8px; flex-wrap: wrap; }
  .pillbar .pills { flex-basis: 100%; gap: 6px; padding-bottom: 4px; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
  .pillbar .pill { padding: 0 12px; height: 36px; font-size: 13px; }
  .pillbar .pills::-webkit-scrollbar { display: none; }
  .scope { font-size: 12px; padding: 5px 10px; }
  .results-head { padding: 10px 14px; }
  #results { padding: 6px; }
  #results li { padding: 12px; }
  .d-band, .d-body, form.edit { padding-left: 16px; padding-right: 16px; }
  .d-band { padding-top: 14px; padding-bottom: 14px; }
  .d-head { flex-direction: column; }
  .d-head h2 { font-size: 19px; }
  .d-actions { justify-content: flex-start; }
  .quotes { margin: 22px 16px 0; }
  .quote .qm .btns { flex-wrap: wrap; }
  .quote .qm .btns .btn { flex: 1 1 auto; text-align: center; }
  .modal { padding: 0; align-items: stretch; }
  .modal-card { width: 100%; max-height: none; height: 100dvh; border-radius: 0; padding: 18px 16px; }
  .modal-foot { bottom: -18px; margin: 18px -16px -18px; padding: 12px 16px; }
  .modal-foot .btn { width: 100%; padding: 11px; }
  .modal-card table { display: block; overflow-x: auto; }
  .login-card { padding: 24px 20px; }
}
