*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #070d1a;
  --bg2:       #0c1526;
  --panel:     rgba(16, 26, 48, 0.85);
  --panel2:    rgba(12, 21, 38, 0.7);
  --border:    rgba(80, 120, 200, 0.16);
  --border-hi: rgba(80, 160, 255, 0.42);
  --text:      #dde6f5;
  --muted:     #7a8fa8;
  --faint:     rgba(122, 143, 168, 0.55);
  --accent:    #4f9eff;
  --accent2:   #7c5cfa;
  --gold:      #f0b429;
  --gold-dim:  rgba(240, 180, 41, 0.14);
  --cyan:      #22d3ee;
  --cyan-dim:  rgba(34, 211, 238, 0.12);
  --slate-dim: rgba(100, 120, 155, 0.14);
  --green:     #34d399;
  --green-dim: rgba(52, 211, 153, 0.1);
  --red:       #f87171;
  --red-dim:   rgba(248, 113, 113, 0.12);
  --sb-w:      236px;
  --r:         14px;
}

html, body { width: 100%; min-height: 100vh; }
body {
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 18% 5%,  rgba(79,158,255,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 95%, rgba(124,92,250,0.10) 0%, transparent 60%);
}
a { color: var(--accent); }
::selection { background: rgba(79,158,255,0.3); }

.view { display: none; min-height: 100vh; position: relative; z-index: 2; }
.view.active { display: flex; }

/* ── FORM PRIMITIVES ── */
.fg { display: flex; flex-direction: column; gap: 0.4rem; }
.fg label {
  font-size: 0.72rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.07em;
}
.fg label .opt { text-transform: none; letter-spacing: 0; color: var(--faint); font-weight: 400; }
.fg input, .fg select, .fg textarea {
  background: rgba(7, 13, 26, 0.8);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.72rem 1rem;
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-size: 0.9rem; width: 100%; outline: none; resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.fg input:focus, .fg select:focus, .fg textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,158,255,0.10);
}
.fg select option { background: #0c1526; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.7rem 1.1rem; border-radius: 10px;
  font-family: "DM Sans", sans-serif; font-size: 0.875rem; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.18s; text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, #2e6be6 0%, #6d36f0 100%);
  color: #fff; box-shadow: 0 4px 18px rgba(79,158,255,0.3);
}
.btn-primary:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(79,158,255,0.4); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover { border-color: var(--border-hi); color: var(--text); background: rgba(79,158,255,0.06); }
.btn-danger { background: var(--red-dim); border: 1px solid rgba(248,113,113,0.28); color: var(--red); }
.btn-danger:hover { background: rgba(248,113,113,0.2); }
.btn-success { background: var(--green-dim); border: 1px solid rgba(52,211,153,0.3); color: var(--green); }
.btn-success:hover { background: rgba(52,211,153,0.18); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.err { color: var(--red); font-size: 0.78rem; text-align: center; min-height: 1em; }

/* ══════════ AUTH ══════════ */
#view-auth { align-items: center; justify-content: center; padding: 2rem; flex-direction: column; }
.auth-glow {
  position: fixed; width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, rgba(79,158,255,0.08) 0%, transparent 70%);
  top: 50%; left: 50%; transform: translate(-50%,-50%); pointer-events: none;
}
.auth-card {
  position: relative; width: min(400px, 100%);
  background: var(--panel); border: 1px solid var(--border); border-radius: 20px;
  backdrop-filter: blur(24px); padding: 2.4rem 2rem 1.6rem;
  display: flex; flex-direction: column; gap: 1.1rem;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
}
.auth-emblem {
  margin: 0 auto; width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, #2e6be6, #6d36f0);
  display: flex; align-items: center; justify-content: center; font-size: 1.8rem;
  box-shadow: 0 8px 28px rgba(79,158,255,0.35);
}
.auth-heading { text-align: center; }
.auth-heading h1 {
  font-family: "Rajdhani", sans-serif; font-size: 1.6rem; font-weight: 700; letter-spacing: 0.02em;
}
.auth-heading p { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }
.auth-tabs {
  display: flex; gap: 0.3rem; background: rgba(7,13,26,0.6);
  border: 1px solid var(--border); border-radius: 11px; padding: 0.25rem;
}
.auth-tab {
  flex: 1; padding: 0.55rem; border: none; background: transparent;
  color: var(--muted); font-family: "DM Sans", sans-serif; font-size: 0.83rem; font-weight: 600;
  border-radius: 8px; cursor: pointer; transition: all 0.18s;
}
.auth-tab.active { background: rgba(79,158,255,0.14); color: var(--accent); }
.auth-submit { width: 100%; padding: 0.9rem; }
.auth-note { font-size: 0.7rem; color: var(--faint); text-align: center; line-height: 1.4; }

