:root {
  --primary-green: #0d5c3d;
  --primary-green-dark: #094a31;
  --primary-green-light: #10754d;
  --accent-green: #14a76c;
  --accent-green-light: #1bc47d;
  --bg-primary: #ffffff;
  --bg-secondary: #f8faf9;
  --bg-tertiary: #f0f4f2;
  --text-primary: #1a1a1a;
  --text-secondary: #4a5568;
  --text-tertiary: #718096;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 3px 0 rgba(13, 92, 61, 0.1), 0 1px 2px 0 rgba(13, 92, 61, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(13, 92, 61, 0.1), 0 2px 4px -1px rgba(13, 92, 61, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(13, 92, 61, 0.1), 0 4px 6px -2px rgba(13, 92, 61, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(13, 92, 61, 0.1), 0 10px 10px -5px rgba(13, 92, 61, 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: linear-gradient(135deg, #f8faf9 0%, #e8f5f0 100%);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* ==================== ログイン画面 ==================== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #0d5c3d 0%, #14a76c 100%);
  position: relative;
  overflow: hidden;
}

#login-screen::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  border-radius: 50%;
  top: -200px;
  right: -200px;
  animation: float 6s ease-in-out infinite;
}

#login-screen::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
  border-radius: 50%;
  bottom: -100px;
  left: -100px;
  animation: float 8s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-20px); }
}

.login-container {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 48px;
  width: 100%;
  max-width: 460px;
  position: relative;
  z-index: 1;
  animation: slideUp 0.5s ease-out;
}

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

.logo {
  text-align: center;
  margin-bottom: 36px;
}

.logo h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary-green);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.logo p {
  color: var(--text-secondary);
  font-size: 15px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  background: var(--bg-tertiary);
  padding: 6px;
  border-radius: var(--radius-md);
}

.tab-btn {
  flex: 1;
  padding: 12px 24px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.tab-btn.active {
  background: var(--primary-green);
  color: white;
  box-shadow: var(--shadow-sm);
}

.tab-btn:hover:not(.active) {
  background: rgba(13, 92, 61, 0.08);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.form-group {
  margin-bottom: 28px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: inherit;
  transition: var(--transition);
  background: var(--bg-primary);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px rgba(20, 167, 108, 0.1);
}

.form-group input::placeholder {
  color: var(--text-tertiary);
}

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

.btn {
  padding: 16px 28px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-light) 100%);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

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

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--primary-green);
  color: white;
  border-color: var(--primary-green);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ==================== ダッシュボード ==================== */
#dashboard-screen {
  display: none;
  min-height: 100vh;
}

#dashboard-screen.active {
  display: flex;
}

/* ナビゲーションバー */
.navbar {
  background: var(--bg-primary);
  padding: 24px 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.nav-brand h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary-green);
  letter-spacing: -0.5px;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-green-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 17px;
  box-shadow: var(--shadow-sm);
}

.nav-user span {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 15px;
}

/* ダッシュボードコンテナ */
.dashboard-container {
  display: flex;
  min-height: calc(100vh - 80px);
}

/* サイドバー */
.sidebar {
  width: 280px;
  background: linear-gradient(180deg, var(--primary-green) 0%, var(--primary-green-dark) 100%);
  color: white;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 100;
}

.sidebar-header {
  padding: 36px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

.menu {
  flex: 1;
  padding: 28px 20px;
  overflow-y: auto;
  list-style: none;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: var(--transition);
  font-size: 15px;
  font-weight: 500;
  position: relative;
}

.menu-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 0;
  background: var(--accent-green-light);
  border-radius: 0 4px 4px 0;
  transition: var(--transition);
}

.menu-item:hover,
.menu-item.active {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  padding-left: 24px;
}

.menu-item:hover::before,
.menu-item.active::before {
  height: 24px;
}

/* メインコンテンツ */
.content {
  flex: 1;
  padding: 48px 56px;
  overflow-y: auto;
  background: var(--bg-secondary);
}

.content-section {
  display: none;
  animation: fadeInUp 0.4s ease-out;
}

.content-section.active {
  display: block;
}

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

.content-section h2 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.content-section > p {
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.7;
  margin-bottom: 36px;
}

/* フォームコンテナ */
.form-container {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  margin-bottom: 32px;
  transition: var(--transition);
}

