:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9bb4;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --nav-h: 56px;
  --footer-h: 52px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  background: rgba(26, 35, 50, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  margin-right: 0.5rem;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-links a {
  color: var(--muted);
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  font-size: 0.9rem;
  white-space: nowrap;
  text-decoration: none;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: var(--surface2);
  text-decoration: none;
}

.main {
  flex: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

h1 {
  font-size: 1.35rem;
  margin: 0 0 0.5rem;
}
h2 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.75rem;
}
.sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.field {
  margin-bottom: 0.9rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font-size: 0.95rem;
}
textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.5;
  font-family: inherit;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
}
.btn:hover {
  background: var(--primary-hover);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-danger {
  background: var(--danger);
}
.btn-block {
  width: 100%;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.status {
  margin-top: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  font-size: 0.9rem;
  display: none;
}
.status.show {
  display: block;
}
.status.info {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}
.status.success {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}
.status.error {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

audio {
  width: 100%;
  margin-top: 0.75rem;
}

details.advanced {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}
details.advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 0.85rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  background: var(--surface);
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.login-box h1 {
  font-size: 1.15rem;
}

.hist-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  margin-bottom: 0.65rem;
  background: var(--bg);
}
.hist-item .meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.hist-item .title {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.docs pre,
.docs code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
}
.docs pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  overflow-x: auto;
  line-height: 1.45;
}
.docs table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 0.75rem 0;
}
.docs th,
.docs td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.55rem;
  text-align: left;
}
.docs th {
  background: var(--surface2);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.checkbox-line input {
  width: auto;
}

@media (max-width: 640px) {
  .row {
    grid-template-columns: 1fr;
  }
  .brand {
    font-size: 0.9rem;
  }
  .nav-links a {
    padding: 0.35rem 0.55rem;
    font-size: 0.82rem;
  }
  .main {
    padding: 1rem 0.75rem 1.5rem;
  }
  .card {
    padding: 1rem;
  }
}
