:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #5c6985;
  --line: #d9e0ee;
  --accent: #1f6feb;
  --accent-2: #0b5ed7;
  --danger: #c62828;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 50% -20%, rgba(31, 111, 235, 0.12), transparent 34%),
    linear-gradient(180deg, #f7faff 0%, #eef3f8 100%);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 32px;
}

.narrow-shell {
  width: min(720px, calc(100% - 32px));
}

.auth-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 16px;
}

.auth-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(217, 224, 238, 0.9);
  border-radius: 24px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 22px;
  max-width: 460px;
  min-height: 430px;
  padding: 36px;
  width: min(460px, calc(100vw - 32px));
}

.transfer-card {
  max-width: 520px;
  min-height: auto;
  width: min(520px, calc(100vw - 32px));
}

.home-card {
  max-width: 620px;
  min-height: auto;
  width: min(620px, calc(100vw - 32px));
}

.auth-head {
  display: grid;
  gap: 10px;
  text-align: center;
}

.auth-head h1 {
  font-size: 28px;
  line-height: 1.2;
  margin: 0;
}

.auth-head p {
  color: var(--muted);
  line-height: 1.7;
  margin: 0 auto;
  max-width: 320px;
}

.auth-card .form-grid {
  align-content: start;
  gap: 16px;
}

.auth-card .actions {
  display: block;
}

.auth-card .primary-btn {
  min-height: 48px;
  width: 100%;
}

.subtle-link {
  align-self: end;
  color: var(--muted);
  display: inline-flex;
  font-size: 14px;
  justify-content: center;
  min-height: 24px;
  text-align: center;
}

.subtle-link:hover {
  color: var(--accent);
}

.home-section,
.feature-link,
.result-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.home-section {
  display: grid;
  gap: 14px;
  background: rgba(248, 251, 255, 0.68);
}

.section-title,
.feature-link {
  display: grid;
  gap: 6px;
}

.section-title strong,
.feature-link strong {
  font-size: 16px;
}

.section-title span,
.feature-link span,
.result-line {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.feature-link {
  background: #f8fbff;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.feature-link:hover {
  border-color: rgba(31, 111, 235, 0.4);
  transform: translateY(-1px);
}

.tabs {
  background: #eef3f8;
  border-radius: 12px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
}

.tab-btn {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  min-height: 40px;
}

.tab-btn.active {
  background: #fff;
  box-shadow: 0 4px 14px rgba(23, 32, 51, 0.08);
  color: var(--text);
  font-weight: 600;
}

.compact-options {
  align-items: end;
}

.result-box {
  background: #f8fbff;
  display: grid;
  gap: 12px;
}

.limit-box {
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 14px;
  display: grid;
  gap: 5px;
  padding: 12px 14px;
}

.limit-box strong {
  font-size: 14px;
}

.limit-box span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.code-display {
  color: var(--accent);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0;
  text-align: center;
}

.link-row,
.stacked-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.home-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

.compact-message {
  min-height: 22px;
  padding-top: 0;
}

.assist-action {
  color: var(--accent);
  display: inline-flex;
  font-weight: 600;
  margin-left: 8px;
}

.assist-action:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

.pickup-text {
  min-height: 160px;
  resize: vertical;
}

.code-input {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  min-height: 220px;
}

.code-block {
  background: #0f172a;
  border-radius: 12px;
  color: #e5e7eb;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
  max-height: 360px;
  overflow: auto;
  padding: 14px;
  white-space: pre;
}

.file-native-input {
  min-height: 48px;
}

.file-choose-btn {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  min-height: 48px;
  padding: 0 14px;
}

.file-choose-btn:hover {
  background: #f8fbff;
}

.wide-btn {
  min-height: 44px;
  width: 100%;
}

body.auth-mode .shell,
body[data-page="gate"] .shell {
  margin-top: 0;
}

body.admin-active {
  background: var(--bg);
}

body.admin-active .auth-shell {
  display: block;
  min-height: auto;
  padding: 0;
}

body.admin-active #adminShell {
  margin: 24px auto 32px;
  width: min(1180px, calc(100% - 32px));
}

.topbar,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topbar {
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.2;
}

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

.muted-text,
.hint {
  color: var(--muted);
  font-size: 14px;
}

.hint {
  margin: 0;
}

.admin-link,
.primary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font: inherit;
}

.primary-btn:disabled,
.ghost-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.admin-link,
.primary-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.admin-link:hover,
.primary-btn:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.ghost-btn:hover {
  background: #f2f5fb;
}

.panel {
  padding: 18px 20px;
  margin-bottom: 16px;
}

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

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

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}

td {
  font-size: 14px;
}

.filename {
  word-break: break-all;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.download-btn,
.delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
}

.download-btn {
  background: var(--accent);
  color: #fff;
}

.download-btn:hover {
  background: var(--accent-2);
}

.delete-btn {
  background: #fff;
  color: var(--danger);
  border-color: #f0bcbc;
}

.delete-btn:hover {
  background: #fff6f6;
}

.empty-state,
.message {
  color: var(--muted);
  padding: 12px 2px 0;
}

.footer {
  padding: 0 2px;
  color: var(--muted);
  line-height: 1.6;
}

.form-grid,
.upload-box {
  display: grid;
  gap: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.upload-meta {
  display: grid;
  gap: 8px;
}

.upload-name,
.upload-percent {
  color: var(--muted);
  font-size: 14px;
}

.progress-shell {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e9eef7;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.15s linear;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 14px;
  color: var(--muted);
}

input[type="password"],
input[type="text"],
input[type="number"],
input[type="datetime-local"],
input[type="file"],
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  font: inherit;
  background: #fff;
}

textarea {
  line-height: 1.6;
  min-height: 150px;
}

.auth-card input[type="password"],
.auth-card input[type="text"],
.auth-card select {
  border-radius: 12px;
  font-size: 16px;
  min-height: 48px;
  padding: 11px 14px;
}

.auth-card textarea {
  border-radius: 12px;
}

.checkbox-field {
  align-content: end;
  display: flex;
  gap: 8px;
  min-height: 40px;
}

.checkbox-field input,
.check-item input {
  width: 16px;
  height: 16px;
}

.check-list {
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  padding: 10px;
}

.check-item {
  align-items: flex-start;
  display: flex;
  gap: 8px;
  line-height: 1.4;
}

.check-item span {
  color: var(--text);
  word-break: break-all;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hidden {
  display: none;
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1180px);
    margin-top: 12px;
  }

  .auth-shell {
    padding: 24px 16px;
  }

  .auth-card {
    min-height: 400px;
    padding: 28px 22px;
    width: min(460px, calc(100vw - 32px));
  }

  .transfer-card {
    min-height: auto;
  }

  .home-card {
    width: calc(100vw - 32px);
  }

  .auth-head h1 {
    font-size: 24px;
  }

  .topbar,
  .panel {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar {
    flex-direction: column;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .link-row,
  .stacked-actions,
  .home-actions {
    grid-template-columns: 1fr;
  }

  .admin-link,
  .primary-btn,
  .ghost-btn,
  .download-btn,
  .delete-btn {
    width: 100%;
  }
}
