@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── ☀️ ライトモード（極上の水色50・クリアテーマ） ── */
:root {
  --bg-primary: #f0f9ff;         /* 水色50 */
  --bg-secondary: #ffffff;       /* 真っ白 */
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f8fafc;
  --border: #e2e8f0;
  --border-focus: #0ea5e9;
  --text-primary: #0f172a;       /* 濃いネイビーグレー */
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent: #0ea5e9;             /* スカイブルー */
  --accent-hover: #0284c7;
  --accent-glow: rgba(14, 165, 233, 0.15);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  /* 爽やかなブルー〜パープルのグラデーション */
  --gradient-accent: linear-gradient(135deg, #0ea5e9 0%, #3b82f6 50%, #6366f1 100%);
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --font-sans: 'Noto Sans JP', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* ── 🌙 ダークモード（あなたの元のカッコいい黒テーマ） ── */
[data-theme="dark"] {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a26;
  --bg-card-hover: #22222f;
  --bg-input: #15151f;
  --border: #2a2a3a;
  --border-focus: #6366f1;
  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #555568;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --gradient-accent: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

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

html { font-size: 15px; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ── Utility ── */
.container { max-width: 960px; margin: 0 auto; padding: 0 24px; }
.hidden { display: none !important; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }

/* ── Top Bar ── */
.topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.topbar-logo {
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.topbar-nav { display: flex; align-items: center; gap: 8px; }

.topbar-nav a, .topbar-nav button {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 6px;
  transition: all 0.2s;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-sans);
}

.topbar-nav a:hover, .topbar-nav button:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.topbar-nav .nav-user {
  color: var(--accent);
  font-weight: 500;
}

/* ── Auth Pages ── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(14, 165, 233, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
    var(--bg-primary);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}

.auth-card .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s ease, color 0.3s ease;
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
}

.form-group .help-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 5px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.checkbox-row label {
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-sans);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-accent);
  color: #fff;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.35);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-block { width: 100%; }

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }

/* ── Dashboard ── */
.dashboard { padding: 32px 0; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.stat-card .stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.stat-card .stat-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Generate Section ── */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.section-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
}

.section-card h2 .icon {
  font-size: 1.2rem;
}

/* ── Progress ── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  margin: 12px 0;
}

.progress-bar .fill {
  height: 100%;
  background: var(--gradient-accent);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ── Status Indicator ── */
.status-generating {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--accent-glow);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius);
  margin-top: 16px;
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Article Result ── */
.result-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.result-card .result-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--success);
}

.result-card .result-meta {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

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

/* ── History Table ── */
.history-table {
  width: 100%;
  border-collapse: collapse;
}

.history-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}

.history-table td {
  padding: 12px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.history-table tr:hover td {
  background: var(--bg-card-hover);
}

.history-table .title-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-posted { background: var(--success-bg); color: var(--success); }
.badge-generated { background: var(--accent-glow); color: var(--accent); }
.badge-error { background: var(--danger-bg); color: var(--danger); }
.badge-generating { background: var(--warning-bg); color: var(--warning); }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 16px;
}

.alert-error {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.alert-success {
  background: var(--success-bg);
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.alert-info {
  background: var(--accent-glow);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: var(--accent-hover);
}

/* ── Plan Cards ── */
.plan-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.plan-free { background: rgba(136,136,160,0.15); color: var(--text-secondary); }
.plan-light { background: rgba(34,197,94,0.12); color: var(--success); }
.plan-standard { background: rgba(99,102,241,0.12); color: var(--accent); }
.plan-pro { background: rgba(245,158,11,0.12); color: var(--warning); }

/* ── Settings ── */
.settings-section {
  margin-bottom: 32px;
}

.settings-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Link ── */
a.link {
  color: var(--accent);
  text-decoration: none;
}

a.link:hover {
  text-decoration: underline;
}

/* ── Auth toggle ── */
.auth-toggle {
  text-align: center;
  margin-top: 24px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.auth-toggle a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab {
  padding: 10px 18px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font-sans);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
}

.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

/* ── Preview Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 780px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

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

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover { color: var(--text-primary); }

.preview-content {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 24px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.8;
  border: 1px solid var(--border);
}

.preview-content h2 { font-size: 1.3rem; margin: 24px 0 12px; }
.preview-content h3 { font-size: 1.1rem; margin: 20px 0 10px; }
.preview-content p { margin-bottom: 12px; }

/* ── Responsive ── */
@media (max-width: 640px) {
  html { font-size: 14px; }
  .auth-card { padding: 28px 20px; }
  .section-card { padding: 20px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 16px; }
  .container { padding: 0 16px; }
  .history-table { font-size: 0.82rem; }
  .history-table th, .history-table td { padding: 8px; }
}