.form-container:hover {
  box-shadow: var(--shadow-lg);
}

/* 結果コンテナ */
.result-container {
  margin-top: 32px;
  padding: 24px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border-color);
  min-height: 200px;
  transition: var(--transition);
  display: none;
}

.result-container.show {
  display: block;
  border-style: solid;
  border-color: var(--accent-green);
  background: var(--bg-primary);
}

.result-container img {
  max-width: 100%;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  margin-top: 16px;
}

.result-container pre {
  padding: 20px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--accent-green);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
  margin-top: 12px;
  overflow-x: auto;
}

.success-message {
  color: var(--accent-green);
  font-weight: 600;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: rgba(20, 167, 108, 0.1);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--accent-green);
}

/* 履歴タブ */
.history-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.history-tab-btn {
  padding: 12px 24px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.history-tab-btn.active {
  background: var(--primary-green);
  color: white;
  border-color: var(--primary-green);
  box-shadow: var(--shadow-sm);
}

.history-tab-btn:hover:not(.active) {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.history-content {
  display: none;
}

.history-content.active {
  display: block;
}

/* グリッドコンテナ */
.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.grid-item {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.grid-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.grid-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.grid-item-content {
  padding: 20px;
}

.grid-item p {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 12px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.grid-item small {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* リストコンテナ */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.list-item {
  background: var(--bg-primary);
  padding: 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateX(4px);
  border-color: var(--accent-green);
}

.list-item h4 {
  color: var(--text-primary);
  margin-bottom: 6px;
  font-size: 16px;
  font-weight: 600;
}

.list-item p {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ローディング */
.loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 15px;
}

.loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* エラーメッセージ */
.error-message {
  color: #e74c3c;
  font-size: 14px;
  margin-top: 10px;
  padding: 12px 16px;
  background: rgba(231, 76, 60, 0.1);
  border-radius: var(--radius-md);
  border-left: 4px solid #e74c3c;
  display: none;
}

.error-message.show {
  display: block;
}

/* レスポンシブ */
@media (max-width: 1024px) {
  .sidebar {
    width: 240px;
  }
  
  .content {
    padding: 24px;
  }
}

@media (max-width: 768px) {
  #dashboard-screen.active {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    max-height: auto;
  }
  
  .menu {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px;
  }
  
  .menu-item {
    flex: 1 1 calc(50% - 8px);
    min-width: 140px;
  }
  
  .navbar {
    padding: 16px 20px;
  }
  
  .content {
    padding: 20px;
  }
  
  .form-container {
    padding: 24px;
  }
  
  .grid-container {
    grid-template-columns: 1fr;
  }
  
  .login-container {
    padding: 32px 24px;
  }
}

/* スクロールバー */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
  background: var(--primary-green);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-green-dark);
}

/* ユーティリティ */
.text-center {
  text-align: center;
}

.mt-4 {
  margin-top: 24px;
}

.mb-4 {
  margin-bottom: 24px;
}

.hidden {
  display: none !important;
}

/* ==================== モバイルヘッダー ==================== */
.mobile-header {
  display: none;
  background: var(--bg-primary);
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1001;
}

.mobile-menu-btn {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mobile-menu-btn span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  transition: var(--transition);
}

.mobile-menu-btn.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.active span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

.mobile-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-green);
}

.user-avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-green-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
}

/* サイドバーオーバーレイ */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ==================== プロジェクト選択 ==================== */
.nav-center {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 400px;
  margin: 0 auto;
}

.project-selector {
  position: relative;
  width: 100%;
}

.project-selector-btn {
  width: 100%;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  transition: var(--transition);
}

.project-selector-btn:hover {
  background: var(--bg-primary);
  border-color: var(--accent-green);
}

.project-selector-btn svg {
  flex-shrink: 0;
  transition: transform 0.3s;
}

.project-selector-btn.active svg {
  transform: rotate(180deg);
}

.project-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  opacity: 0;
  transform: translateY(-10px);
  transition: var(--transition);
  pointer-events: none;
}

.project-dropdown:not(.hidden) {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.project-dropdown-header {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}

.project-search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
}

.project-search:focus {
  outline: none;
  border-color: var(--accent-green);
}

