@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --bg-color: #f3f4f6;
  --card-bg: rgba(255, 255, 255, 0.85);
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --border-color: rgba(229, 231, 235, 0.5);
  --success-color: #10b981;
  --danger-color: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  /* ポップで明るいアニメーショングラデーション背景 */
  background: linear-gradient(-45deg, #ff9a9e, #fecfef, #f6d365, #a1c4fd);
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

h1, h2, h3 {
  color: var(--text-main);
  font-weight: 600;
  margin-bottom: 1rem;
}

.container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

/* Glassmorphism Card */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
  margin-bottom: 2rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
}

/* Form Styles */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

input[type="text"],
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.9);
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-success:hover {
  filter: brightness(1.1);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
}

.btn-outline:hover {
  background: rgba(79, 70, 229, 0.05);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.btn-icon:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
}

/* Lists */
.message-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message-item {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid #e5e7eb;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.message-item:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.message-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary-color);
}

.message-date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.message-content {
  color: var(--text-main);
  line-height: 1.6;
  white-space: pre-wrap;
  margin-bottom: 1rem;
}

.message-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid #f3f4f6;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
}

.status-unread {
  background: #fee2e2;
  color: var(--danger-color);
}

.status-read {
  background: #d1fae5;
  color: var(--success-color);
}

/* Notifications */
.notification-bell {
  position: relative;
  display: inline-block;
  font-size: 1.5rem;
}

.badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--danger-color);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Portal Grid */
.portal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 3rem;
}

.portal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  padding: 3rem 2rem;
  background: white;
  border-radius: 20px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  transition: all 0.3s;
  border: 2px solid transparent;
}

.portal-card:hover {
  border-color: var(--primary-color);
  transform: translateY(-5px);
}

.portal-card i {
  font-size: 3rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.portal-card h2 {
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.portal-card p {
  color: var(--text-muted);
}

/* Nav */
nav {
  width: 100%;
  margin-bottom: 2rem;
}
.back-link {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}
.back-link:hover {
  color: var(--primary-color);
}
.back-link i {
  margin-right: 0.5rem;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Update V2 Styles */
.search-bar {
  display: flex;
  margin-bottom: 1.5rem;
  position: relative;
}
.search-bar i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.search-bar input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: white;
}
.badge-important {
  background: #fee2e2;
  color: #b91c1c;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  margin-right: 0.5rem;
  vertical-align: middle;
}
.message-item.urgent {
  border-left: 4px solid #ef4444;
  background: #fffafa;
}
.attachment-img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  margin-top: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  display: block;
}
.poll-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.poll-btn {
  background: white;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}
.poll-btn:hover {
  background: var(--primary-color);
  color: white;
}
.poll-btn.selected {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.3);
}
.progress-container {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  margin: 0.5rem 0;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--success-color);
  transition: width 0.3s ease;
}
.stats-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 500;
  margin-bottom: 0.5rem;
}
.checkbox-label input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  cursor: pointer;
}
.poll-results {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  background: #f9fafb;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.poll-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.25rem;
  margin-top: 1rem;
}
.poll-title {
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--primary-color);
  display: flex;
  align-items: center;
}
.poll-title i {
  margin-right: 0.5rem;
}
.poll-option-radio {
  display: block;
  margin-bottom: 0.75rem;
  cursor: pointer;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: white;
  transition: all 0.2s;
}
.poll-option-radio:hover {
  border-color: var(--primary-hover);
  background: #f5f3ff;
}
.poll-option-radio input[type="radio"] {
  margin-right: 0.75rem;
  transform: scale(1.2);
}
.poll-bar-container {
  margin-bottom: 0.75rem;
}
.poll-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  font-weight: 500;
}
.poll-bar-bg {
  width: 100%;
  background: #e5e7eb;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}
.poll-bar-fill {
  background: var(--primary-color);
  height: 100%;
  transition: width 0.4s ease;
}

/* Editor Styles */
.editor-toolbar {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  background: #f3f4f6;
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}
.editor-btn {
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: var(--text-color);
  font-size: 0.9rem;
}
.editor-btn:hover {
  background: #e5e7eb;
}
.rich-editor {
  border: 1px solid var(--border-color);
  border-radius: 0 0 8px 8px;
  padding: 0.75rem;
  min-height: 150px;
  background: white;
  font-family: inherit;
  outline: none;
}
.rich-editor:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.badge-scheduled {
  background: #dbeafe;
  color: #1e3a8a;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  margin-right: 0.5rem;
  vertical-align: middle;
}
.rich-content ul, .rich-content ol {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

/* Category Badge */
.badge-category {
  background: #f3f4f6;
  color: #4b5563;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 0.5rem;
  display: inline-block;
  vertical-align: middle;
  border: 1px solid #d1d5db;
}

/* Comments Section */
.comments-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}
.comment-item {
  background: #f9fafb;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  position: relative;
}
.comment-header {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  display: flex;
  justify-content: space-between;
}
.comment-text {
  font-size: 0.9rem;
  color: var(--text-color);
  word-break: break-word;
}
.comment-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.comment-input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
}

/* File Attachment */
.attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #e0e7ff;
  color: #4338ca;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 0.5rem;
  border: 1px solid #c7d2fe;
}
.attachment-file:hover {
  background: #c7d2fe;
}

/* Collapsible Message */
details.message-details > summary::marker,
details.message-details > summary::-webkit-details-marker {
  display: none;
}
details.message-details[open] .summary-icon {
  transform: rotate(90deg);
}
.message-summary {
  margin: -1rem;
  padding: 1rem;
  border-radius: 8px;
  display: block;
}
.message-summary:hover {
  background: #f9fafb;
}
details.message-details[open] .message-summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

@media (max-width: 640px) {
  .portal-grid {
    grid-template-columns: 1fr;
  }
  .card {
    padding: 1.5rem;
  }
  .message-header {
    flex-direction: column;
  }
  .message-date {
    margin-top: 0.25rem;
  }
}

/* Enhanced Poll & Status Badges */
.badge-unanswered {
  background: #ea580c;
  color: #ffffff;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 0.5rem;
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  box-shadow: 0 1px 3px rgba(234, 88, 12, 0.35);
  animation: pulse-unanswered 2s infinite ease-in-out;
}

@keyframes pulse-unanswered {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.03); }
}

.badge-deadline {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.badge-deadline-expired {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #e5e7eb;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.badge-top-vote {
  background: #fef08a;
  color: #854d0e;
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 9999px;
  font-weight: 700;
  margin-left: 0.4rem;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  border: 1px solid #fde047;
}

.poll-bar-bg {
  background: #f3f4f6;
  border-radius: 6px;
  height: 12px;
  overflow: hidden;
  margin-top: 4px;
}

.poll-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.poll-deadline-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-radius: 6px;
  font-size: 0.8rem;
  color: #92400e;
  margin-bottom: 0.75rem;
}

.poll-expired-banner {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  background: #fef2f2;
  border: 1px solid #fee2e2;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #991b1b;
  font-weight: 500;
  margin-bottom: 0.75rem;
}
