/* Complete AI Web app: dashboard, fact sheet, interview, editor, report and sign-in. Tokens come from tokens.css. */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 400 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.02em; line-height: 1.15; margin: 0 0 .4em; font-weight: 700; }
h1 { font-size: clamp(24px, 3vw, 32px); }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 .7em; }
a { color: var(--blue); }
code, .mono { font-family: var(--mono); font-size: 13px; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { font: 600 11.5px/1.3 var(--mono); letter-spacing: .09em; text-transform: uppercase; color: var(--blue); margin: 0 0 8px; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 999px; padding: 10px 18px; font: 600 14.5px/1.1 var(--sans); border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; background: var(--blue); color: var(--on-blue); min-height: 40px; }
.btn:hover { background: var(--blue-ink); text-decoration: none; }
.btn.ghost { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--blue-100); background: var(--paper); }
.btn.soft { background: var(--blue-50); color: var(--blue); }
.btn.orange { background: var(--orange); color: #1f1304; }
.btn.danger { background: var(--paper); color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.btn.sm { padding: 6px 12px; min-height: 32px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: wait; }
label { display: block; font-weight: 600; font-size: 13.5px; margin: 0 0 12px; }
label > span.hint { font-weight: 400; color: var(--muted); display: block; font-size: 12.5px; }
input[type=text], input[type=email], input[type=url], input[type=tel], input:not([type]), textarea, select {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font: 400 15px/1.4 var(--sans);
}
textarea { resize: vertical; min-height: 80px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--blue-200); border-color: var(--blue); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; }

/* layout */
.top { position: sticky; top: 0; z-index: 30; background: var(--paper); border-bottom: 1px solid var(--line); }
.top .in { height: 60px; display: flex; align-items: center; gap: 16px; padding: 0 20px; }
.top .brand img { height: 34px; display: block; }
.top .site-switch { font-weight: 600; color: var(--ink); text-decoration: none; padding: 6px 10px; border-radius: 8px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .site-switch:hover { background: var(--blue-50); }
.top .spacer { flex: 1; }
.top .who { color: var(--muted); font-size: 13px; }
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100vh - 60px); }
.side { border-right: 1px solid var(--line); background: var(--paper); padding: 18px 12px; }
.side a { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.side a:hover { background: var(--blue-50); color: var(--blue); }
.side a.on { background: var(--blue-50); color: var(--blue); font-weight: 600; }
.side .sec { font: 600 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 18px 12px 8px; }
.side .badge { margin-left: auto; }
.main { padding: 28px clamp(16px, 3vw, 40px) 60px; max-width: 1100px; width: 100%; }
.main.wide { max-width: none; padding: 0; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); display: flex; overflow-x: auto; gap: 4px; padding: 8px; }
  .side .sec { display: none; }
  .side a { white-space: nowrap; }
}

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card.narrow { max-width: 480px; margin: 60px auto; }
.card h2 { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat .n { font: 700 30px/1 var(--display); }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 6px; }
.badge { display: inline-block; font: 600 11.5px/1 var(--sans); padding: 5px 9px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); }
.badge.ok { background: var(--green-50); color: var(--green); }
.badge.warn { background: var(--orange-50); color: var(--orange-ink); }
.badge.bad { background: color-mix(in srgb, var(--red) 12%, var(--paper)); color: var(--red); }
.badge.blue { background: var(--blue-50); color: var(--blue); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--blue-50); color: var(--ink); margin-bottom: 16px; }
.notice.warn { background: var(--orange-50); }
.notice.bad { background: color-mix(in srgb, var(--red) 10%, var(--paper)); }
.notice.ok { background: var(--green-50); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.bar { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--blue); border-radius: 99px; width: 0; transition: width .4s; }
.bar.orange > i { background: var(--orange); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.t th { font-weight: 600; color: var(--muted); font-size: 12.5px; }
pre.code { background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow: auto; font: 12.5px/1.5 var(--mono); white-space: pre; max-height: 360px; }
.keybox { display: flex; gap: 8px; align-items: center; }
.keybox code { flex: 1; background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow: auto; white-space: nowrap; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border: 1px solid var(--line); background: var(--paper); color: var(--ink-2); border-radius: 999px; padding: 7px 14px; font: 600 13.5px var(--sans); cursor: pointer; }
.tabs button.on { background: var(--blue); color: var(--on-blue); border-color: var(--blue); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; z-index: 99; font-weight: 500; box-shadow: var(--shadow-lift); max-width: 90vw; }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } }

