:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --line: #e7ebf1;
  --text: #1f2a37;
  --soft: #6b7280;
  --brand: #2f6bff;
  --brand-soft: #eaf0ff;
  --radius-lg: 16px;
  --radius-md: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
}

body {
  padding-top: 56px;
  padding-bottom: 84px;
}

button,
input,
textarea,
select {
  font: inherit;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  height: 56px;
  background: #f8fafc;
  border-bottom: 1px solid #dde3ea;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(22px, calc((100vw - 980px) / 2));
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.brand-logo {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
}

.brand-name {
  font-size: 20px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 148px;
  background: #ffffff;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.14);
  padding: 8px;
  z-index: 15;
}

.user-dropdown::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 18px;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border-top: 1px solid #dbe3ee;
  border-left: 1px solid #dbe3ee;
  transform: rotate(45deg);
}

.user-dropdown-item {
  width: 100%;
  border: 0;
  cursor: pointer;
  background: #ffffff;
  border-radius: 9px;
  text-align: left;
  padding: 9px 10px;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
}

.user-dropdown-item .item-icon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: #eef2ff;
  color: #4f46e5;
  font-size: 11px;
}

.user-dropdown-item:hover {
  background: #f6f8fc;
}

.link-btn,
.primary-btn,
.mode-btn,
.feature-tab,
.generate-btn,
#paperTypeBtn,
#sendCodeBtn,
#refreshScanBtn,
.icon-btn,
#pasteBtn {
  border: 0;
  cursor: pointer;
}

.link-btn {
  background: transparent;
  color: #6f7785;
  font-weight: 500;
}

.primary-btn {
  padding: 8px 18px;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(90deg, #2f6bff, #3f7fff);
}

#openLoginBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 128px;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 12px;
  padding-right: 12px;
}

#openLoginBtnText {
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.open-login-arrow {
  flex: 0 0 auto;
  font-size: 12px;
  line-height: 1;
  color: #475569;
}

#openLoginBtn.logged {
  justify-content: space-between;
  color: #1e293b;
  background: #ffffff;
  border: 1px solid #dbe3ee;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

#openLoginBtn.logged #openLoginBtnText {
  flex: 1;
  text-align: left;
}

.primary-btn.full {
  width: 100%;
  border-radius: 10px;
  margin-top: 12px;
}

.page {
  max-width: 980px;
  margin: 22px auto 0;
  padding: 0 14px 96px;
}

.guide {
  margin-bottom: 12px;
  background: #f7fbff;
  border: 1px solid #dce9ff;
  color: #35558f;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.feature-tabs {
  display: flex;
  justify-content: center;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.feature-tab {
  background: transparent;
  color: #6c7584;
  padding: 5px 12px;
  border-radius: 8px;
  font-weight: 500;
}

.feature-tab.active {
  color: var(--brand);
  background: var(--brand-soft);
}

.mode-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 4px;
  justify-self: center;
}

.mode-btn {
  height: 36px;
  min-width: 170px;
  border-radius: 8px;
  color: #657084;
  background: transparent;
}

.mode-btn.active {
  color: #ffffff;
  background: linear-gradient(90deg, #2f6bff, #3f7fff);
}

.paper-type {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #4b5563;
  cursor: pointer;
}

#paperTypeBtn {
  background: transparent;
  color: #6b7280;
  max-width: 220px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.paper-type-value {
  display: flex;
  align-items: center;
  gap: 6px;
}

.paper-type-arrow {
  color: #9ca3af;
  font-size: 16px;
  line-height: 1;
}

.paper-dropdown {
  margin-top: -8px;
  border: 1px solid #dbe2ec;
  border-radius: 10px;
  background: #ffffff;
  padding: 6px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  display: grid;
  gap: 8px;
}

.paper-dropdown-item {
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  color: #111827;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.paper-dropdown-item:hover {
  background: #f3f6fb;
}

.paper-dropdown-item.active {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.paper-item-main {
  display: grid;
  gap: 4px;
}

.paper-item-title {
  color: #111827;
  font-size: 14px;
  font-weight: 600;
}

.paper-item-desc {
  color: #6b7280;
  font-size: 12px;
  line-height: 1.45;
}

.paper-item-check {
  color: #2563eb;
  font-size: 16px;
  line-height: 1.2;
  margin-top: 1px;
  opacity: 0;
}

.paper-dropdown-item.active .paper-item-check {
  opacity: 1;
}

.input-card,
.output-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: #ffffff;
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

h3 {
  margin: 0;
  font-size: 14px;
}

.output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.counter-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

#inputCounter {
  color: #9aa3b1;
  font-size: 12px;
}

#pasteBtn,
#sendCodeBtn,
#refreshScanBtn,
#copyOutputBtn {
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f7f9fc;
  color: #5f6978;
  padding: 0 10px;
}

