:root {
  --bg: #f7f7f5; --panel: #fff; --text: #1d1d1b; --muted: #6b6b66; --line: #e2e2dd; --accent: #2f5d50; --accent-text: #fff; --warn: #a33b20;
  --radius: 8px; color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.5;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161615; --panel: #1f1f1d; --text: #ecece8; --muted: #a2a29b; --line: #34342f; --accent: #6fb39d; --accent-text: #0d1a16; --warn: #f08a6c; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
.top { display: flex; gap: 16px; align-items: center; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-size: 17px; }
.back { margin-left: auto; color: var(--accent); }
.muted { color: var(--muted); }
.layout { display: grid; grid-template-columns: 180px minmax(0, 1fr) 340px; min-height: calc(100vh - 54px); }
nav { border-right: 1px solid var(--line); padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
nav button { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: var(--radius); color: var(--text); font: inherit; cursor: pointer; }
nav button[aria-current="page"] { background: var(--accent); color: var(--accent-text); }
main { padding: 20px 24px; max-width: 900px; }
aside { border-left: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--panel); }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 20px 0 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
label { display: block; margin: 10px 0 4px; font-weight: 600; }
label.inline { display: inline-flex; gap: 6px; font-weight: 400; margin: 6px 12px 6px 0; align-items: center; }
input[type="text"], input[type="email"], input[type="number"], select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); font: inherit; }
textarea { min-height: 160px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
button.primary, button.secondary, button.danger { padding: 7px 14px; border-radius: var(--radius); font: inherit; cursor: pointer; border: 1px solid var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); }
button.secondary { background: none; color: var(--accent); }
button.danger { background: none; color: var(--warn); border-color: var(--warn); }
button:disabled { opacity: .5; cursor: default; }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 13px; border: 1px solid var(--line); }
.badge.live { border-color: var(--accent); color: var(--accent); }
.preview { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.thumbs figure { margin: 0; }
.thumbs img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); background: var(--line); }
.thumbs figcaption { font-size: 13px; color: var(--muted); }
.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 8px 10px; border-radius: var(--radius); white-space: pre-wrap; }
.msg.me { background: var(--accent); color: var(--accent-text); align-self: flex-end; max-width: 90%; }
.msg.buddy { background: var(--bg); border: 1px solid var(--line); max-width: 95%; }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: var(--radius); opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }
@media (max-width: 1100px) { .layout { grid-template-columns: 160px minmax(0, 1fr); } aside { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); } }
@media (max-width: 700px) { .layout { grid-template-columns: 1fr; } nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); } main { padding: 16px; } }
.short { min-height: 100px; }
aside textarea { min-height: 80px; }
