/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warn: #d97706;
  --warn-light: #fef3c7;
  --error: #dc2626;
  --error-light: #fee2e2;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 40px -10px rgba(0,0,0,0.1);
  --transition: 0.2s ease;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", "Courier New", monospace;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 3rem 1.5rem 1.5rem;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 50%, #f0f9ff 100%);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(37,99,235,0.05) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(22,163,74,0.04) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-inner { position: relative; z-index: 1; max-width: 600px; margin: 0 auto; }

.logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  background: #fff;
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 1.1rem;
  color: var(--gray-600);
  margin-bottom: 1.5rem;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--gray-600);
  box-shadow: var(--shadow-sm);
}

/* ===== Container ===== */
.container {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
}

/* ===== Drop Zone ===== */
.paste-section { margin-bottom: 2rem; }

.drop-zone {
  border: 3px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: #fff;
  position: relative;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
  outline: none;
}

.drop-zone.dragover {
  border-style: solid;
  border-width: 3px;
}

.drop-zone-empty { display: flex; flex-direction: column; align-items: center; }

.paste-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  background: var(--gray-100);
  border-radius: 50%;
  margin-bottom: 1.5rem;
  color: var(--gray-400);
  transition: all var(--transition);
}

.drop-zone:hover .paste-icon-wrapper,
.drop-zone.dragover .paste-icon-wrapper {
  background: #fff;
  color: var(--primary);
}

.paste-icon { transition: all var(--transition); }

.drop-zone-empty h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 0.5rem;
}

.hint-text {
  color: var(--gray-500);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

kbd {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--gray-600);
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 14px rgba(37,99,235,0.25);
}

.btn-upload:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37,99,235,0.35);
}

.btn-upload:active { transform: translateY(0); }

/* ===== Preview State ===== */
.drop-zone-preview { display: flex; flex-direction: column; align-items: center; }

.preview-wrapper {
  position: relative;
  max-width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.preview-wrapper img {
  display: block;
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius-sm);
}

/* Scanning Overlay */
.scanning-overlay {
  position: absolute;
  inset: 0;
  background: rgba(37,99,235,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  backdrop-filter: blur(1px);
}

.scanning-overlay p {
  background: #fff;
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  font-weight: 600;
  color: var(--primary);
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}

.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #2563eb, transparent);
  box-shadow: 0 0 12px rgba(37,99,235,0.6);
  animation: scan 1.2s ease-in-out infinite;
}

@keyframes scan {
  0%, 100% { top: 0%; opacity: 0.8; }
  50% { top: calc(100% - 3px); opacity: 1; }
}

.preview-actions { margin-top: 1rem; }

.btn-reupload {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.2rem;
  background: #fff;
  color: var(--gray-600);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-reupload:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ===== Result Section ===== */
.result-section { margin-bottom: 2rem; }

.result-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
  border: 1px solid var(--gray-200);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.success-card { border-left: 4px solid var(--success); }
.warn-card { border-left: 4px solid var(--warn); }
.error-card { border-left: 4px solid var(--error); }

.result-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.result-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
}

.success-icon { background: var(--success-light); color: var(--success); }
.warn-icon { background: var(--warn-light); color: var(--warn); }
.error-icon { background: var(--error-light); color: var(--error); }

.result-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-800);
  flex: 1;
}

.result-meta {
  font-size: 0.8rem;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.result-body { padding-left: 0; }

.result-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.result-content-box {
  position: relative;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 1rem;
  padding-right: 5rem;
}

.decoded-content {
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--gray-800);
  white-space: pre-wrap;
  word-break: break-all;
  word-wrap: break-word;
  max-height: 200px;
  overflow-y: auto;
}

.btn-copy {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-copy:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-copy.copied {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.link-actions { margin-top: 0.85rem; }

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--transition);
}

.btn-link:hover {
  background: var(--primary);
  color: #fff;
}

.warn-text { color: var(--gray-600); margin-bottom: 0.75rem; }

.tip-list {
  margin-left: 1.2rem;
  color: var(--gray-600);
  font-size: 0.9rem;
}

.tip-list li { margin-bottom: 0.3rem; }

/* ===== History ===== */
.history-section {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  margin-bottom: 2rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.history-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-700);
}

.btn-clear-history {
  background: none;
  border: none;
  color: var(--gray-400);
  font-size: 0.8rem;
  cursor: pointer;
  transition: color var(--transition);
}

.btn-clear-history:hover { color: var(--error); }

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.history-item:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.history-item-content {
  flex: 1;
  min-width: 0;
}

.history-item-text {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--gray-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-time {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.15rem;
}

.history-item-copy {
  flex-shrink: 0;
  margin-left: 1rem;
  padding: 0.35rem 0.7rem;
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  color: var(--gray-500);
  cursor: pointer;
  transition: all var(--transition);
}

.history-item-copy:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--gray-400);
  border-top: 1px solid var(--gray-200);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--gray-900);
  color: #fff;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  animation: toastIn 0.25s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .hero { padding: 2rem 1rem 1rem; }
  .hero h1 { font-size: 1.8rem; }
  .tagline { font-size: 0.95rem; }
  .container { padding: 1.5rem 1rem; }
  .drop-zone { padding: 2rem 1rem; }
  .drop-zone-empty h2 { font-size: 1.1rem; }
  .result-card { padding: 1.25rem; }
  .result-content-box { padding-right: 1rem; }
  .btn-copy { position: static; margin-top: 0.75rem; }
  .decoded-content { font-size: 0.85rem; }
}
