/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a1a;
  --bg-card: #12122a;
  --bg-card-hover: #1a1a3a;
  --primary: #00ccbb;
  --primary-dark: #009e90;
  --text: #e0e0e0;
  --text-muted: #8a8aaa;
  --text-heading: #ffffff;
  --border: #2a2a4a;
  --badge-easy: #22c55e;
  --badge-mid: #eab308;
  --badge-hard: #ef4444;
  --attitude-coop: #22c55e;
  --attitude-mixed: #eab308;
  --attitude-diff: #ef4444;
  --shadow: rgba(0, 0, 0, 0.4);
  --transition: 0.25s ease;
}

[data-theme="light"] {
  --bg: #f5f5f0;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f0ea;
  --primary: #0ea5a0;
  --primary-dark: #0c8a86;
  --text: #333340;
  --text-muted: #6a6a7a;
  --text-heading: #1a1a2e;
  --border: #d0d0d8;
  --shadow: rgba(0, 0, 0, 0.1);
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

/* ===== Header ===== */
.header {
  padding: 20px 10%;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.header h1 {
  font-size: 1.5rem;
  color: var(--primary);
  font-weight: 700;
  white-space: nowrap;
}

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

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

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-display-name {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.user-menu-link {
  font-size: 0.82rem;
  color: var(--primary);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all var(--transition);
}
.user-menu-link:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.user-menu-logout:hover {
  color: #ef4444;
  border-color: #ef4444;
}

.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.2rem;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
}
.theme-toggle:hover { background: var(--bg-card-hover); }

/* ===== Main Content ===== */
.main { padding: 32px 10%; }

/* ===== Input Section ===== */
.input-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  margin-bottom: 32px;
}

.input-section h2 {
  font-size: 1.1rem;
  color: var(--text-heading);
  margin-bottom: 20px;
  font-weight: 600;
}

.input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-end;
}

.input-group {
  flex: 1;
  min-width: 200px;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-btn {
  display: none;
}

.radio-label {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all var(--transition);
  user-select: none;
  background: var(--bg);
}
.radio-label:hover { border-color: var(--primary); }
.radio-btn:checked + .radio-label {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-generate {
  padding: 12px 32px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform 0.15s;
  white-space: nowrap;
}
.btn-generate:hover { background: var(--primary-dark); }
.btn-generate:active { transform: scale(0.97); }
.btn-generate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== Loading ===== */
.loading-indicator {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.loading-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Error ===== */
.error-message {
  text-align: center;
  padding: 32px 20px;
  color: var(--badge-hard);
  font-size: 0.95rem;
}

/* ===== Cards Grid ===== */
.cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.persona-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.persona-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px var(--shadow);
}
.persona-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.card-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-heading);
}

.card-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-left: 8px;
  white-space: nowrap;
}

.card-occupation {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 8px;
}

.card-concern {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-difficulty-初級 { background: rgba(34,197,94,0.15); color: var(--badge-easy); }
.badge-difficulty-中級 { background: rgba(234,179,8,0.15); color: var(--badge-mid); }
.badge-difficulty-上級 { background: rgba(239,68,68,0.15); color: var(--badge-hard); }

.badge-attitude-coop { background: rgba(34,197,94,0.12); color: var(--attitude-coop); }
.badge-attitude-mixed { background: rgba(234,179,8,0.12); color: var(--attitude-mixed); }
.badge-attitude-diff { background: rgba(239,68,68,0.12); color: var(--attitude-diff); }

/* ===== Detail Panel ===== */
.detail-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  display: none;
  animation: fadeIn 0.3s ease;
}
.detail-panel.visible { display: block; }

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

.detail-close {
  float: right;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
}
.detail-close:hover { border-color: var(--primary); color: var(--primary); }

.detail-name {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 4px;
}

.detail-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.detail-field {
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.detail-field-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-field-value {
  font-size: 0.95rem;
  color: var(--text);
}

.detail-section {
  margin-bottom: 24px;
}

.detail-section h3 {
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 12px;
  font-weight: 600;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.detail-section p {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.8;
}

.detail-section ul {
  list-style: none;
  padding: 0;
}

.detail-section ul li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  color: var(--text);
  position: relative;
  padding-left: 20px;
}
.detail-section ul li:last-child { border-bottom: none; }
.detail-section ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 16px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

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

.theme-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: all var(--transition);
}

.theme-tag {
  padding: 12px 20px;
  background: var(--bg);
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  display: block;
  transition: all var(--transition);
}
.theme-tag:hover {
  color: var(--primary);
  background: var(--bg-card);
}
.theme-tag.active {
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.theme-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: normal;
}

.theme-detail {
  display: none;
  padding: 16px 20px;
  background: var(--bg-card);
}
.theme-detail.visible {
  display: block;
}

.theme-detail-desc {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 12px;
}

.theme-detail-points {
  list-style: none;
  padding: 0;
}
.theme-detail-points li {
  font-size: 0.85rem;
  color: var(--primary);
  padding: 4px 0 4px 20px;
  position: relative;
}
.theme-detail-points li::before {
  content: '\25B8';
  position: absolute;
  left: 0;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}
