/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html, body {
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  color: #212121;
  background: #f5f5f5;
  height: 100%;
}

/* === Login overlay === */
.login-overlay {
  position: fixed;
  inset: 0;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.login-overlay.hidden { display: none; }
.login-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 40px;
  width: 360px;
  text-align: center;
}
.login-card h2 {
  font-size: 20px;
  font-weight: 500;
  color: #333;
  margin-bottom: 8px;
}
.login-card p {
  font-size: 14px;
  color: #757575;
  margin-bottom: 20px;
}
.login-card input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #bdbdbd;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 12px;
}
.login-submit {
  width: 100%;
  padding: 10px;
  background: #3F51B5;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.login-submit:hover { background: #3949AB; }
.login-error {
  color: #c62828;
  font-size: 13px;
  margin-top: 12px;
}

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 8px 24px;
  height: 56px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 24px;
}
.header-logo {
  font-size: 18px;
  font-weight: 700;
  color: #3F51B5;
}
.header-logo sup {
  font-size: 10px;
}
.header-title {
  font-size: 18px;
  font-weight: 500;
  color: #333;
}
.header-back {
  display: none;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 14px;
  color: #3F51B5;
  cursor: pointer;
}
.header-back .material-icons { font-size: 20px; }

/* === Step bar === */
.step-bar {
  display: flex;
  background: #f26e22;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
}
.step-item {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  opacity: 0.7;
  position: relative;
}
.step-item.active {
  opacity: 1;
  font-weight: 700;
}
.step-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 25%;
  width: 50%;
  height: 3px;
  background: #fff;
  border-radius: 2px 2px 0 0;
}

/* === Main layout === */
.main-layout {
  display: flex;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  gap: 24px;
  min-height: calc(100vh - 100px);
}
.message-column {
  flex: 1;
  min-width: 0;
}

/* === Page title === */
.page-title {
  font-size: 20px;
  font-weight: 400;
  color: #333;
  margin-bottom: 16px;
  line-height: 1.4;
}

/* === Settings row === */
.settings-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}
.setting-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.setting-group label {
  font-size: 12px;
  color: #757575;
  font-weight: 500;
}
.setting-group input {
  padding: 6px 10px;
  border: 1px solid #bdbdbd;
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  width: 180px;
}

/* === Note card === */
.note-card {
  background: #fff;
  border: 1px solid #95c3ff;
  border-radius: 8px;
  overflow: hidden;
}
.note-content {
  padding: 24px;
}
.note-content textarea {
  width: 100%;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: #424242;
  resize: vertical;
  min-height: 120px;
}
.note-actions {
  display: flex;
  justify-content: flex-end;
  padding: 8px 16px;
  border-top: 1px solid #e8e8e8;
  background: #fafafa;
}
.ai-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid #086ff7;
  color: #086ff7;
  border-radius: 20px;
  padding: 6px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.ai-btn:hover { background: #e8f0fe; }
.ai-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  vertical-align: middle;
}