.project-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.project-item:hover {
  background: var(--bg-tertiary);
}

.project-item.active {
  background: rgba(20, 167, 108, 0.1);
  color: var(--accent-green);
  font-weight: 600;
}

.project-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.project-dropdown-footer {
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

.btn-new-project {
  width: 100%;
  padding: 10px 12px;
  background: var(--primary-green);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.btn-new-project:hover {
  background: var(--primary-green-dark);
}

  color: #0d5c3d;
  border-bottom-color: #0d5c3d;
}

.team-tab:hover:not(.active) {
  color: #334155;
}

.team-tab-content {
  display: none;
}

.team-tab-content.active {
  display: block;
}

.team-actions {
  margin-bottom: 1.5rem;
}

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

.team-card {
  padding: 1.5rem;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  transition: all 0.2s;
}

.team-card:hover {
  border-color: #0d5c3d;
  box-shadow: 0 4px 12px rgba(13, 92, 61, 0.1);
}

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

.team-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.team-role-badge {
  padding: 0.25rem 0.75rem;
  background: #0d5c3d;
  color: white;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
}

.team-role-badge.admin {
  background: #667eea;
}

.team-role-badge.member {
  background: #14a76c;
}

.team-role-badge.viewer {
  background: #94a3b8;
}

.team-card-description {
  color: #64748b;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.team-card-stats {
  display: flex;
  gap: 1.5rem;
  font-size: 0.875rem;
  color: #64748b;
}

.team-card-stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.team-card-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 0.5rem;
}

.team-card-actions .btn {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}

/* Members Management */
.members-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.members-header h4 {
  margin: 0;
  color: #1e293b;
}

.members-list {
  display: grid;
  gap: 0.75rem;
}

.member-card {
  padding: 1rem;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.member-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d5c3d, #14a76c);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.125rem;
  flex-shrink: 0;
}

.member-info {
  flex: 1;
}

.member-name {
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.25rem;
}

.member-email {
  font-size: 0.875rem;
  color: #64748b;
}

.member-role {
  padding: 0.25rem 0.75rem;
  background: #f1f5f9;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #475569;
}

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

.member-actions .btn {
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
}

/* Media Library */
.media-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.media-filters {
  display: flex;
  gap: 0.5rem;
}

.media-filters select {
  padding: 0.5rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: white;
  color: #334155;
  font-size: 0.875rem;
  cursor: pointer;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  max-height: 500px;
  overflow-y: auto;
}

.media-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #f1f5f9;
  cursor: pointer;
  transition: all 0.2s;
}

.media-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.media-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
  padding: 0.5rem;
  color: white;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.media-item:hover .media-item-overlay {
  opacity: 1;
}

.media-item-actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.media-item:hover .media-item-actions {
  opacity: 1;
}

.media-item-action {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.media-item-action:hover {
  background: white;
  transform: scale(1.1);
}

.media-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: #94a3b8;
}

/* Tag Management */
.tag-create {
  margin-bottom: 1.5rem;
}

.inline-form {
  display: flex;
  gap: 0.5rem;
}

.inline-form input[type="text"] {
  flex: 1;
  padding: 0.5rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.875rem;
}

.inline-form input[type="color"] {
  width: 50px;
  height: 38px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: white;
  transition: all 0.2s;
}

.tag-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tag-chip-name {
  flex: 1;
}

.tag-chip-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
}

.tag-chip-delete {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.2s;
}

.tag-chip-delete:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Tag Selector (for content) */
.tag-selector {
  margin-top: 1rem;
}

.tag-selector-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
  margin-bottom: 0.5rem;
  display: block;
}

.tag-selector-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-selector-chip {
  padding: 0.375rem 0.75rem;
  border-radius: 16px;
  font-size: 0.875rem;
  border: 1px solid #e2e8f0;
  background: white;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}

.tag-selector-chip:hover {
  border-color: #0d5c3d;
  background: #f0fdf4;
}

.tag-selector-chip.selected {
  border-color: #0d5c3d;
  background: #0d5c3d;
  color: white;
}

/* Responsive */
@media (max-width: 768px) {
  .modal-large {
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
  }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
  }

  .team-card-stats {
    flex-direction: column;
    gap: 0.5rem;
  }

  .members-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .media-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ==================== ローディング表示 ==================== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #14a76c;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: white;
  margin-top: 1rem;
  font-size: 1rem;
}

.btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ==================== エラー表示 ==================== */
.error-message {
  background: #fee;
  border: 1px solid #fcc;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  color: #c33;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.error-message-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.error-message-content {
  flex: 1;
}

.error-message-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.error-message-text {
  font-size: 0.9rem;
  line-height: 1.5;
}

.error-message-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #c33;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.error-message-close:hover {
  opacity: 1;
}

.success-message {
  background: #efe;
  border: 1px solid #cfc;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  color: #3c3;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.warning-message {
  background: #fff8e1;
  border: 1px solid #ffecb3;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  color: #f57c00;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.info-message {
  background: #e3f2fd;
  border: 1px solid #bbdefb;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  color: #1976d2;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* トースト通知 */
.toast-container {
  position: fixed;
  top: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
}

.toast {
  background: white;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.toast-success {
  border-left: 4px solid #4caf50;
}

.toast.toast-error {
  border-left: 4px solid #f44336;
}

.toast.toast-warning {
  border-left: 4px solid #ff9800;
}

.toast.toast-info {
  border-left: 4px solid #2196f3;
}

.toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.toast-message {
  font-size: 0.9rem;
  color: #64748b;
}

.toast-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.toast-close:hover {
  opacity: 1;
}

@media (max-width: 768px) {
  .toast-container {
    top: 1rem;
    right: 1rem;
    left: 1rem;
    max-width: none;
  }
}
/* Prompt Library Styles */
.prompt-library-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.prompt-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  transition: all 0.3s ease;
  position: relative;
}

.prompt-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

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

.prompt-card-title {
  font-size: 1.1em;
  font-weight: 600;
  color: #2c3e50;
  margin: 0;
  flex: 1;
}

.prompt-card-category {
  display: inline-block;
  background: #e8f5e9;
  color: #2e7d32;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: 500;
  margin-left: 10px;
}

.prompt-card-content {
  color: #555;
  font-size: 0.95em;
  line-height: 1.6;
  margin: 12px 0;
  max-height: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.prompt-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.prompt-tag {
  background: #f5f5f5;
  color: #666;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.8em;
}

.prompt-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #f0f0f0;
}

.prompt-card-usage {
  font-size: 0.85em;
  color: #999;
}

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

.prompt-card-actions button {
  padding: 6px 14px;
  font-size: 0.9em;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-copy {
  background: #2196F3;
  color: white;
}

.btn-copy:hover {
  background: #1976D2;
}

.btn-copy.copied {
  background: #4CAF50;
}

.btn-edit {
  background: #FFC107;
  color: white;
}

.btn-edit:hover {
  background: #FFA000;
}

.btn-delete {
  background: #f44336;
  color: white;
}

.btn-delete:hover {
  background: #d32f2f;
}

.prompt-badge-system {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #673AB7;
  color: white;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.75em;
  font-weight: 500;
}

/* Prompt Modal */
.prompt-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.prompt-modal.show {
  display: flex;
}

.prompt-modal-content {
  background: white;
  border-radius: 12px;
  padding: 30px;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.prompt-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.prompt-modal-header h3 {
  margin: 0;
  color: #2c3e50;
}

.prompt-modal-close {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: #999;
}

.prompt-modal-close:hover {
  color: #333;
}

.prompt-modal-body .form-group {
  margin-bottom: 20px;
}

.prompt-modal-body label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #333;
}

.prompt-modal-body input,
.prompt-modal-body textarea,
.prompt-modal-body select {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1em;
}

.prompt-modal-body textarea {
  min-height: 120px;
  resize: vertical;
}

.prompt-tags-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  min-height: 42px;
}

.prompt-tags-input input {
  border: none;
  outline: none;
  flex: 1;
  min-width: 100px;
  padding: 4px;
}

.prompt-tag-item {
  background: #2196F3;
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.9em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.prompt-tag-remove {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.1em;
  padding: 0;
  line-height: 1;
}

.prompt-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

@media (max-width: 768px) {
  .prompt-library-list {
    grid-template-columns: 1fr;
  }
  
  .prompt-library-controls {
    flex-direction: column;
  }
  
  .prompt-library-controls .form-group,
  .prompt-library-controls button {
    width: 100%;
  }
}

/* ===================================
   Modern SaaS Header Styles
   =================================== */

/* ==================== 改善されたヘッダー ==================== */

/* Navbar - より洗練されたデザイン */
.navbar {
  height: 56px; /* 高さを最適化 */
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: var(--transition);
}

/* Logo */
.navbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-green);
  text-decoration: none;
  transition: var(--transition);
}

