:root {
  --ink: #0A0A0A;
  --surface: #151517;
  --line: #2A2A2E;
  --text: #F5F3EE;
  --muted: #A9A6A0;
  --yellow: #FFD400;
  --yellow-hi: #FFE45C;
  --danger: #FF8A7A;
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --gutter: 24px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--yellow); }
a:hover { color: var(--yellow-hi); }
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; background: var(--yellow); color: var(--ink); padding: 8px 12px; z-index: 50; }
.skip:focus { top: 8px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.wrap { max-width: 1360px; margin-inline: auto; padding-inline: var(--gutter); }
.narrow { max-width: 920px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border: 1px solid var(--line);
  background: transparent; cursor: pointer; text-decoration: none; color: var(--text);
  font-size: 15px; font-weight: 500;
}
.btn:hover { border-color: var(--muted); color: var(--text); }
.btn-primary { background: var(--yellow); border-color: var(--yellow); color: var(--ink); font-weight: 700; }
.btn-primary:hover { background: var(--yellow-hi); border-color: var(--yellow-hi); color: var(--ink); }
.btn-ghost { color: var(--muted); }
.btn-lg { font-size: 17px; padding: 14px 28px; }
.btn[disabled] { opacity: .5; cursor: progress; }

.chip {
  min-height: 40px; padding: 8px 14px; border: 1px solid var(--line); background: transparent;
  cursor: pointer; font-size: 14px; color: var(--text);
}
.chip[aria-pressed="true"] { background: var(--yellow); border-color: var(--yellow); color: var(--ink); font-weight: 600; }
.chip-fixed { border-color: var(--yellow); color: var(--yellow); cursor: default; }
.pill { min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; }
.pill[aria-pressed="true"] { background: var(--text); color: var(--ink); border-color: var(--text); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* Top bar */
.topbar { border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--ink); z-index: 20; }
.topbar-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; padding-block: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 18px; font-weight: 600; direction: ltr; }
.brand b { color: var(--yellow); font-weight: 700; }
.brand-mark { width: 36px; height: 36px; background: var(--yellow); color: var(--ink); display: grid; place-items: center; font-weight: 700; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.nav a { padding: 9px 14px; border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 14px; }
.nav a[aria-current="page"] { background: var(--yellow); border-color: var(--yellow); color: var(--ink); font-weight: 600; }
.top-search { flex: 1 1 320px; max-width: 560px; display: flex; gap: 8px; }
.top-search input { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); padding: 10px 14px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; color: var(--muted); }
.input, textarea.input {
  width: 100%; background: var(--ink); border: 1px solid var(--line); padding: 12px 14px; font-size: 17px;
}
textarea.input { resize: vertical; min-height: 96px; font-size: 19px; }
.error { color: var(--danger); font-size: 14px; margin: 0; }

/* Home */
.hero { padding-block: 64px 40px; display: flex; flex-direction: column; gap: 28px; }
.hero h1 { margin: 0; font-size: clamp(34px, 5vw, 54px); line-height: 1.15; font-weight: 700; max-width: 18ch; }
.hero p.lead { margin: 0; color: var(--muted); font-size: 17px; max-width: 62ch; }
.panel { background: var(--surface); border: 1px solid var(--line); padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.panel-foot { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 16px; }
.credits { font-size: 13px; color: var(--muted); margin: 0; max-width: 52ch; }
.recent { display: flex; flex-direction: column; gap: 10px; }
.recent a { color: var(--text); text-decoration: none; background: var(--surface); border: 1px solid var(--line); padding: 9px 14px; font-size: 14px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--gutter); }
.login .panel { width: min(420px, 100%); gap: 16px; }
.login h1 { margin: 0; font-size: 26px; }
.login p { margin: 0; color: var(--muted); }
.login .brand { margin-bottom: 8px; }

