* {
  box-sizing: border-box;
}

:root {
  --bg0: #070a13;
  --bg1: #0b1220;
  --surface: rgba(17, 24, 39, 0.72);
  --surface-2: rgba(30, 41, 59, 0.75);
  --border: rgba(148, 163, 184, 0.22);
  --border-2: rgba(148, 163, 184, 0.35);
  --text: #e5e7eb;
  --muted: rgba(226, 232, 240, 0.72);
  --muted-2: rgba(148, 163, 184, 0.9);
  --accent: #39d7ff;
  --accent-2: #a7f3d0;
  --danger: #7f1d1d;
  --danger-border: #b91c1c;
  --radius: 14px;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
}

body {
  margin: 0;
  font-family: "Avenir Next", Avenir, "Gill Sans", "Trebuchet MS", sans-serif;
  background: radial-gradient(1200px 900px at 18% -10%, rgba(57, 215, 255, 0.18), transparent 55%),
    radial-gradient(1100px 900px at 92% 0%, rgba(167, 243, 208, 0.12), transparent 55%),
    radial-gradient(900px 700px at 55% 105%, rgba(129, 140, 248, 0.10), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  color: var(--text);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      125deg,
      rgba(255, 255, 255, 0.035) 0px,
      rgba(255, 255, 255, 0.035) 1px,
      transparent 1px,
      transparent 10px
    );
  opacity: 0.25;
  mix-blend-mode: overlay;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 10, 19, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.topbar h1 {
  word-break: break-word;
  min-width: 0;
}

h1, h2 {
  margin: 0 0 8px 0;
}

h1 {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  letter-spacing: 0.4px;
  font-weight: 650;
}

h2 {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  font-weight: 600;
  letter-spacing: 0.2px;
}

p {
  margin: 0;
  color: var(--muted);
}

.btn {
  background: linear-gradient(135deg, rgba(57, 215, 255, 0.95), rgba(167, 243, 208, 0.85));
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: inherit;
  box-shadow: 0 10px 26px rgba(57, 215, 255, 0.12);
}
.btn:hover {
  filter: brightness(1.05) saturate(1.05);
}
.btn:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}
.btn-small {
  padding: 8px 10px;
  font-size: 13px;
}
.btn-ghost {
  background: rgba(7, 10, 19, 0.45);
  border-color: var(--border);
  box-shadow: none;
}
.btn-ghost:hover {
  background: rgba(30, 41, 59, 0.55);
}
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}
.btn-inline {
  padding: 6px 10px;
  margin-left: 4px;
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1080px;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(7, 10, 19, 0.55);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
.search-input:focus-visible {
  border-color: rgba(57, 215, 255, 0.75);
  box-shadow: 0 0 0 2px rgba(57, 215, 255, 0.18);
}

.search-hint {
  margin-top: 8px;
  color: var(--muted-2);
  font-size: 14px;
}

.search-controls {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.control {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: rgba(226, 232, 240, 0.85);
}

.select-control {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(7, 10, 19, 0.55);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
}
.select-control:focus-visible {
  border-color: rgba(57, 215, 255, 0.75);
  outline: none;
}

.text-input {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(7, 10, 19, 0.55);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
.text-input:focus-visible {
  border-color: rgba(57, 215, 255, 0.75);
  box-shadow: 0 0 0 2px rgba(57, 215, 255, 0.18);
}
.text-area {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(7, 10, 19, 0.55);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  resize: vertical;
}
.text-area:focus-visible {
  border-color: rgba(57, 215, 255, 0.75);
  box-shadow: 0 0 0 2px rgba(57, 215, 255, 0.18);
}
.label {
  font-size: 13px;
  color: rgba(226, 232, 240, 0.85);
}
.hint {
  margin-top: 8px;
  color: rgba(148, 163, 184, 0.9);
  font-size: 13px;
  line-height: 1.5;
}
.hint code {
  font-size: 12px;
}
.muted {
  color: var(--muted);
}

.status-banner {
  margin-top: 12px;
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: rgba(7, 10, 19, 0.55);
  color: rgba(226, 232, 240, 0.92);
  font-size: 13px;
}
.status-banner .btn-inline {
  vertical-align: middle;
}

.status-banner[data-type="loading"] {
  border-color: rgba(57, 215, 255, 0.55);
  color: rgba(191, 219, 254, 0.95);
}

.status-banner[data-type="empty"] {
  border-color: rgba(245, 158, 11, 0.55);
  color: rgba(253, 230, 138, 0.95);
}

.status-banner[data-type="error"] {
  border-color: rgba(248, 113, 113, 0.55);
  color: rgba(254, 202, 202, 0.95);
}

.status-banner[data-type="ready"] {
  border-color: rgba(34, 197, 94, 0.35);
  color: rgba(187, 247, 208, 0.95);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.link-list {
  display: grid;
  gap: 8px;
}

.link-item,
.hub {
  display: block;
  text-decoration: none;
  color: rgba(186, 230, 253, 0.95);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(7, 10, 19, 0.55);
}
@media (prefers-reduced-motion: no-preference) {
  .link-item, .hub {
    transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  }
}
.link-item:hover,
.hub:hover {
  border-color: var(--border-2);
  background: rgba(30, 41, 59, 0.55);
  transform: translateY(-2px);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.30);
}
.link-item:focus-visible,
.hub:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

.empty-section-hint {
  margin: 0;
  padding: 8px 0;
  color: rgba(148, 163, 184, 0.7);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.link-item small,
.hub small {
  display: block;
  color: rgba(148, 163, 184, 0.88);
  margin-top: 4px;
}

mark {
  background: rgba(167, 243, 208, 0.95);
  color: rgba(7, 10, 19, 0.95);
  border-radius: 2px;
  padding: 0 2px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.engine-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}
.engine-head-text {
  min-width: 0;
}
.engine-api {
  flex: 0 0 420px;
  max-width: 520px;
}
.engine-api-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.engine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.engine-pane {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 12px;
  display: grid;
  gap: 10px;
}
.engine-pane h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.1px;
}
.engine-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 10px;
  align-items: center;
}

.engine-output {
  margin-top: 14px;
}
.engine-output-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin: 10px 0;
}
.engine-pre {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(7, 10, 19, 0.55);
  overflow-x: auto;
  white-space: pre-wrap;
  line-height: 1.45;
  min-height: 72px;
}

@media (max-width: 760px) {
  .engine-head {
    flex-direction: column;
  }
  .engine-api {
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
  }
  .engine-api-row {
    grid-template-columns: 1fr;
  }
  .engine-row {
    grid-template-columns: 1fr;
  }
}

.footer {
  padding: 16px;
  text-align: center;
  color: rgba(148, 163, 184, 0.92);
  border-top: 1px solid var(--border);
  background: rgba(7, 10, 19, 0.35);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* Shown when opened as file:// so user knows why nothing works */
.file-protocol-warning {
  margin: 0;
  padding: 16px 20px;
  background: var(--danger);
  border-bottom: 2px solid var(--danger-border);
  color: #fecaca;
  font-size: 14px;
  line-height: 1.5;
}
.file-protocol-warning pre {
  margin: 8px 0;
  padding: 10px 12px;
  background: #0f172a;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 13px;
}
.file-protocol-warning code { font-size: 13px; }
html:not([lang="zh-CN"]) .file-protocol-warning [lang="zh"] { display: none; }
html[lang="zh-CN"] .file-protocol-warning [lang="en"] { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .topbar {
    animation: enterTop 420ms ease-out both;
  }
  .layout > .card {
    animation: enterCard 520ms ease-out both;
  }
  .layout > .card:nth-child(1) { animation-delay: 0ms; }
  .layout > .card:nth-child(2) { animation-delay: 40ms; }
  .layout > .card:nth-child(3) { animation-delay: 80ms; }
  .layout > .card:nth-child(4) { animation-delay: 120ms; }
  .layout > .card:nth-child(5) { animation-delay: 160ms; }
  .layout > .card:nth-child(6) { animation-delay: 200ms; }
}

@keyframes enterTop {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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