/* custompc.ai shared styles. One palette expressed as custom properties; dark follows the OS
   unless [data-theme] overrides it (set before first paint by the inline script in each head). */
:root {
  --bg: #f7f7f5;
  --bg-2: #ffffff;
  --bg-3: #ecece8;
  --fg: #1c1c1a;
  --fg-2: #44443f;
  --fg-3: #6b6b64;
  --line: #d9d9d3;
  --accent: #2b6cb0;
  --accent-fg: #ffffff;
  --good: #2f855a;
  --warn: #b7791f;
  --bad: #c53030;
  --radius: 10px;
  --max: 1080px;
  --sidebar: 260px;
  /* Heading face matches the wordmark (Candara). Local fonts only: Candara's licence forbids
     web embedding. Optima is the macOS/iOS stand-in; elsewhere headings fall back to the body face. */
  --font-head: Candara, Optima, "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131315; --bg-2: #1c1c1f; --bg-3: #26262a; --fg: #ececea; --fg-2: #c4c4bf; --fg-3: #9c9c95;
    --line: #34343a; --accent: #6aa5e6; --accent-fg: #0f1a26; --good: #68d391; --warn: #f6c453; --bad: #fc8181;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131315; --bg-2: #1c1c1f; --bg-3: #26262a; --fg: #ececea; --fg-2: #c4c4bf; --fg-3: #9c9c95;
  --line: #34343a; --accent: #6aa5e6; --accent-fg: #0f1a26; --good: #68d391; --warn: #f6c453; --bad: #fc8181;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.25; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .92em; }
pre { background: var(--bg-3); padding: .75rem 1rem; border-radius: var(--radius); overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--fg-2); font-weight: 600; font-size: .85rem; }
button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--bg-2); color: var(--fg);
  padding: .5rem .9rem; border-radius: var(--radius);
}
button:hover, .btn:hover { background: var(--bg-3); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--fg); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .55rem .75rem; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.muted { color: var(--fg-2); } .small { font-size: .85rem; } .right { text-align: right; }
.hidden, [hidden] { display: none !important; }
input[type="radio"], input[type="checkbox"] { width: auto; padding: 0; border: 0; margin: 0; }

/* Header / nav */
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; border-bottom: 1px solid var(--line);
  background: var(--bg-2); position: sticky; top: 0; z-index: 20;
}
.topbar .brand { display: inline-flex; align-items: center; color: var(--fg); line-height: 1; }
.topbar .brand:hover { text-decoration: none; color: var(--fg-2); }
/* Wordmark: /img/wordmark.svg is a single unfilled path; painting it as a mask lets it take
   currentColor, so it follows the theme. Aspect ratio comes from the SVG viewBox (infra/make_wordmark.py). */
.topbar .wordmark {
  display: block; height: 18px; aspect-ratio: 513.23 / 70.26; background: currentColor;
  -webkit-mask: url(/img/wordmark.svg) no-repeat center / contain; mask: url(/img/wordmark.svg) no-repeat center / contain;
}
.topbar nav { display: flex; gap: .2rem; flex-wrap: wrap; }
.topbar nav a { color: var(--fg-2); padding: .35rem .6rem; border-radius: var(--radius); }
.topbar nav a:hover, .topbar nav a.active { background: var(--bg-3); color: var(--fg); text-decoration: none; }
.topbar .spacer { flex: 1; }
.iconbtn.round { width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 50%; color: var(--fg-2); position: relative; }
.iconbtn.round:hover { background: var(--bg-3); color: var(--fg); text-decoration: none; }
.topbar .account .dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg-2); }
.topbar #menu-btn { display: none; }
.backdrop { position: fixed; inset: 0; z-index: 24; background: rgba(0, 0, 0, .4); }

