/* ---------------------------------------------------------
   Cadence admin / lesson library
   --------------------------------------------------------- */

.admin-body {
  padding-bottom: 0;
}

.admin-main {
  min-height: calc(100vh - 76px);
  padding: 42px 0 80px;
}

.login-card {
  max-width: 520px;
  margin: 6vh auto 0;
  padding: 38px;
}

.login-card h1,
.admin-hero h1 {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.login-card h1 {
  font-size: 40px;
}

.admin-lead {
  margin: 13px 0 25px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.login-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.login-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.login-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 11px 14px;
  color: var(--ink);
  background: var(--surface);
}

.login-row .btn {
  flex: none;
}

.login-note {
  margin: 20px 0 0;
  color: var(--muted-light);
  font-size: 11.5px;
  line-height: 1.7;
}

.login-note code {
  border-radius: 4px;
  padding: 1px 4px;
  color: var(--ink-soft);
  background: var(--paper-deep);
  font-family: var(--mono);
  font-size: 10.5px;
}

.admin-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}

.admin-hero h1 {
  font-size: 46px;
}

.admin-hero p {
  max-width: 700px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.admin-count {
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 15px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.55);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.03em;
}

/* ---------------------------------------------------------
   Translation status
   --------------------------------------------------------- */

.translation-card {
  margin-bottom: 22px;
}

.translation-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.translation-title {
  min-width: 0;
}

.translation-title h2 {
  margin-top: 4px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.translation-meta {
  margin-top: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.01em;
  line-height: 1.6;
}

.translation-side {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.translation-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.translation-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.translation-badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.translation-badge.is-good {
  border-color: rgba(60, 107, 82, 0.22);
  color: #3c6b52;
  background: rgba(89, 149, 115, 0.09);
}

.translation-badge.is-warn {
  border-color: rgba(185, 71, 37, 0.22);
  color: var(--accent-deep);
  background: rgba(223, 97, 57, 0.08);
}

.translation-refresh {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 11px;
  transition: border-color 160ms var(--ease), background 160ms var(--ease), color 160ms var(--ease);
}

.translation-refresh:hover {
  border-color: #b9b1a1;
  color: var(--ink);
}

.translation-refresh:disabled {
  opacity: 0.55;
  cursor: default;
}

.translation-refresh-icon {
  font-size: 14px;
  line-height: 1;
}

.translation-refresh.is-loading .translation-refresh-icon {
  animation: translation-spin 900ms linear infinite;
}

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

.translation-progress {
  margin-top: 20px;
}

.translation-progress-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.translation-progress-label {
  color: var(--muted);
  font-size: 11.5px;
}

.translation-count {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}

.translation-percent {
  margin-left: auto;
  color: var(--forest);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}

.translation-bar {
  height: 9px;
  overflow: hidden;
  margin-top: 10px;
  border-radius: 4px;
  background: var(--paper-deep);
  box-shadow: inset 0 0 0 1px rgba(214, 207, 193, 0.55);
}

.translation-bar-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 4px;
  background: var(--forest);
  transition: width 600ms var(--ease);
}

.translation-summary {
  margin-top: 9px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.65;
}

.translation-error {
  margin-top: 12px;
  border: 1px solid rgba(185, 71, 37, 0.2);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--accent-deep);
  background: rgba(223, 97, 57, 0.07);
  font-size: 11.5px;
  line-height: 1.6;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.65fr);
  gap: 22px;
  align-items: start;
}

.admin-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px;
  background: rgba(255, 253, 248, 0.82);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
}

.admin-card.translation-card {
  padding: 24px 26px 22px;
}

.library-card {
  position: sticky;
  top: 22px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 17px;
}

.panel-head h2 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: -0.015em;
}

.panel-head p {
  margin: 5px 0 0;
  color: var(--muted-light);
  font-size: 11.5px;
  line-height: 1.6;
}

.admin-reset {
  flex: none;
  margin-top: 3px;
  color: var(--accent-deep);
}

.admin-lesson-list {
  max-height: min(62vh, 620px);
  overflow: auto;
  margin: 0 -9px;
  padding: 0 9px;
}

.admin-lesson {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 15px 0;
}

.admin-lesson:first-child {
  border-top: 0;
  padding-top: 3px;
}

.admin-lesson.is-editing {
  margin: 8px -12px;
  border: 0;
  border-radius: 14px;
  padding: 13px 12px;
  background: var(--accent-soft);
}

.admin-lesson-cover {
  flex: none;
  width: 56px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper-deep);
  object-fit: cover;
}

.admin-lesson-copy {
  flex: 1;
  min-width: 0;
}

