/* PinLead HQ — dark navy theme modelled on Marketing Secrets */
:root {
  --bg: #0a1224; --bg2: #0d1730; --panel: #111d38; --panel2: #16244a; --line: #22335c;
  --text: #e8edf7; --muted: #93a0bd; --faint: #6b7896;
  --accent: #2f6bff; --accent2: #5b8cff; --good: #22c55e; --warn: #f59e0b; --bad: #ef4444;
  --radius: 14px; --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
html.light {
  --bg: #f4f6fb; --bg2: #ffffff; --panel: #ffffff; --panel2: #eef2fb; --line: #dde3f0;
  --text: #16203a; --muted: #56627e; --faint: #8a94ab; --shadow: 0 1px 2px rgba(20,30,60,.06), 0 6px 18px rgba(20,30,60,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent2); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 272px 1fr; height: 100vh; }
.sidebar { background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; gap: 6px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .02em; font-size: 18px; padding: 4px 8px 16px; }
.brand .dot { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #8b5cf6); display: grid; place-items: center; font-size: 16px; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; border: 1px solid transparent; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.active { background: var(--panel2); color: var(--text); border-color: var(--line); }
.nav .ico { width: 22px; text-align: center; font-size: 17px; }
.side-sep { height: 1px; background: var(--line); margin: 12px 4px; }
.side-label { font-weight: 700; font-size: 14px; padding: 2px 8px 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); padding: 9px 14px; border-radius: 10px; font-weight: 600; }
.btn:hover { border-color: var(--accent2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2458e0; }
.btn.big { padding: 12px 16px; font-size: 15px; width: 100%; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.chatlist { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.chatlist a { padding: 7px 10px; border-radius: 8px; color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatlist a:hover, .chatlist a.active { background: var(--panel); color: var(--text); }
.side-foot { margin-top: auto; padding-top: 12px; font-size: 12px; color: var(--faint); display: flex; justify-content: space-between; align-items: center; }

.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--bg); position: relative; }
.search { flex: 1; max-width: 560px; margin: 0 auto; position: relative; }
.search input { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 10px 40px; outline: none; }
.search input:focus { border-color: var(--accent); }
.search .sico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.results { position: absolute; top: 46px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 420px; overflow-y: auto; z-index: 50; padding: 6px; }
.results a { display: flex; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.results a:hover { background: var(--panel2); }
.results .kind { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; margin-left: auto; }
.iconbtn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; }
.menu-toggle { display: none; }
.content { flex: 1; overflow-y: auto; padding: 28px 32px 60px; }
.page { max-width: 1180px; margin: 0 auto; }

/* ---------- typography & blocks ---------- */
h1.page-title { font-size: 26px; font-weight: 800; letter-spacing: .01em; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 24px; }
.section-title { font-size: 13px; font-weight: 800; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; margin: 32px 0 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); color: var(--text); transition: border-color .15s, transform .15s; min-height: 0; }
a.card:hover, button.card:hover { border-color: var(--accent2); transform: translateY(-1px); }
button.card { text-align: left; }
.card .emoji { font-size: 26px; width: 48px; height: 48px; border-radius: 12px; background: var(--panel2); display: grid; place-items: center; }
.card h3 { margin: 4px 0 0; font-size: 16px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.tag.live { color: var(--good); } .tag.dev { color: var(--warn); } .tag.paused, .tag.unknown { color: var(--faint); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.chip { padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-weight: 600; font-size: 13.5px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.conversation-notice, .conversation-action, .conversation-thread { margin: 18px 0; }
.conversation-page .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.conversation-text { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; max-height: 480px; overflow-y: auto; }
.conversation-page label { display: block; margin: 12px 0 6px; }
.conversation-page textarea { width: 100%; min-height: 100px; resize: vertical; padding: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.conversation-page input { max-width: 100%; padding: 9px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.conversation-page button:disabled { opacity: .55; cursor: not-allowed; }
.conversation-page [role=status] { display: block; margin-top: 8px; }
.conversation-holds { padding-left: 22px; color: var(--warn); }
.conversation-page { overflow-wrap: anywhere; }
@media (max-width: 760px) { .conversation-page .grid.two { grid-template-columns: minmax(0, 1fr); } }
.input { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
.input:focus { border-color: var(--accent); }
label.lbl { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 12px 0 6px; }

/* hero / dashboard */
.hero { background: linear-gradient(135deg, rgba(47,107,255,.18), rgba(139,92,246,.12)); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.hero h2 { margin: 0 0 6px; font-size: 22px; }
.hero p { margin: 0; color: var(--muted); }
.steps { display: flex; flex-direction: column; gap: 8px; }
.step { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); }
.step .num { width: 26px; height: 26px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; font-size: 13px; font-weight: 800; color: var(--accent2); flex: none; }
.step.done .num { background: var(--good); color: #fff; }
.step:hover { border-color: var(--accent2); }

/* training panel (MS pattern) */
.training { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 22px; overflow: hidden; }
.training-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.training-head b { font-size: 15px; }
.training-body { padding: 18px; display: grid; grid-template-columns: 1fr 320px; gap: 18px; }
.training.hidden .training-body { display: none; }
.training.hidden .training-head { border-bottom: 0; }
.lesson { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); margin-bottom: 8px; }
.lesson .n { color: var(--accent2); font-weight: 800; }
.tool-hero { display: flex; gap: 18px; align-items: center; margin-bottom: 18px; }
.tool-hero .emoji { font-size: 34px; width: 68px; height: 68px; border-radius: 16px; background: var(--panel2); display: grid; place-items: center; }
.highlight { background: rgba(47,107,255,.2); color: var(--text); padding: 0 8px; border-radius: 6px; }

/* markdown */
.md { line-height: 1.65; }
.md h1 { font-size: 24px; } .md h2 { font-size: 19px; margin-top: 26px; } .md h3 { font-size: 16px; }
.md table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 14px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--panel2); }
.md code { background: var(--panel2); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.md pre { background: var(--bg2); border: 1px solid var(--line); padding: 12px; border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--accent); margin: 10px 0; padding: 2px 14px; color: var(--muted); }

/* chat */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 65px); margin: -28px -32px -60px; }
.chat-setup { padding: 14px 32px; border-bottom: 1px solid var(--line); background: var(--bg); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.chat-setup select { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.skill-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: rgba(47,107,255,.18); border: 1px solid var(--accent); font-size: 13px; font-weight: 600; }
.skill-pill button { background: none; border: 0; color: var(--muted); padding: 0; font-size: 15px; line-height: 1; }
.messages { flex: 1; overflow-y: auto; padding: 24px 32px; }
.messages-inner { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; flex-direction: column; gap: 6px; }
.msg.user { align-items: flex-end; }
.msg.user .bubble { background: var(--accent); color: #fff; border-radius: 16px 16px 4px 16px; padding: 10px 14px; max-width: 80%; white-space: pre-wrap; }
.msg.assistant .bubble { background: var(--panel); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 14px 18px; max-width: 100%; }
.msg-actions { display: flex; gap: 8px; }
.composer { border-top: 1px solid var(--line); padding: 14px 32px 18px; background: var(--bg); }
.composer-inner { max-width: 860px; margin: 0 auto; display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 52px; max-height: 240px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; outline: none; }
.composer textarea:focus { border-color: var(--accent); }
.typing { color: var(--muted); font-size: 13px; }
.modal-back { position: fixed; inset: 0; background: rgba(3,8,20,.6); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; width: min(640px, 100%); max-height: 85vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-body { padding: 14px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.pick { display: flex; gap: 12px; padding: 10px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; }
.pick:hover { background: var(--panel2); }
.pick.on { border-color: var(--accent); background: rgba(47,107,255,.12); }
.pick input { margin-top: 4px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--good); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 700; z-index: 200; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, rgba(47,107,255,.25), transparent), var(--bg); }
.login .panel { width: min(400px, 100%); padding: 32px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 80; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-toggle { display: grid; }
  .content { padding: 20px 16px 60px; }
  .training-body { grid-template-columns: 1fr; }
  .grid.two { grid-template-columns: 1fr; }
  .chat-wrap { margin: -20px -16px -60px; }
  .chat-setup, .messages, .composer { padding-left: 16px; padding-right: 16px; }
}

/* Library reader */
.lib-reader { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
.lib-toc { position: sticky; top: 12px; max-height: calc(100vh - 140px); overflow: auto; display: flex; flex-direction: column; gap: 2px; padding: 10px; }
.lib-toc a { padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: 13.5px; line-height: 1.35; text-decoration: none; }
.lib-toc a:hover { background: var(--panel2); }
.lib-toc a.active { background: var(--panel2); border-left: 3px solid var(--accent2); }
.lib-body { margin-top: 14px; font-size: 15.5px; line-height: 1.7; max-width: 75ch; }
.lib-body p { margin: 0 0 12px; }
@media (max-width: 860px) { .lib-reader { grid-template-columns: 1fr; } .lib-toc { position: static; max-height: 240px; } }

/* Studio (Higgsfield) */
.studio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-top: 14px; }
.studio-tile { position: relative; aspect-ratio: 9 / 16; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--panel2); padding: 0; cursor: pointer; transition: transform .15s, border-color .15s; }
.studio-tile:hover { transform: translateY(-2px); border-color: var(--accent2); }
.studio-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.studio-play { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 46px; height: 46px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; font-size: 18px; }
.studio-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 10px 8px; font-size: 12px; color: #fff; text-align: left; background: linear-gradient(transparent, rgba(0,0,0,.8)); }
.studio-audio { height: 100%; display: grid; place-items: center; font-size: 48px; }
.btn.small { padding: 6px 10px; font-size: 13px; }

/* Funnels */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 28px; line-height: 1.1; }
.stat span { color: var(--muted); font-weight: 600; font-size: 13.5px; }
.stat em { font-style: normal; color: var(--accent2); font-size: 12.5px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 700; font-size: 12.5px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); }
.finput { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.tag.fstatus.live { background: rgba(34,197,94,.15); color: #22c55e; }
.tag.fstatus.draft { background: rgba(250,204,21,.15); color: #eab308; }
.tag.fstatus.paused { background: rgba(148,163,184,.18); color: #94a3b8; }
.todo-hq { background: rgba(250,204,21,.12); border: 1px solid rgba(250,204,21,.4); border-radius: 10px; padding: 8px 10px; font-size: 13px; margin: 12px 0 0; }
.research { font-size: 12.5px; color: var(--muted); border-left: 3px solid var(--accent2); padding: 4px 10px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 2px; }
.model-hint { font-size: 12.5px; color: var(--muted); padding: 6px 24px 0; }
.research .beat { opacity: .8; font-style: italic; }
