/* Joy Chat console — flat, compact, black on white with one accent. No frameworks. */
:root { --ink:#161616; --muted:#525252; --line:#e0e0e0; --bg:#fff; --soft:#f4f4f4; --accent:#0f62fe; --accent-ink:#fff; --ok:#198038; --err:#da1e28; --note:#fcf4d6; }
@media (prefers-color-scheme: dark) { :root { --ink:#f4f4f4; --muted:#c6c6c6; --line:#393939; --bg:#161616; --soft:#262626; --accent:#78a9ff; --accent-ink:#161616; --ok:#42be65; --err:#ff8389; --note:#3a3420; } }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 18px; margin: 0 0 12px; font-weight: 600; } h2 { font-size: 14px; margin: 24px 0 8px; font-weight: 600; }
p { margin: 0 0 12px; } .muted { color: var(--muted); } .right { text-align: right; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--soft); padding: 1px 4px; border-radius: 2px; }
code.wrap, code.key { word-break: break-all; } code.key { display: inline-block; margin-top: 6px; font-size: 14px; padding: 6px 8px; letter-spacing: 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=url], select, textarea { width: 100%; padding: 7px 8px; border: 1px solid var(--line); border-radius: 2px; background: var(--bg); }
input[type=color] { width: 56px; height: 32px; padding: 2px; border: 1px solid var(--line); background: var(--bg); }
label { display: block; margin: 12px 0 4px; font-weight: 600; } label.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-weight: 400; } label.inline select { width: auto; }
button, a.button { display: inline-block; margin-top: 12px; padding: 7px 14px; border: 1px solid var(--accent); border-radius: 2px; background: var(--accent); color: var(--accent-ink); cursor: pointer; }
a.button:hover { text-decoration: none; } button:disabled { opacity: .5; cursor: default; }
button.secondary { background: var(--bg); color: var(--ink); border-color: var(--line); }
button.link { margin: 0; padding: 0; border: 0; background: none; color: var(--accent); }
form.narrow { max-width: 420px; } form.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 12px 0; }
form.inline-form label { margin: 0; align-self: center; } form.inline-form input, form.inline-form select { width: auto; min-width: 180px; } form.inline-form button { margin: 0; }
textarea.snippet { font: 12px ui-monospace, Menlo, Consolas, monospace; background: var(--soft); resize: vertical; }

table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; } th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); } td form { margin: 0; } td .inline-form { margin: 0; }
.flash { padding: 8px 12px; border-left: 3px solid var(--ok); background: var(--soft); margin: 0 0 16px; } .flash.err { border-color: var(--err); } .flash p:last-child { margin: 0; }

.top { display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 44px; border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 700; color: var(--ink); } .top .org { color: var(--muted); padding-left: 16px; border-left: 1px solid var(--line); }
.top nav { display: flex; gap: 4px; flex: 1; } .top nav a { padding: 12px 10px; color: var(--ink); border-bottom: 2px solid transparent; }
.top nav a[aria-current=page] { border-color: var(--accent); } .top .me { display: flex; align-items: center; gap: 12px; } .top .me .who { color: var(--muted); } .top .me form { margin: 0; }
main.page { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }

body.bare { display: grid; place-items: start center; padding: 48px 16px; background: var(--soft); }
.card { width: 100%; max-width: 400px; background: var(--bg); border: 1px solid var(--line); padding: 24px; } .card.wide { max-width: 1040px; }
.card .brand { font-weight: 700; margin-bottom: 16px; } .card form + form { margin-top: 12px; }
ol.steps { padding-left: 18px; } ol.steps li { margin-bottom: 8px; }
ul.codes { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; } ul.codes code { font-size: 13px; }
ul.list { list-style: none; padding: 0; } ul.list form { margin: 0; }
button.row { display: flex; justify-content: space-between; width: 100%; margin: 0 0 8px; background: var(--bg); color: var(--ink); border-color: var(--line); text-align: left; } button.row span { color: var(--muted); }
iframe.preview { width: 100%; height: 640px; border: 1px solid var(--line); background: var(--soft); }

/* inbox */
main.inbox-main { height: calc(100% - 44px); padding: 0; }
main.inbox-main > .flash { margin: 8px 16px; }
#inbox { display: grid; grid-template-columns: 320px 1fr; height: 100%; }
.convs { border-right: 1px solid var(--line); overflow-y: auto; }
.filters { display: flex; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); }
.filters button { flex: 1; margin: 0; padding: 10px 4px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); }
.filters button[aria-selected=true] { color: var(--ink); border-color: var(--accent); }
#conv-list { list-style: none; margin: 0; padding: 0; }
#conv-list li { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; } #conv-list li:hover { background: var(--soft); }
#conv-list li[aria-current=true] { background: var(--soft); box-shadow: inset 3px 0 0 var(--accent); }
#conv-list .row1 { display: flex; justify-content: space-between; gap: 8px; } #conv-list .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#conv-list .time { color: var(--muted); flex: none; } #conv-list .preview { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#conv-list .unread { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); text-align: center; font-size: 11px; }
#more { margin: 12px; } #conv-empty, #thread-empty { padding: 24px 16px; }
.thread { display: flex; flex-direction: column; min-width: 0; height: 100%; overflow: hidden; }
#thread { display: flex; flex-direction: column; height: 100%; } #thread[hidden] { display: none; }
#thread > header { display: flex; justify-content: space-between; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
#thread h1 { margin: 0; font-size: 15px; } #thread .grow { flex: 1; min-width: 0; } #t-back { display: none; margin: 0; } #thread header p { margin: 0; } #thread .actions { display: flex; gap: 12px; align-items: center; } #thread .actions button { margin: 0; }
.tags { display: flex; gap: 8px; align-items: center; padding: 6px 16px; border-bottom: 1px solid var(--line); min-height: 36px; } .tags form { margin: 0; } .tags input { width: 140px; padding: 3px 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; padding: 1px 8px; border: 1px solid var(--line); border-radius: 10px; }
.tag button { margin: 0; padding: 0 2px; border: 0; background: none; color: var(--muted); }
#messages { flex: 1; list-style: none; margin: 0; padding: 16px; overflow-y: auto; }
#messages li { max-width: 72%; margin: 0 0 10px; } #messages .bubble { padding: 8px 10px; background: var(--soft); border-radius: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
#messages .meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
#messages li.agent { margin-left: auto; } #messages li.agent .bubble { background: var(--accent); color: var(--accent-ink); } #messages li.agent .meta { text-align: right; }
#messages li.note { margin-left: auto; } #messages li.note .bubble { background: var(--note); color: var(--ink); border: 1px dashed var(--line); }
#messages li.event { max-width: 100%; text-align: center; color: var(--muted); font-size: 12px; }
#typing { padding: 0 16px; } #reply { border-top: 1px solid var(--line); padding: 8px 16px 12px; margin: 0; }
#reply .modes { display: flex; gap: 16px; } #reply .modes label { margin: 0 0 6px; font-weight: 400; }
#reply textarea { resize: none; } #reply.note textarea { background: var(--note); }
#reply .send { display: flex; justify-content: space-between; align-items: center; } #reply .send button { margin-top: 8px; }
@media (max-width: 760px) { #inbox { grid-template-columns: 1fr; } #inbox.has-open .convs { display: none; } #inbox:not(.has-open) .thread { display: none; } #t-back { display: inline-block; } .top { flex-wrap: wrap; height: auto; padding: 8px 12px; } .top .me .who { display: none; } main.inbox-main { height: calc(100% - 84px); } #messages li { max-width: 90%; } }