/* findings */
.finding { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.finding:last-child { border-bottom: 0; }
.finding .dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 6px; background: var(--muted); }
.finding.high .dot { background: var(--red); }
.finding.medium .dot { background: var(--orange); }
.finding.low .dot { background: var(--blue-200); }
.finding.good .dot { background: var(--green); }
.finding p { margin: 4px 0 0; color: var(--ink-2); }
.finding .fix { color: var(--ink); }
.finding .fix::before { content: "Fix: "; font-weight: 600; }
.score { display: grid; place-items: center; width: 120px; height: 120px; border-radius: 50%; border: 10px solid var(--blue-50); font: 700 36px/1 var(--display); color: var(--blue); flex-shrink: 0; }
.score.mid { color: var(--orange-ink); border-color: var(--orange-50); }
.score.low { color: var(--red); border-color: color-mix(in srgb, var(--red) 15%, var(--paper)); }

/* chat (interview + editor) */
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat .log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; }
.msg.assistant { background: var(--paper-2); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user { background: var(--blue); color: var(--on-blue); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.system { align-self: center; background: transparent; color: var(--muted); font-size: 13px; padding: 2px; }
.msg ul { margin: 6px 0 0; padding-left: 18px; }
.chat form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--paper); }
.chat form textarea { margin: 0; min-height: 44px; max-height: 160px; flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 8px; }
.chips button { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 6px 12px; font: 500 13px var(--sans); cursor: pointer; color: var(--ink-2); }
.chips button:hover { border-color: var(--blue-100); color: var(--blue); }
.interview { height: calc(100vh - 220px); min-height: 420px; padding: 0; overflow: hidden; display: flex; flex-direction: column; }

/* editor */
.editor { display: grid; grid-template-columns: 1fr 400px; height: calc(100vh - 60px); }
.editor .stage { display: flex; flex-direction: column; min-width: 0; background: var(--line-2); }
.editor .stagebar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.editor .stagebar select { width: auto; margin: 0; padding: 6px 10px; }
.editor .stagebar .status { font-size: 13px; color: var(--ink-2); }
.editor iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.editor .frame-wrap { flex: 1; display: flex; justify-content: center; min-height: 0; }
.editor .frame-wrap.mobile iframe { max-width: 390px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.editor .panel { display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--paper); min-height: 0; }
.editor .panel .ptabs { display: flex; border-bottom: 1px solid var(--line); }
.editor .panel .ptabs button { flex: 1; padding: 11px 6px; border: 0; background: none; font: 600 13px var(--sans); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.editor .panel .ptabs button.on { color: var(--blue); border-bottom-color: var(--blue); }
.editor .panel .pbody { flex: 1; min-height: 0; overflow: auto; }
.editor .panel .pbody.chatbody { overflow: hidden; display: flex; flex-direction: column; }
.editor .pad { padding: 14px 16px; }
.change { padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.change .meta { color: var(--muted); font-size: 12px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.media-grid figure { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--paper-2); }
.media-grid img { width: 100%; height: 80px; object-fit: cover; display: block; }
.media-grid figcaption { font-size: 11px; padding: 4px 6px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1000px) {
  .editor { grid-template-columns: 1fr; grid-template-rows: 55vh 1fr; height: auto; min-height: calc(100vh - 60px); }
  .editor .panel { border-left: 0; border-top: 1px solid var(--line); min-height: 60vh; }
}

/* fact sheet form */
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 0 0 16px; background: var(--paper); }
legend { font: 700 15px var(--display); padding: 0 6px; }
.rep { border: 1px dashed var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; position: relative; }
.rep .rm { position: absolute; top: 8px; right: 8px; }
.sticky-save { position: sticky; bottom: 0; background: color-mix(in srgb, var(--ground) 92%, transparent); padding: 12px 0; display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--line); backdrop-filter: blur(8px); }
.src { font: 500 11px var(--mono); color: var(--muted); margin-left: 6px; }

/* sign-in & consent */
body.login, body.consent { display: grid; place-items: start center; padding: 20px; }
body.login .card, body.consent .card { width: 100%; }
body.consent fieldset { margin: 12px 0; }
body.consent .row { display: flex; font-weight: 400; gap: 8px; margin: 6px 0; }
.warn { color: var(--orange-ink); }
.grow { flex: 1; min-width: 120px; }
.row .bar { flex: 1; }
.spacer { flex: 1; }
