* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg: #f0f4ff;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #047857;
  --success-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --error: #b91c1c;
  --error-bg: #fef2f2;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(37, 99, 235, 0.08);
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #eef4ff 0%, var(--bg) 220px, #f8fafc 100%);
  color: var(--text);
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 120px;
}

.hero {
  margin-bottom: 20px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -0.02em;
}

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

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
}

textarea {
  width: 100%;
  min-height: 180px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  resize: vertical;
  line-height: 1.6;
  background: #fbfdff;
}

textarea:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: none;
  border-radius: 14px;
  font-weight: 600;
}

.btn-primary {
  background: linear-gradient(180deg, #3b82f6 0%, var(--primary) 100%);
  color: #fff;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

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

.btn-ghost {
  background: transparent;
  color: var(--muted);
  min-height: auto;
  width: auto;
  padding: 6px 10px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner.dark {
  border-color: rgba(37, 99, 235, 0.2);
  border-top-color: var(--primary);
}

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

.toast {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  line-height: 1.5;
  animation: fadeIn 0.2s ease;
}

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

.toast.warning {
  background: var(--warn-bg);
  color: var(--warn);
}

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

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

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 18px;
}

.count {
  margin-left: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  border: 1px dashed var(--border);
  border-radius: 16px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  background: #f8fafc;
  font-weight: 700;
  color: #374151;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #f9fbff;
}

.required {
  color: var(--error);
  font-weight: 700;
}

.action-col {
  width: 64px;
  text-align: center;
}

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

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

.bottom-inner {
  max-width: 960px;
  margin: 0 auto;
}

.filename {
  margin: 0 0 10px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.progress-panel {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  background: #f8fbff;
  border: 1px solid #dbeafe;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5edff;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #60a5fa 0%, #2563eb 100%);
  transition: width 0.35s ease;
}

.progress-label {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}
