@font-face {
  font-family: "wireless-tools-iconfont";
  src: url("/static/font/iconfont/iconfont-tools-toggle.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

.tools-shell {
  --tool-ink: #10202f;
  --tool-muted: #5f7283;
  --tool-line: #d6e2ea;
  --tool-panel: rgba(255, 255, 255, 0.92);
  --tool-soft: #f4f8fb;
  --tool-soft-2: #edf4f8;
  --tool-red: #d33f38;
  --tool-teal: #0f8f83;
  --tool-blue: #2563eb;
  --tool-shadow: 0 18px 38px rgba(10, 32, 47, 0.12);
  color: var(--tool-ink);
  min-height: 100vh;
  padding: 16px 0 52px;
  background:
    linear-gradient(180deg, rgba(245, 249, 251, 0.96), rgba(250, 252, 253, 0.99)),
    radial-gradient(circle at top, rgba(53, 168, 255, 0.08), transparent 42%);
}

.dark .tools-shell {
  --tool-ink: #eaf3f6;
  --tool-muted: #9ab0bc;
  --tool-line: #263844;
  --tool-panel: rgba(18, 27, 34, 0.92);
  --tool-soft: #10181f;
  --tool-soft-2: #13202a;
  --tool-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  background:
    linear-gradient(180deg, rgba(7, 19, 25, 0.96), rgba(10, 21, 28, 0.99)),
    radial-gradient(circle at top, rgba(53, 168, 255, 0.1), transparent 42%);
}

.tools-shell,
.tools-shell * {
  box-sizing: border-box;
}

#tools #page_wrapper {
  text-align: left;
}

#tools #page_content {
  width: 100%;
  justify-content: flex-start;
}

#tools #page_content > div {
  width: 100%;
  max-width: none;
  margin: 0;
  align-self: stretch;
  display: block;
}

#tools #navbar {
  min-height: 44px;
}

#tools #navbar_menu {
  margin-left: 0.45rem;
  margin-right: 0.45rem;
}

#tools #navbar a {
  margin: 1px 3px;
  padding: 3px 8px;
}

#tools #navbar .site_logo {
  height: 3em;
}

#tools #navbar h2 {
  padding-left: 0;
}

#tools #navbar #navbar_items {
  padding-right: 0.2rem;
}

#tools #nav_right > li:nth-child(1) #search {
  width: 230px;
}

#tools #nav_right > li:nth-child(1) #search .icon {
  min-height: 1.5rem;
  min-width: 1.5rem;
}

.tools-hero,
.tools-shared-panel,
.tools-tabs-panel,
.tools-workbench {
  width: 100%;
  max-width: none;
  margin: 0 auto;
}

.tools-main {
  width: min(1280px, calc(100% - 24px));
  margin: 30px auto 60px;
  padding: 0;
  box-sizing: border-box;
  display: grid;
  gap: 12px;
}

.tools-main > *,
.tools-workbench > *,
.tool-grid > *,
.tool-actions,
.shared-tool-actions {
  min-width: 0;
}

.tools-hero {
  min-height: 280px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(240px, 360px);
  gap: 24px;
  align-items: end;
  padding: clamp(20px, 2.2vw, 28px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  color: #ffffff;
  background:
    linear-gradient(100deg, rgba(4, 15, 21, 0.92), rgba(8, 18, 25, 0.55) 58%, rgba(12, 26, 35, 0.2)),
    url("/static/home/tools-hero.svg") center / cover;
  box-shadow: var(--tool-shadow);
}

.tools-hero > div:first-child {
  max-width: 860px;
}

.tools-kicker {
  margin: 0 0 10px;
  color: #7ef0e0;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  font-size: 13px;
}

.tools-hero h1,
.workbench-head h2,
.tool-form h3,
.firmware-card h3 {
  letter-spacing: 0;
  margin-top: 0;
}

.tools-hero h1 {
  margin-bottom: 12px;
  font-size: clamp(32px, 4vw, 58px);
  line-height: 1.05;
}

.tools-hero p {
  margin: 0;
  max-width: 760px;
  color: #e3f1f2;
  font-size: 17px;
  line-height: 1.65;
}

.tools-hero p a {
  color: #7ef0e0;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tools-status {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 12px;
}

.status-card {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.12);
}

.status-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

.status-card p {
  margin: 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
  line-height: 1.6;
}

.tools-shared-panel {
  padding: 10px;
  border: 1px solid var(--tool-line);
  background: var(--tool-panel);
  border-radius: 12px;
  box-shadow: var(--tool-shadow);
  backdrop-filter: blur(8px);
}

