/* Wayde AI Brain. Brand: black, white, magenta #FF00DB, cyan #00FFF2; Poppins. */
:root {
  --black: #000000;
  --white: #FFFFFF;
  --magenta: #FF00DB;
  --cyan: #00FFF2;
  --grad: linear-gradient(90deg, var(--magenta), var(--cyan));

  --bg: #FFFFFF;
  --surface: #F5F6F8;
  --line: #E2E4E9;
  --text: #000000;
  --muted: #5B616D;
  --accent-text: #B4009A;     /* magenta, darkened to read on white */
  --focus: #FF00DB;
  --danger: #B42318;
  --ok: #067647;
  --chip: #FFFFFF;
  --chip-on: #000000;
  --chip-on-text: #FFFFFF;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 18px;
  --font: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --surface: #121315; --line: #2A2C31; --text: #FFFFFF; --muted: #A3A8B3;
    --accent-text: #FF5CE8; --chip: #121315; --chip-on: #FFFFFF; --chip-on-text: #000000; --danger: #FF8A80; --ok: #6CE9A6;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --surface: #121315; --line: #2A2C31; --text: #FFFFFF; --muted: #A3A8B3;
  --accent-text: #FF5CE8; --chip: #121315; --chip-on: #FFFFFF; --chip-on-text: #000000; --danger: #FF8A80; --ok: #6CE9A6;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.6 var(--font); -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

h1 { font-size: clamp(28px, 4vw, 38px); line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 8px; }
h2 { font-size: 20px; line-height: 1.3; font-weight: 600; margin: 0; }
.lede { color: var(--muted); margin: 0 0 28px; max-width: 62ch; }
.note { color: var(--muted); font-size: 14px; margin: 0; }
.opt { color: var(--muted); font-weight: 400; }

/* ---------- Header ---------- */
.bar {
  background: var(--black); color: var(--white);
  display: flex; align-items: center; gap: 28px;
  padding: 14px max(16px, calc((100vw - 1040px) / 2));
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand-word { height: auto; }
.brand-sub { font-weight: 500; font-size: 15px; padding-left: 10px; border-left: 1px solid #3A3A3A; color: #DADADA; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a {
  text-decoration: none; color: #BDBDBD; font-weight: 500; font-size: 14px;
  padding: 8px 12px; border-radius: 999px;
}
.tabs a:hover { color: var(--white); }
.tabs a[aria-current="page"] { color: var(--black); background: var(--white); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px;
  background: var(--magenta); color: var(--white); font-size: 12px; line-height: 20px; text-align: center; }
.who { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #BDBDBD; flex: none; }
.rule { height: 3px; background: var(--grad); }

main { max-width: 1040px; margin: 0 auto; padding: 44px 16px 96px; }
.view { max-width: 820px; }
#view-library, #view-ask { max-width: 1040px; }

/* ---------- Controls ---------- */
.btn {
  font: 500 15px/1 var(--font); border-radius: 999px; padding: 13px 22px; cursor: pointer;
  border: 1.5px solid var(--text); background: transparent; color: var(--text);
}
.btn:hover { background: var(--surface); }
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary:hover { background: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--magenta) 35%, transparent); }
.btn[disabled] { opacity: .5; cursor: progress; }
.link-btn { font: 500 14px var(--font); background: none; border: 0; color: inherit; cursor: pointer; padding: 6px 2px; text-decoration: underline; text-underline-offset: 3px; }
.link-btn.danger { color: var(--danger); }
.bar .link-btn { color: #BDBDBD; }

label, legend, .field-label { display: block; font-weight: 500; font-size: 14px; margin: 0 0 6px; }
input, select, textarea {
  width: 100%; font: 400 15px/1.4 var(--font); color: var(--text); background: var(--bg);
  border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 11px 13px;
}
textarea { line-height: 1.6; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--magenta) 22%, transparent); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

/* ---------- Source switch ---------- */
.source { display: inline-flex; padding: 4px; gap: 4px; border-radius: 999px; background: var(--surface); margin-bottom: 18px; }
.source button {
  font: 500 14px var(--font); border: 0; background: transparent; color: var(--muted);
  padding: 8px 18px; border-radius: 999px; cursor: pointer;
}
.source button[aria-checked="true"] { background: var(--text); color: var(--bg); }

/* ---------- Drop zone (the one bold element: the brand gradient frame) ---------- */
.drop {
  position: relative; border-radius: var(--r-lg); padding: 2px; cursor: pointer;
  background: var(--grad);
}
.drop-inner {
  border-radius: calc(var(--r-lg) - 2px); background: var(--bg);
  padding: 56px 28px; text-align: center; transition: background-color .2s ease;
}
.drop-title { font-size: 22px; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.01em; }
.drop-hint { color: var(--muted); margin: 0; }
.u { text-decoration: underline; text-underline-offset: 3px; color: var(--text); }
.drop.is-over .drop-inner { background: color-mix(in srgb, var(--bg) 88%, var(--cyan)); }
.drop.is-busy { cursor: progress; }
.drop.is-busy .drop-inner { background: var(--surface); }

.link-row { display: flex; gap: 10px; }
.link-row input { flex: 1; }

.status { margin-top: 18px; padding: 14px 16px; border-radius: var(--r-md); background: var(--surface); font-size: 14px; }
.status.err { background: color-mix(in srgb, var(--danger) 10%, var(--bg)); color: var(--danger); }
.spinner { display: inline-block; width: 14px; height: 14px; margin-right: 10px; vertical-align: -2px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--magenta); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Metadata form ---------- */
.meta { margin-top: 28px; }
.readout { display: flex; gap: 16px; align-items: flex-start; padding: 16px; border: 1.5px solid var(--line); border-radius: var(--r-md); margin-bottom: 24px; }
.readout img { width: 120px; height: 90px; object-fit: cover; border-radius: var(--r-sm); background: var(--surface); flex: none; }
.readout-line { margin: 0 0 4px; font-weight: 500; }
.readout summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.readout-list { margin: 10px 0 0; padding-left: 20px; max-height: 260px; overflow: auto; font-size: 13px; color: var(--muted); }
.readout-list li { margin-bottom: 6px; }
.readout-list b { color: var(--text); font-weight: 500; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
.span-2 { grid-column: span 2; }
.subgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 16px; border-radius: var(--r-md); background: var(--surface); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.hint { font-size: 13px; color: var(--muted); margin: -2px 0 10px; }
.choice input:disabled + span { opacity: .75; cursor: default; }
.choice { display: inline-flex; align-items: center; margin: 0; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice span { padding: 9px 16px; border-radius: 999px; border: 1.5px solid var(--line); font-weight: 500; font-size: 14px; }
.choice input:checked + span { background: var(--text); color: var(--bg); border-color: var(--text); }
.choice input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 26px; }

/* ---------- Review ---------- */
.review { margin-top: 32px; padding: 26px; border-radius: var(--r-lg); background: var(--surface); }
.review-head { margin-bottom: 20px; }
.review-kind { margin: 0 0 4px; font-size: 13px; color: var(--accent-text); font-weight: 500; }
.review-meta { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.review textarea { margin-bottom: 18px; background: var(--bg); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip {
  font: 500 13px var(--font); padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--chip); color: var(--text);
}
.chip[aria-pressed="true"] { background: var(--chip-on); color: var(--chip-on-text); border-color: var(--chip-on); }
.chip.is-new { border-style: dashed; }
.tag-add { max-width: 280px; }
.review .actions { margin-top: 22px; }
#add-another { margin-top: 20px; }
.badge { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }

/* ---------- Drafts ---------- */
.list { display: grid; gap: 14px; }
.list .review { margin-top: 0; }
.empty { padding: 40px 0; color: var(--muted); }

/* ---------- Library ---------- */
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.head-row input { max-width: 300px; margin-bottom: 10px; }
.lib { border-top: 1.5px solid var(--text); }
.lib-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 20px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.lib-row.child { padding-left: 28px; position: relative; }
.lib-row.child::before { content: ""; position: absolute; left: 10px; top: 0; bottom: 50%; width: 10px; border-left: 1.5px solid var(--line); border-bottom: 1.5px solid var(--line); border-bottom-left-radius: 6px; }
.lib-row.retired .lib-title { color: var(--muted); text-decoration: line-through; }
.lib-title { font-weight: 600; }
.lib-meta { font-size: 13px; color: var(--muted); }
.lib-tags { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.lib-tags span { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--surface); color: var(--muted); }
.lib-actions { display: flex; gap: 14px; align-items: flex-start; }

/* ---------- Ask ---------- */
.ask { display: flex; gap: 10px; margin-bottom: 28px; }
.ask input { flex: 1; }
.results { display: grid; gap: 12px; }
.result { padding: 18px 20px; border-radius: var(--r-md); border: 1.5px solid var(--line); }
.result-top { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.result-src { font-weight: 600; }
.result-where { font-size: 13px; color: var(--muted); margin: 2px 0 8px; }
.result-text { margin: 0; white-space: pre-line; font-size: 14px; max-height: 9.6em; overflow: hidden; }
.result.open .result-text { max-height: none; }
.match { font-size: 12px; font-weight: 500; color: var(--accent-text); flex: none; }
.result-text { color: var(--text); }

/* ---------- Sign in ---------- */
.signin { min-height: 100vh; background: var(--black); color: var(--white); display: grid; place-items: center; padding: 24px 16px; }
.signin-panel { width: 100%; max-width: 380px; text-align: center; }
.signin-icon { display: block; margin: 0 auto 18px; }
.signin-word { display: block; margin: 0 auto 6px; height: auto; }
.signin h1 { font-size: 18px; font-weight: 500; color: #BDBDBD; margin: 0 0 36px; letter-spacing: 0; }
.signin form { text-align: left; }
.signin label { color: #DADADA; }
.signin input { background: #111; border-color: #333; color: var(--white); }
.signin .btn-primary { width: 100%; margin-top: 14px; background: var(--white); color: var(--black); border-color: var(--white); }
.signin .note { color: #BDBDBD; margin-top: 14px; min-height: 1.6em; }
.stack > * + * { margin-top: 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; box-shadow: 0 6px 24px rgba(0,0,0,.18); z-index: 10; }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .bar { flex-wrap: wrap; gap: 12px; padding-top: 12px; padding-bottom: 10px; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; }
  .who { margin-left: auto; }
  #who-email { display: none; }
  .brand-word { width: 96px; }
  main { padding-top: 28px; }
  .grid, .subgrid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .drop-inner { padding: 40px 18px; }
  .link-row, .ask { flex-direction: column; }
  .review { padding: 18px; }
  .lib-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Several files at once ---------- */
.batch-row { display: grid; grid-template-columns: 1fr 220px 150px; gap: 10px; align-items: center; margin-bottom: 8px; }
.b-info { font-size: 13px; color: var(--muted); }
.b-info.err-text { color: var(--danger); }
@media (max-width: 760px) { .batch-row { grid-template-columns: 1fr; padding-bottom: 10px; border-bottom: 1px solid var(--line); } }

/* Who can see it: real checkboxes */
.checks { gap: 10px 26px; }
.checks .choice, #share-boxes .choice { gap: 8px; }
.checks .choice input { position: static; opacity: 1; width: 18px; height: 18px; margin: 0; accent-color: var(--text); cursor: pointer; }
.checks .choice span { border: 0; padding: 0; border-radius: 0; background: none !important; color: var(--text) !important; font-size: 15px; }
#share-boxes { display: contents; }
