:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Sarasa Gothic SC", sans-serif;
  font-synthesis: none;
  --ink: #1f2724;
  --muted: #66716c;
  --line: #d9dfda;
  --soft: #eef2ee;
  --surface: #ffffff;
  --page: #f4f6f3;
  --green: #2f6653;
  --green-dark: #244f40;
  --green-soft: #e5eee8;
  --amber: #a06117;
  --danger: #9c4039;
  --shadow: 0 18px 48px rgba(27, 46, 38, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #f8faf8 0, var(--page) 320px);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  width: min(100% - 40px, 940px);
  min-height: 78px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(47, 102, 83, 0.14);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border: 1px solid #e3e6e2;
  border-radius: 50%;
}

.brand div {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 17px;
  font-weight: 650;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
}

.local-badge svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.8;
}

main {
  width: min(100% - 40px, 760px);
  margin: 48px auto 64px;
}

.unlock-panel {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-heading {
  padding: 34px 36px 28px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 28px;
  line-height: 1.25;
  font-weight: 650;
}

.panel-heading > p:last-child {
  max-width: 540px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.form-stack {
  display: grid;
  gap: 24px;
  padding: 30px 36px 36px;
}

.field-group {
  display: grid;
  gap: 9px;
}

.field-group > label {
  font-size: 14px;
  font-weight: 650;
}

.file-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-row > span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-note {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  line-height: 1.5;
}

.password-row {
  position: relative;
}

.password-row input {
  width: 100%;
  height: 48px;
  padding: 0 50px 0 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd3cd;
  border-radius: 6px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.password-row input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 102, 83, 0.13);
}

.icon-button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.icon-button:hover {
  color: var(--ink);
  background: var(--soft);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.primary-button,
.secondary-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  cursor: pointer;
}

.primary-button svg,
.secondary-button svg,
.text-button svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.9;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  padding: 11px 20px;
  color: #fff;
  background: var(--green);
  border: 1px solid var(--green);
  font-weight: 650;
  transition: background 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

.primary-button:hover:not(:disabled) {
  background: var(--green-dark);
  border-color: var(--green-dark);
}

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

.secondary-button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 9px 13px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #cbd9cf;
  font-weight: 600;
}

.secondary-button:hover {
  background: #dce9e0;
}

.secondary-button.compact {
  min-height: 38px;
  padding: 7px 11px;
  font-size: 13px;
}

.optional-import {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.optional-import summary {
  position: relative;
  padding: 15px 28px 15px 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.optional-import summary::-webkit-details-marker {
  display: none;
}

.optional-import summary::after {
  content: "";
  position: absolute;
  top: 18px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 150ms ease;
}

.optional-import[open] summary::after {
  top: 22px;
  transform: rotate(225deg);
}

.optional-content {
  display: grid;
  gap: 12px;
  padding: 0 0 17px;
}

.optional-content p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.status-line {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  color: var(--muted);
  background: var(--soft);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}

.status-line svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  stroke-width: 1.8;
}

.status-line[data-state="working"] {
  color: var(--amber);
  background: #fff5e7;
}

.status-line[data-state="success"] {
  color: var(--green);
  background: var(--green-soft);
}

.status-line[data-state="error"] {
  color: var(--danger);
  background: #fbecea;
}

.device-section {
  margin-top: 34px;
  padding: 0 4px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
}

.device-section h2 {
  margin-bottom: 7px;
  font-size: 16px;
  font-weight: 650;
}

.device-section p {
  max-width: 500px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.text-button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 7px 9px;
  background: transparent;
  border: 0;
  font-size: 13px;
  font-weight: 600;
}

.text-button.danger {
  color: var(--danger);
}

.text-button:hover {
  background: rgba(156, 64, 57, 0.07);
}

.install-note {
  margin-top: 34px;
  padding: 18px 4px 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.install-note svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  stroke-width: 1.8;
}

.install-note p {
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.65;
}

@media (display-mode: standalone) {
  .install-note {
    display: none;
  }
}

@media (max-width: 640px) {
  .app-header,
  main {
    width: min(100% - 28px, 760px);
  }

  .app-header {
    min-height: 70px;
  }

  .local-badge {
    font-size: 0;
  }

  .local-badge svg {
    width: 19px;
    height: 19px;
  }

  main {
    margin-top: 26px;
    margin-bottom: 40px;
  }

  .panel-heading {
    padding: 27px 22px 23px;
  }

  h1 {
    font-size: 24px;
  }

  .form-stack {
    gap: 21px;
    padding: 24px 22px 27px;
  }

  .file-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .file-row > span {
    width: 100%;
  }

  .device-section {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .text-button {
    align-self: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
