:root {
  --primary-color: #FF0000;
  --secondary-color: #333;
  --accent-color: #3EA6FF;
  --background-color: #f5f6fa;
  --text-color: #333;
  --input-border: #ddd;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header h1 {
  color: var(--primary-color);
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.back-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-block;
}

.back-btn:hover {
  background: #cc0000;
}

.profile-section {
  background: white;
  border-radius: 15px;
  padding: 2rem 2rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.profile-header {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

.profile-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 4px; }
.profile-top h2 { margin: 0; }
.profile-handle-line { margin: 0; color: #666; font-size: 0.9rem; }
.profile-handle-line[hidden] { display: none; }
.profile-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.profile-tags span { padding: 3px 10px; border-radius: 999px; background: #eef4ff; color: #2a5db0; font-size: 0.85rem; font-weight: 700; }
.profile-more { display: block; margin: 0 0 14px; padding: 0; border: 0; background: none; color: #2a5db0; font: inherit; font-size: 0.9rem; cursor: pointer; }

/* 次の上映: 自己紹介のすぐ下に1件だけ。全体が上映のページへのリンク。 */
.next-screening { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 18px 0 0; padding: 10px 14px; border-radius: 12px; background: #171717; color: #fff; text-decoration: none; }
.next-screening:hover { background: #2b2b2b; }
.next-screening-label { flex: none; font-size: 0.75rem; color: #ffb3b3; font-weight: 700; }
.next-screening-when { flex: none; font-weight: 800; font-size: 0.95rem; }
.next-screening-what { min-width: 0; flex: 1; font-size: 0.92rem; overflow-wrap: anywhere; }
.next-screening-btn { flex: none; padding: 7px 12px; border-radius: 999px; background: #e50914; color: #fff; font-weight: 700; font-size: 0.85rem; }

/* 一緒に見たい作品・開いた上映の節 */
.profile-block { background: white; border-radius: 15px; padding: 1.5rem 2rem; margin-bottom: 1.25rem; box-shadow: 0 5px 15px rgba(0,0,0,0.05); }
.profile-block h3 { margin: 0 0 4px; font-size: 1.1rem; color: #333; }
.profile-block-lead { margin: 0 0 14px; color: #666; font-size: 0.88rem; }
.picks-more { display: block; margin: 10px 0 0; padding: 0; border: 0; background: none; color: #2a5db0; font: inherit; font-size: 0.9rem; cursor: pointer; }
.picks-more[hidden] { display: none; }
.own-empty { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border: 1px dashed #bbb; border-radius: 12px; background: #fafafa; color: #555; font-size: 0.92rem; }
.own-empty a { color: #fff; background: var(--accent-color); padding: 8px 14px; border-radius: 999px; font-weight: 700; text-decoration: none; font-size: 0.9rem; }
.records { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.records li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 0.92rem; color: #333; }
.records-when { flex: none; color: #888; font-size: 0.82rem; }
.records-kind { flex: none; color: #2a5db0; font-size: 0.8rem; }
.records-delete { margin-left: auto; padding: 2px 10px; border: 1px solid #ccc; border-radius: 999px; background: #fff; color: #666; font: inherit; font-size: 0.78rem; cursor: pointer; }
.records-delete:disabled { opacity: 0.6; cursor: default; }

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent-color);
  background: #fff;
}

.profile-info h2 {
  color: var(--secondary-color);
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

/* フォロー数は小さく1行（押すと下の一覧へ）。 */
.profile-stats {
  display: flex;
  gap: 14px;
  margin-bottom: 10px;
}

.stat-item {
  background: none;
  border: none;
  font: inherit;
  color: #666;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
}

.stat-number {
  font-weight: bold;
  color: #333;
  margin-right: 3px;
}

.profile-description {
  color: #444;
  line-height: 1.6;
  margin-bottom: 1rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.profile-description.open {
  display: block;
}

.profile-more + .profile-description,
.profile-description:has(+ .profile-more:not([hidden])) {
  margin-bottom: 4px;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.follow-notice {
  color: #666;
  font-size: 0.9rem;
}

/* チャンネルに招待（段階6）。フォローの横の控えめなボタンと、その下に開く小さな欄。 */
.channel-invite-btn {
  padding: 0.45rem 1rem;
  border: 1px solid #c9cdd4;
  border-radius: 20px;
  background: white;
  color: #333;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
}

.profile-invite {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid #e6e8ec;
  border-radius: 12px;
  background: #fafafb;
}

.profile-invite-lead,
.profile-invite-help,
.profile-invite-status {
  margin: 0;
  font-size: 0.88rem;
}

.profile-invite-help {
  color: #666;
}

.profile-invite-status:empty {
  display: none;
}

.profile-invite-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  font-size: 0.88rem;
  font-weight: bold;
}

.profile-invite-row select {
  max-width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: white;
  font: inherit;
  font-weight: normal;
}

.profile-invite-actions {
  display: flex;
  gap: 0.5rem;
}

.profile-invite-actions button {
  padding: 0.45rem 1rem;
  border: 0;
  border-radius: 20px;
  background: #e50914;
  color: white;
  font: inherit;
  font-size: 0.88rem;
  font-weight: bold;
  cursor: pointer;
}

.profile-invite-actions button.secondary {
  border: 1px solid #bbb;
  background: white;
  color: #333;
}

.profile-invite-actions button:disabled {
  opacity: 0.6;
  cursor: default;
}

.edit-profile-btn {
  display: inline-block;
  text-decoration: none;
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 25px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  transition: all 0.3s ease;
}

.edit-profile-btn:hover {
  background: #2d8fd9;
  transform: translateY(-2px);
}

.follow-section {
  background: white;
  border-radius: 15px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.follow-tabs {
  display: flex;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #eee;
}

.follow-tab {
  flex: 1;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 1rem;
  font-weight: bold;
  color: #666;
  transition: all 0.3s ease;
}

.follow-tab.active {
  color: var(--primary-color);
  border-bottom: 2px solid var(--primary-color);
}

[hidden] {
  display: none !important;
}

.user-list {
  display: grid;
  gap: 1rem;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #eee;
  border-radius: 10px;
  transition: all 0.3s ease;
}

.user-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

.user-info {
  flex: 1;
}

.user-name {
  display: inline-block;
  font-weight: bold;
  color: var(--secondary-color);
  margin-bottom: 0.2rem;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.user-name:hover {
  text-decoration: underline;
}

.user-profile {
  font-size: 0.9rem;
  color: #666;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.follow-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.follow-btn:hover {
  background: #218838;
  transform: translateY(-1px);
}

.follow-btn.following {
  background: white;
  color: #28a745;
  border: 2px solid #28a745;
}

.follow-btn.following:hover {
  background: #f8f9fa;
  color: #218838;
  border-color: #218838;
}

.follow-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: #666;
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: #666;
}

.error-message {
  background: #f8d7da;
  color: #721c24;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .back-btn {
    position: static;
    margin: 16px 0 0 16px;
  }

  .container {
    padding: 10px;
  }

  .profile-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .profile-top,
  .profile-stats,
  .profile-tags,
  .profile-actions {
    justify-content: center;
  }

  .profile-block {
    padding: 1.1rem 1rem;
  }

  .next-screening-what {
    flex-basis: 100%;
  }

  .user-item {
    flex-direction: column;
    text-align: center;
  }
}
