/*
 * Browser agent workspace (/agent, /instinct). Visual language follows the
 * connect approval page: zinc greys, black primary actions, the Raq.com logo.
 * AIDEV-NOTE: agents drive this page by its labels and IDs; restyle freely,
 * but keep the markup in access.blade.php and the scripts' class names.
 */
:root {
    color-scheme: light;
    --ink: #09090b;
    --text: #27272a;
    --muted: #71717a;
    --line: #e4e4e7;
    --field: #d4d4d8;
    --ground: #f4f4f5;
    --card: #fff;
    --primary: #18181b;
    --focus: #18181b26;
    --error: #b42318;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--ground);
    -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(1100px 520px at 30% -160px, #fff 0%, #ffffff00 72%), var(--ground); }
/* A faint dot grid that fades out towards the bottom of the first screen. */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: 640px; z-index: -1; pointer-events: none; background: radial-gradient(#09090b14 1px, transparent 1.2px) 0 0 / 22px 22px; -webkit-mask-image: linear-gradient(#000, #0000); mask-image: linear-gradient(#000, #0000); }
main { max-width: 1040px; margin: 0 auto; padding: 32px 32px 72px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 448px); column-gap: 72px; align-items: start; }
main > header { grid-column: 1; grid-row: 1 / span 2; position: sticky; top: 32px; }
main > #message, main > #login-panel { grid-column: 2; }
main > #message { margin-top: 72px; }
main > #message:not(:empty) + #login-panel { margin-top: 12px; }
#login-panel { margin-top: 72px; }

header { margin-bottom: 26px; }
.brand { display: inline-flex; align-items: center; margin-bottom: 44px; border-radius: 6px; }
.brand img { display: block; height: 28px; width: auto; }
h1 { font-size: 40px; line-height: 1.08; letter-spacing: -.035em; font-weight: 680; color: var(--ink); margin: 0 0 14px; text-wrap: balance; }
h2 { font-size: 18px; letter-spacing: -.01em; font-weight: 600; color: var(--ink); margin: 24px 0 10px; }
h3 { font-size: 15px; font-weight: 600; color: var(--ink); }
header p { margin: 0; max-width: 34rem; color: var(--muted); font-size: 16px; line-height: 1.6; }

.steps { list-style: none; counter-reset: step; margin: 36px 0 0; padding: 0; display: grid; gap: 22px; max-width: 30rem; }
.steps li { counter-increment: step; position: relative; display: grid; gap: 2px; padding-left: 44px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 2px #09090b0d; font-size: 13px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 13.5px; top: 30px; bottom: -20px; width: 1px; background: var(--line); }
.steps strong { font-size: 15px; font-weight: 600; color: var(--ink); }
.steps span { font-size: 14px; line-height: 1.5; color: var(--muted); }

section, article { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; margin-top: 16px; box-shadow: 0 1px 2px #09090b0a, 0 12px 32px -24px #09090b29; }
#login-panel { border-radius: 18px; box-shadow: 0 1px 2px #09090b0d, 0 2px 6px -2px #09090b0d, 0 28px 56px -32px #09090b40; }
.card-head { padding: 22px 24px 0; }
.card-head h2 { margin: 0 0 4px; }
.card-head .meta { margin: 0; }
article { padding: 20px; }
article h3 { margin: 0 0 6px; overflow-wrap: anywhere; }
article p, .answer { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; margin: 6px 0; }
#login-panel, #workspace { padding: 0; overflow: hidden; }
#login-form, #workspace > * { padding-inline: 24px; }
#login-form { padding-block: 18px 24px; }
#workspace { padding-bottom: 24px; }

form { display: grid; gap: 8px; }
label { font-size: 13px; font-weight: 500; color: var(--text); margin-top: 8px; }
form > label:first-child { margin-top: 0; }
input, textarea, select { width: 100%; min-height: 42px; border: 1px solid var(--field); border-radius: 9px; padding: 10px 12px; font: inherit; font-size: 15px; background: #fff; color: var(--ink); box-shadow: 0 1px 2px #09090b0d; transition: border-color .15s, box-shadow .15s; }
input[readonly] { background: #fafafa; color: var(--text); }
#connect-user-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 18px; font-weight: 600; letter-spacing: .18em; text-align: center; }
textarea { resize: vertical; line-height: 1.5; }
select { appearance: none; padding-right: 36px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%2371717a' stroke-width='1.5'/%3E%3C/svg%3E") right 12px center / 16px no-repeat; }
input:focus, textarea:focus, select:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }

button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; border: 1px solid var(--primary); border-radius: 9px; background: var(--primary); color: #fff; padding: 0 16px; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s, opacity .15s; }
form > button[type="submit"] { margin-top: 10px; }
button:hover { background: #27272a; }
button:not(.secondary) { background-image: linear-gradient(#ffffff14, #ffffff00); box-shadow: inset 0 1px 0 #ffffff1f, 0 1px 2px #09090b33; }
button:disabled { opacity: .5; cursor: wait; }
button.secondary { background: #fff; color: var(--ink); border-color: var(--line); box-shadow: 0 1px 2px #09090b0d; }
button.secondary:hover { background: #fafafa; border-color: var(--field); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, .brand:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--focus); }

details { border-top: 1px solid var(--line); margin-top: 8px; }
details > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 14px 0; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--ink); }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 16px; height: 16px; flex: none; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 4l4 4-4 4' fill='none' stroke='%2371717a' stroke-width='1.5'/%3E%3C/svg%3E") center / 16px no-repeat; transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
details form { margin: 0 0 14px; }
#login-form details { margin-top: 10px; }
#login-form details > summary { padding: 12px 0 4px; color: var(--muted); font-size: 13px; }
#connect-flow { margin: 0; padding: 0 24px; background: #fafafa; border-top: 1px solid var(--line); }
#connect-flow > form > .meta { margin: 0 0 4px; }
#connect-flow > summary { padding: 16px 0; }
#connect-flow[open] { padding-bottom: 22px; }
#connect-status-box { display: grid; gap: 8px; margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--field); }
#connect-status-text:not(:empty) { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; }
#connect-status-text:not(:empty)::before { content: ""; width: 8px; height: 8px; flex: none; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 3px #f59e0b26; }
#connect-token-box { display: grid; gap: 8px; margin-top: 8px; padding: 16px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }

.toolbar, .actions, .view-tabs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions { margin: 10px 0; }
.toolbar { justify-content: space-between; padding-block: 14px; border-bottom: 1px solid var(--line); background: #fafafa; }
.toolbar > button { min-height: 34px; padding: 0 12px; font-size: 13px; }
.view-tabs { gap: 2px; padding: 3px; border-radius: 10px; background: var(--ground); border: 1px solid var(--line); margin-right: auto; }
.view-tabs button.view-tab { min-height: 32px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; box-shadow: none; color: var(--muted); font-size: 13px; }
.view-tabs button.view-tab:hover { color: var(--ink); }
.view-tabs button.view-tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px #09090b1a, 0 0 0 1px var(--line); }
.inline-control { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--muted); }
.inline-control select { width: auto; min-width: 200px; min-height: 34px; padding-block: 6px; font-size: 13px; }
#connection-meta { margin: 14px 0 0; }
#tools-panel, #priorities-panel, #questions-panel { padding-top: 6px; }
#modules-list { margin: 14px 0 6px; gap: 6px; }
#modules-list button { min-height: 30px; padding: 0 12px; border-radius: 999px; font-size: 13px; }
.search-row { display: flex; gap: 8px; flex-wrap: wrap; }
.search-row input, .search-row select { flex: 1 1 200px; }
.search-row button { flex: none; }
.tool-picker { margin-top: 16px; display: grid; gap: 8px; }
#tool-runner, #tool-result-card { box-shadow: none; background: #fafafa; }
#tool-runner h2 { margin-top: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; }
#tool-result-card h3 { margin: 0 0 4px; }
.tool-output { background: #0c0c0f; color: #e4e4e7; border-radius: 12px; padding: 16px; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.55; margin: 12px 0 0; min-height: 3rem; }
#tool-history-wrap { margin-top: 16px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.checkbox input { width: 16px; min-height: 16px; height: 16px; accent-color: var(--primary); box-shadow: none; }

#message:empty { display: none; }
#message { margin: 0 0 4px; padding: 12px 14px; border-radius: 10px; background: #fff; border: 1px solid var(--line); font-size: 14px; }
#message.error { color: var(--error); background: #fef3f2; border-color: #fecdca; }
[hidden] { display: none !important; }
.meta { color: var(--muted); font-size: 13px; line-height: 1.55; }
#board h2:first-child { margin-top: 18px; }

/* Signed in: one wider column for the console, without the connection steps. */
main:has(> #workspace:not([hidden])) { display: block; max-width: 920px; }
main:has(> #workspace:not([hidden])) .steps, main:has(> #workspace:not([hidden])) header > p { display: none; }
main:has(> #workspace:not([hidden])) h1 { font-size: 30px; margin-bottom: 10px; }
main:has(> #workspace:not([hidden])) > #message { margin-top: 0; }

@media (max-width: 880px) {
    main { display: block; max-width: 560px; }
    main > header { position: static; }
    main > #message, #login-panel { margin-top: 0; }
    main > #message:not(:empty) + #login-panel { margin-top: 12px; }
    h1 { font-size: 32px; }
    .steps { margin: 28px 0 8px; gap: 16px; }
}

@media (max-width: 600px) {
    main { padding: 20px 16px 48px; }
    .brand { margin-bottom: 28px; }
    .brand img { height: 24px; }
    h1 { font-size: 28px; }
    section, article { border-radius: 14px; }
    #login-form, #workspace > *, #connect-flow, .card-head { padding-inline: 16px; }
    .card-head { padding-top: 18px; }
    #login-form { padding-block: 18px; }
    .toolbar > button { flex: 1 1 auto; }
    .view-tabs { width: 100%; }
    .view-tabs button.view-tab { flex: 1 1 auto; }
}
