@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-header: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #10b981;
  --success-bg: #d1fae5;
  --error: #ef4444;
  --radius: 20px;
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
  --bg: #121212;
  --surface: #1e1e1e;
  --border: #333333;
  --text: #f8fafc;
  --text-header: #ffffff;
  --muted: #9ca3af;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --error: #ef4444;
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 40px 20px;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.layout-wrapper {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  text-align: center;
  margin-bottom: 24px;
}

header h1 {
  margin: 0 0 8px 0;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-header);
  letter-spacing: -0.025em;
}

header a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

header a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  margin-bottom: 16px;
  color: var(--muted) !important;
}

.github-link:hover {
  color: var(--text) !important;
  text-decoration: none !important;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 500;
}

.demo-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--surface);
  background: var(--success);
  border-radius: 4px;
  vertical-align: middle;
}

.main-panel {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.unsupported-msg {
  text-align: center;
  color: var(--muted);
  font-weight: 500;
  padding: 40px 20px;
  font-size: 1.25rem;
}

.unsupported-msg h2 {
  color: var(--text);
  margin-bottom: 16px;
  font-size: 1.75rem;
}

.unsupported-icon {
  margin: 0 auto 20px auto;
  display: block;
  color: var(--error);
}

.nav-header {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}

  .btn-back {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--muted);
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color 0.2s, color 0.2s;
  }

.btn-back:hover {
  background-color: var(--border);
  color: var(--text);
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
  position: relative;
  min-height: 40px;
}

.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--text);
  color: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  opacity: 0.25;
  transition: opacity 0.3s ease;
}

.step-circle.active {
  opacity: 1;
}

.step-line {
  width: 24px;
  height: 2px;
  background-color: var(--text);
  opacity: 0.25;
}

.step {
  text-align: center;
}

.step h2 {
  margin: 0 0 12px 0;
  font-size: 1.75rem;
  font-weight: 600;
  text-align: center;
}

.step p {
  margin: 0 0 24px 0;
  color: var(--muted);
  font-size: 1.15rem;
  text-align: center;
}

