/* Nika's Server — shared styles.
   Plain, practical UI: flat surfaces, 1px borders, system type, one accent. */

:root {
  --bg: #f5f5f6;
  --surface: #ffffff;
  --surface-2: #efeff1;
  --border: #dcdce1;
  --text: #191a1c;
  --muted: #666a73;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --danger: #b42318;
  --ok: #177245;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 18, 22, 0.06);
}

html[data-theme="dark"] {
  --bg: #141518;
  --surface: #1b1d21;
  --surface-2: #22252a;
  --border: #2f333a;
  --text: #e6e7ea;
  --muted: #9aa0aa;
  --accent: #5b8cff;
  --accent-text: #0d1015;
  --danger: #f97066;
  --ok: #4ade80;
  --shadow: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 12px; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 30px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 14px; }

code, pre {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

/* ---------- layout ---------- */

main { flex: 1; width: 100%; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 760px; }

.section { padding: 56px 0; }
.section + .section { border-top: 1px solid var(--border); }
.section h2 { margin-bottom: 16px; }
.section p { color: var(--muted); max-width: 68ch; }

/* ---------- top nav ---------- */

.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.nav-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { color: var(--text); font-weight: 650; font-size: 16px; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand span { color: var(--accent); }

.nav-links { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.nav-links a {
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
}
.nav-links a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--text); background: var(--surface-2); }

/* the nav sign-in button must keep its own colours (link rules win otherwise) */
.nav-links a.btn,
.nav-links a.btn:hover { color: var(--accent-text); padding: 6px 12px; }
.nav-links a.btn:hover { background: var(--accent); filter: brightness(1.07); }
.nav-links a.btn.secondary,
.nav-links a.btn.secondary:hover { color: var(--text); }
.nav-links a.btn.secondary:hover { background: var(--surface-2); }

.nav-user { color: var(--muted); font-size: 14px; padding: 0 6px; }

.icon-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }

/* ---------- buttons & form controls ---------- */

.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn.danger { background: var(--danger); color: #fff; }
html[data-theme="dark"] .btn.danger { color: #2b0b08; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: default; }

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
}
.link-btn:hover { color: var(--danger); background: var(--surface-2); }

input[type="text"], input[type="password"], input[type="search"], select, textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }

input[type="file"] { font: inherit; font-size: 14px; color: var(--muted); max-width: 100%; }
input[type="file"]::file-selector-button {
  font: inherit;
  font-size: 13px;
  margin-right: 10px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { border-color: var(--accent); }
.field { margin-bottom: 14px; }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.notice {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--muted);
}

.error-text { color: var(--danger); font-size: 13px; margin: 0 0 12px; }

/* ---------- hero ---------- */

