:root {
  --bg: #f9f9f9;
  --surface: #ffffff;
  --text: #333;
  --primary: #007bff;
  --primary-hover: #0069d9;
  --success: #28a745;
  --accent: #f0f0f0;
  --border: #dee2e6;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  padding: 16px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.hub-link {
  display: inline-block;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--primary);
  text-decoration: none;
}

.hub-link:hover {
  text-decoration: underline;
}

.hub-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.page-header h1 {
  margin: 0 0 20px;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
}

.shell {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.field-block {
  margin-bottom: 20px;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-row input {
  flex: 1;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.input-row input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-color: var(--primary);
}

.icon-btn {
  flex-shrink: 0;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover {
  background: #e2e2e2;
}

.icon-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.char-count {
  margin: 8px 0 0;
  font-size: 14px;
  color: #666;
}

.qr-section {
  position: relative;
  margin-bottom: 20px;
}

.qr-host {
  display: none;
  justify-content: center;
  align-items: center;
  margin: 0 auto;
  padding: 20px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.qr-host.is-visible {
  display: flex;
  animation: fadeIn 0.35s ease-out;
}

.qr-host canvas,
.qr-host img {
  display: block;
  max-width: 100%;
  height: auto;
}

.qr-placeholder {
  margin: 0;
  padding: 48px 16px;
  text-align: center;
  color: #888;
  font-size: 15px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.qr-placeholder.is-hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 480px) {
  .actions {
    flex-direction: row;
  }
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

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

.btn-primary:hover:not(:disabled):not([aria-disabled="true"]) {
  background: var(--primary-hover);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.btn-secondary {
  background: var(--accent);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #e5e5e5;
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.page-footer {
  margin-top: 32px;
  text-align: center;
  font-size: 14px;
  color: #777;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  background: var(--success);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 640px) {
  body {
    padding: 24px;
  }

  .page-header h1 {
    margin-bottom: 24px;
  }

  .qr-host {
    padding: 24px;
  }
}

@media (min-width: 1024px) {
  .page-header h1 {
    margin-bottom: 28px;
  }
}
