:root {
  --bg: #f6f5f3;
  --card-bg: #ffffff;
  --primary: #1c3d5a;
  --primary-disabled: #a7b3bd;
  --text-primary: #1f2430;
  --text-secondary: #444a52;
  --text-muted: #5c6370;
  --text-faint: #9a9a95;
  --success: #2f7a44;
  --success-bg: #e6f2ea;
  --danger: #ad3535;
  --danger-bg: #f9e8e8;
  --warning: #a3660a;
  --warning-bg: #fbf1e0;
  --neutral-bg: #ebeae7;
  --border: #e4e2dd;
  --divider: #f0efec;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);

  --container: min(420px, 100%);
  --radius-sm: 5px;
  --radius-md: 8px;

  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
  overflow-wrap: break-word;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: hidden;
  /* 禁止 iOS 橡皮筋回弹造成的上下/左右位移空白 */
  overscroll-behavior: none;
  background-color: var(--bg);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
}

html {
  overflow-x: hidden;
  overflow-y: hidden;
}

body {
  height: 100%;
  min-height: 100%;
  position: relative;
}

button, input, textarea {
  font: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

img {
  max-width: 100%;
  display: block;
}

input, textarea {
  outline: none;
}

#app {
  width: var(--container);
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  max-width: 100%;
  margin: 0 auto;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* ====== GLOBAL UTILITY CLASSES (matching mini-program app.wxss) ====== */

.g-card {
  background-color: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow);
}

.g-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.g-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  min-height: 44px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  gap: 8px;
}

.g-btn-primary:disabled {
  background-color: var(--primary-disabled);
}

.g-btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--card-bg);
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  min-height: 44px;
  padding: 0 20px;
  font-size: 14px;
}

.g-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 3px;
  background-color: var(--neutral-bg);
  color: var(--text-muted);
  font-weight: 500;
}

.g-status-pill--processing {
  background-color: var(--warning-bg);
  color: var(--warning);
}

.g-status-pill--success {
  background-color: var(--success-bg);
  color: var(--success);
}

.g-status-pill--empty {
  background-color: var(--neutral-bg);
  color: var(--text-muted);
}

.g-status-pill--failed {
  background-color: var(--danger-bg);
  color: var(--danger);
}

.g-empty {
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  padding: 40px 0;
}

/* ====== NAV BAR ====== */

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--divider);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-back {
  font-size: 14px;
  color: var(--primary);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
}

.nav-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.nav-spacer {
  width: 60px;
}

/* ====== LOGIN PAGE (matching login.wxml / login.wxss) ====== */

.login-page {
  padding: 50px 30px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
}

.login-brand__icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  margin-bottom: 4px;
}

.login-title {
  font-size: 19px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 10px;
}

.login-subtitle {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 4px;
}

.login-form {
  width: 100%;
}

.login-field {
  display: flex;
  align-items: center;
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 11px 12px;
  margin-bottom: 10px;
  gap: 8px;
}

.login-field__icon {
  color: var(--text-faint);
  flex-shrink: 0;
}

.login-field__input {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
  border: none;
  background: none;
  min-width: 0;
}

.login-submit {
  width: 100%;
  margin-top: 24px;
}

.login-error {
  text-align: center;
  color: var(--danger);
  font-size: 13px;
  padding: 9px 0 0;
}

/* ====== PAGES COMMON ====== */

.page {
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}

/* ====== HOME PAGE (matching index.wxml / index.wxss) ====== */

.home-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.home-brand__logo {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  flex-shrink: 0;
}

.home-brand__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.home-brand__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.home-brand__meta {
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-entry {
  display: flex;
  align-items: center;
  background-color: var(--primary);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  margin-bottom: 16px;
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
}

.main-entry-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background-color: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  flex-shrink: 0;
}

.main-entry-text {
  flex: 1;
  min-width: 0;
}

.main-entry-title {
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 3px;
}

.main-entry-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.main-entry__arrow {
  color: rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
}

.home-sub-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.home-sub-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  border: none;
  box-shadow: var(--shadow);
}

.recent-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.recent-more {
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  background: none;
  border: none;
  flex-shrink: 0;
}

.recent-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.record-card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  min-width: 0;
}

.record-card__thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: 0;
  padding-bottom: 100%;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  background-color: var(--divider);
}

.record-card__thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.record-card__info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.record-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.record-count {
  font-size: 12px;
  color: var(--text-muted);
}

.record-time {
  font-size: 11px;
  color: var(--text-faint);
}

.logout-bar {
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  padding: 16px 0;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
}

.upload-picker {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
  display: flex;
  align-items: flex-end;
}

.upload-picker__panel {
  width: 100%;
  background: var(--card-bg);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}

.upload-picker__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  text-align: center;
}

.upload-picker__actions {
  display: flex;
  gap: 10px;
}

.upload-picker__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  border-radius: var(--radius-md);
  background-color: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  border: none;
}

.upload-picker__btn-icon {
  color: var(--primary);
}