/* ══════════ APP LAYOUT ══════════ */
#view-app { flex-direction: row; }
.sidebar {
  width: var(--sb-w); background: rgba(7, 13, 26, 0.92);
  border-right: 1px solid var(--border); backdrop-filter: blur(24px);
  display: flex; flex-direction: column; padding: 0 0.75rem 1.25rem;
  flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sb-brand {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 1.4rem 0.6rem 1.1rem; border-bottom: 1px solid var(--border); margin-bottom: 0.5rem;
}
.sb-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #2e6be6, #6d36f0);
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
  flex-shrink: 0; box-shadow: 0 4px 12px rgba(79,158,255,0.3);
}
.sb-brand-text { display: flex; flex-direction: column; }
.sb-name { font-family: "Rajdhani", sans-serif; font-size: 1rem; font-weight: 700; letter-spacing: 0.03em; line-height: 1.1; }
.sb-sub { font-size: 0.68rem; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.nav-group-label {
  font-size: 0.65rem; font-weight: 700; color: rgba(122,143,168,0.55);
  text-transform: uppercase; letter-spacing: 0.1em; padding: 0.75rem 0.6rem 0.3rem;
}
.nav-item {
  display: flex; align-items: center; gap: 0.65rem; padding: 0.6rem 0.75rem;
  border-radius: 10px; cursor: pointer; color: var(--muted); font-size: 0.875rem; font-weight: 500;
  transition: all 0.18s; border: 1px solid transparent; user-select: none; margin-bottom: 1px;
}
.nav-item:hover { color: var(--text); background: rgba(79,158,255,0.07); }
.nav-item.active { color: var(--accent); background: rgba(79,158,255,0.1); border-color: rgba(79,158,255,0.2); }
.nav-ico { font-size: 0.95rem; width: 18px; text-align: center; }
.sb-space { flex: 1; }
.sb-footer { border-top: 1px solid var(--border); padding-top: 0.85rem; display: flex; flex-direction: column; gap: 0.5rem; }
.user-pill {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem;
  background: var(--panel2); border-radius: 10px; border: 1px solid var(--border); cursor: pointer;
  transition: border-color 0.18s;
}
.user-pill:hover { border-color: var(--border-hi); }
.user-head { width: 30px; height: 30px; border-radius: 7px; image-rendering: pixelated; flex-shrink: 0; background: var(--bg2); }
.user-pill-text { display: flex; flex-direction: column; min-width: 0; }
.user-pill-name { font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-pill-rank { font-size: 0.68rem; color: var(--muted); }

.main { flex: 1; padding: 2rem 2rem 3rem; overflow-y: auto; min-height: 100vh; max-width: 1100px; }

/* ── PAGE HEADER ── */
.page-hdr {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 1.75rem; flex-wrap: wrap; gap: 1rem;
}
.page-title { font-family: "Rajdhani", sans-serif; font-size: 1.7rem; font-weight: 700; letter-spacing: 0.02em; }
.page-sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }
.page-enter { animation: fadeUp 0.25s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.sec-label {
  font-size: 0.68rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.09em; margin: 1.5rem 0 0.75rem;
}

/* ── GUILD CARDS ── */
.guild-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.guild-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r);
  backdrop-filter: blur(14px); padding: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem;
  position: relative; overflow: hidden; transition: all 0.22s;
}
.guild-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); opacity: 0.7;
}
.guild-card:hover { border-color: var(--border-hi); transform: translateY(-3px); box-shadow: 0 16px 40px rgba(0,0,0,0.4); }
.guild-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.guild-crest {
  width: 46px; height: 46px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(135deg, #1c2d52, #2a1d52);
  border: 1px solid var(--border-hi);
  display: flex; align-items: center; justify-content: center;
  font-family: "Rajdhani", sans-serif; font-weight: 700; font-size: 0.9rem; color: var(--accent); letter-spacing: 0.04em;
}
.guild-name { font-family: "Rajdhani", sans-serif; font-size: 1.15rem; font-weight: 700; line-height: 1.15; }
.guild-tag { font-size: 0.7rem; color: var(--accent); font-weight: 600; letter-spacing: 0.05em; }
.guild-desc { font-size: 0.82rem; color: var(--muted); line-height: 1.45; min-height: 1.2em; }
.guild-meta { display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--faint); flex-wrap: wrap; }
.guild-meta .dot-sep { opacity: 0.5; }
.guild-card-actions { display: flex; gap: 0.5rem; margin-top: auto; }
.guild-card-actions .btn { flex: 1; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.18rem 0.55rem;
  border-radius: 5px; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
}
.badge-Leader  { background: var(--gold-dim);  color: var(--gold);  border: 1px solid rgba(240,180,41,0.3); }
.badge-Officer { background: var(--cyan-dim);  color: var(--cyan);  border: 1px solid rgba(34,211,238,0.3); }
.badge-Member  { background: var(--slate-dim); color: var(--muted); border: 1px solid rgba(100,120,155,0.25); }
.rank-badge {
  display: inline-flex; align-items: center; padding: 0.16rem 0.5rem; border-radius: 5px;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.04em;
}