#copyOutputBtn:hover {
  background: #eaf1ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

#scanLoginPane #refreshScanBtn {
  display: block;
  margin: 12px auto 0;
}

#inputText {
  width: 100%;
  min-height: 210px;
  resize: vertical;
  border: 0;
  outline: 0;
  line-height: 1.7;
  color: #334155;
}

.generate-btn {
  height: 46px;
  border-radius: 9px;
  color: #ffffff;
  font-weight: 700;
  background: linear-gradient(90deg, #2f6bff, #3f7fff);
}

.generate-btn.is-stop {
  background: #e64b4b;
}

.output-card {
  min-height: 220px;
  max-height: min(72vh, 760px);
  display: flex;
  flex-direction: column;
}

#outputText {
  margin: 10px 0 0;
  color: #334155;
  word-break: break-word;
  min-height: 150px;
  flex: 1;
  overflow-y: auto;
  line-height: 1.75;
  padding-right: 4px;
}

#outputText > *:first-child {
  margin-top: 0;
}

#outputText > *:last-child {
  margin-bottom: 0;
}

#outputText p,
#outputText ul,
#outputText ol,
#outputText blockquote,
#outputText pre {
  margin: 0 0 10px;
}

#outputText h1,
#outputText h2,
#outputText h3,
#outputText h4 {
  margin: 0 0 10px;
  color: #111827;
  line-height: 1.4;
}

#outputText ul,
#outputText ol {
  padding-left: 22px;
}

#outputText a {
  color: #2563eb;
  text-decoration: underline;
}

#outputText code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  background: #f3f4f6;
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 0.92em;
}

#outputText pre {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  overflow-x: auto;
}

#outputText pre code {
  background: transparent;
  padding: 0;
}

#outputText blockquote {
  border-left: 3px solid #bfdbfe;
  background: #f8fbff;
  color: #475569;
  padding: 8px 12px;
}

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  color: #9aa3b1;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  z-index: 5;
}

.footer-links {
  display: flex;
  gap: 14px;
}

.footer a {
  color: #8e98a8;
  text-decoration: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.modal.hidden,
.hidden {
  display: none;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}

.modal-card {
  position: relative;
  width: min(460px, calc(100vw - 24px));
  margin: 90px auto 0;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e5e9f0;
  padding: 16px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f1f4f8;
  color: #4b5563;
  font-size: 18px;
}

.login-tabs {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.login-tabs button {
  height: 36px;
  border: 1px solid #e5eaf1;
  border-radius: 8px;
  background: #f8fafc;
  color: #6b7280;
}

.login-tabs button.active {
  color: #ffffff;
  background: linear-gradient(90deg, #2f6bff, #3f7fff);
  border-color: transparent;
}

.login-panel-error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #f5c2c7;
  background: #fff1f2;
  color: #b42318;
  font-size: 13px;
  line-height: 1.5;
}

.login-pane {
  margin-top: 14px;
}

.login-pane label {
  display: block;
  margin: 12px 0 6px;
  color: #4b5563;
  font-size: 13px;
}

.login-pane input {
  width: 100%;
  height: 40px;
  border: 1px solid #dce3ec;
  border-radius: 8px;
  padding: 0 10px;
}

.sms-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.scan-box {
  margin-top: 12px;
  min-height: 180px;
  border: 1px dashed #cdd6e3;
  border-radius: 10px;
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
  color: #5d6879;
}

.scan-box small {
  color: #8b95a5;
}

.scan-qr-wrap {
  position: relative;
  width: 168px;
  height: 168px;
  border-radius: 8px;
  overflow: hidden;
}

.scan-qr-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.scan-qr-empty {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: #f8fafc;
  color: #64748b;
  padding: 0 14px;
  font-size: 13px;
  line-height: 1.5;
}

.scan-expire-tip {
  margin-top: 2px;
  color: #6b7280;
  font-size: 12px;
}

.scan-expire-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}

.scan-expire-mask.hidden {
  display: none;
}

.scan-expire-refresh {
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.4;
}

.download-guide-card {
  width: min(440px, calc(100vw - 24px));
}

.download-guide-content {
  margin-top: 16px;
  text-align: center;
}

.download-app-icon {
  width: 84px;
  height: 84px;
  border-radius: 18px;
  display: block;
  margin: 0 auto 14px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.download-guide-line {
  margin: 0;
  color: #374151;
  font-size: 14px;
  line-height: 1.7;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #111827;
  color: #ffffff;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
}

.toast.show {
  opacity: 1;
}

@media (max-width: 768px) {
  .topbar {
    padding: 0 12px;
  }

  .brand-name {
    font-size: 16px;
  }

  .mode-switch {
    width: 100%;
    justify-self: stretch;
  }

  .mode-btn {
    min-width: 0;
    width: 50%;
  }

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

  .output-card {
    max-height: min(66vh, 680px);
  }
}
