/* hserv-core UI — warm neutral palette inspired by the Claude desktop app. Light + dark. */
:root {
  --bg: #f5f4ef; --panel: #ffffff; --panel2: #f0eee6; --hover: #ebe8de; --border: #e1ddd1; --text: #1f1e1d; --muted: #6f6b62; --faint: #9c978c;
  --accent: #c96442; --accent-soft: #f4e3db; --ok: #3f8f4a; --ok-soft: #e1f0e2; --warn: #a46d0b; --warn-soft: #f7ecd2; --err: #c2413a; --err-soft: #f8e0de;
  --info: #3b6fb6; --info-soft: #e0eaf7; --code-bg: #f3f1ea; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px; color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #1f1e1d; --panel: #262624; --panel2: #2e2d2b; --hover: #353431; --border: #3b3a37; --text: #eceae4; --muted: #a8a49a; --faint: #7b776e;
  --accent: #d97757; --accent-soft: #3d2a22; --ok: #78c27f; --ok-soft: #22331f; --warn: #e3b456; --warn-soft: #3a2f17; --err: #ec7a70; --err-soft: #3d2220;
  --info: #84aee6; --info-soft: #1f2b3b; --code-bg: #1b1a19; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25); color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #1f1e1d; --panel: #262624; --panel2: #2e2d2b; --hover: #353431; --border: #3b3a37; --text: #eceae4; --muted: #a8a49a; --faint: #7b776e;
  --accent: #d97757; --accent-soft: #3d2a22; --ok: #78c27f; --ok-soft: #22331f; --warn: #e3b456; --warn-soft: #3a2f17; --err: #ec7a70; --err-soft: #3d2220;
  --info: #84aee6; --info-soft: #1f2b3b; --code-bg: #1b1a19; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25); color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 20px; margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .grow { flex: 1; min-width: 0; } .stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.two { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--panel); padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); text-decoration: none; } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--err); } .btn.ghost { border-color: transparent; background: transparent; } .btn.sm { padding: 3px 8px; font-size: 12px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 80px; }
label.field { display: block; } label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

/* cards, pills, tables */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card.click { cursor: pointer; transition: border-color .12s, transform .12s; } .card.click:hover { border-color: var(--accent); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; background: var(--panel2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--err-soft); color: var(--err); } .pill.info { background: var(--info-soft); color: var(--info); } .pill.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); } .dot.ok { background: var(--ok); } .dot.err { background: var(--err); } .dot.warn { background: var(--warn); }
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 500; } tr.click { cursor: pointer; } tr.click:hover td { background: var(--hover); }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; } .kv > div:nth-child(odd) { color: var(--muted); font-size: 12.5px; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.banner { padding: 10px 14px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); border: 1px solid transparent; }
.banner.info { background: var(--info-soft); color: var(--info); } .banner.err { background: var(--err-soft); color: var(--err); }

/* meters */
.meter { height: 8px; border-radius: 99px; background: var(--panel2); overflow: hidden; } .meter > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter.ok > i { background: var(--ok); } .meter.warn > i { background: var(--warn); } .meter.err > i { background: var(--err); }
.stat { font-size: 24px; font-weight: 600; letter-spacing: -.02em; } .stat small { font-size: 13px; color: var(--muted); font-weight: 400; }