/* Page shells */
.page { width: 100%; max-width: var(--max); margin: 0 auto; padding: 1.5rem 1rem 3rem; flex: 1; }
.page.narrow { max-width: 760px; }
.band { background: var(--bg-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 1.25rem 1rem; margin: 1.25rem -1rem; }
footer.site { border-top: 1px solid var(--line); color: var(--fg-3); font-size: .8rem; padding: 1rem; text-align: center; }
footer.site a { color: var(--fg-2); margin: 0 .4rem; }

/* Chat layout */
.chat-shell { display: grid; grid-template-columns: var(--sidebar) 1fr; gap: 0; flex: 1; min-height: 0; }
/* Sidebar: pinned to the viewport under the 52px top bar. Only #past (the chat list) scrolls;
   the New build button and the foot (Builder, More, collapse) stay put however many chats exist. */
.sidebar { display: flex; flex-direction: column; position: sticky; top: 52px; height: calc(100vh - 52px); align-self: start; border-right: 1px solid var(--line); background: var(--bg-2); padding: 1rem .75rem; overflow: hidden; }
.sidebar #new-build { display: flex; align-items: center; justify-content: center; gap: .4rem; width: 100%; flex: none; }
.sidebar #past { flex: 1; min-height: 0; overflow-y: auto; margin-top: .5rem; }
.sidebar .side-foot { flex: none; margin-top: .5rem; border-top: 1px solid var(--line); padding-top: .5rem; }
.sidebar .item.nav { display: flex; align-items: center; gap: .5rem; }
.sidebar .side-tools { display: flex; align-items: center; margin-top: .4rem; }
.sidebar .side-tools .spacer { flex: 1; }
.sidebar .side-tools .iconbtn.round { width: 34px; height: 34px; }
.sidebar .side-tools .iconbtn.round svg { transition: transform .15s; }
.sidebar h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-3); margin: .5rem .4rem; }
.sidebar .item { display: block; padding: .45rem .5rem; border-radius: var(--radius); color: var(--fg); font-size: .9rem; }
.sidebar .item:hover, .sidebar .item.active { background: var(--bg-3); text-decoration: none; }
.sidebar .row { display: flex; align-items: center; border-radius: var(--radius); }
.sidebar .row .item { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .row:hover, .sidebar .row.active { background: var(--bg-3); }
.sidebar .row:hover .item, .sidebar .row.active .item { background: none; }
.sidebar .row .iconbtn { opacity: 0; }
.sidebar .row:hover .iconbtn, .sidebar .row.active .iconbtn, .sidebar .row .iconbtn:focus-visible { opacity: 1; }
.sidebar .pin { color: var(--fg-3); margin-right: .3rem; vertical-align: -1px; }
.sidebar details { margin: .1rem 0; }
.sidebar summary { display: flex; align-items: center; gap: .3rem; padding: .35rem .5rem; border-radius: var(--radius); font-size: .9rem; cursor: pointer; list-style: none; }
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary:hover { background: var(--bg-3); }
.sidebar summary .fname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar summary .caret { display: inline-block; width: .9rem; color: var(--fg-3); transition: transform .15s; }
.sidebar details[open] > summary .caret { transform: rotate(90deg); }
.sidebar summary .iconbtn { opacity: 0; }
.sidebar summary:hover .iconbtn, .sidebar summary .iconbtn:focus-visible { opacity: 1; }
.sidebar details .row { padding-left: 1rem; }
.sidebar .empty { display: block; padding: .2rem .5rem .3rem 1.5rem; }
.sidebar .more-links { margin: 0; }
.sidebar .more-links summary { color: var(--fg-3); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.sidebar .more-links .item { padding: .3rem .5rem .3rem 1.4rem; font-size: .85rem; color: var(--fg-2); }
.sidebar .more-links p { padding: .3rem .5rem 0 1.4rem; font-size: .75rem; margin: 0; }
body.chat footer.site { display: none; }
/* Collapsed sidebar (desktop only): icon column, New build on top, mirrored collapse icon at the
   bottom. The drawer on small screens ignores the state. */
@media (min-width: 721px) {
  html.side-collapsed .chat-shell { --sidebar: 60px; }
  html.side-collapsed .sidebar { padding: 1rem .5rem; align-items: center; }
  html.side-collapsed .sidebar .label, html.side-collapsed .sidebar #past, html.side-collapsed .sidebar #side-more { display: none; }
  html.side-collapsed .sidebar #new-build, html.side-collapsed .sidebar .item.nav { width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 50%; }
  html.side-collapsed .sidebar .side-foot { width: 100%; display: flex; flex-direction: column; align-items: center; gap: .3rem; }
  html.side-collapsed .sidebar .side-tools { margin-top: 0; }
  html.side-collapsed .sidebar .side-tools .spacer { display: none; }
  html.side-collapsed .sidebar .side-tools .iconbtn.round svg { transform: scaleX(-1); }
}
.iconbtn { border: 0; background: none; padding: .2rem .5rem; line-height: 1; font-size: 1.1rem; color: var(--fg-2); border-radius: 6px; }
.iconbtn:hover { background: var(--bg-3); color: var(--fg); }
.chat-main { display: flex; flex-direction: column; min-height: calc(100vh - 52px); }
.chat-head { display: flex; align-items: center; gap: .4rem; padding: .45rem 1rem; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 52px; z-index: 10; }
.chat-head .title { font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .spacer { flex: 1; }
.chat-head > button:not(.iconbtn) { padding: .3rem .7rem; font-size: .88rem; }

/* Popover menu (chat and folder options) */
.menu { position: absolute; z-index: 40; min-width: 12.5rem; padding: .3rem; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0, 0, 0, .12); }
.menu button { display: flex; width: 100%; align-items: center; gap: .5rem; text-align: left; border: 0; background: none; padding: .45rem .6rem; border-radius: 6px; font-size: .92rem; }
.menu button:hover { background: var(--bg-3); }
.menu button .grow { flex: 1; }
.menu button .hint { color: var(--fg-3); font-size: .8rem; }
.menu button.danger { color: var(--bad); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: .3rem 0; }

/* Dialogs (share, rename, confirm) */
dialog.cupc { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); color: var(--fg); padding: 1.1rem 1.25rem; width: calc(100% - 2rem); max-width: 460px; }
dialog.cupc::backdrop { background: rgba(0, 0, 0, .35); }
dialog.cupc h3 { margin-bottom: .6rem; }
dialog.cupc .actions { display: flex; gap: .5rem; align-items: center; margin-top: .9rem; }
dialog.cupc .actions .spacer { flex: 1; }
.share-opt { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius); margin: .4rem 0; cursor: pointer; }
.share-opt input { margin-top: .3rem; flex: none; }
.share-opt .small { display: block; }
.share-make { width: 100%; margin-top: .7rem; }
.share-link { display: flex; gap: .4rem; margin-top: .7rem; }
.share-link input { flex: 1; font-size: .85rem; }
.messages { flex: 1; overflow-y: auto; padding: 1.5rem 1rem; width: 100%; max-width: 860px; margin: 0 auto; }
.msg { margin: 0 0 1.25rem; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { background: var(--bg-3); border-radius: 18px 18px 4px 18px; padding: .6rem .9rem; max-width: 80%; }
.msg.bot .bubble { max-width: 100%; }
.msg .bubble p:last-child { margin-bottom: 0; }
/* Composer: a floating pill. In an open chat it sticks to the bottom over a fade; on the empty
   home page (.hero still in .messages) it sits directly under the guide, and the hero + pill
   block is centred vertically, so the box is where the eye lands before any chat exists. */
.composer { position: sticky; bottom: 0; z-index: 5; padding: .5rem 1rem 1rem; background: linear-gradient(to bottom, transparent, var(--bg) 35%); }
.composer .inner {
  max-width: 860px; margin: 0 auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 28px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .08); padding: .45rem .45rem .45rem 1.1rem; transition: border-color .15s, box-shadow .15s;
}
.composer .inner:focus-within { border-color: var(--accent); box-shadow: 0 6px 24px rgba(0, 0, 0, .1), 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.composer form { display: flex; gap: .5rem; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 160px; border: 0; background: none; padding: .6rem 0; border-radius: 0; resize: none; }
.composer textarea:focus { outline: none; }
.composer form .primary { border-radius: 999px; padding: .6rem 1.1rem; }
.composer .note { margin: .5rem auto 0; max-width: 860px; font-size: .78rem; text-align: center; }
.chat-main:has(.hero) { justify-content: center; }
.messages:has(.hero) { flex: 0 0 auto; display: flex; flex-direction: column; padding-bottom: 0; }
.chat-main:has(.hero) .composer { position: static; padding-top: 0; background: none; }
.chat-main:has(.hero) .composer .inner, .chat-main:has(.hero) .composer .note { max-width: 640px; }
.hero { text-align: center; margin: 0 auto .75rem; max-width: 640px; width: 100%; }
.hero h1 { font-size: 1.8rem; margin-bottom: .3rem; }
.hero > p { margin-bottom: .5rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }
.chip { border: 1px solid var(--line); background: var(--bg-2); border-radius: 999px; padding: .35rem .8rem; font-size: .88rem; cursor: pointer; color: var(--fg); }
.chip:hover { background: var(--bg-3); }
.chip.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.thinking { display: flex; align-items: center; gap: .55rem; color: var(--fg-2); }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-3); animation: pulse 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .3; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }

/* Home-page guide (inside .hero) */
.guide { margin-top: 1.25rem; }
.guide h2 { font-size: 1rem; font-weight: 500; margin-bottom: .4rem; color: var(--fg-2); }
.guide p { margin-bottom: .5rem; }
.guide .chips { justify-content: center; }
.guide .group { margin: .5rem 0 .9rem; }
.guide .glabel { display: block; font-size: .78rem; color: var(--fg-3); text-transform: uppercase; letter-spacing: .04em; }
.guide .amt { width: 9.5rem; border-radius: 999px; padding: .35rem .8rem; font-size: .88rem; }
.guide #g-reuse { max-width: 420px; }
.guide .results { text-align: left; max-height: 220px; overflow: auto; padding: .3rem .6rem; }
.guide .results div { padding: .15rem 0; }
.guide-foot { margin-top: .75rem; }
.more { position: relative; display: inline-block; }
.chip-menu { position: absolute; top: calc(100% + .35rem); left: 0; z-index: 15; display: flex; flex-direction: column; align-items: stretch; gap: .3rem; min-width: 13rem; padding: .4rem; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0, 0, 0, .12); }
.chip-menu.flip { left: auto; right: 0; }
.chip-menu .chip { text-align: left; }

/* Build card */
.build { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); margin: 1rem 0; overflow: hidden; }
.build .head { display: flex; justify-content: space-between; align-items: baseline; padding: .75rem 1rem; border-bottom: 1px solid var(--line); gap: 1rem; flex-wrap: wrap; }
.build .head > div > strong { font-family: var(--font-head); font-size: 1.15rem; }
.build .head .total { font-size: 1.25rem; font-weight: 600; }
.build table td.slot { color: var(--fg-2); width: 6.5rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.build table td.price { text-align: right; white-space: nowrap; }
.build table td .links a { margin-right: .5rem; font-size: .85rem; }
.build table td .spec { color: var(--fg-3); font-size: .82rem; }
.build .foot { padding: .6rem 1rem; color: var(--fg-2); font-size: .85rem; border-top: 1px solid var(--line); }
.tag { display: inline-block; font-size: .72rem; padding: .05rem .45rem; border-radius: 999px; border: 1px solid var(--line); color: var(--fg-2); margin-left: .35rem; vertical-align: middle; }
.tag.reused { border-color: var(--good); color: var(--good); }
.tag.est { border-color: var(--warn); color: var(--warn); }
.issues li { margin: .25rem 0; }
.issues .blocker { color: var(--bad); } .issues .warning { color: var(--warn); }

/* Pipeline */
.pipeline { margin: 1rem 0; }
.pipeline .pipe-head { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin-bottom: .4rem; }
.pipeline .caption { margin: .4rem 0 0; font-size: .92rem; }
.pipeline .tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .5rem; }
.pipeline .tabs button { padding: .25rem .6rem; font-size: .82rem; border-radius: 999px; }
.pipeline .tabs button.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.pipeline svg { width: 100%; height: auto; display: block; }
.pipeline .legend { font-size: .82rem; color: var(--fg-2); margin-top: .35rem; }