/* === Criterion detail === */
.criterion-detail {
  margin-top: 20px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 24px;
}
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.detail-label {
  font-size: 14px;
  color: #757575;
}
.detail-dropdown select {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: #3F51B5;
  background: #fff;
  border: 1px solid #bdbdbd;
  border-radius: 4px;
  padding: 6px 28px 6px 10px;
  cursor: pointer;
  appearance: auto;
}
.detail-scores {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.detail-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 12px;
}
.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-yellow { background: #fff8e1; color: #f57f17; }
.badge-red { background: #fce4ec; color: #c62828; }
.badge-blue { background: #e3f2fd; color: #1565c0; }

.detail-section { margin-bottom: 12px; }
.detail-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: #757575;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.detail-section p, .detail-section div {
  font-size: 14px;
  line-height: 1.6;
  color: #424242;
}
.divider {
  border: none;
  border-top: 1px solid rgba(0,0,0,0.12);
  margin: 12px 0;
}

/* === Chip button === */
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 16px;
  padding: 4px 14px;
  font-family: inherit;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  margin-top: 8px;
}
.chip-btn:hover { background: #eee; }

/* === Tone section === */
.tone-section {
  margin-top: 20px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 24px;
}
.tone-header {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
}
.tone-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.tone-chip {
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 16px;
  padding: 6px 16px;
  font-family: inherit;
  font-size: 13px;
  color: #555;
  cursor: pointer;
}
.tone-chip:hover,
.tone-chip.active {
  background: #e3f2fd;
  border-color: #1565c0;
  color: #1565c0;
}
.tone-result {
  margin-top: 12px;
  padding: 16px;
  background: #fafafa;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}
#toneRewrittenText {
  font-size: 14px;
  line-height: 1.6;
  color: #424242;
  margin-bottom: 12px;
  white-space: pre-wrap;
}

/* === Action buttons === */
.action-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}
.btn-primary {
  padding: 8px 24px;
  border: 1px solid #bdbdbd;
  border-radius: 4px;
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  color: #555;
  cursor: pointer;
}
.btn-primary:hover { background: #f5f5f5; }

/* === Report sidebar === */
.report-sidebar {
  width: 360px;
  flex-shrink: 0;
}
.report-panel {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  position: sticky;
  top: 24px;
}
.report-close-row {
  display: flex;
  justify-content: flex-end;
  padding: 8px 12px 0;
}

/* === Score summary === */
.report-summary {
  padding: 8px 24px 16px;
  text-align: left;
}
.report-intro {
  font-size: 14px;
  color: #757575;
  margin-bottom: 4px;
}
.report-score-big {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.score-value {
  font-size: 36px;
  font-weight: 700;
  color: #212121;
}
.score-label {
  font-size: 14px;
  color: #757575;
}
.report-sub {
  font-size: 13px;
  color: #757575;
  margin-top: 2px;
}

/* === Criteria rows === */
.report-criteria {
  border-top: 1px solid rgba(0,0,0,0.12);
}
.criteria-row {
  border-bottom: 1px solid rgba(0,0,0,0.12);
}
.criteria-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  cursor: pointer;
  user-select: none;
}
.criteria-row-header:hover { background: #fafafa; }
.criteria-row-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.criteria-status-icon {
  font-size: 20px;
}
.criteria-status-icon.pass { color: #4caf50; }
.criteria-status-icon.partial { color: #ff9800; }
.criteria-status-icon.fail { color: #f44336; }
.criteria-row-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}
.criteria-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  white-space: nowrap;
}
.criteria-row-score {
  font-size: 13px;
  font-weight: 500;
  color: #333;
}
.criteria-expand-icon {
  font-size: 20px;
  color: #757575;
  transition: transform 0.2s;
}
.criteria-row.expanded .criteria-expand-icon {
  transform: rotate(180deg);
}
.criteria-row-body {
  display: none;
  padding: 0 24px 16px;
}
.criteria-row.expanded .criteria-row-body {
  display: block;
}
.criteria-detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9e9e9e;
  margin-bottom: 4px;
  margin-top: 10px;
}
.criteria-detail-label:first-child { margin-top: 0; }
.criteria-detail-text {
  font-size: 13px;
  line-height: 1.5;
  color: #616161;
}

/* === Report footer === */
.report-footer {
  padding: 12px 24px;
  font-size: 13px;
  color: #3F51B5;
  cursor: pointer;
  border-top: 1px solid rgba(0,0,0,0.12);
}
.report-footer:hover { text-decoration: underline; }

/* === Loading overlay === */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.loading-overlay[hidden] { display: none; }
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e0e0e0;
  border-top-color: #3F51B5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p {
  font-size: 16px;
  color: #555;
}

/* === Responsive === */
@media (max-width: 900px) {
  .main-layout { flex-direction: column; }
  .report-sidebar { width: 100%; }
  .report-panel { position: static; }
}

/* === Inline error banner === */
.eval-error-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  color: #b91c1c;
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.4;
}
.eval-error-banner[hidden] { display: none; }
.eval-error-icon { font-size: 20px; color: #dc2626; }
