:root {
  color-scheme: light;
  --bg: #edf2ef;
  --bg-soft: #f8faf7;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --ink: #171615;
  --muted: #69615b;
  --line: #dde7e2;
  --accent: #0f315f;
  --accent-warm: #b57b67;
  --danger: #c03945;
  --shadow: 0 26px 70px rgba(50, 76, 72, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 84% 12%, rgba(185, 137, 112, 0.18), transparent 38%),
    linear-gradient(130deg, #fffdf9 0%, var(--bg) 52%, #dce8e3 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.page-shell {
  width: min(1420px, calc(100vw - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 0 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.site-header {
  display: flex;
  align-items: center;
  gap: 18px;
  width: min(980px, 100%);
  margin-bottom: 18px;
}

.logo-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 12px 36px rgba(35, 33, 30, 0.08);
}

.logo-mark svg {
  width: 36px;
  height: 36px;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(28px, 3.5vw, 36px);
  line-height: 1.05;
  letter-spacing: 0;
}

.site-header p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.manage-link {
  margin-left: auto;
  padding: 12px 18px;
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 15px;
  box-shadow: 0 10px 24px rgba(15, 49, 95, 0.14);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(430px, 1.1fr) minmax(400px, 0.9fr);
  gap: 30px;
  min-height: 0;
  padding: 32px;
  background: rgba(248, 250, 247, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.left-stack {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 24px;
  align-content: start;
  min-height: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 18px 45px rgba(50, 41, 33, 0.06);
}

.secret-panel {
  padding: 24px 28px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  font-size: 18px;
  font-weight: 800;
}

.count-pill {
  min-width: 64px;
  padding: 5px 12px;
  color: #6d6570;
  font-size: 17px;
  text-align: center;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
}

.secret-input-wrap {
  position: relative;
}

.secret-input {
  width: 100%;
  min-height: 58px;
  padding: 0 82px 0 20px;
  color: #71675e;
  font-size: 22px;
  letter-spacing: 0;
  background: #fbfdfb;
  border: 1px solid #dce6e1;
  border-radius: 18px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.secret-input:focus {
  border-color: rgba(15, 49, 95, 0.42);
  box-shadow: 0 0 0 4px rgba(15, 49, 95, 0.08);
}

.clear-secret {
  position: absolute;
  top: 50%;
  right: 9px;
  min-height: 40px;
  padding: 0 13px;
  color: var(--accent-warm);
  font-size: 16px;
  font-weight: 700;
  background: transparent;
  border: 0;
  border-radius: 11px;
  transform: translateY(-50%);
}

.clear-secret:not(:disabled):hover {
  background: rgba(181, 123, 103, 0.08);
}

.control-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
}

.save-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #3f3a36;
  font-size: 16px;
  user-select: none;
}

.save-toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.ghost-button {
  padding: 7px 12px;
  color: var(--accent-warm);
  font-size: 16px;
  background: transparent;
  border: 0;
}

.help-text,
.error-text {
  min-height: 20px;
  margin: 14px 0 0;
  line-height: 1.55;
  font-size: 17px;
}

.help-text {
  color: #3f4d63;
}

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

.error-text:empty {
  display: none;
}

.qr-panel {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 26px;
  align-items: center;
  padding: 28px;
}

.qr-preview {
  position: relative;
  display: grid;
  place-items: center;
  width: 190px;
  aspect-ratio: 1;
  background: #fbfdfb;
  border: 1px solid #dce6e1;
  border-radius: 20px;
  overflow: hidden;
}

#qrCanvas {
  display: block;
  width: 160px;
  height: 160px;
}

.qr-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: #4d443d;
  background: #fbfdfb;
}

.qr-empty[hidden] {
  display: none !important;
}

.qr-empty span {
  width: 58px;
  aspect-ratio: 1;
  border: 4px solid #38302b;
  border-radius: 18px;
}

.qr-empty strong {
  font-size: 15px;
}

.guide-panel h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.qr-copy p {
  margin: 16px 0 20px;
  color: #454a58;
  line-height: 1.75;
}

.mini-field {
  display: grid;
  gap: 10px;
  min-height: 86px;
  padding: 17px 20px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.mini-field span,
.metric-card span {
  color: #5f5750;
  font-weight: 700;
  font-size: 14px;
}

.mini-field strong {
  overflow-wrap: anywhere;
  font-size: 18px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 22px;
}

.soft-button {
  min-height: 48px;
  padding: 0 20px;
  color: var(--accent-warm);
  font-weight: 800;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: 0 10px 24px rgba(54, 46, 38, 0.04);
  transition: transform 150ms ease, border-color 150ms ease, color 150ms ease;
}

.soft-button:not(:disabled):hover {
  color: #8f5f50;
  border-color: rgba(181, 123, 103, 0.34);
  transform: translateY(-1px);
}

.code-panel {
  position: relative;
  min-height: 0;
  padding: 26px;
  overflow: hidden;
}

.code-panel::after {
  content: "";
  position: absolute;
  right: -34px;
  bottom: -44px;
  width: 154px;
  height: 96px;
  background: #e8f0ec;
  border-radius: 80% 0 0 0;
}

.status-row {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 18px;
  color: #56504b;
  font-size: 17px;
  font-weight: 800;
  background: #eef2f0;
  border-radius: 999px;
}

.status-badge i {
  width: 9px;
  height: 9px;
  background: #726c66;
  border-radius: 999px;
}

.status-badge.is-ready {
  color: #12325e;
  background: rgba(15, 49, 95, 0.1);
}

.status-badge.is-ready i {
  background: #1f7d50;
}

.status-badge.is-error {
  color: var(--danger);
  background: rgba(192, 57, 69, 0.09);
}

.status-badge.is-error i {
  background: var(--danger);
}

.code-box {
  position: relative;
  z-index: 1;
  margin-top: 22px;
  padding: 22px 24px;
  text-align: center;
  background: linear-gradient(180deg, #fff 0%, rgba(255, 255, 255, 0.7) 100%);
  border: 1px solid #f3eee9;
  border-radius: 24px;
}

.code-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  text-align: left;
}

.code-title span {
  color: #5f5750;
  font-size: 19px;
  font-weight: 800;
}

.code-title strong {
  color: #9b351e;
  font-size: 17px;
}

.totp-code {
  display: flex;
  justify-content: center;
  gap: 10px;
  min-height: 62px;
  margin: 0 auto;
}

.totp-code span {
  display: grid;
  place-items: center;
  width: 50px;
  height: 56px;
  color: var(--accent);
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
  background: #edf3f0;
  border-radius: 12px;
}

.totp-code.is-empty span {
  width: 20px;
  height: 20px;
  margin-top: 23px;
  color: transparent;
  background: #dedddc;
  border-radius: 7px;
}

#codeHelp {
  margin: 14px 0 0;
  color: #2f445e;
  font-size: 18px;
  line-height: 1.7;
}

.metric-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(120px, 0.72fr) minmax(170px, 1fr);
  gap: 14px;
  margin-top: 18px;
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 78px;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.metric-card strong {
  color: #5e5a56;
  font-size: 24px;
  letter-spacing: 0;
}

.guide-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-content: center;
  padding: 24px 28px;
  color: #4a433d;
}

.guide-panel h2 {
  font-size: 21px;
}

.guide-panel ol,
.guide-panel ul {
  margin: 10px 0 0;
  padding-left: 20px;
  line-height: 1.7;
  font-size: 16px;
}

.site-footer {
  margin-top: 12px;
  color: #7c736c;
  font-size: 14px;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  min-width: 160px;
  padding: 12px 18px;
  color: #fff;
  text-align: center;
  background: rgba(23, 22, 21, 0.88);
  border-radius: 14px;
  opacity: 0;
  transform: translate(-50%, 14px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 1121px) {
  .page-shell {
    height: 100vh;
  }

  .workspace {
    align-items: stretch;
  }
}

@media (min-width: 1121px) and (max-height: 900px) {
  .page-shell {
    padding: 14px 0 8px;
  }

  .site-header {
    gap: 14px;
    margin-bottom: 14px;
  }

  .logo-mark {
    width: 52px;
    height: 52px;
    border-radius: 18px;
  }

  .logo-mark svg {
    width: 32px;
    height: 32px;
  }

  .site-header p {
    margin-top: 6px;
    font-size: 15px;
  }

  .manage-link {
    padding: 10px 16px;
  }

  .workspace {
    gap: 26px;
    padding: 28px;
    border-radius: 26px;
  }

  .left-stack {
    gap: 20px;
  }

  .secret-panel,
  .guide-panel {
    padding: 22px 24px;
  }

  .panel-heading {
    margin-bottom: 12px;
  }

  .secret-input {
    min-height: 52px;
    font-size: 21px;
  }

  .help-text,
  .error-text {
    margin-top: 12px;
    line-height: 1.5;
    font-size: 16px;
  }

  .status-badge {
    font-size: 16px;
  }

  .code-title span {
    font-size: 18px;
  }

  .code-title strong {
    font-size: 16px;
  }

  .guide-panel ol,
  .guide-panel ul {
    line-height: 1.6;
    font-size: 15px;
  }

  .guide-panel h2 {
    font-size: 20px;
  }

  .code-panel {
    padding: 24px;
  }

  .code-box {
    margin-top: 18px;
    padding: 20px 22px;
  }

  .code-title {
    margin-bottom: 16px;
  }

  .totp-code {
    min-height: 58px;
  }

  .totp-code span {
    width: 46px;
    height: 52px;
    font-size: 34px;
  }

  .totp-code.is-empty span {
    margin-top: 19px;
  }

  #codeHelp {
    margin-top: 12px;
    font-size: 17px;
  }

  .metric-grid {
    margin-top: 16px;
  }

  .metric-card {
    min-height: 74px;
    padding: 14px 18px;
  }

  .metric-card span {
    font-size: 15px;
  }

  .metric-card strong {
    font-size: 23px;
  }

  .site-footer {
    margin-top: 8px;
    font-size: 13px;
  }
}

@media (min-width: 1121px) and (max-height: 780px) {
  .site-footer {
    display: none;
  }
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
    min-height: 0;
    padding-bottom: 34px;
  }

  .left-stack {
    display: contents;
  }

  .secret-panel {
    order: 1;
  }

  .code-panel {
    min-height: 0;
    order: 2;
  }

  .guide-panel {
    order: 3;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 16px, 560px);
    padding-top: 10px;
  }

  .site-header {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 10px;
  }

  .site-header > div:not(.logo-mark) {
    min-width: 0;
  }

  .manage-link {
    margin-left: 0;
    align-self: start;
    justify-self: end;
    width: auto;
    padding: 9px 12px;
    font-size: 13px;
    line-height: 1;
    text-align: center;
  }

  .logo-mark {
    width: 52px;
    height: 52px;
    border-radius: 18px;
  }

  .logo-mark svg {
    width: 32px;
    height: 32px;
  }

  .site-header h1 {
    font-size: 24px;
  }

  .site-header p {
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.4;
  }

  .workspace {
    gap: 12px;
    padding: 10px;
    border-radius: 20px;
  }

  .left-stack {
    gap: 12px;
  }

  .panel,
  .code-box {
    border-radius: 18px;
  }

  .secret-panel,
  .qr-panel,
  .guide-panel {
    padding: 16px;
  }

  .qr-panel,
  .guide-panel {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    margin-bottom: 10px;
  }

  .secret-input {
    padding-right: 76px;
  }

  .help-text,
  .error-text {
    margin-top: 10px;
  }

  .code-panel {
    padding: 0;
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .code-panel::after {
    display: none;
  }

  .qr-preview {
    width: 100%;
    max-width: 260px;
    margin: 0 auto;
  }

  #qrCanvas {
    width: 210px;
    height: 210px;
  }

  .code-title {
    align-items: center;
    flex-direction: row;
    margin-bottom: 12px;
  }

  .status-row {
    align-items: center;
    flex-direction: row;
    gap: 12px;
  }

  .soft-button {
    width: 100%;
  }

  .status-row .soft-button {
    flex: 0 0 auto;
    width: auto;
    min-height: 44px;
    padding: 0 16px;
  }

  .code-box {
    margin-top: 12px;
    padding: 16px;
  }

  .totp-code {
    gap: 7px;
    min-height: 54px;
  }

  .totp-code span {
    flex: 1 1 0;
    width: auto;
    max-width: 42px;
    height: 54px;
    font-size: 30px;
    border-radius: 10px;
  }

  .totp-code.is-empty span {
    flex: 0 0 20px;
    height: 20px;
    margin-top: 17px;
  }

  #codeHelp {
    margin-top: 10px;
    line-height: 1.5;
  }

  .metric-grid {
    grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
    gap: 8px;
    margin-top: 10px;
  }

  .metric-card {
    min-height: 70px;
    padding: 12px 14px;
  }

  .guide-panel {
    gap: 14px;
  }

  .guide-panel ol,
  .guide-panel ul {
    margin-top: 8px;
    line-height: 1.6;
  }

  .site-footer {
    margin-top: 8px;
  }
}