/* Builder */
.builder { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.builder .slots .row { display: grid; grid-template-columns: 6rem 1fr auto; gap: .5rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.builder .slots .row .name { font-size: .92rem; }
.builder .filters { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .75rem; }
.builder .results .r { display: grid; grid-template-columns: 1fr auto auto; gap: .5rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
@media (max-width: 900px) { .builder { grid-template-columns: 1fr; } }

/* Pricing */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.plan { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); padding: 1.1rem; }
.plan .price { font-size: 1.6rem; font-weight: 600; }
.plan ul { padding-left: 1.1rem; margin: .75rem 0; }

/* Cards */
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); padding: 1rem 1.1rem; margin: 1rem 0; }
.notice { border-left: 0; background: var(--bg-3); border-radius: var(--radius); padding: .6rem .9rem; font-size: .9rem; }
.form-row { display: grid; grid-template-columns: 10rem 1fr; gap: .75rem; align-items: center; margin: .6rem 0; }
@media (max-width: 720px) {
  .topbar { padding: .5rem .75rem; gap: .5rem; }
  .topbar #menu-btn { display: inline-flex; }
  .topbar nav { display: none; }
  .topbar .brand { flex: 1; justify-content: center; }
  .topbar .spacer { display: none; }
  .chat-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: fixed; top: 0; bottom: 0; left: 0; height: auto; width: min(84vw, 320px); z-index: 25; box-shadow: 0 0 30px rgba(0, 0, 0, .3); }
  .sidebar .side-tools { display: none; }
  .chat-head { top: 57px; }
  .chat-main { min-height: calc(100vh - 57px); }
  .composer .note { display: none; }
  .hero h1 { font-size: 1.5rem; }
  .guide .chips { gap: .4rem; }
  .chip { padding: .3rem .7rem; font-size: .85rem; }
  .form-row { grid-template-columns: 1fr; }
}