.upload-picker__cancel {
  width: 100%;
  margin-top: 12px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  background-color: var(--bg);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  border: none;
}

/* ====== PROCESSING PAGE (matching processing.wxml / processing.wxss) ====== */

.processing-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 0 30px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--neutral-bg);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

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

.processing-tip {
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.processing-hint {
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  margin-bottom: 30px;
  line-height: 1.6;
}

.processing-back {
  width: 200px;
}

/* ====== RECORDS LIST (matching records.wxml / records.wxss) ====== */

.records-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: var(--shadow);
}

.date-field {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
}

.date-field__text {
  display: flex;
  align-items: center;
  height: 38px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  pointer-events: none;
}

.date-field__text--placeholder {
  color: var(--text-faint);
}

.date-field__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
}

.records-filter__sep {
  font-size: 12px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.records-filter__reset {
  font-size: 12px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  padding: 4px 0;
}

.records-item {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  padding: 10px;
}

.records-item:last-child {
  margin-bottom: 0;
}

.records-thumb {
  width: 60px;
  height: 60px;
  border-radius: 4px;
  margin-right: 12px;
  background-color: var(--divider);
  flex-shrink: 0;
  object-fit: cover;
}

.records-count {
  font-size: 12px;
  color: var(--text-muted);
}

.load-more {
  text-align: center;
  color: var(--primary);
  font-size: 13px;
  padding: 12px 0;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
}

/* ====== RECORD DETAIL (matching record-detail.wxml / record-detail.wxss) ====== */

.origin-image {
  width: 100%;
  border-radius: 6px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.state-block {
  text-align: center;
  padding: 40px 0;
}

.state-block__icon {
  margin-bottom: 10px;
}

.state-text {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.state-text--danger {
  color: var(--danger);
}

.retry-btn {
  width: 160px;
}

/* ====== UPLOADING STATE ====== */

.uploading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
}

.copy-all-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background-color: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 10px 0;
  margin-bottom: 12px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: none;
  width: 100%;
}

.delete-bar {
  text-align: center;
  color: var(--danger);
  font-size: 13px;
  padding: 16px 0;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
}

.raw-response {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ====== HAZARD CARD (matching hazard-card.wxml / hazard-card.wxss) ====== */

.hazard-card {
  background-color: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.hazard-card__header {
  display: flex;
  align-items: flex-start;
  margin-bottom: 10px;
}

.seq-badge {
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 3px;
  background-color: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  margin-right: 8px;
  flex-shrink: 0;
}

.hazard-card__desc {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.hazard-card__section {
  margin-bottom: 6px;
  padding-left: 28px;
}

.hazard-card__section:last-of-type {
  margin-bottom: 0;
}

.hazard-card__label {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 2px;
}

.hazard-card__content {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.hazard-card__content--standard {
  color: var(--text-faint);
  font-size: 12px;
}

.feedback-bar {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--divider);
}

.feedback-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 0;
  border-radius: 4px;
  background-color: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  border: none;
}

.feedback-btn--active {
  background-color: var(--success-bg);
  color: var(--success);
}

.feedback-btn--danger {
  background-color: var(--danger-bg);
  color: var(--danger);
}

/* ====== DISLIKE MODAL (matching dislike-modal.wxml / dislike-modal.wxss) ====== */

.modal-mask {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: flex-end;
}

.modal-panel {
  width: 100%;
  background-color: var(--card-bg);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.reason-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.reason-item {
  padding: 6px 12px;
  border-radius: 4px;
  background-color: var(--bg);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  border: none;
}

.reason-item--active {
  background-color: var(--primary);
  color: #fff;
}

.modal-textarea {
  width: 100%;
  height: 80px;
  background-color: var(--bg);
  border: none;
  border-radius: 4px;
  padding: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  resize: none;
  outline: none;
}

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

.modal-actions .g-btn-ghost,
.modal-actions .g-btn-primary {
  flex: 1;
}

/* ====== IMAGE PREVIEW OVERLAY ====== */

.image-preview {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.image-preview__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  font-size: 18px;
}

/* ====== TOAST / NOTICE ====== */

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 4px;
  z-index: 300;
  pointer-events: none;
  animation: toastIn 0.2s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ====== HIDDEN FILE INPUT ====== */

.hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ====== SETTINGS PANEL ====== */

.settings-panel {
  margin-bottom: 12px;
}

.settings-toggle {
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  padding: 8px 0;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
}

.settings-form {
  padding: 12px 0 0;
  border-top: 1px dashed var(--border);
  margin-top: 8px;
}

.settings-form label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.settings-form input {
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 8px;
}

.upload-preview {
  margin-bottom: 16px;
}

.upload-preview__img {
  width: 100%;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  max-height: 260px;
  object-fit: cover;
}

.upload-preview__meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.upload-preview__actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.upload-preview__actions .g-btn-primary,
.upload-preview__actions .g-btn-ghost {
  flex: 1;
}
