:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e2e2e2;
  --panel: #fafafa;
  --accent: #2563eb;
  --danger: #dc2626;
  --green: #16a34a;
  --yellow: #d97706;
  --red: #dc2626;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.layout {
  display: flex;
  min-height: 100vh;
}

.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
}

.auth-form {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 28px;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form h2 {
  margin: 0 0 4px;
  font-size: 16px;
  text-align: center;
}

.auth-form input[type="password"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
  text-align: center;
}

.sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 20px;
  overflow-y: auto;
}

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

.sidebar-header h2 {
  font-size: 16px;
  margin: 0;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s;
}

.history-item:hover {
  border-color: var(--accent);
}

.history-item .h-date {
  font-size: 11px;
  color: var(--muted);
}

.history-item .h-theme {
  font-size: 13px;
  margin: 4px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-item .h-score {
  font-weight: 700;
  color: var(--accent);
}

.history-item .h-genre {
  display: inline-block;
  font-size: 10px;
  color: var(--accent);
  background: #eef2ff;
  border-radius: 999px;
  padding: 2px 8px;
  margin: 2px 0 4px;
}

.history-empty {
  color: var(--muted);
  font-size: 13px;
}

.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 820px;
}

h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 20px;
}

textarea#scriptInput {
  width: 100%;
  min-height: 220px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  font-family: inherit;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 28px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-ghost-danger {
  background: none;
  border: 1px solid var(--border);
  color: var(--danger);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.status {
  font-size: 13px;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.result-section {
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

.score-hero {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 24px;
}

.total-score {
  font-size: 64px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.score-label {
  font-size: 18px;
  color: var(--muted);
}

.genre-badge {
  margin-left: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  padding: 4px 14px;
  white-space: nowrap;
}

.genre-badge:empty {
  display: none;
}

.block {
  margin-bottom: 24px;
}

.block h3 {
  font-size: 15px;
  margin: 0 0 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.block p {
  margin: 0;
  line-height: 1.7;
  font-size: 15px;
}

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

.category-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.category-item .cat-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 12px;
  margin-bottom: 8px;
}

.category-item .cat-name {
  font-weight: 700;
  font-size: 14px;
  flex: 1 1 auto;
  min-width: 0;
}

.category-item .cat-score {
  font-weight: 700;
  font-size: 14px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.bar-track {
  width: 100%;
  height: 8px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.bar-fill.green { background: var(--green); }
.bar-fill.yellow { background: var(--yellow); }
.bar-fill.red { background: var(--red); }

.cat-comment {
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 6px;
}

.cat-improvement {
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
  color: #444;
  background: var(--panel);
  border-radius: 6px;
  padding: 8px 10px;
}

.cat-improvement strong {
  color: var(--accent);
}

.top-improvements {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.8;
}

.raw-fallback {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 20px;
}

.raw-fallback pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--panel);
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
}