.empty-state p {
  font-size: 0.95rem;
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 24px 10%;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}
.site-footer a {
  color: var(--primary);
  text-decoration: none;
}
.site-footer a:hover {
  text-decoration: underline;
}

/* ===== Mypage ===== */
.mypage-title {
  font-size: 1.3rem;
  color: var(--text-heading);
  font-weight: 700;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.mypage-history-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mypage-history-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  transition: all var(--transition);
}
.mypage-history-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.mypage-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.mypage-history-date {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
}

.mypage-role-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}
.mypage-role-badge.role-client {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}
.mypage-role-badge.role-consultant {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}
.mypage-role-badge.role-observer {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
}
.mypage-role-badge.role-none {
  background: rgba(138, 138, 170, 0.15);
  color: var(--text-muted);
}

.mypage-history-body {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  margin-bottom: 8px;
}

.mypage-history-detail {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.mypage-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-shrink: 0;
  font-weight: 500;
}

.mypage-value {
  font-size: 0.92rem;
  color: var(--text);
}

.mypage-memo-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.mypage-memo-content {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.7;
  margin-top: 6px;
}

.mypage-memo-content.mypage-memo-truncated {
  max-height: 4.2em;
  overflow: hidden;
  position: relative;
}
.mypage-memo-content.mypage-memo-truncated::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2em;
  background: linear-gradient(transparent, var(--bg-card));
  pointer-events: none;
}

.mypage-memo-toggle {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 4px 0;
  margin-top: 4px;
  transition: color var(--transition);
}
.mypage-memo-toggle:hover {
  color: var(--primary-dark);
}

.back-link-header {
  color: var(--primary);
  text-decoration: none;
}
.back-link-header:hover {
  text-decoration: underline;
}

/* ===== Responsive (tablet) ===== */
@media (max-width: 768px) {
  .header {
    padding: 16px 5%;
  }
  .header h1 {
    font-size: 1.3rem;
  }
  .main {
    padding: 24px 5%;
  }
  .cards-container {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
  .site-footer {
    padding: 16px 5%;
  }
  .mypage-title {
    font-size: 1.15rem;
  }
}

/* ===== Responsive (mobile) ===== */
@media (max-width: 640px) {
  .header {
    padding: 12px 5%;
    gap: 8px;
  }
  .header h1 {
    font-size: 1.15rem;
  }
  .header .subtitle {
    font-size: 0.78rem;
  }
  .theme-toggle {
    font-size: 1rem;
    padding: 5px 10px;
  }

  .main {
    padding: 16px 5%;
  }

  .input-section {
    padding: 16px;
    margin-bottom: 24px;
  }
  .input-section h2 {
    font-size: 1rem;
    margin-bottom: 16px;
  }
  .input-row {
    flex-direction: column;
    gap: 16px;
  }
  .input-group {
    min-width: 100%;
  }
  .input-group label {
    font-size: 0.8rem;
  }
  .radio-label {
    padding: 7px 12px;
    font-size: 0.82rem;
  }
  .btn-generate {
    width: 100%;
    padding: 12px 20px;
    font-size: 0.95rem;
  }

  .cards-container {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 24px;
  }
  .persona-card {
    padding: 16px;
  }
  .card-name {
    font-size: 1.05rem;
  }
  .card-meta {
    font-size: 0.78rem;
  }
  .card-occupation {
    font-size: 0.85rem;
  }
  .card-concern {
    font-size: 0.82rem;
  }

  .detail-panel {
    padding: 16px;
    border-radius: 8px;
  }
  .detail-name {
    font-size: 1.15rem;
  }
  .detail-sub {
    font-size: 0.82rem;
    margin-bottom: 16px;
  }
  .detail-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 20px;
  }
  .detail-field {
    padding: 10px 12px;
  }
  .detail-field-label {
    font-size: 0.7rem;
  }
  .detail-field-value {
    font-size: 0.88rem;
  }
  .detail-section h3 {
    font-size: 0.92rem;
  }
  .detail-section p {
    font-size: 0.85rem;
  }
  .detail-section ul li {
    font-size: 0.85rem;
    padding-left: 16px;
  }

  .theme-tags {
    width: 100%;
  }
  .theme-item {
    width: 100%;
  }
  .theme-tag {
    padding: 10px 14px;
    font-size: 0.85rem;
  }
  .theme-detail {
    padding: 12px 14px;
  }
  .theme-detail-desc {
    font-size: 0.8rem;
  }
  .theme-detail-points li {
    font-size: 0.8rem;
  }

  .site-footer {
    padding: 16px 5%;
    font-size: 0.75rem;
    margin-top: 24px;
  }

  .mypage-title {
    font-size: 1.05rem;
    margin-bottom: 16px;
  }
  .mypage-history-card {
    padding: 14px 16px;
  }
  .mypage-history-body {
    gap: 10px 20px;
  }
  .mypage-history-date {
    font-size: 0.82rem;
  }
  .mypage-role-badge {
    font-size: 0.72rem;
  }

  .empty-state {
    padding: 40px 16px;
  }
  .empty-state-icon {
    font-size: 2.4rem;
  }
  .empty-state p {
    font-size: 0.85rem;
  }
}
