:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1f232c; --line: #2a2f3a;
  --text: #e6e8ee; --muted: #9098a8; --accent: #6ea8fe; --accent2: #3d7be0;
  --bad: #ff6b6b; --ok: #4fd18b; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
button {
  background: var(--accent2); border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600;
}
button:hover { filter: brightness(1.1); }
button.ghost { background: transparent; border: 1px solid var(--line); font-weight: 500; }
button.danger { background: #a33; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--bad); min-height: 1.5em; }
.okmsg { color: var(--ok); }

/* centered card (home, login, admin login) */
.center { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: 100%; max-width: 360px; }
.card h1 { margin: 0 0 6px; font-size: 22px; }
.card form { display: grid; gap: 10px; margin-top: 16px; }

/* app shell */
.app { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.topbar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; margin-right: 10px; }
.tab { background: transparent; border: 0; color: var(--muted); padding: 7px 12px; border-radius: 8px; font-weight: 600; }
.tab.active { background: var(--panel2); color: var(--text); }
.spacer { flex: 1; }
.view { overflow: auto; padding: 18px; }
.view.browse { padding: 0; display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
.urlbar { display: flex; gap: 6px; padding: 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.urlbar input { flex: 1; }
.urlbar button { padding: 8px 11px; }
iframe#frame { width: 100%; height: 100%; border: 0; background: #fff; }
.start { display: grid; place-items: center; color: var(--muted); height: 100%; text-align: center; padding: 20px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; text-align: left; font-weight: 500; }
.tile:hover { border-color: var(--accent); }
.tile b { display: block; font-size: 16px; margin-bottom: 2px; }
.tile span { color: var(--muted); font-size: 13px; }
h2.sec { margin: 0 0 4px; }
p.note { color: var(--muted); margin: 0 0 14px; font-size: 13px; }

/* chat */
.chat { max-width: 820px; margin: 0 auto; display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 10px; }
.msgs { overflow: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 6px; }
.msg { padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; max-width: 85%; }
.msg.user { background: var(--accent2); align-self: flex-end; }
.msg.assistant { background: var(--panel2); align-self: flex-start; }
.msg.error { background: #3a1f24; color: #ffb3b3; align-self: flex-start; }
.composer { display: flex; gap: 8px; }
.composer textarea { flex: 1; resize: none; height: 56px; }

/* admin */
.admin { max-width: 1100px; margin: 0 auto; padding: 20px; }
.admin header { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.admin h1 { margin: 0; font-size: 22px; flex: 1; }
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.site { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 10px; }
.site h3 { margin: 0; display: flex; gap: 8px; align-items: center; }
.site h3 input { flex: 1; font-weight: 700; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row label { color: var(--muted); font-size: 13px; min-width: 110px; }
.row input[type=number] { width: 90px; }
.row input.grow { flex: 1; min-width: 120px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); color: var(--muted); }
.pill.owner { color: #ffd479; } .pill.friends { color: #9ad0ff; } .pill.public { color: var(--bad); } .pill.off { color: var(--muted); }
.link { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; color: var(--muted); }
.friends { display: grid; gap: 6px; }
.friend { display: flex; gap: 8px; align-items: center; background: var(--panel2); padding: 6px 8px; border-radius: 8px; }
.friend b { flex: 1; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-top: 16px; }
.box h2 { margin: 0 0 10px; font-size: 17px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.warn { background: #3a2a14; color: #ffd49a; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.stats { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.stats b { color: var(--text); }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; }

.mt { margin-top: 12px; }
#frameWrap { position: relative; min-height: 0; height: 100%; }


.links { display: grid; gap: 6px; }
.linkrow { display: grid; grid-template-columns: 1fr 1fr 2fr auto auto; gap: 6px; }
@media (max-width: 700px) { .linkrow { grid-template-columns: 1fr 1fr; } }


.fullw { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.lockbox { margin: 0 0 16px; }
.lockbox.on { border-color: var(--bad); background: #2a1519; }
.grow-text { flex: 1; min-width: 220px; }
.pill.live { color: var(--ok); }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; }

