* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(74, 144, 226, 0.13), transparent 28rem),
    linear-gradient(135deg, #f5f7fa 0%, #edf2f7 100%);
  color: #1f2937;
}

body {
  min-height: 100vh;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.hero-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 24px;
  border: 1px solid rgba(215, 222, 231, 0.9);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 18px 48px rgba(28, 53, 94, 0.08);
}

.eyebrow {
  margin: 0 0 8px;
  color: #4f6f9f;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-header h1 {
  margin: 0;
  color: #1c355e;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.15;
}

.hero-copy {
  max-width: 760px;
  margin: 10px 0 0;
  color: #5f6f86;
  line-height: 1.7;
}

.hero-copy code {
  border-radius: 7px;
  padding: 2px 7px;
  background: #eef3fb;
  color: #1c355e;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
}

.workflow-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.9fr) minmax(460px, 1.1fr);
  gap: 20px;
  align-items: start;
}

.panel,
.card {
  border: 1px solid rgba(215, 222, 231, 0.9);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 36px rgba(28, 53, 94, 0.07);
}

.panel {
  padding: 20px;
}

.input-panel {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 172px);
}

.result-panel {
  display: grid;
  gap: 16px;
}

.card {
  padding: 18px;
}

.card-header {
  margin-bottom: 14px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.section-heading.compact {
  gap: 10px;
}

.step-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #1c355e;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.section-heading h2,
.card-header h2 {
  margin: 0;
  color: #1c355e;
  font-size: 18px;
}

.section-heading p,
.card-header p {
  margin: 5px 0 0;
  color: #6b7280;
  font-size: 13px;
  line-height: 1.55;
}

.analysis-context-label,
.trainer-select-label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 18px;
  color: #4b5563;
  font-size: 12px;
  font-weight: 800;
}

.analysis-context-label select,
.trainer-select-label select {
  width: 100%;
  border: 1px solid #d7dee7;
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  color: #1f2937;
  font: inherit;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid #d7dee7;
  border-radius: 16px;
  background: #fff;
  padding: 18px;
  color: #1f2937;
  font: inherit;
  font-size: 16px;
  line-height: 1.7;
  outline: none;
}

#promptInput {
  flex: 1;
  min-height: 420px;
  margin-top: 16px;
  resize: none;
}

textarea:focus,
select:focus {
  border-color: #1c355e;
  box-shadow: 0 0 0 4px rgba(28, 53, 94, 0.08);
}

button,
#copyButton,
#trainerCheckButton,
.secondary-button {
  border: none;
  border-radius: 11px;
  padding: 10px 16px;
  background: #1c355e;
  color: white;
  cursor: pointer;
  font-weight: 700;
  transition: 0.18s ease;
}

button:hover,
#copyButton:hover,
#trainerCheckButton:hover {
  background: #27497f;
}

.secondary-button {
  background: #e8edf5;
  color: #1c355e;
  white-space: nowrap;
}

.secondary-button:hover {
  background: #d9e2f0;
}

.helper-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

#generatedPrompt {
  min-height: 190px;
  max-height: 320px;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  border-radius: 14px;
  background: #f8fafc;
  padding: 16px;
  line-height: 1.7;
}

.empty-message {
  color: #8a94a6;
}

.score-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 15px 16px;
  margin-bottom: 14px;
}

.score-label {
  margin-bottom: 4px;
  font-size: 17px;
  font-weight: 800;
}

.score-message {
  font-size: 13px;
  line-height: 1.6;
}

.score-number {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  font-size: 24px;
  font-weight: 800;
}

