/* ============================================================
   TARA SISTER X投稿管理 - Stylesheet
   Aesthetic: Warm, refined, Japanese-inspired wellness
   ============================================================ */

:root {
  /* Warm palette inspired by natural materials */
  --ink: #1a1a2e;
  --ink-light: #3a3a5e;
  --ink-muted: #8888a0;
  --warm-bg: #faf8f5;
  --warm-card: #ffffff;
  --warm-border: #e8e4df;
  --warm-hover: #f5f2ed;
  --accent: #8b6f4e;
  --accent-hover: #73593c;
  --accent-light: #f0e8dd;
  --claude-blue: #4a7fb5;
  --claude-bg: #e8f0f8;
  --openai-green: #5a9e6f;
  --openai-bg: #e8f5ec;
  --success: #5a9e6f;
  --error: #c45e5e;
  --error-bg: #fde8e8;

  --font-display: 'Cormorant Garamond', 'Georgia', serif;
  --font-body: 'Zen Kaku Gothic New', 'Hiragino Sans', sans-serif;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(26,26,46,0.06);
  --shadow-md: 0 4px 12px rgba(26,26,46,0.08);
  --shadow-lg: 0 8px 24px rgba(26,26,46,0.12);
  --transition: 0.2s ease;
}

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

body {
  font-family: var(--font-body);
  background: var(--warm-bg);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
}

/* ===== Screens ===== */
.screen { display: none; }
.screen.active { display: block; }

/* ===== Login ===== */
.login-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(160deg, #f5f0e8 0%, #faf8f5 50%, #f0ebe3 100%);
}

.login-brand {
  text-align: center;
  margin-bottom: 2.5rem;
}

.login-mark {
  font-family: var(--font-body);
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  border: 2px solid var(--accent);
  border-radius: 50%;
}

.login-brand h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  color: var(--ink);
}

.login-sub {
  font-size: 0.8rem;
  color: var(--ink-muted);
  letter-spacing: 0.1em;
  margin-top: 0.3rem;
}

.login-form {
  width: 100%;
  max-width: 360px;
}

/* ===== Form elements ===== */
.input-group {
  margin-bottom: 1rem;
}

.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-light);
  margin-bottom: 0.3rem;
}

.input-group input,
.input-group textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--warm-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: var(--warm-card);
  color: var(--ink);
  transition: border-color var(--transition);
}

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

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.error-text {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 0.75rem;
  text-align: center;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--warm-card);
  color: var(--ink);
  border: 1px solid var(--warm-border);
}
.btn-secondary:hover { background: var(--warm-hover); }

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
}
.btn-ghost:hover { color: var(--ink); background: var(--warm-hover); }

.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
}
.btn-danger:hover { background: var(--error-bg); }

.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

/* ===== App Header ===== */
.app-header {
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--warm-card);
  border-bottom: 1px solid var(--warm-border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-right: 2rem;
}

.header-mark {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
}

.header-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.1em;
}

.header-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.nav-btn {
  background: none;
  border: none;
  padding: 0.4rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all var(--transition);
}

.nav-btn:hover { color: var(--ink); background: var(--warm-hover); }
.nav-btn.active { color: var(--accent); background: var(--accent-light); font-weight: 500; }

/* ===== Main content ===== */
.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

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

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.05em;
}

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

/* ===== Cards ===== */
.card {
  background: var(--warm-card);
  border: 1px solid var(--warm-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.card h3 {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-bottom: 0.75rem;
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--warm-card);
  border: 1px solid var(--warm-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--ink);
}

.stat-value-sm { font-size: 1rem; }

/* ===== Tables ===== */
.table-container { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: var(--ink);
  color: white;
  font-weight: 500;
  font-size: 0.78rem;
  white-space: nowrap;
}

thead th:first-child { border-radius: var(--radius) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius) 0 0; }

tbody td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--warm-border);
  vertical-align: top;
}

tbody tr:hover { background: var(--warm-hover); }

.cell-actions { white-space: nowrap; }
.cell-actions button { margin-right: 0.3rem; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 500;
}

.badge-claude { background: var(--claude-bg); color: var(--claude-blue); }
.badge-openai { background: var(--openai-bg); color: var(--openai-green); }
.badge-success { background: var(--openai-bg); color: var(--success); }
.badge-fail { background: var(--error-bg); color: var(--error); }

.tweet-preview {
  max-width: 320px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-light);
}

/* ===== Prompts ===== */
.prompt-textarea {
  width: 100%;
  padding: 0.85rem;
  border: 1px solid var(--warm-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.85rem;
  line-height: 1.7;
  resize: vertical;
  background: var(--warm-bg);
}

.prompt-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--warm-card);
}

.prompt-guide {
  font-size: 0.85rem;
  color: var(--ink-muted);
  line-height: 1.6;
}

.prompt-vars code {
  background: var(--accent-light);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--accent);
}

/* ===== Analysis ===== */
.winner-card {
  background: var(--accent-light);
  border: 1px solid var(--warm-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
}

.chart-area {
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 1rem 0;
}

.chart-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.chart-bar-group {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 140px;
}

.chart-bar {
  width: 14px;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.5s ease;
}

.chart-bar.claude { background: var(--claude-blue); }
.chart-bar.openai { background: var(--openai-green); }

.chart-label {
  font-size: 0.65rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.3rem;
}

/* ===== Result card ===== */
.result-body {
  background: var(--warm-bg);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.7;
  margin-top: 0.5rem;
}

.result-body .meta {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-top: 0.5rem;
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal[hidden] { display: none; }

.modal-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(26,26,46,0.4);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--warm-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--warm-border);
}

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

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--ink-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body { padding: 1.5rem; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* ===== Pager ===== */
.pager {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  animation: toastIn 0.3s ease;
}

.toast[hidden] { display: none; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== Utilities ===== */
.loading {
  text-align: center;
  color: var(--ink-muted);
  padding: 2rem;
}

.text-muted { color: var(--ink-muted); }
.text-sm { font-size: 0.8rem; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .app-header {
    flex-wrap: wrap;
    height: auto;
    padding: 0.75rem 1rem;
  }
  .header-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-top: 0.5rem;
    gap: 0;
  }
  .nav-btn { font-size: 0.75rem; padding: 0.35rem 0.65rem; }
  .app-main { padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .input-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
}
