:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #69768a;
  --line: #dce4ef;
  --primary: #1769e0;
  --primary-dark: #0f4fad;
  --ok: #19a974;
  --shadow: 0 14px 38px rgba(28, 42, 68, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.mobile-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
}

.hero {
  padding: 18px 4px 16px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 14px;
  color: #fff;
  background: var(--primary);
  border-radius: 8px;
  font-size: 22px;
  font-weight: 800;
}

.hero p,
.hero h1 {
  margin: 0;
}

.hero p {
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.hero h1 {
  margin-top: 6px;
  font-size: 30px;
  line-height: 1.12;
}

.upload-card,
.result-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: rgba(23, 105, 224, 0.72);
  box-shadow: 0 0 0 4px rgba(23, 105, 224, 0.12);
}

.photo-picker {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 150px;
  padding: 20px;
  text-align: center;
  background: #f7f9fd;
  border: 2px dashed #bfd0e8;
  border-radius: 8px;
}

.photo-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.photo-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 10px;
  color: #fff;
  background: var(--primary);
  border-radius: 50%;
  font-size: 34px;
  line-height: 1;
}

.photo-picker strong {
  font-size: 19px;
}

.photo-picker small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-height: 90px;
  color: var(--muted);
}

.recognition-notice {
  padding: 11px 12px;
  color: #315a96;
  background: #eef4ff;
  border: 1px solid #d7e5fb;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.55;
}

.preview-grid span {
  display: grid;
  grid-column: 1 / -1;
  place-items: center;
  min-height: 90px;
  background: #f7f9fd;
  border: 1px solid #e8eef8;
  border-radius: 8px;
}

.preview-card {
  display: grid;
  gap: 9px;
  min-width: 0;
  padding: 8px;
  background: #f7f9fd;
  border: 1px solid #e8eef8;
  border-radius: 8px;
}

.preview-card img {
  width: 100%;
  height: 150px;
  object-fit: contain;
  background: #fff;
  border: 1px solid #e8eef8;
  border-radius: 8px;
}

.preview-card label {
  gap: 5px;
  font-size: 12px;
}

.preview-card input {
  min-height: 40px;
  padding: 8px 9px;
  font-size: 14px;
}

.preview-card small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.submit-button {
  min-height: 52px;
  color: #fff;
  background: var(--primary);
  border: 0;
  border-radius: 8px;
  font-size: 17px;
  font-weight: 800;
}

.submit-button:disabled {
  cursor: wait;
  background: #93b7eb;
}

.result-panel {
  margin-top: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--primary);
  background: #eef4ff;
  border: 1px solid #d7e5fb;
  border-radius: 8px;
  font-weight: 800;
}

.result-list {
  display: grid;
  gap: 10px;
}

.result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 12px;
  background: #f7f9fd;
  border: 1px solid #e8eef8;
  border-radius: 8px;
}

.result-item div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.result-item strong {
  color: var(--ok);
  overflow-wrap: anywhere;
}

.result-item span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.delete-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  color: #dc2626;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  font-weight: 800;
}

.delete-button:disabled {
  opacity: 0.62;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 14px;
  z-index: 10;
  padding: 13px 14px;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  text-align: center;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgb(15 23 42 / 0.45);
  backdrop-filter: blur(2px);
}

.loading-overlay[hidden] {
  display: none;
}

.loading-box {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(260px, 100%);
  padding: 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #e8eef8;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #dbe7fb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@media (max-width: 380px) {
  .hero h1 {
    font-size: 26px;
  }

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