.score-red { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.score-orange { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.score-yellow { background: #fefce8; border-color: #fde68a; color: #854d0e; }
.score-green { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

.checker-intro {
  margin: 0 0 14px;
  color: #4b5563;
  font-size: 13px;
  line-height: 1.7;
}

.checker-issue {
  border: 1px solid #dbe3ee;
  border-left: 5px solid #1c355e;
  border-radius: 15px;
  padding: 14px;
  margin-bottom: 14px;
  background: #f8fafc;
}

.checker-issue-warning { border-left-color: #f97316; background: #fff8f0; }
.checker-issue-notice { border-left-color: #eab308; background: #fffde8; }
.checker-issue-info { border-left-color: #3b82f6; background: #f5f9ff; }

.issue-title-row,
.warning-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.issue-title-row strong {
  color: #1c355e;
}

.issue-level,
.rule-score {
  flex: none;
  border-radius: 999px;
  padding: 3px 9px;
  background: rgba(255, 255, 255, 0.82);
  color: #374151;
  font-size: 12px;
  font-weight: 800;
}

.checker-issue p {
  margin: 0;
  line-height: 1.65;
}

.issue-section,
.rewrite-box > div {
  margin-top: 10px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.78);
  padding: 10px;
}

.issue-section span,
.improved-title,
.rewrite-title,
.bad-prompt-box span,
.model-answer-box span,
.trainer-hints span {
  display: inline-block;
  margin-bottom: 4px;
  color: #4b5563;
  font-size: 12px;
  font-weight: 800;
}

.improved-prompt-box {
  border: 1px solid #d7dee7;
  border-radius: 15px;
  padding: 14px;
  background: #fff;
  margin: 2px 0 14px;
}

.improved-prompt-box pre,
.model-answer-box pre {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.7;
  font-family: inherit;
  color: #1f2937;
}

.legacy-rule-details {
  border-top: 1px solid #e5e7eb;
  padding-top: 12px;
  margin-top: 4px;
}

.legacy-rule-details summary,
.trainer-card summary {
  cursor: pointer;
}

.warning {
  border-left: 5px solid #d35400;
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 14px;
  background: #fff8f3;
  line-height: 1.6;
}

.warning-red { border-left-color: #dc2626; background: #fff5f5; }
.warning-orange { border-left-color: #f97316; background: #fff8f0; }
.warning-yellow { border-left-color: #eab308; background: #fffde8; }
.warning-green { border-left-color: #16a34a; background: #f5fff8; }

.warning-description,
.matched-words,
.tag-list {
  margin-top: 8px;
}

.matched-words {
  color: #4b5563;
  font-size: 13px;
}

.matched-words code {
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  padding: 2px 6px;
  margin: 2px;
  font-family: inherit;
  font-size: 12px;
}

.rewrite-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.rewrite-box p {
  margin: 0;
  color: #374151;
  font-size: 12px;
  line-height: 1.55;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #edf2ff;
  color: #294172;
  padding: 6px 12px;
  margin-top: 6px;
  margin-right: 8px;
  font-size: 13px;
  font-weight: 700;
}

.trainer-card {
  padding: 0;
  overflow: hidden;
}

.trainer-card summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  list-style: none;
}

.trainer-card summary::-webkit-details-marker {
  display: none;
}

.details-indicator {
  flex: none;
  border-radius: 999px;
  background: #eef3fb;
  color: #1c355e;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
}

.trainer-card[open] .details-indicator {
  color: #fff;
  background: #1c355e;
}

.trainer-card[open] .details-indicator::before {
  content: "閉じる";
}

.trainer-card[open] .details-indicator {
  font-size: 0;
}

.trainer-card[open] .details-indicator::before {
  font-size: 12px;
}

.trainer-content {
  display: grid;
  gap: 12px;
  padding: 0 18px 18px;
}

.trainer-select-label {
  margin-top: 0;
}

.trainer-lesson,
.trainer-feedback {
  border: 1px solid #dbe3ee;
  border-radius: 14px;
  padding: 14px;
  background: #f8fafc;
}

.trainer-category {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 10px;
  background: #edf2ff;
  color: #294172;
  font-size: 12px;
  font-weight: 800;
}

.trainer-lesson h3 {
  margin: 10px 0;
  color: #1c355e;
  font-size: 16px;
}

.bad-prompt-box,
.model-answer-box,
.trainer-hints {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.bad-prompt-box p,
.model-answer-box p,
.trainer-instruction {
  margin: 0;
  line-height: 1.65;
}

.trainer-instruction {
  margin-top: 10px;
  color: #374151;
}

.trainer-answer {
  min-height: 120px;
  height: 120px;
  resize: vertical;
  padding: 14px;
  border-radius: 12px;
  font-size: 14px;
}

.trainer-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.trainer-feedback {
  line-height: 1.65;
}

.trainer-feedback-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.trainer-feedback-summary span {
  flex: none;
  border-radius: 999px;
  padding: 3px 9px;
  background: #fff;
  color: #1c355e;
  font-weight: 800;
}

.checkpoint-list,
.trainer-hints ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.checkpoint-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.checkpoint-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  font-size: 13px;
}

.checkpoint-list li span {
  font-weight: 900;
}

.checkpoint-passed { color: #166534; }
.checkpoint-missing { color: #6b7280; }

.trainer-hints {
  margin-top: 10px;
}

.trainer-hints li {
  margin-top: 6px;
  color: #374151;
}

.model-answer-box {
  margin-top: 10px;
}

.why-box {
  background: #fffdf0;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 14px;
  }

  .hero-header,
  .workflow-layout,
  .helper-header {
    display: flex;
    flex-direction: column;
  }

  .input-panel {
    position: static;
    min-height: auto;
  }

  #promptInput {
    min-height: 300px;
  }

  .rewrite-box,
  .checkpoint-list {
    grid-template-columns: 1fr;
  }
}