.shared-tool-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.shared-tool-summary {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.shared-tool-summary strong {
  font-size: 14px;
  line-height: 1.3;
}

.shared-tool-summary span {
  color: var(--tool-muted);
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.shared-tool-actions__buttons {
  margin-top: 0;
}

.shared-task-progress {
  width: 100%;
  display: grid;
  gap: 8px;
}

.shared-task-progress__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--tool-muted);
  font-size: 13px;
}

.shared-task-progress__head strong {
  color: var(--tool-ink);
  font-size: 13px;
}

.tools-tabs-panel,
.tools-workbench,
.tool-console,
.tool-form,
.firmware-card {
  border: 1px solid var(--tool-line);
  background: var(--tool-panel);
  border-radius: 12px;
  box-shadow: var(--tool-shadow);
}

.tools-tabs-panel {
  padding: 8px 8px 0;
  backdrop-filter: blur(8px);
}

.tools-search span,
.field span {
  display: block;
  margin-bottom: 7px;
  color: var(--tool-muted);
  font-weight: 700;
  font-size: 13px;
}

.tools-search input,
.field input,
.field select,
.official-firmware-search input,
.serial-input {
  width: 100%;
  border: 1px solid var(--tool-line);
  border-radius: 10px;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--tool-ink);
  background: var(--tool-soft);
  outline: none;
}

.serial-send-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(96px, 10%) auto;
  gap: 10px;
  align-items: start;
  margin-top: 14px;
}

.serial-send-text {
  resize: vertical;
}

.serial-send-row.is-expanded .serial-send-text {
  grid-column: 1 / -1;
  min-height: 120px;
  line-height: 1.5;
}

.serial-compose-toggle,
.serial-send-button {
  white-space: nowrap;
}

.serial-compose-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 8px;
}

.serial-compose-icon {
  font-family: "wireless-tools-iconfont";
  font-size: 18px;
  font-style: normal;
  line-height: 1;
  speak: never;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.serial-compose-icon--open::before {
  content: "\e76c";
}

.serial-compose-icon--fold::before {
  content: "\e76d";
}

.tools-search input:focus,
.field input:focus,
.field select:focus,
.serial-input:focus {
  border-color: rgba(37, 99, 235, 0.6);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.device-state {
  min-height: 42px;
  border: 1px solid var(--tool-line);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--tool-ink);
  background: var(--tool-soft);
  text-align: center;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 0;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}

.tool-list::-webkit-scrollbar {
  display: none;
}

.tool-card {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: auto;
  min-width: clamp(124px, 11vw, 168px);
  padding: 11px 14px;
  text-align: center;
  color: var(--tool-ink);
  background: var(--tool-soft);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  scroll-snap-align: start;
  border-radius: 10px 10px 0 0;
  border-bottom-color: transparent;
  white-space: nowrap;
}

.tool-card:hover {
  transform: translateY(-1px);
}

.tool-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.tool-card.active {
  border-color: rgba(211, 63, 56, 0.65);
  box-shadow: inset 0 -2px 0 rgba(211, 63, 56, 0.9);
  background: var(--tool-panel-strong);
}

.tool-card img {
  width: 24px;
  height: 24px;
}

.tool-card__label {
  font-weight: 800;
  font-size: 14px;
  line-height: 1.2;
}

.dark .tool-card {
  background: #0f171d;
  color: #b7c4cc;
  border-color: #263844;
}

.dark .tool-card.active {
  background: #16212a;
  color: #f2f7fa;
  border-color: rgba(211, 63, 56, 0.65);
}

.dark .tool-card__label {
  color: inherit;
}

.tools-workbench {
  padding: 14px;
  backdrop-filter: blur(8px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 14px;
  align-items: stretch;
}

.workbench-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 14px;
  grid-column: 1 / -1;
}

.workbench-head > div:first-child {
  min-width: 0;
}

.workbench-head h2 {
  margin: 0;
  font-size: 30px;
}

.workbench-head p {
  color: var(--tool-muted);
  margin: 8px 0 0;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.flash-tool-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
}

.flash-tool-grid > .tool-form {
  align-self: start;
}

.flash-tool-grid .tool-btn,
.flash-tool-grid input,
.flash-tool-grid select,
.flash-file-row {
  scroll-margin-top: 160px;
}

#tool-panel {
  min-width: 0;
}

.tool-form,
.firmware-card {
  padding: 16px;
  min-width: 0;
}

.tool-form.full {
  grid-column: 1 / -1;
}

.tool-form h3,
.firmware-card h3 {
  margin-bottom: 10px;
  font-size: 18px;
}

