:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --text: #1d2520;
  --muted: #667067;
  --line: #dce2da;
  --primary: #2f6f4e;
  --primary-strong: #24593e;
  --primary-soft: #e8f3ec;
  --danger: #b84032;
  --shadow: 0 18px 50px rgba(31, 48, 38, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(95, 141, 105, 0.16), transparent 30rem),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #ffffff;
  color: var(--text);
}

input:focus,
select:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(47, 111, 78, 0.12);
}

input[type="checkbox"] {
  width: auto;
  accent-color: var(--primary);
}

.app {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0;
}

.upload-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(220, 226, 218, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 36px);
}

.auth-app {
  width: min(520px, calc(100% - 32px));
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-panel {
  width: 100%;
}

.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px 14px;
}

.user-bar strong,
.user-bar span {
  display: block;
}

.user-bar strong {
  margin-bottom: 3px;
  color: var(--text);
  font-size: 15px;
}

.user-bar span {
  color: var(--muted);
  font-size: 13px;
}

.form-stack,
.admin-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.admin-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  margin-bottom: 8px;
}

.form-stack label,
.admin-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.admin-form button {
  align-self: end;
}

.admin-section {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 18px;
}

.admin-section + .admin-section {
  margin-top: 18px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.section-heading h2 {
  margin-bottom: 5px;
  font-size: 20px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.model-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 14px;
}

.model-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.provider-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.provider-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #e1e7de;
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.provider-item strong {
  display: block;
  margin-bottom: 4px;
}

.provider-item p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.status-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid #b8d7c4;
  border-radius: 999px;
  background: #eef8f2;
  color: var(--primary-strong);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.muted {
  border-color: var(--line);
  background: #f2f4f1;
  color: var(--muted);
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 14px;
  margin: 0 0 18px;
}

.filter-bar label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 22px;
  border: 1px solid #b8d7c4;
  border-radius: 8px;
  background: #eef8f2;
  padding: 14px 16px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

#selected-count {
  color: var(--primary-strong);
  font-size: 14px;
  font-weight: 700;
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.12;
  letter-spacing: 0;
}

.subtitle {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.counter {
  min-width: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  text-align: center;
  background: var(--primary-soft);
}

.counter strong {
  display: block;
  color: var(--primary-strong);
  font-size: 30px;
  line-height: 1;
}

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

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 28px;
  border: 2px dashed #aebdaf;
  border-radius: 8px;
  background: #fbfcfa;
  cursor: pointer;
  text-align: center;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.drop-zone.is-dragging {
  transform: translateY(-2px);
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-size: 40px;
  line-height: 1;
}

.drop-title {
  display: block;
  margin-bottom: 8px;
  font-size: 20px;
  font-weight: 750;
}

.drop-hint {
  display: block;
  max-width: 520px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin: 18px 0 12px;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 700;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 12px 18px;
  font-weight: 700;
  text-decoration: none;
}

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

.home-hero {
  max-width: 720px;
  margin: 18px 0 26px;
}

.home-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.home-action-card {
  display: grid;
  gap: 10px;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 24px;
  color: var(--text);
  text-decoration: none;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.home-action-card:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-2px);
}

.home-action-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-size: 28px;
  font-weight: 800;
}

.home-action-card strong {
  font-size: 24px;
}

.home-action-card span:last-child {
  max-width: 320px;
  color: var(--muted);
  line-height: 1.6;
}

.mock-photo {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, #eef1ed, #fbfcfa);
  color: var(--muted);
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.primary {
  background: var(--primary);
  color: #ffffff;
}

.primary:not(:disabled):hover,
.button-link.primary:hover {
  background: var(--primary-strong);
}

.button-link.is-disabled {
  pointer-events: none;
  cursor: not-allowed;
  opacity: 0.5;
}

.secondary {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
}

.secondary:not(:disabled):hover,
.button-link.secondary:hover {
  background: #f3f6f2;
}

.message {
  min-height: 24px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 14px;
}

.message.error {
  color: var(--danger);
}

.preview-section {
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

h2 {
  margin-bottom: 14px;
  font-size: 20px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfa;
  text-align: center;
}

.empty-state p {
  margin: 0;
  padding: 16px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.photo-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #eef1ed;
}

.photo-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.photo-info > div:first-child {
  min-width: 0;
}

.photo-info h3 {
  max-width: 138px;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.photo-info p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.photo-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.crop-button {
  padding: 8px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.remove-button {
  padding: 8px 10px;
  border: 1px solid #f0d2cd;
  background: #fff7f5;
  color: var(--danger);
  font-size: 13px;
}

.remove-button:hover {
  background: #fdebe7;
}

.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(29, 37, 32, 0.55);
}

.crop-modal[hidden] {
  display: none;
}

.crop-dialog {
  width: min(980px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 8px;
  background: #ffffff;
  padding: 18px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.24);
}

.crop-head,
.crop-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.crop-head {
  margin-bottom: 14px;
}

.crop-head h2 {
  margin-bottom: 6px;
}

.crop-head p,
.crop-actions span {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

#crop-canvas {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1ed;
  touch-action: none;
}

.crop-actions {
  align-items: center;
  margin-top: 14px;
}

.status-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 20px 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 16px;
}

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

.task-id {
  margin-bottom: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  font-weight: 700;
}

.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
}

.status-pill.small {
  display: inline-flex;
  padding: 5px 9px;
  font-size: 12px;
}

.status-pill.overdue,
.status-pill.needs_practice {
  background: #fff0ec;
  color: var(--danger);
}

.status-pill.mastered {
  background: #eef1ed;
  color: var(--muted);
}

.task-toolbar {
  margin-top: 0;
}

.uploaded-list {
  display: grid;
  gap: 12px;
}

.uploaded-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.file-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 800;
}

