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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f6fa;
  color: #2d3436;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ---- Header ---- */
header {
  text-align: center;
  margin-bottom: 36px;
}

header h1 {
  font-size: 26px;
  font-weight: 700;
  color: #1e1e2f;
  letter-spacing: -0.3px;
}

/* ---- Top Nav (base) ---- */
.top-nav {
  margin-top: 16px;
  font-size: 14px;
}

.top-nav a {
  text-decoration: none;
  color: #4f6ef7;
  font-weight: 500;
  transition: color 0.15s;
}

.top-nav a:hover {
  color: #3e5de6;
}

/* Tab-style nav (pill buttons) */
.top-nav.tab-nav {
  display: inline-flex;
  gap: 4px;
  background: #ebedf2;
  border-radius: 10px;
  padding: 4px;
}

.top-nav.tab-nav a {
  padding: 8px 20px;
  border-radius: 8px;
  color: #636e72;
  font-weight: 500;
}

.top-nav.tab-nav a.active {
  background: #fff;
  color: #4f6ef7;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.top-nav.tab-nav a:not(.active):hover {
  color: #2d3436;
}

/* Breadcrumb nav */
.top-nav.breadcrumb-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.breadcrumb-nav .crumb-btn {
  padding: 4px 10px;
  border-radius: 6px;
  background: #f5f6fa;
  transition: background 0.15s;
}

.breadcrumb-nav .crumb-btn:hover {
  background: #eef0f8;
  text-decoration: none;
}

.breadcrumb-nav .crumb-sep {
  color: #c0c7d0;
  font-weight: 300;
}

.breadcrumb-nav .crumb-current {
  font-weight: 600;
  color: #333;
  padding: 4px 10px;
}

/* ---- Main Layout ---- */
.main-layout {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 28px;
  align-items: start;
}

@media (max-width: 960px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 16px 8px;
  }

  header {
    margin-bottom: 20px;
  }

  header h1 {
    font-size: 18px;
  }

  .input-section {
    padding: 16px 14px;
    border-radius: 12px;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .form-group {
    margin-bottom: 12px;
  }

  .form-group select,
  .form-group textarea {
    font-size: 16px;  /* prevent iOS zoom on focus */
    padding: 10px 12px;
  }

  .submit-btn {
    padding: 14px 0;
    font-size: 16px;
  }

  /* Result section mobile */
  .result-section {
    padding: 16px 14px;
    border-radius: 12px;
    min-height: auto;
  }

  .result-placeholder {
    min-height: 200px;
  }

  .placeholder-icon {
    font-size: 36px;
  }

  .result-placeholder p {
    font-size: 13px;
  }

  .score-circle {
    width: 72px;
    height: 72px;
  }

  .score-number {
    font-size: 26px;
  }

  .score-label {
    font-size: 10px;
  }

  /* 4-column dim scores → 2×2 on mobile */
  .dimension-scores {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 18px;
  }

  .dim-card {
    padding: 10px 6px;
  }

  .dim-card .dim-name {
    font-size: 11px;
  }

  .dim-card .dim-score {
    font-size: 18px;
  }

  /* Result blocks */
  .result-block {
    padding: 12px 14px;
    margin-bottom: 12px;
  }

  .result-block h3 {
    font-size: 13px;
  }

  .error-item,
  .suggestion-item {
    font-size: 13px;
    padding: 6px 0;
  }

  .comment-text {
    font-size: 13px;
  }

  .transcribed-box {
    font-size: 12px;
    padding: 10px 12px;
  }

  /* Loading */
  .loading-overlay p {
    font-size: 13px;
  }

  .top-nav.tab-nav a {
    padding: 6px 12px;
    font-size: 12px;
  }
}

/* ---- Input Section ---- */
.input-section {
  background: #fff;
  border-radius: 16px;
  padding: 28px 28px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-group-half {
  flex: 1;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: #555;
  letter-spacing: 0.2px;
}

.label-hint {
  font-weight: 400;
  font-size: 12px;
  color: #aaa;
}

.form-group select,
.form-group textarea {
  width: 100%;
  border: 1.5px solid #e2e5ee;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: #333;
  background: #fafbfc;
  transition: all 0.2s;
  resize: vertical;
  line-height: 1.6;
}

.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #4f6ef7;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.08);
}

.word-count {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: #aaa;
}

/* ---- Image Upload ---- */
.image-upload-area {
  border: 2px dashed #dde1ed;
  border-radius: 12px;
  min-height: 88px;
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
  background: #fafbfc;
}

