:root {
  --bg: #0f0f12;
  --surface: #18181f;
  --surface-hover: #22222c;
  --border: #2a2a36;
  --text: #e8e8ed;
  --text-muted: #8888a0;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --system: #22c55e;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 2rem;
}

.hidden { display: none !important; }

.back-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  transition: color 0.2s;
}
.back-link:hover { color: var(--accent-hover); }

.loading, .not-found {
  text-align: center;
  padding: 4rem;
  color: var(--text-muted);
  font-size: 1rem;
}

.profile {
  max-width: 640px;
  margin: 0 auto;
}

.profile-header {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.avatar-placeholder {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Unbounded', sans-serif;
  font-size: 2rem;
  font-weight: 600;
  color: white;
  border: 2px solid var(--border);
}

.avatar-upload-label {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.avatar-upload-label:hover { background: var(--accent-hover); }

.phone-edit input,
.email-edit input,
.change-password-form input {
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.change-password-form .btn-primary { margin-top: 0.25rem; }
.form-message { font-size: 0.85rem; margin-top: 0.5rem; }
.logout-btn {
  font: inherit;
  padding: 0.5rem 1rem;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
}
.logout-btn:hover { background: rgba(239, 68, 68, 0.1); }

.bio-text.muted { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.75rem; }
.contact-visibility-add {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.contact-visibility-add input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--bg);
  color: var(--text);
}
.contact-visibility-search-results {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}
.contact-visibility-search-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
}
.contact-visibility-search-item:hover { background: var(--surface-hover); }
.contact-visibility-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.contact-visibility-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.contact-visibility-item:last-child { border-bottom: none; }
.contact-visibility-remove {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
  flex-wrap: wrap;
}

.profile-name-row h1 {
  font-family: 'Unbounded', sans-serif;
  font-size: 1.3rem;
  font-weight: 600;
}

.role-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.role-badge.creator { background: rgba(34,197,94,0.15); color: #22c55e; }
.role-badge.admin { background: rgba(245,158,11,0.15); color: #f59e0b; }
.role-badge.user { display: none; }

.nickname-edit-btn {
  font-size: 0.9rem;
  padding: 0.25rem 0.5rem;
  margin-left: 0.25rem;
}
.nickname-edit {
  margin-top: 0.5rem;
}
.nickname-edit input {
  font: inherit;
  width: 100%;
  max-width: 240px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 0.5rem;
}
.nickname-edit input:focus { border-color: var(--accent); outline: none; }

.profile-status {
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  min-height: 1.2em;
}
.profile-status.online { color: var(--system); }
.profile-status.offline { color: var(--text-muted); }

.profile-stats {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.stat-sep { color: var(--border); }

/* Bio */
.bio-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.bio-section h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.bio-text {
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  min-height: 1.4em;
}
.bio-edit textarea {
  font: inherit;
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  resize: vertical;
  margin-bottom: 0.5rem;
}
.bio-edit textarea:focus { border-color: var(--accent); }
.bio-actions { display: flex; gap: 0.5rem; }

.btn-primary {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* Posts */
.posts-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.posts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.posts-header h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.post-form {
  margin-bottom: 1rem;
}
.post-form textarea {
  font: inherit;
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  resize: vertical;
  margin-bottom: 0.5rem;
}
.post-form textarea:focus { border-color: var(--accent); }

.posts-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.post {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.post-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.post-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}
.post-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.post-nick {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
}
.post-nick.creator { color: #22c55e; }
.post-nick.admin { color: #f59e0b; }
.post-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
}
.post-text {
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.post-delete {
  font: inherit;
  font-size: 0.7rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: 0.5rem;
  padding: 0;
  transition: color 0.2s;
}
.post-delete:hover { color: var(--danger); }

.post-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.post-views { color: var(--text-muted); }

.posts-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 1.5rem;
}

@media (max-width: 600px) {
  body { padding: 0.75rem; }
  .profile-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1rem;
    gap: 1rem;
  }
  .profile-name-row { justify-content: center; }
  .profile-name-row h1 { font-size: 1.1rem; }
  .profile-stats { justify-content: center; }
  .avatar, .avatar-placeholder { width: 80px; height: 80px; }
  .avatar-placeholder { font-size: 1.6rem; }
  .bio-section, .posts-section { padding: 1rem; }
  .post { padding: 0.75rem; }
  .bio-text, .post-text { font-size: 0.85rem; }
  .btn-primary, .btn-ghost { padding: 0.5rem 0.75rem; font-size: 0.8rem; }
}