/* Results */
.results { padding-block: 20px 64px; display: flex; flex-direction: column; gap: 16px; }
.translated { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.translated span.q { border: 1px solid var(--line); padding: 5px 10px; color: var(--text); unicode-bidi: plaintext; }
.notice { border: 1px solid var(--yellow); color: var(--text); padding: 12px 14px; font-size: 14px; margin: 0; }
.layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.layout > .main-col { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.layout > aside { flex: 1 1 300px; max-width: 100%; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; }
.tab { min-height: 44px; padding: 10px 18px; background: transparent; border: 0; border-bottom: 3px solid transparent; color: var(--muted); cursor: pointer; font-size: 15px; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--yellow); font-weight: 700; }
.toolbar .chips { padding-bottom: 8px; gap: 6px; }
.status { color: var(--muted); padding-block: 32px; margin: 0; }

.masonry { column-width: 220px; column-gap: 14px; }
.card { break-inside: avoid; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--line); position: relative; }
.card-img { display: block; background: #1E1E21; min-height: 120px; }
.card-img img { width: 100%; height: auto; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; }
.card-meta .who { display: flex; flex-direction: column; min-width: 0; }
.card-meta .src { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta .sub { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.save-btn { min-height: 36px; padding: 6px 10px; font-size: 12px; white-space: nowrap; }
.save-btn.saved { background: var(--yellow); border-color: var(--yellow); color: var(--ink); font-weight: 600; }
.card.as-link .card-img { display: none; }
.card .fallback { display: none; padding: 16px 12px 0; }
.card.as-link .fallback { display: block; }
.fallback a { color: var(--text); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }

.links { display: flex; flex-direction: column; gap: 10px; }
.link-row { background: var(--surface); border: 1px solid var(--line); padding: 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.link-row .body { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.link-row .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.link-row .meta b { color: var(--yellow); font-weight: 600; }
.link-row a.title { color: var(--text); font-weight: 600; font-size: 16px; text-decoration: none; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.link-row .snippet { color: var(--muted); font-size: 14px; margin: 0; unicode-bidi: plaintext; }

.mindset { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--yellow); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.mindset h2 { margin: 0; font-size: 20px; }
.angle { border-top: 1px solid var(--line); padding-top: 12px; }
.angle h3 { margin: 0 0 4px; font-size: 15px; }
.angle p { margin: 0; color: var(--muted); font-size: 14px; }
.mindset .btn { color: var(--yellow); border-color: var(--yellow); }

/* Board picker */
.picker {
  position: absolute; inset-inline: 8px; bottom: 52px; z-index: 10; background: var(--ink); border: 1px solid var(--yellow);
  padding: 12px; display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto;
}
.picker .head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.picker button.board-opt { text-align: start; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.picker button.board-opt:hover { border-color: var(--yellow); }
.picker form { display: flex; gap: 6px; }
.picker form input { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); padding: 8px 10px; font-size: 14px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; background: transparent; border: 0; color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); }

/* Boards */
.page { padding-block: 40px 64px; display: flex; flex-direction: column; gap: 28px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head h1 { margin: 0; font-size: 34px; line-height: 1.2; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.board-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.board-card:hover { border-color: var(--yellow); color: var(--text); }
.board-thumbs { display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; gap: 2px; height: 180px; background: var(--line); }
.board-thumbs > div { background: #1E1E21 center / cover no-repeat; }
.board-thumbs > div:first-child { grid-row: span 2; }
.board-card .info { padding: 14px 16px; display: flex; flex-direction: column; }
.board-card .info strong { font-size: 16px; }
.board-card .info span { font-size: 13px; color: var(--muted); }
.new-board { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; background: var(--surface); border: 1px solid var(--line); padding: 16px; }
.new-board .field { flex: 1 1 240px; }
.empty { border: 1px dashed var(--line); padding: 32px; color: var(--muted); margin: 0; }
.back { text-decoration: none; font-size: 14px; }

.toast { position: fixed; inset-inline: 16px; bottom: 16px; margin-inline: auto; max-width: 420px; background: var(--text); color: var(--ink); padding: 12px 16px; font-weight: 600; z-index: 40; }

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .hero { padding-block: 36px 28px; }
  .masonry { column-width: 150px; column-gap: 10px; }
  .top-search { order: 3; flex-basis: 100%; max-width: none; }
  .layout > aside { order: -1; }
}
.notices { display: flex; flex-direction: column; gap: 8px; }
.notices:empty { display: none; }
.status.tight { padding: 0; }
.opts { display: flex; flex-direction: column; gap: 6px; }
