/* ==========================================================
   Web Group shared stylesheet - mobile first.
   Tool sites: 70/30 two columns on desktop, tool first on mobile.
   Essay sites: single centred column, 720px measure.
   ========================================================== */

:root {
    --brand: #1d4ed8;
    --brand-dark: #1e40af;
    --brand-soft: #e8f0ff;
    --accent: #059669;
    --ink: #111827;
    --ink-soft: #4b5563;
    --line: #e5e7eb;
    --bg: #ffffff;
    --bg-soft: #f7f8fa;
    --page-bg: linear-gradient(180deg, #f3f6fc 0%, #eef2f9 100%);
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
    --measure: 760px;
    --wrap: 1180px;
}

/* ---------- colour themes: sites.theme -> body.theme-<name> (addWebsite --theme / blueprint "theme") ----------
   Same layout on every site, different background + brand colour so the network does not look cloned. */
body.theme-green  { --brand: #2f9e63; --brand-dark: #1f6b43; --brand-soft: #dff0e4; --page-bg: linear-gradient(180deg, #eef7f0 0%, #e2f0e5 100%); --bg-soft: #f2f8f4; }
body.theme-paper  { --brand: #8a5a2b; --brand-dark: #6b4320; --brand-soft: #f3e7d8; --page-bg: linear-gradient(180deg, #f8f3ea 0%, #efe7db 100%); --bg-soft: #f7f2ea; --line: #e6ddd0; }
body.theme-violet { --brand: #6d28d9; --brand-dark: #5b21b6; --brand-soft: #ede9fe; --page-bg: linear-gradient(180deg, #f6f3ff 0%, #ede8fb 100%); --bg-soft: #f6f4fc; }
body.theme-amber  { --brand: #b45309; --brand-dark: #92400e; --brand-soft: #fdebd0; --page-bg: linear-gradient(180deg, #fff8ec 0%, #fbefd9 100%); --bg-soft: #fcf7ee; --line: #ecdfc9; }
body.theme-rose   { --brand: #be123c; --brand-dark: #9f1239; --brand-soft: #ffe4e9; --page-bg: linear-gradient(180deg, #fff1f4 0%, #fbe4ea 100%); --bg-soft: #fdf4f6; }
body.theme-slate  { --brand: #334155; --brand-dark: #1e293b; --brand-soft: #e2e8f0; --page-bg: linear-gradient(180deg, #f4f6f9 0%, #e9edf2 100%); --bg-soft: #f3f5f8; --accent: #0f766e; }
body.theme-teal   { --brand: #0f766e; --brand-dark: #115e59; --brand-soft: #d8f0ec; --page-bg: linear-gradient(180deg, #effaf8 0%, #e0f2ef 100%); --bg-soft: #f0f8f6; }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}
/* home pages carry the themed gradient; content pages stay plain for reading */
body.home-chat, body.home-tools { background: var(--page-bg); }
body.has-bottombar { padding-bottom: 72px; }

img { max-width: 100%; height: auto; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.9rem; line-height: 1.25; margin: 0 0 .6rem; }
h2 { font-size: 1.4rem; line-height: 1.3; margin: 2rem 0 .7rem; }
h3 { font-size: 1.12rem; margin: 1.4rem 0 .5rem; }
p { margin: 0 0 1rem; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
.muted { color: var(--ink-soft); }
.hint { font-size: .85rem; color: var(--ink-soft); margin: .4rem 0 0; }
.lede { font-size: 1.05rem; color: var(--ink-soft); }
.section { margin: 2.5rem auto; }

/* ---------- topbar (aivita.chat layout, identical on every site) ---------- */
.topbar { position: sticky; top: 0; z-index: 40; background: rgba(255, 255, 255, .94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding-top: 8px; padding-bottom: 8px; }

.brand-lockup { display: flex; align-items: center; gap: 11px; min-width: 0; color: var(--ink); }
.brand-lockup:hover { text-decoration: none; }
.brand-text { min-width: 0; }
.brand-text strong { display: block; font-size: 15px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.brand-text em { display: block; font-style: normal; font-size: 12px; color: var(--brand); margin-top: 2px; white-space: nowrap; }
.avatar-orb {
    width: 42px; height: 42px; border-radius: 12px; flex: none; display: grid; place-items: center;
    background: linear-gradient(145deg, var(--brand), var(--brand-dark)); color: #fff; font-weight: 700; font-size: 19px;
    background-size: cover; background-position: center; border: 1px solid rgba(0, 0, 0, .08);
}

.desktop-nav { display: none; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.nav-link { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 7px 12px; font-size: 12.5px; white-space: nowrap; }
.nav-link:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.nav-button {
    display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink);
    border-radius: 8px; padding: 7px 12px; font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap;
    transition: border-color .15s, color .15s, background .15s;
}
.nav-button:hover { border-color: var(--brand); color: var(--brand); }
.nav-lang svg { color: var(--brand); }
.nav-button-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.nav-button-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }

.signin { display: flex; align-items: center; min-height: 32px; }
.signin[hidden] { display: none; }
.signin-problem { font-size: 12px; color: #b91c1c; max-width: 220px; line-height: 1.3; }

.account-menu { position: relative; }
.account-menu[hidden] { display: none; }
.account-credits { font-weight: 600; }
.account-credits::after { content: " cr"; font-weight: 400; color: var(--ink-soft); }
.account-dropdown {
    position: absolute; right: 0; top: calc(100% + 6px); display: none; flex-direction: column; min-width: 180px;
    background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px; gap: 2px; z-index: 50;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .16);
}
.account-dropdown.is-open { display: flex; }
.account-dropdown a, .account-dropdown button {
    text-align: left; background: transparent; border: 0; color: var(--ink); border-radius: 6px; padding: 9px 10px;
    font: inherit; font-size: 13px; cursor: pointer; text-decoration: none;
}
.account-dropdown a:hover, .account-dropdown button:hover { background: var(--bg-soft); color: var(--brand); text-decoration: none; }

.nav-toggle { display: inline-grid; place-items: center; width: 40px; height: 40px; background: #fff; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); cursor: pointer; }

/* legacy hooks still used by account.php */
.account { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.avatar { border-radius: 50%; }
.credits { background: var(--bg-soft); border-radius: 999px; padding: 3px 10px; }

@media (min-width: 900px) {
    .desktop-nav { display: flex; }
    .nav-toggle { display: none; }
}
@media (max-width: 899px) {
    /* burger opens the same nav as a panel under the bar */
    .desktop-nav.open {
        display: flex; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; align-items: stretch;
        padding: 12px 16px 16px; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 16px 30px rgba(15, 23, 42, .12);
    }
    .desktop-nav.open .nav-link, .desktop-nav.open .nav-button { justify-content: center; text-align: center; }
    .desktop-nav.open .account-dropdown { position: static; display: flex; box-shadow: none; border: 0; padding: 0; }
    .desktop-nav.open .account-toggle { display: none; }
    .brand-text strong { max-width: 160px; }
}

/* ---------- bottom action bar (home page): Settings | Share Web | Subscribe ---------- */
.bottom-actions {
    position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 39;
    width: min(100%, 520px); display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    padding: 8px 16px 12px; background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0; backdrop-filter: blur(6px); box-shadow: 0 -8px 30px rgba(15, 23, 42, .08);
}
.bottom-actions button, .bottom-actions a {
    display: grid; place-items: center; gap: 3px; color: var(--ink-soft); background: transparent; border: 0;
    font: inherit; font-size: 11px; cursor: pointer; padding: 4px 2px; text-decoration: none;
}
.bottom-actions svg { color: var(--brand); }
.bottom-actions > :last-child { color: var(--brand); font-weight: 600; }
.bottom-actions button:hover, .bottom-actions a:hover { color: var(--brand); text-decoration: none; }

/* ---------- language modal ---------- */
.modal-lang { max-width: 520px; }
.lang-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
.lang-option { border: 1.5px solid var(--line); background: var(--bg-soft); color: var(--ink); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; text-align: left; }
.lang-option:hover { border-color: var(--brand); }
.lang-option.is-active { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand) inset; }
@media (min-width: 520px) { .lang-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---------- floating toast (pages without a tool panel) ---------- */
.wg-toast {
    position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 12px); z-index: 70; opacity: 0; pointer-events: none;
    background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: 0 10px 30px rgba(15, 23, 42, .25);
    transition: opacity .18s ease, transform .18s ease; max-width: min(92vw, 480px);
}
.wg-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.wg-toast.error { background: #b91c1c; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
    font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none;
    transition: background .15s ease, box-shadow .15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink-soft); border-color: var(--line); }
.btn-offer { background: var(--accent); color: #fff; }
.btn-offer:hover { background: #047857; color: #fff; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 26px; font-size: 1.02rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- cards ---------- */
.card {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.tool-card { padding: 22px; }
.sticky { position: static; }
.pill { display: inline-block; font-size: .78rem; background: var(--bg-soft); border-radius: 999px; padding: 3px 10px; color: var(--ink-soft); }

/* ---------- layouts ---------- */
.layout-tool { display: grid; grid-template-columns: 1fr; gap: 28px; padding-top: 28px; padding-bottom: 48px; }
.layout-essay { max-width: var(--measure); padding-top: 28px; padding-bottom: 48px; }

@media (min-width: 992px) {
    .layout-tool { grid-template-columns: minmax(0, 7fr) minmax(280px, 3fr); gap: 36px; }
    .sticky { position: sticky; top: 84px; }
    h1 { font-size: 2.25rem; }
}

/* ---------- home workspace: essays | tools | My Space ---------- */
.home-layout {
    display: flex; flex-direction: column; gap: 20px;
    width: 100%; max-width: 1500px; margin: 0 auto; padding: 22px 16px 10px;
}
.home-layout .workspace { order: 0; }
.home-layout .myspace { order: 1; }
.home-layout .rail-essays { order: 2; }

.workspace {
    background: #fff; border: 1px solid var(--line); border-radius: 16px;
    padding: 22px; box-shadow: var(--shadow); min-width: 0;
}
.workspace-head h1 { margin-bottom: .4rem; }
.workspace-head .lede { margin-bottom: 1rem; }

.tool-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tool-tab {
    border: 1px solid var(--line); background: var(--bg-soft); color: var(--ink-soft);
    border-radius: 999px; padding: 7px 14px; font-size: .88rem; font-weight: 600; cursor: pointer;
}
.tool-tab.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.panel-tagline { color: var(--ink-soft); font-size: .95rem; margin-bottom: 14px; }
.signin-note { margin: 18px 0 0; font-size: .88rem; color: var(--ink-soft); }
body.is-signed-in [data-signed-out] { display: none; }

.rail {
    background: #fff; border: 1px solid var(--line); border-radius: 16px;
    padding: 16px 18px; min-width: 0;
}
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.rail-head strong { font-size: .95rem; }
.rail-head-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.storage-meter { font-size: .8rem; color: var(--ink-soft); background: var(--bg-soft); border-radius: 999px; padding: 3px 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { font-size: .8rem; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; color: var(--ink-soft); }
.chip:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.rail-list { list-style: none; margin: 0; padding: 0; }
.rail-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.rail-list li:last-child { border-bottom: 0; }
.rail-list a { font-size: .92rem; font-weight: 600; }
.rail-list p { margin: 4px 0 0; font-size: .82rem; }

.myspace .ws-body { min-height: 120px; }
.ws-file {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px;
    padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .86rem;
}
.ws-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-size { color: var(--ink-soft); font-size: .78rem; }
.ws-del { background: none; border: 0; font-size: 1.1rem; line-height: 1; color: var(--ink-soft); cursor: pointer; }
.ws-del:hover { color: #b91c1c; }
.ws-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.ws-upload { cursor: pointer; }

.home-seo { padding-bottom: 20px; }

@media (min-width: 1100px) {
    .home-layout {
        display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.6fr) minmax(0, 0.92fr);
        gap: 24px; align-items: start;
    }
    .home-layout .rail-essays { order: 0; position: sticky; top: 84px; max-height: calc(100vh - 104px); overflow-y: auto; }
    .home-layout .workspace { order: 0; }
    .home-layout .myspace { order: 0; position: sticky; top: 84px; }
}

.hero { background: var(--bg-soft); padding: 56px 0; text-align: center; border-bottom: 1px solid var(--line); }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tool-tile { display: block; color: inherit; margin: 0; }
.tool-tile:hover { text-decoration: none; border-color: var(--brand); }

.post-list, .link-list { list-style: none; padding: 0; margin: 0; }
.post-list li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.post-list a { font-weight: 600; }
.link-list li { padding: 6px 0; }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.field input, .field textarea, .field select {
    width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
    font: inherit; background: #fff; color: var(--ink);
}
.field textarea { resize: vertical; min-height: 110px; }
.field input:focus, .field textarea:focus, .field select:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}
.tool-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.cost-note { font-size: .85rem; color: var(--ink-soft); }

.tool-status { margin-top: 16px; padding: 12px 14px; border-radius: 10px; background: var(--bg-soft); font-size: .92rem; }
.tool-status.error { background: #fef2f2; color: #b91c1c; }
.tool-result { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 18px; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.result-actions { display: flex; gap: 8px; }
.result-body { border: 1px solid var(--line); border-radius: 10px; padding: 16px; background: var(--bg-soft); }

/* ---------- prose (SEO essay) ---------- */
.prose { font-size: 15.5px; line-height: 1.68; }
.prose h2 { font-size: 1.32rem; }
.prose h3 { font-size: 1.08rem; }
.prose ul, .prose ol { padding-left: 1.2rem; }
.prose li { margin-bottom: .4rem; }
.prose table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }

.essay-head { margin-bottom: 18px; }
.essay-meta { font-size: .86rem; color: var(--ink-soft); }
.breadcrumb { font-size: .85rem; color: var(--ink-soft); display: flex; gap: 6px; margin-bottom: 10px; }

.toc { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin: 0 0 22px; }
.toc-title { font-weight: 700; font-size: .9rem; margin: 0 0 6px; }
.toc ol { margin: 0; padding-left: 1.1rem; font-size: .9rem; }
.toc li { margin-bottom: .25rem; }
.toc .toc-l3 { margin-left: .8rem; list-style: circle; }

.data-anchor { margin: 28px 0; }
.table-wrap { overflow-x: auto; }
.data-anchor table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.data-anchor th, .data-anchor td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }

.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq-answer { margin-top: 8px; color: var(--ink-soft); }

/* ---------- offers ---------- */
.offer {
    border: 1px solid var(--line); border-left: 3px solid var(--accent);
    border-radius: var(--radius); padding: 16px 18px; margin: 22px 0; background: #f6fdf9;
}
.offer-label { font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.offer-headline { font-weight: 700; margin: 6px 0 4px; }
.offer-body { font-size: .9rem; color: var(--ink-soft); }
.offer-side { margin-top: 0; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, .55); }
.modal-card { position: relative; background: #fff; border-radius: 16px; padding: 28px; width: 100%; max-width: 440px; box-shadow: var(--shadow); }
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: 0; font-size: 1.6rem; cursor: pointer; color: var(--ink-soft); }
.modal-note { font-size: .8rem; color: var(--ink-soft); text-align: center; margin: 12px 0 0; }
.plans { display: grid; gap: 12px; margin: 18px 0; }
.plan { display: block; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; cursor: pointer; position: relative; }
.plan:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29, 78, 216, .12); }
.plan input { margin-right: 8px; }
.plan-name { font-weight: 600; }
.plan-price { display: block; font-size: 1.3rem; font-weight: 700; margin-top: 4px; }
.plan-price small { font-size: .8rem; font-weight: 500; color: var(--ink-soft); }
.plan-badge { position: absolute; top: -10px; right: 12px; background: var(--accent); color: #fff; font-size: .7rem; padding: 3px 8px; border-radius: 999px; }
.plan-note { display: block; font-size: .82rem; color: var(--ink-soft); margin-top: 2px; }
.modal-plans { max-width: 480px; }
.plan-tabs { display: flex; gap: 6px; margin-top: 14px; border-bottom: 1px solid var(--line); }
.plan-tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; font-weight: 600; font-size: .9rem; color: var(--ink-soft); cursor: pointer; margin-bottom: -1px; }
.plan-tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.plans[hidden] { display: none; }
.ws-addspace { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--brand); color: var(--brand); background: transparent; border-radius: 999px; padding: 3px 10px; font-size: .78rem; font-weight: 600; cursor: pointer; }
.ws-addspace:hover { background: #eef2ff; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); background: var(--bg-soft); padding: 40px 0 24px; margin-top: 40px; font-size: .92rem; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 26px; }
.footer h3 { font-size: .92rem; margin: 0 0 8px; }
.footer ul { list-style: none; padding: 0; margin: 0; }
.footer li { margin-bottom: 6px; }
.footer a { color: var(--ink-soft); }
.footer-brand { font-weight: 700; margin-bottom: 4px; }
.related-sites { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; gap: 14px; flex-wrap: wrap; font-size: .86rem; }
.copyright { margin-top: 18px; font-size: .82rem; color: var(--ink-soft); }

.pagination { display: flex; gap: 16px; align-items: center; margin-top: 28px; font-size: .92rem; }

/* ==========================================================
   Chat-assistant home (settings.home_layout = "chat", e.g. airesume)
   Modelled on aivita.chat: guides rail | chat shell | My Space.
   The guides rail and the chat thread are twice aivita's default
   height (80vh -> 160vh).
   ========================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

body.home-chat .footer { margin-top: 0; }

.chat-layout { padding-top: 18px; }
.chat-layout .chat-rail.rail-essays { min-height: 160vh; }

.chat-shell {
    display: flex; flex-direction: column; min-width: 0;
    background: #fff; border: 1px solid var(--line); border-radius: 20px;
    box-shadow: 0 18px 50px rgba(30, 41, 59, .10); padding: 6px 18px 16px;
}

.chat-workspace { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.chat-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0 8px; }
.chat-title-row h1 { margin: 0; font-size: 1.45rem; }
.chat-tools { display: flex; gap: 8px; }
.chat-tool-btn { border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink-soft); font-size: 12.5px; padding: 6px 12px; cursor: pointer; }
.chat-tool-btn:hover { border-color: var(--brand); color: var(--brand); }

.history-collapse { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 0; color: var(--ink-soft); font-size: 12.5px; padding: 2px 2px 8px; cursor: pointer; }
.history-collapse .chev { display: inline-block; transition: transform .2s ease; }
.history-block.is-collapsed .history-collapse .chev { transform: rotate(-90deg); }
.history-block.is-collapsed .chat-history { display: none; }
.history-count { background: var(--bg-soft); border-radius: 999px; padding: 1px 8px; font-size: 11px; }
.chat-history { max-height: 90vh; overflow-y: auto; padding-right: 4px; margin-bottom: 10px; scrollbar-width: thin; }

.chat-messages { display: grid; align-content: start; gap: 12px; }
.chat-thread { min-height: 160vh; margin: 4px 0 14px; }

.msg { border-radius: 14px; padding: 14px 16px; font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; position: relative; }
.msg-assistant { border: 1px solid var(--line); background: #fff; box-shadow: 0 2px 10px rgba(15, 23, 42, .04); }
.msg-user { justify-self: end; max-width: 88%; border: 1px solid var(--line); background: var(--brand-soft); white-space: pre-wrap; }
.msg-welcome { border-color: var(--line); background: linear-gradient(140deg, #fff, var(--brand-soft)); }
.msg.is-loading { opacity: .7; }
.msg-body h2 { font-size: 1.25rem; margin: .2rem 0 .4rem; }
.msg-body h3 { font-size: 1.02rem; margin: 1rem 0 .35rem; color: var(--brand-dark); }
.msg-body p { margin: 0 0 .6rem; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body ul, .msg-body ol { padding-left: 1.2rem; margin: 0 0 .6rem; }
.msg-body table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.msg-body th, .msg-body td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.msg-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--ink-soft); }
.msg-file { display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 600; }
.msg-file:hover { background: #000; color: #fff; text-decoration: none; }
.msg-copy { position: absolute; top: 8px; right: 8px; border: 0; background: transparent; color: var(--ink-soft); width: 26px; height: 26px; border-radius: 6px; cursor: pointer; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-copy, .msg-copy:focus-visible { opacity: 1; }
.msg-copy:hover { background: var(--bg-soft); color: var(--brand); }
.chat-followup { margin-top: .8rem; padding-top: .6rem; border-top: 1px dashed var(--line); font-weight: 600; }
.chat-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chat-quick button { border: 1px solid var(--brand); background: #fff; color: var(--brand); border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.chat-quick button:hover { background: var(--brand); color: #fff; }
.chat-quick button.is-secondary { border-color: var(--line); color: var(--ink-soft); }
.chat-quick button.is-secondary:hover { background: var(--bg-soft); color: var(--ink); }

.job-list { list-style: none; padding: 0; margin: .4rem 0; display: grid; gap: 10px; counter-reset: job; }
.job-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg-soft); font-size: .93rem; }
.job-item > a:first-child { font-size: 1rem; }
.job-meta { color: var(--ink-soft); font-size: .82rem; }
.job-apply { display: inline-block; margin-top: 4px; font-weight: 600; }

.chat-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.chat-attachments[hidden] { display: none; }
.chat-attach-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 12px; max-width: 100%; }
.chat-attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.chat-attach-x { border: 0; background: transparent; color: var(--ink-soft); width: 20px; height: 20px; border-radius: 5px; cursor: pointer; line-height: 1; }
.chat-attach-x:hover { color: #b91c1c; background: #fef2f2; }

.chat-composer {
    position: sticky; bottom: 12px; z-index: 7; margin-top: auto;
    display: grid; grid-template-columns: 44px minmax(0, 1fr) auto 48px; gap: 8px; align-items: end;
    padding: 8px 0; background: rgba(255, 255, 255, .96); backdrop-filter: blur(4px);
}
.chat-composer textarea {
    width: 100%; resize: none; min-height: 72px; max-height: 200px; font: inherit; font-size: 14px; line-height: 21px;
    border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 14px; color: var(--ink); background: #fff; outline: none;
}
.chat-composer textarea:focus { border-color: var(--brand); }
/* keep the composer above the fixed bottom action bar */
body.has-bottombar .chat-composer { bottom: 78px; }
.chat-attach { width: 44px; height: 48px; display: grid; place-items: center; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--brand); cursor: pointer; }
.chat-attach:hover { border-color: var(--brand); }
.chat-format select { height: 48px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); padding: 0 10px; font: inherit; font-size: 13px; }
.chat-send { width: 48px; height: 48px; border: 0; border-radius: 10px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, var(--brand), var(--brand-dark)); box-shadow: 0 6px 14px rgba(15, 23, 42, .22); cursor: pointer; }
.chat-send:hover { filter: brightness(1.08); }
.chat-send[disabled] { opacity: .55; cursor: not-allowed; }
.chat-cost { margin: 4px 0 10px; font-size: .8rem; }
.chat-workspace .tool-status { margin-top: 0; margin-bottom: 8px; padding: 8px 12px; font-size: .85rem; }

.chat-seo .grid-cards .tool-tile { margin: 0; }

@media (min-width: 1100px) {
    .chat-layout .chat-rail.rail-essays { position: static; max-height: 320vh; overflow-y: auto; }
    .chat-layout .chat-shell { order: 0; }
}

@media (max-width: 480px) {
    .chat-composer { grid-template-columns: 40px minmax(0, 1fr) 44px; }
    .chat-format { grid-column: 1 / -1; }
    .chat-format select { width: 100%; height: 40px; }
    .brand-text em { display: none; }
}
