/* Tenka Cloud — Mobile Controller (mobile-first, dark) */
:root {
  color-scheme: dark;
  --bg: #0b0f17;
  --surface: #141b29;
  --surface-2: #1b2436;
  --border: #243049;
  --text: #e8eef9;
  --muted: #8b97ad;
  --brand: #3b82f6;
  --brand-press: #2563eb;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Top app bar */
.appbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .6rem;
  padding: .85rem 1rem;
  background: rgba(11,15,23,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.appbar .logo { font-weight: 800; color: var(--brand); letter-spacing: .3px; }
.appbar .title { font-weight: 600; }
.appbar .spacer { flex: 1; }
.appbar .who { color: var(--muted); font-size: .85rem; }

.content { flex: 1; padding: 1rem; max-width: 640px; width: 100%; margin: 0 auto; }

/* Buttons */
button {
  font: inherit; cursor: pointer; border: none; border-radius: 10px;
  padding: .8rem 1rem; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); transition: .12s; min-height: 44px;
}
button:hover { border-color: #38507a; }
button:active { transform: translateY(1px); }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--brand-press); }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.block { width: 100%; }

input[type=text], input[type=email], input[type=password], input[type=search] {
  width: 100%; font: inherit; padding: .8rem .9rem; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
input:focus { outline: none; border-color: var(--brand); }
label { display: block; font-size: .85rem; color: var(--muted); margin: .8rem 0 .35rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; gap: .6rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* Login */
.login-wrap { max-width: 420px; margin: 8vh auto 0; padding: 1.25rem; }
.login-wrap h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
.demo-creds { margin-top: 1rem; }
.demo-creds .chip {
  display: inline-flex; flex-direction: column; gap: 2px; padding: .55rem .7rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  margin: .25rem .25rem 0 0; cursor: pointer; font-size: .8rem; text-align: left;
}
.demo-creds .chip b { color: var(--brand); }
.error { color: var(--danger); font-size: .9rem; min-height: 1.1em; }

/* Session status banner */
.status-banner {
  display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  margin-bottom: 1rem;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.waiting { background: #f59e0b; }
.dot.paired, .dot.active { background: var(--ok); }
.dot.stopped, .dot.expired { background: var(--danger); }
.status-banner .grow { flex: 1; }
.status-banner .label { font-weight: 600; text-transform: capitalize; }

/* Pairing panel */
.pair-grid { display: flex; flex-direction: column; gap: 1rem; align-items: center; text-align: center; }
.qr-box { background: #fff; padding: 12px; border-radius: 14px; }
.qr-box img { display: block; width: 220px; height: 220px; }
.code {
  font-size: 2rem; letter-spacing: .4rem; font-weight: 800; color: var(--text);
  background: var(--surface-2); border: 1px dashed var(--border); border-radius: 12px;
  padding: .5rem 1rem;
}
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); width: 100%; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--border); flex: 1; }

/* Search results */
.result {
  display: block; width: 100%; text-align: left; padding: .85rem 1rem; margin-top: .6rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; cursor: pointer;
}
.result:hover { border-color: var(--brand); }
.result .r-title { font-weight: 600; }
.result .r-snippet { color: var(--muted); font-size: .85rem; margin-top: .25rem; }
.result .r-snippet mark { background: rgba(59,130,246,.25); color: #cfe0ff; border-radius: 3px; padding: 0 2px; }

/* Editor */
.editor-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.editor-head .doc-title { font-weight: 700; font-size: 1.1rem; flex: 1; }
textarea.editor {
  width: 100%; min-height: 45vh; resize: vertical; font: inherit; line-height: 1.5;
  padding: 1rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .95rem;
}
textarea.editor:focus { outline: none; border-color: var(--brand); }
.save-hint { font-size: .8rem; color: var(--muted); }
.save-hint.saving { color: #f59e0b; }
.save-hint.saved { color: var(--ok); }

iframe.collabora { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: 12px; background: #fff; }

/* Bottom action bar */
.actionbar {
  position: sticky; bottom: 0; display: flex; gap: .6rem; padding: .75rem 1rem;
  background: rgba(11,15,23,.92); backdrop-filter: blur(10px); border-top: 1px solid var(--border);
}
.actionbar button { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: .6rem 1rem; border-radius: 10px; font-size: .9rem; opacity: 0; transition: .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