/* ── MEMBER LIST ── */
.member-list { display: flex; flex-direction: column; gap: 0.5rem; }
.member-row {
  display: flex; align-items: center; gap: 0.85rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.7rem 1rem; transition: border-color 0.18s;
}
.member-row:hover { border-color: var(--border-hi); }
.mc-head { width: 40px; height: 40px; border-radius: 7px; image-rendering: pixelated; border: 1px solid var(--border); flex-shrink: 0; background: var(--bg2); }
.member-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.member-name { font-family: "Rajdhani", sans-serif; font-size: 0.98rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.member-sub { font-size: 0.72rem; color: var(--muted); }
.member-badges { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; flex-wrap: wrap; }
.member-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }

/* ── REQUESTS ── */
.req-row { display: flex; align-items: center; gap: 0.85rem; background: var(--panel); border: 1px solid rgba(240,180,41,0.22); border-radius: 12px; padding: 0.7rem 1rem; }
.req-msg { font-size: 0.78rem; color: var(--muted); font-style: italic; }

/* ── CHAT ── */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 230px); min-height: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: 0.9rem; }
.chat-msg { display: flex; gap: 0.7rem; }
.chat-msg .mc-head { width: 34px; height: 34px; }
.chat-body { min-width: 0; }
.chat-line1 { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.chat-author { font-weight: 600; font-size: 0.85rem; }
.chat-time { font-size: 0.68rem; color: var(--faint); }
.chat-text { font-size: 0.88rem; color: var(--text); line-height: 1.45; word-break: break-word; white-space: pre-wrap; }
.chat-composer { display: flex; gap: 0.6rem; padding: 0.85rem; border-top: 1px solid var(--border); background: rgba(7,13,26,0.5); }
.chat-composer input { flex: 1; }

/* ── TABS ── */
.tabs { display: flex; gap: 0.4rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab {
  padding: 0.6rem 0.9rem; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); font-family: "DM Sans", sans-serif; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: all 0.18s; display: inline-flex; align-items: center; gap: 0.4rem;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count { background: rgba(240,180,41,0.18); color: var(--gold); font-size: 0.66rem; padding: 0.05rem 0.4rem; border-radius: 999px; }

/* ── SETTINGS / PANELS ── */
.panel-block {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r);
  padding: 1.5rem; margin-bottom: 1rem; display: flex; flex-direction: column; gap: 1rem;
}
.panel-block-title {
  font-size: 0.68rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.09em; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border);
}
.profile-hero { display: flex; align-items: center; gap: 1.1rem; }
.profile-hero .mc-head { width: 80px; height: 80px; border-radius: 12px; border: 2px solid rgba(79,158,255,0.25); box-shadow: 0 0 20px rgba(79,158,255,0.15); }
.profile-hero-name { font-family: "Rajdhani", sans-serif; font-size: 1.45rem; font-weight: 700; }
.stat-inline { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.stat-inline .s { display: flex; flex-direction: column; }
.stat-inline .s b { font-family: "Rajdhani", sans-serif; font-size: 1.3rem; }
.stat-inline .s span { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ── EMPTY ── */
.empty { grid-column: 1 / -1; text-align: center; padding: 3.5rem 2rem; color: var(--muted); }
.empty-ico { font-size: 2.8rem; margin-bottom: 0.85rem; opacity: 0.5; }
.empty-title { font-size: 0.95rem; font-weight: 600; color: var(--text); margin-bottom: 0.35rem; opacity: 0.8; }
.empty-sub { font-size: 0.82rem; }

/* ── MODAL ── */
.overlay {
  position: fixed; inset: 0; background: rgba(2, 6, 18, 0.78); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; z-index: 200; padding: 1.5rem;
}
.overlay.open { display: flex; animation: fadeIn 0.18s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #0c1526; border: 1px solid var(--border); border-radius: 20px; padding: 2rem;
  width: min(460px, 100%); max-height: 92vh; overflow-y: auto; display: flex; flex-direction: column;
  gap: 1.1rem; position: relative; box-shadow: 0 40px 100px rgba(0,0,0,0.65); animation: modalPop 0.22s ease;
}
@keyframes modalPop { from { opacity: 0; transform: scale(0.97) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-title { font-family: "Rajdhani", sans-serif; font-size: 1.3rem; font-weight: 700; letter-spacing: 0.02em; }
.modal-x {
  position: absolute; top: 1.1rem; right: 1.1rem; background: rgba(122,143,168,0.1); border: none;
  border-radius: 8px; width: 30px; height: 30px; color: var(--muted); cursor: pointer; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center; transition: all 0.18s;
}
.modal-x:hover { background: rgba(248,113,113,0.18); color: var(--red); }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; background: #0e1c35; border: 1px solid var(--border);
  border-radius: 12px; padding: 0.85rem 1.1rem; font-size: 0.875rem; font-weight: 500; z-index: 999;
  transform: translateY(140%); transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  max-width: 300px; box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}
.toast.show { transform: translateY(0); }
.toast.ok  { border-color: rgba(52,211,153,0.4); color: var(--green); }
.toast.bad { border-color: rgba(248,113,113,0.4); color: var(--red); }

/* ── LOADING ── */
.loading { text-align: center; padding: 3rem; color: var(--muted); font-size: 0.85rem; }
.spinner {
  width: 28px; height: 28px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; margin: 0 auto 0.85rem; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── RESPONSIVE ── */
@media (max-width: 760px) {
  #view-app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 60; flex-direction: row;
    align-items: center; padding: 0.5rem 0.75rem; gap: 0.4rem; overflow-x: auto; flex-wrap: wrap;
  }
  .sb-brand { border: none; padding: 0.4rem; margin: 0; }
  .nav-group-label { display: none; }
  .nav-item { padding: 0.45rem 0.6rem; }
  .sb-space { display: none; }
  .sb-footer { border: none; padding: 0; flex-direction: row; margin-left: auto; align-items: center; gap: 0.5rem; }
  .sb-footer .btn-ghost { width: auto; }
  .main { padding: 1.25rem 1rem 3rem; }
  .chat-wrap { height: calc(100vh - 280px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.05ms !important; }
}