/* shell layout */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); height: 100vh; }
.side { background: var(--panel2); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; font-weight: 650; font-size: 16px; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.nav h4 { margin: 14px 10px 4px; font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav a:hover { background: var(--hover); } .nav a.active { background: var(--panel); box-shadow: var(--shadow); font-weight: 550; }
.nav a .ico { width: 18px; text-align: center; opacity: .8; }
.me { border-top: 1px solid var(--border); padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.avatar-sm { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; flex: none; overflow: hidden; }
.avatar-sm img, .avatar img { width: 100%; height: 100%; display: block; }
.avatar { width: 56px; height: 56px; border-radius: 14px; overflow: hidden; flex: none; background: var(--panel2); }
.avatar.lg { width: 112px; height: 112px; border-radius: 22px; }
.main { min-width: 0; overflow-y: auto; display: flex; flex-direction: column; }
.page-head { display: flex; align-items: center; gap: 12px; padding: 18px 24px 14px; border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.content { padding: 20px 24px 40px; max-width: 1280px; width: 100%; }
.menu-btn { display: none; }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; } .side { position: fixed; inset: 0 30% 0 0; z-index: 30; transform: translateX(-102%); transition: transform .18s; box-shadow: var(--shadow); }
  .side.open { transform: none; } .menu-btn { display: inline-flex; } .content { padding: 16px; } .page-head { padding: 14px 16px; }
}

/* console (Claude-Code-desktop-like) */
.console { display: grid; grid-template-columns: 250px minmax(0, 1fr); flex: 1; min-height: 0; height: calc(100vh - 0px); }
.sessions { border-right: 1px solid var(--border); overflow-y: auto; padding: 10px; background: var(--bg); }
.sessions .s { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.sessions .s:hover { background: var(--hover); } .sessions .s.active { background: var(--panel); box-shadow: var(--shadow); }
.sessions .s .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-top { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.tabs { display: inline-flex; background: var(--panel2); border-radius: 8px; padding: 2px; }
.tabs button { border: 0; background: transparent; padding: 4px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.transcript { flex: 1; overflow-y: auto; padding: 18px max(18px, calc((100% - 820px) / 2)); }
.msg { margin: 0 0 14px; } .msg.user .bubble { background: var(--panel2); border: 1px solid var(--border); padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg.assistant { line-height: 1.6; } .msg.assistant p { margin: 0 0 10px; }
.md pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.md code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; } .md pre code { background: none; padding: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 14px 0 8px; text-transform: none; letter-spacing: 0; color: var(--text); }
.md h1 { font-size: 20px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15px; } .md ul, .md ol { padding-left: 22px; margin: 6px 0 10px; }
.md table { margin: 8px 0; } .md blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.tool { border: 1px solid var(--border); border-radius: 8px; margin: 6px 0 10px; background: var(--panel); overflow: hidden; }
.tool > summary { cursor: pointer; padding: 6px 10px; display: flex; gap: 8px; align-items: center; list-style: none; font-size: 13px; }
.tool > summary::-webkit-details-marker { display: none; }
.tool .tname { font-weight: 600; } .tool .targ { color: var(--muted); font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.tool pre { margin: 0; padding: 8px 10px; border-top: 1px solid var(--border); background: var(--code-bg); max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.tool.err > summary .tname { color: var(--err); }
.think { color: var(--muted); font-style: italic; font-size: 13px; }
.meta-line { color: var(--faint); font-size: 12px; margin: 4px 0 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.composer { border-top: 1px solid var(--border); padding: 12px max(18px, calc((100% - 820px) / 2)) 16px; }
.composer .box { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); }
.composer textarea { border: 0; box-shadow: none !important; padding: 2px; min-height: 52px; max-height: 260px; background: transparent; }
.composer .opts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.composer .opts select, .composer .opts input { width: auto; padding: 4px 8px; font-size: 12.5px; border-radius: 6px; }
.composer .opts input.cwd { min-width: 160px; flex: 1; font-family: var(--mono); }
.term-frame { flex: 1; border: 0; width: 100%; min-height: 0; background: #000; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 820px) { .console { grid-template-columns: 1fr; } .sessions { display: none; } }

/* board / messages */
.msgs { max-height: 460px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.m { display: flex; gap: 10px; } .m .b { background: var(--panel2); border-radius: 10px; padding: 8px 12px; white-space: pre-wrap; word-wrap: break-word; flex: 1; min-width: 0; }
.m .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; } .m.agent .b { background: var(--info-soft); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; } .login .card { padding: 28px; box-shadow: var(--shadow); }
.login .logo { width: 48px; height: 48px; border-radius: 12px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; margin: 0 auto 14px; }
.login h1 { text-align: center; } .login .sub { text-align: center; color: var(--muted); margin: 4px 0 20px; }
.login input { font-size: 16px; padding: 10px 12px; letter-spacing: .08em; } .login .btn { width: 100%; justify-content: center; padding: 10px; margin-top: 12px; }
.login .sec { margin-top: 16px; font-size: 11.5px; color: var(--faint); text-align: center; line-height: 1.5; }
.err-text { color: var(--err); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow); border: 1px solid var(--border); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; } .modal .body { padding: 18px 20px; }
.modal footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.toasts { position: fixed; bottom: 16px; right: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; }
.toast.err { background: var(--err); color: #fff; }
.secret-box { font-family: var(--mono); background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; word-break: break-all; white-space: pre-wrap; max-height: 260px; overflow: auto; }

/* notes */
.note-body { max-height: 220px; overflow: hidden; position: relative; }
.note-body::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 28px; background: linear-gradient(transparent, var(--panel)); }