.uploaded-main {
  min-width: 0;
}

.uploaded-main h3 {
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.uploaded-main p {
  margin-bottom: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.file-state {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.analysis-section {
  margin-top: 26px;
}

.analysis-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 14px;
}

.analysis-summary p {
  margin-bottom: 0;
  line-height: 1.6;
}

.analysis-summary span {
  flex: 0 0 auto;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.analysis-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.analysis-card h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.analysis-card p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.analysis-card p:last-child {
  margin-bottom: 0;
}

.analysis-card strong {
  color: var(--text);
}

.muted-text {
  color: var(--muted);
}

.wrong-list {
  display: grid;
  gap: 20px;
}

.wrong-card {
  position: relative;
  overflow: hidden;
  border: 1px solid #cfd8d0;
  border-radius: 8px;
  background: #ffffff;
  padding: 18px 18px 18px 22px;
  box-shadow: 0 10px 28px rgba(31, 48, 38, 0.08);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.wrong-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: #b8c4b9;
}

.wrong-card.is-selected {
  border-color: var(--primary);
  background: #fbfffc;
  box-shadow: 0 14px 34px rgba(47, 111, 78, 0.16);
}

.wrong-card.is-selected::before {
  background: var(--primary);
}

.wrong-card-head,
.practice-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.wrong-card-head {
  margin-bottom: 14px;
}

.wrong-title-group {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.wrong-checkbox {
  flex: 0 0 auto;
  border: 1px solid #9fc4ae;
  border-radius: 8px;
  background: #eef8f2;
  color: var(--primary-strong);
  padding: 10px 12px;
  box-shadow: inset 0 0 0 1px rgba(47, 111, 78, 0.05);
}

.wrong-checkbox input {
  width: 18px;
  height: 18px;
}

.wrong-card.is-selected .wrong-checkbox {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.wrong-card-head h3 {
  margin-bottom: 5px;
  font-size: 18px;
}

.wrong-card-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.review-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.wrong-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin-bottom: 14px;
}

.wrong-detail-grid p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.wrong-detail-grid strong {
  color: var(--text);
}

.practice-box {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.review-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) repeat(3, auto) minmax(160px, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.review-form h4 {
  margin: 0 0 4px;
  font-size: 15px;
}

.review-form p {
  margin: 0;
  font-size: 13px;
}

.practice-title-row h4 {
  margin: 0;
  font-size: 15px;
}

.practice-box ol {
  margin: 12px 0 0;
  padding-left: 22px;
}

.practice-box li {
  margin-bottom: 10px;
}

.practice-box li:last-child {
  margin-bottom: 0;
}

.practice-box p {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.practice-box strong {
  color: var(--text);
}

@media (max-width: 700px) {
  .app {
    width: min(100% - 20px, 1120px);
    padding: 10px 0;
  }

  .title-row,
  .toolbar,
  .user-bar,
  .nav-actions,
  .status-box,
  .analysis-summary,
  .photo-info,
  .photo-actions,
  .crop-head,
  .crop-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .counter {
    width: 100%;
  }

  .toolbar button {
    width: 100%;
  }

  .button-link {
    width: 100%;
  }

  .admin-form {
    grid-template-columns: 1fr;
  }

  .model-form,
  .provider-list {
    grid-template-columns: 1fr;
  }

  .section-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .uploaded-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .file-state {
    grid-column: 2;
  }

  .drop-zone {
    min-height: 220px;
  }

  .filter-bar,
  .wrong-detail-grid,
  .home-actions,
  .review-form {
    grid-template-columns: 1fr;
  }

  .wrong-card-head,
  .practice-title-row,
  .selection-bar,
  .wrong-title-group {
    flex-direction: column;
    align-items: stretch;
  }
}