.tool-form h4 {
  margin: 16px 0 10px;
  color: var(--tool-ink);
  font-size: 15px;
  letter-spacing: 0;
}

.firmware-list {
  display: grid;
  gap: 12px;
}

.official-firmware-form {
  display: flex;
  flex-direction: column;
  height: var(--official-firmware-height, clamp(560px, calc(100vh - 300px), 760px));
  min-height: 0;
  overflow: hidden;
}

.official-firmware-controls {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.official-firmware-search {
  margin: 0;
}

.official-firmware-count {
  color: var(--tool-muted);
  font-size: 12px;
  font-weight: 700;
}

.official-firmware-scroll {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.firmware-empty {
  display: grid;
  min-height: 160px;
  place-items: center;
  border: 1px dashed var(--tool-line);
  border-radius: 10px;
  color: var(--tool-muted);
  background: var(--tool-soft);
  text-align: center;
  padding: 16px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--tool-soft-2);
  color: var(--tool-muted);
  font-size: 12px;
  font-weight: 700;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.flash-file-row {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.flash-file-row__file {
  display: block;
}

.flash-file-row__meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.flash-file-row__meta .field {
  margin: 0;
}

.flash-bin-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--tool-line);
}

.flash-bin-section h4 {
  margin-top: 0;
}

.firmware-package-summary {
  margin: 0 0 4px;
  word-break: break-word;
}

.firmware-file-display {
  display: grid;
  gap: 4px;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--tool-line);
  border-radius: 10px;
  background: var(--tool-soft);
}

.firmware-file-display strong {
  color: var(--tool-ink);
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
}

.firmware-file-display small {
  color: var(--tool-muted);
  font-size: 12px;
  line-height: 1.3;
}

.firmware-picker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 42px;
}

.firmware-picker__button {
  margin: 0;
  white-space: nowrap;
}

.firmware-picker__name {
  min-width: 0;
  color: var(--tool-muted);
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.flash-primary-row {
  display: grid;
}

.flash-primary-row .tool-btn {
  width: 100%;
}

.flash-secondary-row {
  margin-top: 10px;
}

.tool-btn,
.mini-btn {
  border: 1px solid var(--tool-line);
  min-height: 42px;
  border-radius: 10px;
  padding: 8px 14px;
  color: var(--tool-ink);
  background: var(--tool-soft);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.tool-btn:hover,
.mini-btn:hover {
  transform: translateY(-1px);
}

.tool-btn.primary {
  color: #ffffff;
  background: linear-gradient(135deg, #d33f38, #b82b25);
  border-color: #b82b25;
}

.tool-btn.danger {
  color: #ffffff;
  background: linear-gradient(135deg, #b82b25, #8f1d18);
  border-color: #8f1d18;
}

.tool-btn:disabled,
.mini-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.tool-note,
.tool-form p,
.firmware-card p {
  color: var(--tool-muted);
  line-height: 1.6;
}

.tool-diagnostics {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--tool-line);
  border-radius: 10px;
  background: var(--tool-soft);
}

.tool-diagnostics h4 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--tool-ink);
}

.diagnostics-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.diagnostics-list div {
  display: grid;
  gap: 4px;
}

.diagnostics-list dt {
  color: var(--tool-muted);
  font-size: 12px;
  font-weight: 700;
}

.diagnostics-list dd {
  margin: 0;
  color: var(--tool-ink);
  word-break: break-word;
}

.tool-console {
  margin-top: 0;
  padding: 16px;
  height: clamp(420px, calc(100vh - 220px), 760px);
  min-height: 0;
  max-height: calc(100vh - 220px);
  position: sticky;
  top: 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.console-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: var(--tool-muted);
  font-weight: 700;
}

.console-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

#tool-log,
.serial-output {
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--tool-line);
  background: var(--tool-soft);
  color: var(--tool-ink);
  white-space: pre-wrap;
  word-break: break-word;
}

#tool-log {
  min-height: 0;
}

.tool-log-time {
  color: var(--tool-muted);
}

.tool-log-entry--error .tool-log-message {
  color: #dc2626;
}

.tool-log-entry--warn .tool-log-message {
  color: #ca8a04;
}

.tool-log-entry--info .tool-log-message {
  color: #16a34a;
}

.tool-log-entry--debug .tool-log-message {
  color: #0891b2;
}

.tool-log-entry--verbose .tool-log-message {
  color: #c026d3;
}

.serial-output {
  height: clamp(280px, 32vh, 420px);
  max-height: none;
  margin-top: 14px;
  overflow-y: auto;
}

.serial-ansi-bold {
  font-weight: 700;
}