.navbar-logo:hover {
  color: var(--primary-green-dark);
}

.navbar-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--primary-green);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  transition: var(--transition);
}

.navbar-logo:hover .navbar-logo-icon {
  background: var(--primary-green-dark);
  transform: scale(1.05);
}

/* Search Bar */
.navbar-search {
  flex: 1;
  max-width: 500px;
  margin: 0 32px;
  position: relative;
}

.navbar-search input {
  width: 100%;
  height: 38px;
  padding: 0 16px 0 40px;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  transition: var(--transition);
}

.navbar-search input:focus {
  outline: none;
  border-color: var(--primary-green);
  background: white;
  box-shadow: 0 0 0 3px rgba(13, 92, 61, 0.08);
}

.navbar-search input::placeholder {
  color: var(--text-tertiary);
}

.navbar-search::before {
  content: '🔍';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  opacity: 0.5;
  pointer-events: none;
}

/* Actions */
.navbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
  position: relative;
}

.navbar-icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--primary-green);
}

.navbar-icon-btn:active {
  transform: scale(0.95);
}

/* Badge */
.navbar-icon-btn .badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 600;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* User Menu */
.navbar-user {
  position: relative;
}

.navbar-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 10px;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
}

.navbar-user-btn:hover {
  background: var(--bg-tertiary);
}

.navbar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary-green) 0%, var(--accent-green) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar-user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navbar-user-dropdown-icon {
  font-size: 12px;
  color: var(--text-tertiary);
  transition: var(--transition);
}

.navbar-user.active .navbar-user-dropdown-icon {
  transform: rotate(180deg);
}

/* User Dropdown */
.navbar-user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 8px;
  display: none;
  animation: dropdownSlideIn 0.2s ease-out;
}

.navbar-user.active .navbar-user-dropdown {
  display: block;
}

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

.navbar-user-dropdown button {
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 14px;
  color: var(--text-primary);
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-user-dropdown button:hover {
  background: var(--bg-tertiary);
  color: var(--primary-green);
}

.navbar-user-dropdown button:last-child {
  color: #ef4444;
  margin-top: 4px;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}

.navbar-user-dropdown button:last-child:hover {
  background: rgba(239, 68, 68, 0.08);
}

/* Responsive */
@media (max-width: 768px) {
  .navbar {
    padding: 0 16px;
    height: 52px;
  }
  
  .navbar-search {
    max-width: 300px;
    margin: 0 16px;
  }
  
  .navbar-user-name {
    display: none;
  }
  
  .navbar-icon-btn {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 480px) {
  .navbar-search {
    display: none;
  }
  
  .navbar-actions {
    gap: 4px;
  }
}
/* ==================== 改善されたモーダル ==================== */

/* Modal Overlay - より強いオーバーレイとブラー効果 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal:not(.hidden) {
  opacity: 1;
  pointer-events: all;
}

/* Modal Content - より洗練されたデザイン */
.modal-content {
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 
              0 0 0 1px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: min(600px, 90vw);
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: center;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Modal Large */
.modal-large {
  max-width: min(900px, 95vw);
}

/* Modal Header - より明確な区切り */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: linear-gradient(to bottom, #ffffff 0%, #fafafa 100%);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.02em;
}

/* Close Button - モダンなデザイン */
.modal-close-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 20px;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  line-height: 1;
  position: relative;
}

.modal-close-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: var(--text-tertiary);
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-close-btn:hover {
  color: var(--text-primary);
  transform: scale(1.05);
}

.modal-close-btn:hover::before {
  opacity: 0.08;
}

.modal-close-btn:active {
  transform: scale(0.95);
}

/* Modal Body - スクロール可能 */
.modal-body {
  padding: 28px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Modal Footer - 改善されたボタン配置 */
.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 20px 28px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #fafafa;
  flex-shrink: 0;
}

.modal-footer .btn-secondary {
  margin-right: auto;
}

/* Form in Modal */
.modal-content form {
  padding: 0;
}

.modal-content form .form-group {
  margin-bottom: 20px;
}

.modal-content form .form-group:last-of-type {
  margin-bottom: 0;
}

/* Search Modal Specific */
.search-modal-content {
  max-width: min(700px, 90vw);
}

.search-input-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 28px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: #fafafa;
}

.search-input-container input {
  flex: 1;
  height: 44px;
  padding: 0 16px;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  font-size: 15px;
  color: var(--text-primary);
  background: white;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-input-container input:focus {
  outline: none;
  border-color: var(--primary-green);
  box-shadow: 0 0 0 3px rgba(13, 92, 61, 0.08);
}

.search-filters {
  display: flex;
  gap: 8px;
  padding: 16px 28px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: white;
}

.filter-chip {
  padding: 8px 16px;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 20px;
  background: white;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--primary-green);
  color: var(--primary-green);
  background: rgba(13, 92, 61, 0.04);
}

.filter-chip.active {
  border-color: var(--primary-green);
  background: var(--primary-green);
  color: white;
}

.search-results {
  padding: 20px 28px;
  min-height: 200px;
}

/* Team Tabs */
.team-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  padding: 4px;
  background: #f0f0f0;
  border-radius: 10px;
}

