:root {
  color-scheme: dark;
  --bg: #0c0d14;
  --surface: #141721;
  --surface-2: #10131b;
  --line: #292e3c;
  --line-strong: #3a4052;
  --text: #f4f3f8;
  --muted: #949bad;
  --accent: #8b5cf6;
  --accent-2: #a855f7;
  --danger: #ff625f;
  --success: #45d483;
  font-family: Inter, "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 85% 10%, rgba(139, 92, 246, 0.13), transparent 34rem),
    linear-gradient(135deg, #0a0c12, #111321 55%, #151020);
}

button,
input,
textarea {
  font: inherit;
}

button,
.button-link {
  min-height: 50px;
  border: 0;
  border-radius: 13px;
  padding: 0 24px;
  font-weight: 750;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover,
.button-link:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.primary {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 30px rgba(139, 92, 246, 0.22);
}

.secondary {
  color: var(--text);
  border: 1px solid var(--line-strong);
  background: transparent;
}

.shell {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 0 0 72px;
}

.mode-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 8px 0 32px;
  animation: enter 480ms ease both;
}

.mode {
  width: 150px;
  padding: 18px 20px 16px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(20, 23, 33, 0.76);
}

.mode strong,
.mode span {
  display: block;
}

.mode strong {
  font-size: 21px;
}

.mode span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.mode.active {
  border-color: rgba(139, 92, 246, 0.58);
}

.workspace {
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(20, 23, 33, 0.9);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.32);
  animation: enter 560ms 80ms ease both;
}

.intro,
.section-label,
.action-row,
.result-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.intro {
  margin-bottom: 32px;
}

.kicker {
  margin: 0 0 7px;
  color: #a991ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
}

.service-state,
#logBadge {
  color: var(--muted);
  font-size: 13px;
}

.service-state::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.service-state.online::before {
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(69, 212, 131, 0.1);
}

.unlock-block {
  padding-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

label,
.route-display span {
  display: block;
  margin-bottom: 10px;
  color: #c7cbd7;
  font-size: 13px;
  font-weight: 700;
}

.inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

input,
textarea {
  width: 100%;
  color: var(--text);
  border: 1px solid var(--line);
  outline: none;
  background: var(--surface-2);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.11);
}

input {
  min-height: 50px;
  border-radius: 13px;
  padding: 0 16px;
}

textarea {
  min-height: 164px;
  resize: vertical;
  border-radius: 16px;
  padding: 16px;
  line-height: 1.55;
}

.message {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.message.success {
  color: var(--success);
}

.extract-area {
  padding-top: 34px;
  transition: opacity 240ms ease, filter 240ms ease;
}

.extract-area.locked {
  opacity: 0.38;
  filter: saturate(0.5);
  pointer-events: none;
  user-select: none;
}

.extract-area.unlocked {
  animation: reveal 380ms ease both;
}

.section-label {
  margin-bottom: 12px;
}

.section-label label,
.section-label h2 {
  margin: 0;
}

.section-label span {
  color: var(--muted);
  font-size: 12px;
}

.settings {
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.settings summary {
  padding: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 16px;
  padding-top: 16px;
}

.settings-grid label {
  margin: 0;
}

.route-display {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
}

.route-display span {
  margin-bottom: 5px;
}

.route-display strong {
  font-size: 14px;
}

.action-row {
  justify-content: flex-start;
  margin: 32px 0;
  color: var(--muted);
  font-size: 13px;
}

.extract-button {
  min-width: 180px;
}

.log-block {
  margin-top: 8px;
}

.log-list {
  min-height: 128px;
  max-height: 330px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #0d1017;
}

.log-empty {
  display: grid;
  min-height: 126px;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.log-row {
  display: grid;
  grid-template-columns: 72px 52px 180px minmax(0, 1fr);
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid #1e2230;
  font-size: 12px;
  animation: logIn 220ms ease both;
}

.log-row:last-child {
  border-bottom: 0;
}

.log-time,
.log-detail {
  color: var(--muted);
}

.log-status {
  color: #70a7ff;
  font-weight: 800;
}

.log-status.ok {
  color: var(--success);
}

.log-status.fail {
  color: var(--danger);
}

.log-name {
  font-weight: 750;
}

.result-block {
  margin-top: 24px;
  padding: 24px;
  border: 1px solid rgba(69, 212, 131, 0.25);
  border-radius: 18px;
  background: rgba(69, 212, 131, 0.06);
  animation: reveal 360ms ease both;
}

.result-url {
  max-width: 680px;
  margin: 10px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 12px;
}

.result-actions {
  display: flex;
  gap: 10px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

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

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

@keyframes logIn {
  from { opacity: 0; transform: translateX(-5px); }
  to { opacity: 1; transform: translateX(0); }
}

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

  .mode-bar {
    gap: 8px;
  }

  .mode {
    width: auto;
    flex: 1;
    padding-inline: 8px;
  }

  .mode strong {
    font-size: 17px;
  }

  .workspace {
    padding: 24px 18px;
    border-radius: 22px;
  }

  .intro,
  .result-block {
    align-items: flex-start;
    flex-direction: column;
  }

  .inline-control,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .inline-control button {
    width: 100%;
  }

  .log-row {
    grid-template-columns: 58px 46px minmax(100px, 0.7fr) minmax(150px, 1.3fr);
    min-width: 570px;
  }
}

.admin-shell {
  padding-top: 36px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.admin-key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.admin-key-row label {
  margin: 0;
}

.admin-generator,
.admin-list-block {
  padding-top: 28px;
}

.generator-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 12px;
}

.generator-grid label {
  margin: 0;
}

.generator-grid .wide {
  grid-column: span 3;
}

.generated-codes {
  max-height: 260px;
  overflow: auto;
  margin: 18px 0 0;
  padding: 18px;
  color: #d9ceff;
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 14px;
  background: #0d1017;
  white-space: pre-wrap;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  background: #0d1017;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid #1e2230;
  font-size: 12px;
}

th {
  color: var(--muted);
  font-weight: 700;
}

.table-action {
  min-height: 34px;
  padding: 0 12px;
  color: var(--danger);
  border: 1px solid rgba(255, 98, 95, 0.3);
  border-radius: 9px;
  background: transparent;
}

@media (max-width: 720px) {
  .admin-header,
  .admin-key-row {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

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

  .generator-grid .wide {
    grid-column: span 2;
  }
}
