:root {
  --bg: #0f0f12;
  --bg-card: #1a1a20;
  --border: #2a2a32;
  --text: #e8e8ec;
  --text-muted: #888;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --err: #ef4444;
  --radius: 10px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
.hidden { display: none !important; }

#login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  text-align: center;
}
.login-header h1 { font-size: 2rem; margin: 0 0 0.5rem; }
.login-header p { color: var(--text-muted); margin: 0 0 1.5rem; }

.login-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
  max-width: 380px;
  margin-bottom: 1.25rem;
}
.login-tab {
  flex: 1;
  padding: 0.6rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}
.login-tab.active { background: var(--accent); color: #fff; }
.login-tab:not(.active):hover { background: rgba(255,255,255,0.05); }

.auth-form {
  width: 100%;
  max-width: 380px;
  text-align: left;
}
.auth-form label { display: block; margin-bottom: 1rem; }
.auth-form input { width: 100%; max-width: 100%; }
.auth-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--err);
  color: var(--err);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}
.auth-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
  line-height: 1.4;
}
.btn-full { width: 100%; text-align: center; }

#main-screen {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.logo { font-weight: 700; font-size: 1.1rem; }
.user-name { display: block; color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }
.nav { flex: 1; padding: 0.75rem 0; overflow-y: auto; }
.nav-link {
  display: block;
  padding: 0.6rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}
.nav-link:hover { background: rgba(255,255,255,0.05); }
.nav-link.active { background: rgba(99, 102, 241, 0.2); color: var(--accent); }
.chat-nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  margin-left: 0.35rem;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}
.nav-admin { border-top: 1px solid var(--border); margin-top: 0.5rem; padding-top: 0.5rem; }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); }

.content { flex: 1; padding: 1.5rem 2rem; overflow-y: auto; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 900px;
}
.card h2 { margin: 0 0 1rem; font-size: 1.35rem; }
.card h3 { margin: 1.5rem 0 0.75rem; font-size: 1.1rem; }
.card p { margin: 0.5rem 0; }

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}
.btn:hover { background: var(--accent-hover); }
.btn-primary { margin-top: 0.5rem; }
.btn-small { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-text { background: transparent; color: var(--text-muted); }
.btn-text:hover { color: var(--text); }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }

.alliance-actions { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.alliance-block { flex: 1; min-width: 220px; }

form label { display: block; margin-bottom: 1rem; }
form input, form select, form textarea {
  width: 100%;
  max-width: 400px;
  padding: 0.5rem 0.75rem;
  margin-top: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
form textarea { min-height: 100px; resize: vertical; }

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}
.table th, .table td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--text-muted); font-weight: 600; font-size: 0.85rem; }
.table td.alliance-actions-cell { white-space: nowrap; vertical-align: middle; overflow: visible; }
.table-alliance-members { border-collapse: separate; border-spacing: 0; }

.alliance-actions-muted { color: var(--text-muted); font-size: 0.9rem; }
.alliance-action-select {
  min-width: 11rem;
  max-width: 100%;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.alliance-action-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.link { color: var(--accent); margin-right: 0.5rem; }
.link:hover { text-decoration: underline; }
.link.active { font-weight: 600; }
.err { color: var(--err); }

.guide-item { margin-bottom: 1.5rem; }
.guide-img { max-width: 100%; height: auto; border-radius: 6px; margin-top: 0.5rem; display: block; }
.guide-text { white-space: pre-wrap; background: var(--bg); padding: 1rem; border-radius: 6px; margin-top: 0.5rem; font-size: 0.9rem; max-height: 400px; overflow-y: auto; }

.help-details { margin-bottom: 0.75rem; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.help-details summary { padding: 0.75rem 1rem; cursor: pointer; }
.help-text { padding: 1rem; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }

.feedback-item, .admin-feedback-item { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.feedback-item .reply, .admin-feedback-item .reply { color: var(--text-muted); margin-top: 0.5rem; font-size: 0.9rem; }
.reply-form { margin-top: 0.5rem; }
.reply-form input { max-width: 300px; margin-right: 0.5rem; }

.chat-hint { color: var(--text-muted); font-size: 0.9rem; margin-top: -0.25rem; }
.chat-tabs { display: flex; gap: 0.5rem; margin: 1rem 0; }
.chat-tab.active { background: var(--accent-hover); }
.chat-list {
  max-height: 460px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  background: var(--bg);
}
.chat-empty { color: var(--text-muted); margin: 0.25rem 0; }
.chat-item { padding: 0.65rem 0.35rem; border-bottom: 1px solid var(--border); }
.chat-item:last-child { border-bottom: none; }
.chat-item-meta { display: flex; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.3rem; }
.chat-item-meta small { color: var(--text-muted); font-size: 0.8rem; }
.chat-nick { cursor: pointer; text-decoration: underline dotted; }
.chat-nick:hover { color: var(--accent-hover); }
.chat-item-text { white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.chat-form { margin-top: 0.9rem; }
.chat-form textarea { max-width: 100%; min-height: 90px; }
.chat-emoji-row { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.6rem; }
.chat-emoji-select { width: 200px; max-width: 200px; }
.chat-actions { display: flex; gap: 0.5rem; align-items: center; }
.chat-mention-menu {
  position: fixed;
  z-index: 1000;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 420px;
  width: 100%;
}
.modal-box h3 { margin: 0 0 0.75rem; font-size: 1.1rem; }
.modal-box label { display: block; margin: 0.75rem 0; }
.modal-box input[type="text"] { width: 100%; max-width: 100%; margin-top: 0.35rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }

@media (max-width: 768px) {
  #main-screen { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .nav { display: flex; flex-wrap: wrap; padding: 0.5rem; }
  .nav-link { padding: 0.5rem; }
  .content { padding: 1rem; }
  .chat-emoji-row { flex-wrap: wrap; }
  .chat-emoji-select { width: 100%; max-width: 100%; }
}
