@import url('https://fonts.googleapis.com/css2?family=Zen+Kaku+Gothic+New:wght@400;600;700&family=Space+Grotesk:wght@500;700&display=swap');

:root {
  --bg: #0a0c12;
  --bg-2: #121728;
  --panel: #151b2b;
  --panel-2: #1b2236;
  --panel-3: #101523;
  --accent: #ff8b3d;
  --accent-2: #3dd6ff;
  --accent-3: #a37bff;
  --text: #f3f4f6;
  --muted: #9aa3b2;
  --line: rgba(255, 255, 255, 0.08);
  --danger: #ff6464;
  --ok: #3ddc97;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  --glow: 0 0 0 2px rgba(255, 139, 61, 0.18), 0 10px 30px rgba(255, 139, 61, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Zen Kaku Gothic New", "Space Grotesk", sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 139, 61, 0.2), transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(61, 214, 255, 0.12), transparent 30%),
    linear-gradient(180deg, #0a0c12 0%, #0f1421 40%, #0a0c12 100%);
  color: var(--text);
  min-height: 100vh;
}

.app {
  display: grid;
  grid-template-columns: 84px 270px 1fr 260px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 30%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 120px);
}

.guilds {
  background: #0a0d16;
  border-right: 1px solid var(--line);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.guild-logo {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ff8b3d, #ff5f57);
  display: grid;
  place-items: center;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.guild-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  width: 100%;
  align-items: center;
  padding-top: 8px;
}

.guild {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  border: 1px solid transparent;
  background: #141a2a;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s ease;
  position: relative;
}

.guild::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.2s ease;
  background: radial-gradient(circle, rgba(255, 139, 61, 0.2), transparent 70%);
}

.guild.active,
.guild:hover {
  border-color: rgba(255, 139, 61, 0.5);
  box-shadow: var(--glow);
}

.guild.active::after,
.guild:hover::after {
  opacity: 1;
}

.guild-add,
.guild-join {
  width: 46px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #111624;
  color: var(--text);
  padding: 8px 0;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.guild-add:hover,
.guild-join:hover {
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.sidebar {
  background: linear-gradient(180deg, #111624, #0c101b 70%);
  border-right: 1px solid var(--line);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guild-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.guild-actions {
  display: flex;
  gap: 8px;
}

.guild-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.invite-btn {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.invite-btn:hover {
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.channel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.add-channel {
  background: var(--accent);
  border: none;
  color: #151515;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(255, 139, 61, 0.2);
  transition: all 0.2s ease;
}

.add-channel:hover {
  transform: translateY(-1px);
}

.add-channel.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.channels {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.category {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-title {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
}

.channel {
  padding: 10px 12px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.channel::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 139, 61, 0.4);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.channel.active {
  color: var(--text);
  border-color: rgba(255, 139, 61, 0.4);
  background: rgba(255, 139, 61, 0.12);
}

.channel.active::before {
  opacity: 1;
}

.channel:hover {
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.badge {
  background: var(--accent);
  color: #101010;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
}

.chat {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #1b2236 0%, #151b2b 100%);
}

.chat-title {
  font-size: 20px;
  font-weight: 700;
}

.chat-meta {
  font-size: 12px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-btn {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-btn:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.user-pill {
  background: rgba(255, 255, 255, 0.1);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.message-tools {
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-3);
}

.notif-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.notif-badge.active {
  background: rgba(255, 139, 61, 0.15);
  color: var(--accent);
}

.messages {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  animation: fadeIn 0.3s ease;
}

.message.deleted {
  opacity: 0.6;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  font-weight: 700;
  background-size: cover;
  background-position: center;
}

.message-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message .meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}

.message .pin {
  font-size: 12px;
  color: var(--accent);
}

.message .user {
  color: var(--text);
  font-weight: 600;
}

.message .edited {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}

.message-actions {
  display: flex;
  gap: 6px;
}

.message-actions button {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
}

.message-actions button:hover {
  border-color: rgba(255, 139, 61, 0.4);
}

.composer {
  display: flex;
  gap: 12px;
  padding: 16px 24px 24px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 21, 35, 0.6), transparent);
}

.composer input {
  flex: 1;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
}

.composer input:focus {
  outline: none;
  border-color: rgba(61, 214, 255, 0.5);
  box-shadow: 0 0 0 2px rgba(61, 214, 255, 0.15);
}

.composer button {
  border-radius: 12px;
  border: none;
  background: var(--accent-2);
  color: #08161c;
  font-weight: 700;
  padding: 0 18px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.composer button:hover {
  transform: translateY(-1px);
}

.presence {
  background: linear-gradient(180deg, #101420, #0b0f19 60%);
  border-left: 1px solid var(--line);
  padding: 20px 16px;
}

.presence-card {
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  height: 100%;
  box-shadow: var(--shadow);
}

.presence-title {
  font-weight: 700;
  margin-bottom: 12px;
}

.members {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.member {
  display: flex;
  gap: 10px;
  align-items: center;
}

.member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  display: grid;
  place-items: center;
  font-weight: 700;
  background-size: cover;
  background-position: center;
}

.member-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.member-name {
  font-size: 14px;
}

.member-role {
  margin-left: auto;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
}

.member-status {
  font-size: 11px;
  color: var(--muted);
}

.member-status.online {
  color: var(--ok);
}

.member-status.dnd {
  color: var(--danger);
}

.member-status.idle {
  color: #ffd166;
}

.member-status.offline {
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6, 8, 12, 0.8);
  backdrop-filter: blur(6px);
  z-index: 20;
}

.modal.open {
  display: flex;
}

.modal-card {
  background: #141824;
  padding: 28px;
  border-radius: 18px;
  width: min(420px, 90vw);
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: rise 0.4s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-card input,
.modal-card select {
  width: 100%;
  padding: 12px;
  margin: 6px 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
}

.modal-card button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #0e0e0e;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.modal-card button:hover {
  transform: translateY(-1px);
}

.modal-card .secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.agree-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.agree-row input {
  width: auto;
}

.nostr-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.settings-label {
  font-weight: 600;
}

.settings-status {
  font-size: 13px;
  color: var(--muted);
}

.settings-actions button {
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #0e0e0e;
  font-weight: 600;
  cursor: pointer;
}

.profile-form label {
  font-size: 12px;
  color: var(--muted);
}

.role-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.role-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.role-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.role-item {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-size: 12px;
}

.role-editor {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
}

.role-perms {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.role-perms label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.role-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.modal-error {
  color: #ff9aa2;
  min-height: 20px;
  font-size: 13px;
}

.legal {
  max-width: 820px;
  margin: 40px auto;
  padding: 24px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.legal h1 {
  margin-top: 0;
}

.legal section {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.policy-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 12px;
}

.policy-links a {
  color: var(--muted);
  text-decoration: none;
}

.policy-links a:hover {
  color: var(--text);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 70px 220px 1fr;
  }
  .presence {
    display: none;
  }
}

@media (max-width: 800px) {
  .app {
    grid-template-columns: 1fr;
  }
  .guilds {
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--line);
    justify-content: center;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .channel-actions {
    grid-template-columns: 1fr 1fr;
  }
}