.admin-lesson h3 {
  overflow: hidden;
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-lesson .lesson-zh {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 9px;
  margin-top: 7px;
  color: var(--muted-light);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.015em;
}

.admin-edit {
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 11px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 11px;
  transition: border-color 160ms var(--ease), background 160ms var(--ease), color 160ms var(--ease);
}

.admin-edit:hover {
  border-color: #b9b1a1;
  background: var(--surface);
  color: var(--ink);
}

.admin-empty {
  margin: 0;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 24px 14px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
  text-align: center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
  margin-bottom: 19px;
}

.field {
  min-width: 0;
  margin-bottom: 18px;
}

.form-grid .field {
  margin-bottom: 0;
}

.field--wide {
  grid-column: 1 / -1;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.015em;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 10px 13px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 13.5px;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.field select {
  cursor: pointer;
}

.field textarea {
  min-height: 250px;
  line-height: 1.7;
  resize: vertical;
}

.field input[type="file"] {
  padding: 9px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.field input::file-selector-button {
  margin-right: 10px;
  border: 0;
  border-radius: 8px;
  padding: 7px 11px;
  color: var(--cream);
  background: var(--forest);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}

.field-optional {
  color: var(--muted-light);
  font-size: 10.5px;
  font-weight: 400;
}

.category-input-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-top: 8px;
}

.category-input-row input {
  flex: 1;
  min-width: 0;
}

.category-add-btn {
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0 14px;
  color: var(--ink-soft);
  background: var(--surface-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms var(--ease), background 160ms var(--ease), color 160ms var(--ease);
}

.category-add-btn:hover {
  border-color: #b9b1a1;
  color: var(--ink);
}

.category-add-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 4px 3px 10px;
  color: var(--ink-soft);
  background: var(--surface-soft);
  font-size: 11px;
  line-height: 1.5;
}

.category-chip-remove {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  color: var(--muted-light);
  background: transparent;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: color 160ms var(--ease), background 160ms var(--ease);
}

.category-chip-remove:hover {
  color: var(--accent);
  background: rgba(223, 97, 57, 0.1);
}

.category-chip-remove:disabled {
  opacity: 0.45;
  cursor: default;
}

.field-hint.is-error {
  color: var(--accent-deep);
}

.field-hint.is-success {
  color: #3c6b52;
}

.words-editor {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.words-editor textarea {
  min-height: 130px;
  resize: vertical;
}

.cover-uploader {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cover-preview {
  flex: none;
  width: 112px;
  height: 92px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--paper-deep);
  object-fit: cover;
}

.cover-uploader-body {
  flex: 1;
  min-width: 0;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.login-row input:focus {
  outline: none;
  border-color: #9ca998;
  box-shadow: 0 0 0 3px rgba(23, 61, 52, 0.08);
}

.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"] {
  border-color: var(--accent);
}

.field-hint {
  margin: 6px 0 0;
  color: var(--muted-light);
  font-size: 11px;
  line-height: 1.65;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.form-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.form-status.is-error {
  color: var(--accent-deep);
}

.form-status.is-success {
  color: #467358;
}

.form-message {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--accent-deep);
  font-size: 12px;
}

.success-panel {
  margin-top: 16px;
  border: 1px solid rgba(89, 149, 115, 0.32);
  border-radius: 14px;
  padding: 15px 17px;
  background: rgba(89, 149, 115, 0.08);
}

.success-panel strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.success-panel p {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.success-panel a {
  color: var(--forest);
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

[hidden] {
  display: none !important;
}

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

  .library-card {
    position: static;
  }

  .admin-lesson-list {
    max-height: 320px;
  }
}

@media (max-width: 640px) {
  .admin-main {
    padding: 26px 0 54px;
  }

  .admin-card.translation-card {
    padding: 20px;
  }

  .translation-head {
    flex-direction: column;
    gap: 14px;
  }

  .translation-side {
    width: 100%;
    align-items: flex-start;
    justify-content: space-between;
  }

  .translation-badges {
    justify-content: flex-start;
  }

  .translation-progress-head {
    flex-wrap: wrap;
  }

  .login-card {
    margin-top: 0;
    padding: 27px 22px;
  }

  .login-card h1 {
    font-size: 34px;
  }

  .login-row {
    flex-direction: column;
  }

  .admin-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .admin-hero h1 {
    font-size: 38px;
  }

  .admin-card {
    border-radius: 19px;
    padding: 20px;
  }

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

  .field--wide {
    grid-column: auto;
  }

  .field textarea {
    min-height: 210px;
  }

  .cover-uploader {
    align-items: flex-start;
  }

  .cover-preview {
    width: 86px;
    height: 72px;
  }

  .header-actions {
    gap: 6px;
  }

  .admin-body .header-icon-btn {
    padding: 7px 9px;
    font-size: 10.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .translation-bar-fill {
    transition: none;
  }

  .translation-refresh.is-loading .translation-refresh-icon {
    animation: none;
  }
}
