:root {
  --primary: #dc2626;
  --primary-dark: #b91c1c;
  --bg: #f8f9fa;
  --fg: #111;
  --muted: #6b7280;
  --border: rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

button { font-family: inherit; }

#topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

#topbar .title {
  font-weight: 500;
  font-size: 16px;
}

#topbar .actions {
  display: flex;
  gap: 6px;
}

#topbar button {
  background: rgba(255, 255, 255, 0.18);
  color: white;
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
  min-width: 36px;
  min-height: 32px;
  font-weight: 500;
}

#topbar button:active { background: rgba(255, 255, 255, 0.32); }

#update-banner {
  background: #fef3c7;
  color: #78350f;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  border-bottom: 1px solid #fde68a;
}

#update-banner button {
  background: #92400e;
  color: white;
  border: 0;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}

#pdf-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 12px;
  min-height: 60vh;
}

.pdf-page {
  position: relative;
  background: white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  margin: 0 auto;
  max-width: 100%;
}

.pdf-page.placeholder {
  background: #e5e7eb;
  width: min(800px, 95vw);
  height: 1000px;
}

.pdf-page canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.link-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.pdf-link {
  position: absolute;
  display: block;
  pointer-events: auto;
  background: rgba(220, 38, 38, 0.0);
  border-radius: 2px;
  transition: background 0.15s;
  text-decoration: none;
}

.pdf-link:hover { background: rgba(220, 38, 38, 0.18); }
.pdf-link:active { background: rgba(220, 38, 38, 0.28); }

#status-msg {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: white;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.error-block {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

#link-preview {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: white;
  display: flex;
  flex-direction: column;
}

#link-preview.hidden { display: none; }

.lp-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: #1f2937;
  color: white;
}

.lp-url {
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  opacity: 0.85;
}

.lp-bar button {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

#preview-close {
  font-size: 16px;
  line-height: 1;
  padding: 6px 10px;
}

#preview-iframe {
  flex: 1;
  border: 0;
  background: #f3f4f6;
}

/* Login page */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
  padding: 20px;
}

.login-body.admin-bg {
  background: linear-gradient(180deg, #e5e7eb 0%, #cbd5e1 100%);
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.login-icon {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  margin: 0 auto 12px;
  display: block;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 500;
  margin: 8px 0 4px;
}

.muted { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.footnote { font-size: 12px; margin-top: 16px; }
.footnote .admin-link { color: var(--muted); text-decoration: underline; }
.footnote .admin-link:hover { color: var(--primary); }

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-card input {
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
}

.login-card input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.login-card button {
  background: var(--primary);
  color: white;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

.login-card button:active { background: var(--primary-dark); }

.error {
  color: var(--primary);
  font-size: 14px;
  margin: 4px 0 0;
}

/* Sperrbildschirm-PIN */
.pin-wrap {
  position: relative;
  margin: 8px 0 4px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pin-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  font-size: 16px;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  text-align: center;
  caret-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  z-index: 2;
}

.pin-input:focus { outline: none; }

.pin-boxes {
  display: flex;
  gap: 10px;
  pointer-events: none;
  position: relative;
  z-index: 1;
}

.pin-box {
  width: 36px;
  height: 44px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, background .15s, transform .12s;
}

.pin-box.active {
  border-color: var(--primary);
  background: white;
}

.pin-box.filled {
  background: var(--primary);
  border-color: var(--primary);
}

.pin-box.filled::after {
  content: '';
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
}

@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.pin-boxes.shake { animation: pin-shake 0.42s ease-in-out; }

/* Admin page */
.admin-body {
  background: #f3f4f6;
  min-height: 100vh;
  padding: 20px;
}

.admin-header {
  max-width: 720px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.admin-header h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 500;
}

.admin-header button {
  background: #1f2937;
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
}

.admin-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin: 0 auto 16px;
  max-width: 720px;
}

.admin-card h2 {
  font-size: 16px;
  font-weight: 500;
  margin: 0 0 12px;
}

#current-info {
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
  margin: 0;
}

#current-info code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--fg);
}

#upload-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#upload-form input[type="file"] {
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #f9fafb;
  font-size: 14px;
}

#upload-form button {
  background: var(--primary);
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  align-self: flex-start;
}

#progress {
  width: 100%;
  height: 8px;
}

#upload-status {
  font-size: 14px;
  margin: 0;
}

button.danger {
  background: var(--primary);
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

button.danger:active { background: var(--primary-dark); }
button.danger:disabled { opacity: 0.5; cursor: not-allowed; }

#kick-status {
  font-size: 14px;
  margin: 8px 0 0;
}