.serial-ansi-dim {
  opacity: 0.72;
}

.serial-ansi-black {
  color: #111827;
}

.serial-ansi-red,
.serial-log-error {
  color: #dc2626;
}

.serial-ansi-green,
.serial-log-info {
  color: #16a34a;
}

.serial-ansi-yellow,
.serial-log-warn {
  color: #ca8a04;
}

.serial-ansi-blue {
  color: #2563eb;
}

.serial-ansi-magenta,
.serial-log-verbose {
  color: #c026d3;
}

.serial-ansi-cyan,
.serial-log-debug {
  color: #0891b2;
}

.serial-ansi-white {
  color: #f8fafc;
}

.serial-ansi-bright-black {
  color: #6b7280;
}

.serial-ansi-bright-red {
  color: #ef4444;
}

.serial-ansi-bright-green {
  color: #22c55e;
}

.serial-ansi-bright-yellow {
  color: #eab308;
}

.serial-ansi-bright-blue {
  color: #3b82f6;
}

.serial-ansi-bright-magenta {
  color: #d946ef;
}

.serial-ansi-bright-cyan {
  color: #06b6d4;
}

.serial-ansi-bright-white {
  color: #ffffff;
}

.progress {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--tool-soft-2);
  margin-top: 14px;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--tool-teal), var(--tool-blue));
  transition: width 0.2s ease;
}

.progress.is-indeterminate span {
  width: 38%;
  min-width: 72px;
  animation: shared-progress-indeterminate 1.1s ease-in-out infinite;
  transition: none;
}

@keyframes shared-progress-indeterminate {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(280%);
  }
}

.info-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.info-table th,
.info-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--tool-line);
  text-align: left;
  vertical-align: top;
}

.info-table th {
  width: 110px;
  color: var(--tool-muted);
  font-weight: 700;
}

.dark .status-card {
  border-color: rgba(255, 255, 255, 0.12);
}

.dark .badge {
  background: rgba(255, 255, 255, 0.06);
}

.dark .tool-btn,
.dark .mini-btn {
  background: var(--tool-soft-2);
}

@media screen and (max-width: 1180px) {
  .tools-hero {
    grid-template-columns: 1fr;
    min-height: 260px;
  }

  .tools-status {
    max-width: 420px;
  }

  .tools-workbench {
    grid-template-columns: 1fr;
  }

  .tool-console {
    position: static;
  }
}

@media screen and (max-width: 760px) {
  .tools-main {
    width: 100%;
    max-width: calc(100% - 20px);
    margin: 24px auto 56px;
    padding: 0 10px;
  }

  .tools-hero {
    padding: 18px;
    border-radius: 12px;
  }

  .tools-workbench {
    padding: 12px;
  }

  .workbench-head {
    flex-direction: column;
  }

  .tool-list {
    gap: 6px;
  }

  .tool-card {
    min-width: clamp(116px, 44vw, 170px);
    padding: 10px 12px;
  }

  .tool-card img {
    width: 22px;
    height: 22px;
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }

  .flash-tool-grid {
    grid-template-columns: 1fr;
  }

  .official-firmware-form {
    height: auto;
    overflow: visible;
  }

  .official-firmware-scroll {
    max-height: 520px;
  }

  .tools-workbench {
    gap: 12px;
  }

  .file-row {
    grid-template-columns: 1fr;
  }

  .serial-send-row {
    grid-template-columns: 1fr 1fr;
  }

  .serial-send-text {
    grid-column: 1 / -1;
  }

  .serial-send-row.is-expanded .serial-send-text {
    grid-column: 1 / -1;
  }

  .flash-file-row__meta {
    grid-template-columns: 1fr;
  }

  .firmware-picker {
    grid-template-columns: 1fr;
  }

  .firmware-picker__name {
    white-space: normal;
  }

  .tool-actions {
    flex-direction: column;
  }

  .tool-btn,
  .mini-btn {
    width: 100%;
    justify-content: center;
  }

  .shared-tool-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

@media screen and (max-width: 520px) {
  .tools-shell {
    padding-top: 12px;
  }

  .tools-main {
    width: 100%;
    max-width: calc(100% - 16px);
    margin: 20px auto 48px;
    padding: 0 8px;
  }

  .tools-hero h1 {
    font-size: 30px;
  }

  .tools-hero p {
    font-size: 15px;
  }

  .tool-form,
  .firmware-card,
  .tools-tabs-panel,
  .tool-console {
    border-radius: 10px;
  }

  #tool-log,
  .serial-output {
    min-height: 150px;
  }

  .serial-output {
    height: clamp(220px, 30vh, 300px);
  }
}
