:root {
  --bg-deep: #0c1014;
  --bg: #121820;
  --panel: #1a222c;
  --panel-edge: rgba(255, 255, 255, 0.08);
  --text: #edf1f5;
  --muted: #9aa7b5;
  --accent: #e85d04;
  --accent-soft: rgba(232, 93, 4, 0.16);
  --ok: #3dcf8e;
  --ok-soft: rgba(61, 207, 142, 0.14);
  --warn: #f0b429;
  --warn-soft: rgba(240, 180, 41, 0.12);
  --radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(232, 93, 4, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(70, 120, 180, 0.12), transparent 50%),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 45%, #0e141b 100%);
  background-attachment: fixed;
}

a {
  color: var(--accent);
}

.page {
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 3rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.55rem;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 0.95rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.brand-product {
  color: var(--muted);
  font-size: 0.85rem;
}

.top-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.top-link:hover {
  color: var(--text);
}

.top-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.version-badge {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--panel-edge);
  background: rgba(255, 255, 255, 0.03);
}

.env-debug {
  margin: 0.85rem 0 0;
  color: #6e7c8c;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.45;
  word-break: break-word;
}

.hero h1 {
  margin: 0.35rem 0 0.75rem;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lede {
  margin: 0 0 1.5rem;
  max-width: 38rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.banner {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
}

.banner[hidden] {
  display: none !important;
}

.banner-warn {
  background: var(--warn-soft);
  border-color: rgba(240, 180, 41, 0.35);
  color: #ffe7a8;
}

.panel {
  margin-top: 0.5rem;
  padding: 1.35rem 1.4rem 1.5rem;
  border-radius: calc(var(--radius) + 2px);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.03), transparent 40%), var(--panel);
  border: 1px solid var(--panel-edge);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.panel-copy {
  margin: 0 0 1.25rem;
  color: var(--muted);
  line-height: 1.5;
}

.status {
  margin: 0;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-idle {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.status-connected {
  background: var(--ok-soft);
  color: var(--ok);
}

.status-error {
  background: rgba(232, 93, 4, 0.15);
  color: #ffb088;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.7rem 1.35rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:not(:disabled):hover {
  transform: translateY(-1px);
}

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

.btn-primary:not(:disabled):hover {
  background: #f06a14;
}

.btn-ghost {
  background: transparent;
  border-color: var(--panel-edge);
  color: var(--text);
}

.btn-ghost:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.04);
}

.device-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.35rem 0 0;
  padding-top: 1.15rem;
  border-top: 1px solid var(--panel-edge);
}

.device-meta dt {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.device-meta dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.footnote {
  margin: 1.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.panel + .panel {
  margin-top: 1.25rem;
}

.dropzone {
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  padding: 1.5rem 1rem;
  border-radius: var(--radius);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.18);
  text-align: center;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:focus-visible,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone-title {
  margin: 0;
  font-weight: 600;
}

.dropzone-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.btn-file {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.sample-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.sample-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--panel-edge);
  background: rgba(255, 255, 255, 0.03);
}

.sample-item-main {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
}

.sample-slot {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  flex-shrink: 0;
}

.sample-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
}

.sample-size {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.sample-item-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.btn-tiny {
  padding: 0.35rem 0.55rem;
  font-size: 0.75rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-edge);
  color: var(--text);
}

.btn-tiny.btn-danger {
  color: #ffb088;
}

.sample-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--panel-edge);
}

.checksum-meta {
  display: flex;
  gap: 1.25rem;
  margin: 0;
}

.checksum-meta dt {
  margin: 0 0 0.15rem;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.checksum-meta dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.95rem;
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
}

.flash-block {
  margin-top: 1.35rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--panel-edge);
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.progress-row progress {
  flex: 1;
  height: 0.65rem;
  appearance: none;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.progress-row progress::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.progress-row progress::-webkit-progress-value {
  background: linear-gradient(90deg, #d35400, var(--accent));
  border-radius: 999px;
  transition: width 0.12s ease;
}

.progress-row progress::-moz-progress-bar {
  background: linear-gradient(90deg, #d35400, var(--accent));
  border-radius: 999px;
}

.progress-label {
  min-width: 8.5rem;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.flash-checksum {
  margin: 0.75rem 0 0;
}

.btn-file.is-disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

.received-log {
  margin: 0;
  max-height: 12rem;
  overflow: auto;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--panel-edge);
  background: rgba(0, 0, 0, 0.28);
  color: #c8d2dc;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.help-steps {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  color: var(--muted);
  line-height: 1.55;
}

.help-steps li + li {
  margin-top: 0.45rem;
}

.about-title {
  margin: 0 0 0.5rem;
  font-weight: 600;
  font-size: 1.05rem;
}

@media (max-width: 560px) {
  .sample-item {
    flex-direction: column;
    align-items: stretch;
  }

  .sample-item-actions {
    justify-content: flex-end;
  }

  .top {
    margin-bottom: 2rem;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-right {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}
