:root {
  --primary: #d32f2f;
  --primary-dark: #b71c1c;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --error: #dc2626;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  background: var(--surface);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  color: var(--primary);
}

.app-main {
  max-width: 540px;
  margin: 0 auto;
  padding: 16px;
}

.page {
  display: none;
  animation: fadeIn 0.2s ease;
}

.page.active {
  display: block;
}

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

.card {
  background: var(--surface);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
}

.hint {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-secondary);
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field span {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field input,
.field select {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: #fafafa;
  -webkit-appearance: none;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

.captcha-row {
  display: flex;
  gap: 10px;
}

.captcha-row input {
  flex: 1;
}

.captcha-row img {
  height: 46px;
  width: 110px;
  border-radius: 10px;
  border: 1px solid var(--border);
  object-fit: contain;
  background: #fff;
  cursor: pointer;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.btn-primary {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  background: #ef9a9a;
  cursor: not-allowed;
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  padding: 8px 0 16px;
  cursor: pointer;
}

.error {
  color: var(--error);
  font-size: 13px;
  margin: 10px 0 0;
  min-height: 18px;
}

/* Login validity bar (2-day countdown) */
.session-bar {
  max-width: 540px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
}

.session-bar[hidden] {
  display: none;
}

.session-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #9a3412;
}

.session-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
  flex-shrink: 0;
}

.session-countdown {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.session-countdown.expiring {
  color: var(--error);
}

.btn-link {
  border: none;
  background: none;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 2px;
  white-space: nowrap;
}

.remember-row {
  display: flex;
  gap: 24px;
  margin: 4px 0 10px;
}

.warn-hint {
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-item {
  background: var(--surface);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s;
}

.result-item:active {
  transform: scale(0.99);
}

.result-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.result-meta {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.result-meta span {
  display: inline-block;
  margin-right: 12px;
}

.result-count {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 0 4px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafafa;
}

.file-name {
  flex: 1;
  font-size: 14px;
  word-break: break-all;
  padding-right: 10px;
}

.file-download {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.file-download:active {
  background: var(--primary-dark);
}

.detail-section {
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.6;
}

.detail-label {
  color: var(--text-secondary);
  margin-right: 6px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(100px);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 100;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.loading {
  text-align: center;
  padding: 30px;
  color: var(--text-secondary);
  font-size: 14px;
}

.file-select {
  cursor: pointer;
}

.file-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
  margin-right: 10px;
  cursor: pointer;
}

.btn-secondary {
  width: 100%;
  height: 44px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 15px;
  cursor: pointer;
}

.btn-secondary:active {
  background: #f0f0f0;
}

/* Download modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
}

.modal.show {
  display: flex;
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 14px;
  padding: 22px 20px 20px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  text-align: center;
}

.modal-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
}

.modal-filename {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  word-break: break-all;
  background: #f7f7f7;
  border-radius: 8px;
  padding: 10px 12px;
}

.modal-filesize {
  margin: -8px 0 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.modal-download {
  display: block;
  height: 46px;
  line-height: 46px;
  text-decoration: none;
  font-weight: 600;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
}

@media (min-width: 640px) {
  .app-main {
    padding: 24px;
  }
}