.hero { padding: 88px 0 72px; }
.hero h1 { font-size: 40px; max-width: 20ch; margin-bottom: 16px; }
.hero p { font-size: 17px; color: var(--muted); max-width: 56ch; margin-bottom: 26px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.hero-meta {
  margin-top: 40px;
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}
.hero-meta strong { display: block; color: var(--text); font-size: 15px; font-weight: 600; }

/* ---------- footer ---------- */

.bottombar {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}
.bottombar a, .bottombar button {
  color: var(--muted);
  background: none;
  border: none;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
.bottombar a:hover, .bottombar button:hover { color: var(--accent); text-decoration: none; }

/* ---------- modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(9, 10, 12, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 460px;
  padding: 22px;
  max-height: 88vh;
  overflow: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }

.rating { display: flex; gap: 4px; margin-bottom: 14px; }
.rating button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 38px;
  height: 34px;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
}
.rating button.on { border-color: var(--accent); color: var(--accent); background: var(--surface-2); }

/* ---------- auth ---------- */

.auth-shell { max-width: 420px; margin: 64px auto; padding: 0 24px; }
.auth-card { padding: 26px; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin: -6px 0 20px; }
.auth-tabs a {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.auth-tabs a:hover { text-decoration: none; color: var(--text); }
.auth-tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.auth-foot { margin-top: 14px; font-size: 13px; color: var(--muted); }

/* ---------- discord chat ---------- */

body.chat-page main { display: flex; }

.chat-shell {
  --d-bg: #313338;
  --d-sidebar: #2b2d31;
  --d-rail: #1e1f22;
  --d-strong: #f2f3f5;
  --d-text: #dbdee1;
  --d-muted: #949ba4;
  --d-hover: #35373c;
  --d-active: #404249;
  --d-input: #383a40;
  --d-blurple: #5865f2;

  display: grid;
  grid-template-columns: 68px 236px minmax(0, 1fr);
  width: 100%;
  height: calc(100vh - 112px);
  background: var(--d-bg);
  color: var(--d-text);
  overflow: hidden;
  font-size: 15px;
}

.rail { background: var(--d-rail); padding: 12px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; overflow-y: auto; }
.rail-btn {
  width: 44px; height: 44px;
  border: none; border-radius: 14px;
  background: var(--d-sidebar); color: var(--d-strong);
  font-size: 17px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.rail-btn:hover { border-radius: 12px; background: var(--d-blurple); }
.rail-btn.active { border-radius: 12px; background: var(--d-blurple); }
.rail-sep { width: 32px; height: 1px; background: #3a3c42; margin: 4px 0; }

.sidebar { background: var(--d-sidebar); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head {
  height: 48px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; border-bottom: 1px solid #232428; color: var(--d-strong);
  font-weight: 600; font-size: 14px;
}
.sidebar-scroll { overflow-y: auto; padding: 10px 8px 16px; flex: 1; }
.sidebar-group h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--d-muted); margin: 14px 8px 4px; font-weight: 700;
}
.side-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 4px; cursor: pointer;
  color: var(--d-muted); font-size: 14px; white-space: nowrap; overflow: hidden;
}
.side-item:hover { background: var(--d-hover); color: var(--d-text); }
.side-item.active { background: var(--d-active); color: var(--d-strong); }
.side-item .name { overflow: hidden; text-overflow: ellipsis; }
.side-item .tag { margin-left: auto; font-size: 11px; background: #3b3d44; border-radius: 4px; padding: 1px 5px; }

.me-panel {
  border-top: 1px solid #232428; background: #232428;
  padding: 8px 10px; display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.me-panel:hover { background: #2a2c31; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--d-blurple); color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.me-panel .who { min-width: 0; }
.me-panel .who strong { display: block; font-size: 13px; color: var(--d-strong); font-weight: 600; }
.me-panel .who small { display: block; font-size: 11px; color: var(--d-muted); }

.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--d-bg); }
.chat-head {
  height: 48px; flex: none; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-bottom: 1px solid #26282d; color: var(--d-strong);
  font-weight: 600; font-size: 15px;
}
.chat-head .sub { font-size: 12px; color: var(--d-muted); font-weight: 400; }
.chat-head .spacer { flex: 1; }
.chat-head button {
  background: none; border: none; color: var(--d-muted); cursor: pointer;
  font-size: 13px; padding: 5px 8px; border-radius: 4px;
}
.chat-head button:hover { background: var(--d-hover); color: var(--d-strong); }

.messages { flex: 1; overflow-y: auto; padding: 16px 16px 8px; min-height: 0; }
.msg { padding: 4px 8px; border-radius: 4px; position: relative; }
.msg:hover { background: rgba(0, 0, 0, 0.06); }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-author { color: var(--d-strong); font-weight: 600; font-size: 15px; cursor: pointer; }
.msg-author:hover { text-decoration: underline; }
.msg-time { font-size: 11px; color: var(--d-muted); }
.msg-text { color: var(--d-text); white-space: pre-wrap; word-wrap: break-word; }
.msg-reactions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.reaction {
  background: #3a3c42; border: 1px solid #47494f; border-radius: 8px;
  padding: 1px 6px; font-size: 12px; cursor: pointer; color: var(--d-text);
}
.reaction.mine { border-color: var(--d-blurple); background: #3d4270; }
.reaction:hover { border-color: #6c6f78; }

.msg-actions { position: absolute; right: 10px; top: -10px; display: none; gap: 2px; background: var(--d-sidebar); border: 1px solid #26282d; border-radius: 5px; padding: 2px; }
.msg:hover .msg-actions { display: flex; }
.msg-actions button { background: none; border: none; cursor: pointer; font-size: 13px; padding: 2px 5px; border-radius: 3px; color: var(--d-text); }
.msg-actions button:hover { background: var(--d-hover); }

.composer { padding: 0 16px 18px; flex: none; }
.composer-inner { background: var(--d-input); border-radius: 8px; padding: 4px 10px; display: flex; align-items: flex-end; gap: 8px; }
.composer textarea {
  background: none; border: none; color: var(--d-text); resize: none;
  padding: 9px 0; max-height: 140px; font-size: 15px; flex: 1;
}
.composer textarea:focus { outline: none; }
.composer .send {
  background: var(--d-blurple); color: #fff; border: none; border-radius: 4px;
  padding: 6px 12px; margin: 5px 0; cursor: pointer; font-size: 13px; font-weight: 600;
}

.emoji-bar { display: flex; gap: 4px; flex-wrap: wrap; padding: 6px 2px 0; }
.emoji-bar button { background: none; border: 1px solid transparent; border-radius: 4px; cursor: pointer; font-size: 15px; padding: 2px 4px; }
.emoji-bar button:hover { background: var(--d-hover); }

.msg-picker {
  position: absolute;
  right: 10px;
  top: 26px;
  display: flex;
  gap: 2px;
  background: var(--d-sidebar);
  border: 1px solid #26282d;
  border-radius: 6px;
  padding: 4px;
  z-index: 6;
}
.msg-picker button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 3px 4px;
  border-radius: 3px;
}
.msg-picker button:hover { background: var(--d-hover); }

.empty-state { color: var(--d-muted); font-size: 14px; padding: 30px 10px; text-align: center; }

/* ---------- files ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 9px 14px; font: inherit; font-size: 14px; color: var(--muted);
  cursor: pointer; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

.file-list { display: flex; flex-direction: column; gap: 10px; }
.file-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
}
.file-icon { width: 36px; height: 36px; border-radius: 6px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 16px; flex: none; }
.file-main { min-width: 0; flex: 1; }
.file-name { font-weight: 550; font-size: 14px; word-break: break-word; }
.file-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.file-actions { display: flex; gap: 6px; flex: none; }

.upload-form { margin-bottom: 24px; }
.upload-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.upload-row .grow { flex: 1; min-width: 220px; }
.shared-picker { border: 1px solid var(--border); border-radius: 6px; max-height: 180px; overflow: auto; padding: 8px; margin-top: 12px; }
.shared-picker label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin: 0 0 6px; }
.shared-picker input { width: auto; }

#previewBody img, #previewBody video { max-width: 100%; border-radius: 6px; background: #000; }
#previewBody pre {
  text-align: left; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 12px; max-height: 52vh; overflow: auto; white-space: pre-wrap;
}
.preview-modal-box { max-width: 760px; }

/* ---------- admin ---------- */

.admin-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.admin-tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 9px 14px; font: inherit; font-size: 14px; color: var(--muted);
  cursor: pointer; margin-bottom: -1px;
}
.admin-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

.panel { display: none; }
.panel.active { display: block; }
.panel > h2 { margin-bottom: 14px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: none; }

.log {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; margin-bottom: 6px; font-size: 13px;
  background: var(--surface);
}
.log.private { border-color: rgba(180, 35, 24, 0.35); background: rgba(180, 35, 24, 0.06); }
.log .who { font-weight: 600; }
.log .when { color: var(--muted); font-size: 11px; margin-left: 8px; }
.log .body { margin-top: 3px; word-break: break-word; }

.badge { display: inline-block; font-size: 11px; border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; color: var(--muted); }
.badge.admin { border-color: var(--accent); color: var(--accent); }

/* ---------- misc ---------- */

.empty { color: var(--muted); font-size: 14px; padding: 20px 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 0.08em; }
.hidden-admin-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .hero { padding: 56px 0 44px; }
  .hero h1 { font-size: 31px; }
  .chat-shell { grid-template-columns: 56px 190px minmax(0, 1fr); }
}

@media (max-width: 680px) {
  .nav-inner { height: auto; padding: 8px 16px; flex-wrap: wrap; }
  .nav-links { gap: 0; }
  .section { padding: 36px 0; }
  .wrap { padding: 0 16px; }
  .chat-shell { grid-template-columns: 52px minmax(0, 1fr); height: calc(100vh - 150px); }
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: absolute; left: 52px; top: 0; bottom: 0; width: 220px; z-index: 5; }
  .file-row { flex-wrap: wrap; }
}
