* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #0f1115; color: #e8e8ec;
}
a { color: #7aa2ff; }

.center { display:flex; align-items:center; justify-content:center; min-height:100vh; }
.wrap { max-width: 720px; margin: 24px auto; padding: 0 16px; }

.card {
  background: #181b21; border: 1px solid #2a2f38; border-radius: 12px;
  padding: 24px; box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.card + .card { margin-top: 16px; }
.cardhead { display:flex; align-items:center; justify-content:space-between; gap: 12px; }
.cardhead h2 { margin: 0; }

h1, h2, h3 { margin-top: 0; }
label { display: block; margin: 12px 0; font-size: 14px; color:#aab; }
input, button, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px; font-size: 15px;
  border: 1px solid #2a2f38; background: #0f1217; color: #e8e8ec;
  font-family: inherit;
}
input:focus { outline: 2px solid #4a7dff; }
button {
  cursor: pointer; background: #3a6dff; border-color: #3a6dff; color: white;
  font-weight: 600; margin-top: 8px;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent; color: #cfd2da; border-color:#2a2f38; }
button.danger { background: #c0392b; border-color: #c0392b; }

.error { color: #ff8b8b; margin-top: 8px; }
.muted { color: #8a90a0; font-size: 13px; }

.topbar {
  display:flex; align-items:center; justify-content:space-between;
  padding: 12px 18px; background:#14171d; border-bottom:1px solid #232831;
  gap: 12px;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar form { margin: 0; }
.topbar form button { width: auto; margin: 0; padding: 6px 12px; }
.rightnav { display:flex; gap:8px; align-items:center; }
.rightnav a { text-decoration: none; }

.urlbox { display:flex; gap:8px; align-items:center; margin: 8px 0 16px; }
.urlbox input { flex:1; }
.urlbox button { width: auto; margin: 0; padding: 8px 14px; }
.urlbox a { text-decoration: none; }

/* Microsoft sign-in button */
.ms-button {
  display:inline-flex; align-items:center; gap:10px; padding: 10px 16px;
  background:#2f2f2f; color:#fff; border:1px solid #2f2f2f; border-radius: 4px;
  font-weight: 600; text-decoration: none; margin-top: 12px;
}
.ms-button:hover { filter: brightness(1.1); }

/* Chat */
.chatbody { display:flex; flex-direction:column; height:100vh; }
.messages {
  flex: 1 1 auto; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.msg { max-width: 75%; padding: 8px 12px; border-radius: 10px; line-height:1.35; word-wrap:break-word; }
.msg .tag { font-size: 11px; opacity: .7; display:block; margin-bottom: 2px; }
.msg.me { align-self: flex-start; background:#2a4cff; color:white; border-bottom-left-radius:2px; }
.msg.them { align-self: flex-start; background:#23272f; border-bottom-left-radius:2px; }
.msg.sys {
  align-self: center; background: transparent; color:#8a90a0;
  font-size: 12px; font-style: italic; max-width: 100%;
}
.fileLink { color: inherit; text-decoration: underline; word-break: break-all; }

.composer {
  display:flex; gap:8px; padding: 10px;
  background:#14171d; border-top:1px solid #232831; align-items:center;
}
.composer input[type="text"], .composer input:not([type]) { flex:1; }
.composer button { width: auto; padding: 10px 18px; margin: 0; }
#attachBtn { padding: 10px 14px; }

.overlay {
  position: fixed; inset: 0; background: rgba(10,12,16,.85);
  display:flex; align-items:center; justify-content:center; padding: 16px; z-index: 100;
}

.overlay[hidden] { display: none; }

/* Admin */
.tablewrap { overflow-x: auto; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #2a2f38; vertical-align: top; }
th { color: #aab; font-weight: 600; }
tbody tr:hover { background: #1d2128; }
td button { width: auto; margin: 0 4px 0 0; padding: 6px 10px; font-size: 13px; }
td a { text-decoration: none; }

.badge {
  display:inline-block; background:#2a2f38; color:#cfd2da; border-radius: 999px;
  padding: 2px 10px; font-size: 12px; margin-left: 6px;
}

.transcript {
  background:#0f1217; border:1px solid #2a2f38; border-radius:8px;
  padding: 12px; max-height: 60vh; overflow:auto; white-space:pre-wrap;
  word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.btnrow button { width: auto; flex: 1 1 auto; min-width: 160px; margin-top: 0; }
textarea { font-family: inherit; resize: vertical; min-height: 60px; }