.btn-huge {
  display: block;
  width: 100%;
  max-width: 480px;
  margin: 0 auto 16px auto;
  padding: 24px 32px;
  font-size: 1.5rem;
  font-family: inherit;
  font-weight: 700;
  color: #fff;
  background-color: var(--accent);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-next {
  margin-top: 24px !important;
  background-color: var(--success);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

[data-theme="dark"] .btn-next {
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-next:hover:not(:disabled) {
  background-color: #059669;
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

[data-theme="dark"] .btn-huge {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-huge:hover:not(:disabled) {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.btn-huge:active:not(:disabled) {
  transform: scale(0.96);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}

.btn-huge:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.status {
  margin: 16px 0 32px 0;
  font-size: 1rem;
  min-height: 1.5em;
  font-weight: 500;
  text-align: center;
}

.status:empty {
  display: none;
}

.status.success { color: var(--muted); }
.status.error { color: var(--error); }
.status .fw-back-to-tiles {
  color: inherit;
  text-decoration: underline;
}
.status .fw-back-to-tiles:hover {
  text-decoration: none;
}

.key-preview-container {
  position: relative;
  height: 60px;
  margin-top: 24px;
  margin-bottom: 24px;
}

.key-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 1.25rem;
  line-height: 60px;
  color: var(--accent);
  letter-spacing: 2px;
  text-align: center;
  font-weight: 600;
  transition: opacity 0.4s ease, filter 0.4s ease, color 0.4s ease;
}

.key-preview.scrambling {
  color: var(--muted);
  filter: blur(1px);
}

.key-preview.revealed {
  text-shadow: 0 0 15px rgba(37, 99, 235, 0.4);
}

#key-preview-dots {
  /* removed transform to match exact baseline */
}

.notes {
  margin: 0;
  padding: 24px;
  border: 2px dashed var(--success);
  border-radius: 12px;
  background-color: var(--success-bg);
}

.notes h2 { 
  color: var(--success); 
  margin-bottom: 8px; 
}

.notes p { 
  color: var(--text); 
  font-weight: 600; 
  margin-bottom: 0; 
}

.instructions-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 24px 0 32px 0;
}

.instruction-item {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
}

.instruction-number {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background-color: var(--text);
  color: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.instruction-item p {
  margin: 0;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
}

.app-footer {
  width: 100%;
  text-align: center;
  margin-top: 32px;
  padding: 16px 0;
}

.theme-toggle-footer {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: color 0.2s ease;
  padding: 8px 16px;
}

.theme-toggle-footer:hover {
  color: var(--text);
}

.step-hidden {
  display: none !important;
}

.step-visible {
  animation: fadeIn 0.4s ease forwards;
}

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

.step-fading-out {
  animation: fadeOut 0.2s ease forwards !important;
}

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

.timeout-indicator {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.timeout-indicator.visible {
  opacity: 1;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 2;
}

.progress-ring-circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 50.26;
  stroke-dashoffset: 50.26;
  stroke-linecap: round;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  width: 100%;
  background: transparent;
  padding: 0;
}

.tab-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s ease;
  position: relative;
  display: flex;
  justify-content: center;
}

.tab-btn span {
  position: relative;
}

.tab-btn:hover {
  opacity: 0.8;
  color: var(--text);
  background: transparent;
}

.tab-btn.active {
  opacity: 1;
  color: var(--text);
  background: transparent;
}

.tab-btn.active span::after {
  content: '';
  position: absolute;
  bottom: -13px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--text-header);
}

/* Firmware Tab Styles */
.device-tiles {
  display: flex;
  gap: 16px;
  margin-bottom: 0;
  min-height: 250px;
  align-items: stretch;
}

.btn-tile {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
  font-size: 1.5rem;
  font-family: inherit;
  font-weight: 700;
  color: var(--text);
  background-color: #e5e7eb;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

[data-theme="dark"] .btn-tile {
  background-color: #2a2a2a;
}

.btn-tile:hover:not(:disabled) {
  background-color: var(--border);
}

[data-theme="dark"] .btn-tile:hover:not(:disabled) {
  background-color: #333333;
}

.btn-tile:active:not(:disabled) {
  transform: scale(0.96);
  transition: transform 0.05s ease;
}

.btn-tile:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.badge-latest {
  background: var(--success);
  color: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75em;
  margin-left: 8px;
  font-weight: bold;
  text-transform: lowercase;
  vertical-align: middle;
}

.release-info-container {
  position: relative;
  margin-bottom: 24px;
}

.release-info {
  background: var(--bg);
  padding: 16px;
  border-radius: 12px;
  font-size: 0.95rem;
  color: var(--text);
  border: 1px solid var(--border);
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.release-info:hover {
  border-color: var(--accent);
}

.release-info a {
  color: var(--text);
  text-decoration: none;
}

.release-info a:hover {
  text-decoration: underline;
}

.release-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-top: 8px;
  z-index: 10;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}

.release-dropdown.visible {
  display: block;
}

.release-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.2s;
  text-align: left;
}

.release-item:last-child {
  border-bottom: none;
}

.release-item:hover {
  background-color: var(--bg);
}

.release-item.selected {
  background-color: var(--bg);
  font-weight: bold;
}

.progress-container {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  margin: 16px 0 24px 0;
  overflow: hidden;
  transition: opacity 0.4s ease, height 0.4s ease, margin 0.4s ease;
}

.progress-container.fade-out {
  opacity: 0;
  height: 0;
  margin-top: 0;
  margin-bottom: 0;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  width: 100%;
  background: transparent;
  padding: 0;
}

.tab-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s ease;
  position: relative;
  display: flex;
  justify-content: center;
}

.tab-btn span {
  position: relative;
}

.tab-btn:hover {
  opacity: 0.8;
  color: var(--text);
  background: transparent;
}

.tab-btn.active {
  opacity: 1;
  color: var(--text);
  background: transparent;
}

.tab-btn.active span::after {
  content: '';
  position: absolute;
  bottom: -13px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--text-header);
}

/* Firmware Tab Styles */
.device-tiles {
  display: flex;
  gap: 16px;
  margin-bottom: 0;
  min-height: 250px;
  align-items: stretch;
}

.btn-tile {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
  font-size: 1.5rem;
  font-family: inherit;
  font-weight: 700;
  color: var(--text);
  background-color: #e5e7eb;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

[data-theme="dark"] .btn-tile {
  background-color: #2a2a2a;
}

.btn-tile:hover:not(:disabled) {
  background-color: var(--border);
}

[data-theme="dark"] .btn-tile:hover:not(:disabled) {
  background-color: #333333;
}

.btn-tile:active:not(:disabled) {
  transform: scale(0.96);
  transition: transform 0.05s ease;
}

.btn-tile:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.badge-latest {
  background: var(--success);
  color: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75em;
  margin-left: 8px;
  font-weight: bold;
  text-transform: lowercase;
  vertical-align: middle;
}

.release-info-container {
  position: relative;
  margin-bottom: 24px;
}

.release-info {
  background: var(--bg);
  padding: 16px;
  border-radius: 12px;
  font-size: 0.95rem;
  color: var(--text);
  border: 1px solid var(--border);
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.release-info:hover {
  border-color: var(--accent);
}

.release-info a {
  color: var(--text);
  text-decoration: none;
}

.release-info a:hover {
  text-decoration: underline;
}

.release-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-top: 8px;
  z-index: 10;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}

.release-dropdown.visible {
  display: block;
}

.release-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.2s;
  text-align: left;
}

.release-item:last-child {
  border-bottom: none;
}

.release-item:hover {
  background-color: var(--bg);
}

.release-item.selected {
  background-color: var(--bg);
  font-weight: bold;
}

.progress-container {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  margin: 16px 0 24px 0;
  overflow: hidden;
  transition: opacity 0.4s ease, height 0.4s ease, margin 0.4s ease;
}

.progress-container.fade-out {
  opacity: 0;
  height: 0;
  margin-top: 0;
  margin-bottom: 0;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}