.image-upload-area:hover {
  border-color: #4f6ef7;
  background: #f8f9ff;
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 88px;
  color: #b0b8c8;
  font-size: 13px;
  gap: 3px;
}

.upload-icon {
  font-size: 26px;
  line-height: 1;
}

.upload-subhint {
  font-size: 11px;
  color: #ccd;
}

.image-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 240px;
  background: #f5f5f5;
}

.image-preview img {
  max-width: 100%;
  max-height: 240px;
  object-fit: contain;
}

.remove-image {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.2s;
}

.remove-image:hover {
  background: rgba(0,0,0,0.7);
}

/* ---- Divider ---- */
.divider {
  display: flex;
  align-items: center;
  margin: 18px 0;
  color: #c0c7d0;
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #eef0f5;
}

.divider-text {
  padding: 0 16px;
}

/* ---- Submit Button ---- */
.submit-btn {
  width: 100%;
  padding: 12px 0;
  background: #4f6ef7;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.submit-btn:hover {
  background: #3e5de6;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 110, 247, 0.3);
}

.quota-info {
  text-align: center;
  margin-top: 10px;
  font-size: 13px;
  color: #4f6ef7;
  font-weight: 600;
}

.submit-btn:disabled {
  background: #b8c4f8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ---- Result Section ---- */
.result-section {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  min-height: 500px;
}

.result-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 420px;
  color: #c0c7d8;
}

.placeholder-icon {
  font-size: 52px;
  margin-bottom: 14px;
  opacity: 0.6;
}

/* ---- Score Circle ---- */
.score-circle-wrapper {
  text-align: center;
  margin-bottom: 24px;
}

.score-circle {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.score-number {
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}

.score-label {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 3px;
}

/* ---- Dimension Scores ---- */
.dimension-scores {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}

.dim-card {
  background: #f8f9fd;
  border-radius: 10px;
  padding: 14px 8px;
  text-align: center;
  border: 1px solid #f0f2f8;
}

.dim-card .dim-name {
  font-size: 11px;
  color: #999;
  margin-bottom: 5px;
}

.dim-card .dim-score {
  font-size: 20px;
  font-weight: 700;
  color: #4f6ef7;
}

/* ---- Result Blocks ---- */
.result-block {
  margin-bottom: 18px;
  padding: 18px 20px;
  background: #fafbfd;
  border-radius: 10px;
  border: 1px solid #f0f2f8;
}

.result-block h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: #1e1e2f;
  display: flex;
  align-items: center;
  gap: 6px;
}

.result-block h3::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 16px;
  background: #4f6ef7;
  border-radius: 2px;
}

.error-item,
.suggestion-item {
  padding: 8px 0;
  border-bottom: 1px solid #f0f2f6;
  font-size: 14px;
  line-height: 1.6;
}

.error-item:last-child,
.suggestion-item:last-child {
  border-bottom: none;
}

.error-original {
  color: #e74c3c;
  text-decoration: line-through;
}

.error-correction {
  color: #27ae60;
  font-weight: 600;
}

.error-explanation {
  display: block;
  font-size: 12px;
  color: #999;
  margin-top: 3px;
}

.vocab-original {
  color: #e67e22;
}

.vocab-suggestion {
  color: #27ae60;
  font-weight: 600;
}

.sentence-original {
  color: #e67e22;
  margin-bottom: 3px;
  font-size: 13px;
}

.sentence-revised {
  color: #27ae60;
  margin-bottom: 3px;
  font-size: 13px;
}

.sentence-reason {
  font-size: 12px;
  color: #aaa;
  font-style: italic;
}

.tip-item {
  padding: 5px 0;
  font-size: 13px;
  line-height: 1.6;
  list-style-type: none;
  position: relative;
  padding-left: 16px;
}

.tip-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 11px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4f6ef7;
}

.tip-item + .tip-item {
  margin-top: 2px;
}

.comment-text {
  font-size: 14px;
  color: #555;
  line-height: 1.7;
}

.comment-text.good {
  color: #27ae60;
}

/* ---- Loading Overlay ---- */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.loading-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid #e8ecf4;
  border-top-color: #4f6ef7;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 14px;
}

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

.loading-overlay p {
  font-size: 14px;
  color: #777;
}

/* ---- Error Banner ---- */
.error-banner {
  background: #fef5f5;
  border: 1px solid #fdd;
  color: #e74c3c;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
}

/* ---- Transcribed text (image upload) ---- */
.transcribed-box {
  background: #fdfaed;
  border: 1px solid #f5e6b8;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13px;
  line-height: 1.7;
  color: #8a7a40;
  white-space: pre-wrap;
  margin-bottom: 20px;
}