.team-tab {
  flex: 1;
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.team-tab:hover {
  color: var(--text-primary);
}

.team-tab.active {
  background: white;
  color: var(--primary-green);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Color Picker */
.color-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.color-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-preset {
  width: 40px;
  height: 40px;
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.color-preset:hover {
  transform: scale(1.1);
  border-color: rgba(0, 0, 0, 0.2);
}

.color-preset.active {
  border-color: var(--primary-green);
  transform: scale(1.1);
}

.color-preset.active::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
  .modal {
    padding: 16px;
    align-items: flex-end;
  }
  
  .modal-content {
    max-height: calc(100vh - 40px);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
  
  .modal-header {
    padding: 20px;
  }
  
  .modal-body {
    padding: 20px;
  }
  
  .modal-footer {
    padding: 16px 20px;
    flex-direction: column-reverse;
  }
  
  .modal-footer .btn {
    width: 100%;
  }
  
  .modal-footer .btn-secondary {
    margin-right: 0;
  }
  
  .search-input-container {
    padding: 20px;
    flex-direction: column;
  }
  
  .search-input-container input {
    width: 100%;
  }
  
  .search-filters {
    padding: 12px 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .search-results {
    padding: 16px 20px;
  }
}

@media (max-width: 480px) {
  .modal-header h3 {
    font-size: 18px;
  }
  
  .team-tabs {
    flex-direction: column;
  }
  
  .color-presets {
    gap: 6px;
  }
  
  .color-preset {
    width: 36px;
    height: 36px;
  }
}


/* ==================== トースト通知 ==================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  min-width: 300px;
  max-width: 500px;
  padding: 16px 20px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15),
              0 0 0 1px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 3000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-message {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
}

/* Toast Types */
.toast-success {
  border-left: 4px solid #10b981;
}

.toast-success .toast-icon {
  color: #10b981;
}

.toast-error {
  border-left: 4px solid #ef4444;
}

.toast-error .toast-icon {
  color: #ef4444;
}

.toast-warning {
  border-left: 4px solid #f59e0b;
}

.toast-warning .toast-icon {
  color: #f59e0b;
}

.toast-info {
  border-left: 4px solid #3b82f6;
}

.toast-info .toast-icon {
  color: #3b82f6;
}

/* ==================== ボタンのローディング状態 ==================== */
.btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  cursor: not-allowed;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spinner 0.6s linear infinite;
}

.btn-primary.loading::after {
  border-color: #ffffff;
  border-top-color: transparent;
}

.btn-secondary.loading::after {
  border-color: var(--primary-color);
  border-top-color: transparent;
}

@keyframes spinner {
  to { 
    transform: rotate(360deg); 
  }
}

/* ==================== モーダルのアクセシビリティ改善 ==================== */

/* モーダルが開いているときの背景スクロール防止 */
body.modal-open {
  overflow: hidden;
}

/* フォーカス可能な要素のフォーカススタイル強化 */
.modal input:focus,
.modal textarea:focus,
.modal select:focus,
.modal button:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* モーダル内のリンクのフォーカススタイル */
.modal a:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ==================== レスポンシブ: トースト通知 ==================== */
@media (max-width: 768px) {
  .toast {
    bottom: 16px;
    right: 16px;
    left: 16px;
    min-width: auto;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .toast {
    bottom: 12px;
    right: 12px;
    left: 12px;
    padding: 14px 16px;
  }
  
  .toast-message {
    font-size: 13px;
  }
}


/* ===== Templates Section ===== */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.template-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-card:hover {
  border-color: #0d5c3d;
  box-shadow: 0 4px 12px rgba(13, 92, 61, 0.1);
  transform: translateY(-2px);
}

.template-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.template-icon {
  font-size: 32px;
}

.template-badge {
  background: #f3f4f6;
  color: #6b7280;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.template-title {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  margin: 0 0 10px 0;
}

.template-description {
  color: #6b7280;
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 15px 0;
}

.template-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 15px;
  border-top: 1px solid #f3f4f6;
}

.template-usage-count {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #9ca3af;
  font-size: 13px;
}

.template-usage-count svg {
  width: 16px;
  height: 16px;
}

/* ===== Generation History Section ===== */
.generation-history-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.history-item {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-item:hover {
  border-color: #0d5c3d;
  box-shadow: 0 2px 8px rgba(13, 92, 61, 0.1);
}

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

.history-item-type {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-type-icon {
  font-size: 20px;
}

.history-type-label {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
}

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

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.btn-icon:hover {
  background: #f3f4f6;
}

.history-item-content {
  margin-bottom: 12px;
}

.history-item-title {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin: 0 0 8px 0;
}

.history-item-preview {
  color: #6b7280;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.history-item-footer {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
  color: #9ca3af;
  padding-top: 12px;
  border-top: 1px solid #f3f4f6;
}

.history-item-date {
  font-weight: 500;
}

.history-item-project,
.history-item-brand-voice {
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 12px;
}

.history-item-tokens {
  margin-left: auto;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.pagination-btn {
  background: white;
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.pagination-btn:hover:not(.active) {
  border-color: #0d5c3d;
  color: #0d5c3d;
}

.pagination-btn.active {
  background: #0d5c3d;
  color: white;
  border-color: #0d5c3d;
  cursor: default;
}

.pagination-ellipsis {
  padding: 8px 4px;
  color: #9ca3af;
}

/* ===== Brand Voices Section ===== */
.brand-voices-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.brand-voice-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s ease;
}

.brand-voice-card:hover {
  border-color: #0d5c3d;
  box-shadow: 0 2px 8px rgba(13, 92, 61, 0.1);
}

.brand-voice-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.brand-voice-name {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

.badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-primary {
  background: #0d5c3d;
  color: white;
}

.brand-voice-card-body {
  margin-bottom: 15px;
}

.brand-voice-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  color: #6b7280;
}

.brand-voice-instructions {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.5;
  margin: 0;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
}

.brand-voice-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 15px;
  border-top: 1px solid #f3f4f6;
}

.brand-voice-date {
  font-size: 13px;
  color: #9ca3af;
}

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

/* History Detail Modal */
.history-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 20px;
  padding: 15px;
  background: #f9fafb;
  border-radius: 8px;
  font-size: 14px;
}

.history-detail-content {
  margin-bottom: 20px;
}

.history-detail-content h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px 0;
}

.generated-content {
  background: #f9fafb;
  padding: 20px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Button variants */
.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-filter {
  background: white;
  border: 1px solid #e5e7eb;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-filter:hover {
  border-color: #0d5c3d;
  color: #0d5c3d;
}

.btn-filter.active {
  background: #0d5c3d;
  color: white;
  border-color: #0d5c3d;
}

/* Required field indicator */
.required {
  color: #ef4444;
  margin-left: 4px;
}

/* Modal size variants */
.modal-large .modal-content {
  max-width: 800px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .templates-grid {
    grid-template-columns: 1fr;
  }
  
  .brand-voices-list {
    grid-template-columns: 1fr;
  }
  
  .history-item-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .history-item-tokens {
    margin-left: 0;
  }
  
  .brand-voice-card-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .brand-voice-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}
