:root {
  color-scheme: light;
  --bg: #f2f6f5;
  --bg-accent: #dcece7;
  --card: rgba(255, 255, 255, 0.94);
  --surface: #f6f9f8;
  --surface-strong: #edf4f1;
  --text: #17221f;
  --muted: #62716c;
  --border: #d9e4e0;
  --primary: #087a5b;
  --primary-strong: #056247;
  --primary-soft: #e5f5ef;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --focus: rgba(8, 122, 91, 0.2);
  --shadow: 0 24px 70px rgba(22, 49, 41, 0.12), 0 3px 12px rgba(22, 49, 41, 0.06);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1513;
  --bg-accent: #133128;
  --card: rgba(18, 29, 26, 0.96);
  --surface: #16231f;
  --surface-strong: #1a2b26;
  --text: #edf7f3;
  --muted: #9cb0a9;
  --border: #2c403a;
  --primary: #45d2a4;
  --primary-strong: #7ce5c2;
  --primary-soft: #173c31;
  --danger: #ff8a80;
  --danger-soft: #3c2220;
  --focus: rgba(69, 210, 164, 0.22);
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34), 0 3px 14px rgba(0, 0, 0, 0.22);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c1513;
    --bg-accent: #133128;
    --card: rgba(18, 29, 26, 0.96);
    --surface: #16231f;
    --surface-strong: #1a2b26;
    --text: #edf7f3;
    --muted: #9cb0a9;
    --border: #2c403a;
    --primary: #45d2a4;
    --primary-strong: #7ce5c2;
    --primary-soft: #173c31;
    --danger: #ff8a80;
    --danger-soft: #3c2220;
    --focus: rgba(69, 210, 164, 0.22);
    --shadow: 0 28px 80px rgba(0, 0, 0, 0.34), 0 3px 14px rgba(0, 0, 0, 0.22);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 0%, var(--bg-accent) 0, transparent 38rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

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

.page-shell {
  width: min(100%, 620px);
  margin: 0 auto;
  padding: max(32px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

.tool-card {
  position: relative;
  overflow: hidden;
  padding: 34px;
  border: 1px solid color-mix(in srgb, var(--border) 86%, transparent);
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.tool-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, #087a5b, #42c99e);
  content: "";
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.product-kicker {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.12em;
}

h1 {
  margin: 0;
  font-size: clamp(1.65rem, 5vw, 2rem);
  line-height: 1.18;
  letter-spacing: -0.035em;
}

.icon-button,
.input-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.icon-button:hover,
.input-action:hover {
  border-color: color-mix(in srgb, var(--primary) 48%, var(--border));
  color: var(--text);
  background: var(--surface-strong);
}

.icon-button:active,
.input-action:active,
.copy-button:active:not(:disabled) {
  transform: translateY(1px);
}

.icon-button:focus-visible,
.input-action:focus-visible,
.copy-button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.theme-toggle {
  flex: 0 0 auto;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 700;
}

.security-notice {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 28px;
  padding: 15px 16px;
  border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border));
  border-radius: 16px;
  color: color-mix(in srgb, var(--primary-strong) 82%, var(--text));
  background: var(--primary-soft);
  font-size: 0.9rem;
  line-height: 1.55;
}

.security-notice p {
  margin: 0;
  font-weight: 650;
}

.security-icon {
  margin-top: 1px;
}

.secret-section {
  margin-bottom: 26px;
}

.field-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.field-heading label {
  font-size: 0.92rem;
  font-weight: 740;
}

.field-hint {
  color: var(--muted);
  font-size: 0.76rem;
}

.input-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus);
}

.input-group.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 14%, transparent);
}

#secret-input {
  width: 100%;
  min-width: 0;
  height: 52px;
  padding: 0 14px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: max(16px, 0.96rem);
  letter-spacing: 0.035em;
}

#secret-input::placeholder {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.88rem;
  letter-spacing: 0;
}

.input-action {
  min-width: 66px;
  height: 52px;
  padding: 0 10px;
  border-width: 0 0 0 1px;
  border-radius: 0;
  font-size: 0.78rem;
  font-weight: 700;
}

.field-message {
  min-height: 1.4em;
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.field-message.is-error {
  color: var(--danger);
}

.field-message.is-success {
  color: var(--primary);
}

.code-panel {
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  text-align: center;
}

.code-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  letter-spacing: 0.11em;
}

.totp-code {
  display: block;
  min-height: 1.25em;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(2.7rem, 12vw, 4.3rem);
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  line-height: 1.08;
  letter-spacing: 0.06em;
  text-shadow: 0 1px 0 color-mix(in srgb, var(--text) 8%, transparent);
  user-select: all;
}

.totp-code.is-waiting {
  color: var(--muted);
  font-size: clamp(1.75rem, 8vw, 2.5rem);
}

.countdown-block {
  margin: 25px 0 22px;
}

.progress-track {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #50d5aa);
  transition: width 180ms linear;
}

.progress-bar.is-ending {
  background: linear-gradient(90deg, #d98324, #ffb44c);
}

.countdown-text {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: var(--primary-strong);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 22%, transparent);
  cursor: pointer;
  font-weight: 780;
  transition: opacity 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.copy-button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary-strong) 88%, #000);
}

.copy-button:disabled {
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.42;
}

.copy-button.is-copied {
  background: #0a8f67;
}

.privacy-details {
  margin-top: 22px;
  border-top: 1px solid var(--border);
}

.privacy-details summary {
  padding: 20px 2px 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 720;
  list-style-position: inside;
}

.privacy-details summary:hover {
  color: var(--text);
}

.privacy-content {
  padding: 5px 2px 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.7;
}

.privacy-content p {
  margin: 9px 0 0;
}

.privacy-content strong {
  color: var(--text);
}

.page-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  padding: 18px 10px 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .page-shell {
    padding-top: max(18px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .tool-card {
    padding: 24px 18px;
    border-radius: 22px;
  }

  .card-header {
    align-items: center;
    margin-bottom: 20px;
  }

  .theme-toggle {
    min-width: 44px;
    padding: 0 10px;
  }

  #theme-label {
    display: none;
  }

  .security-notice {
    margin-bottom: 24px;
    padding: 13px 14px;
    font-size: 0.84rem;
  }

  .input-group {
    grid-template-columns: minmax(0, 1fr) 52px 52px;
  }

  .input-action {
    min-width: 0;
    padding: 0 5px;
  }

  .input-action span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .input-action span:first-child {
    font-size: 1.1rem;
  }

  .code-panel {
    padding: 26px 18px 22px;
  }

  .totp-code {
    letter-spacing: 0.025em;
  }
}

@media (max-width: 365px) {
  .tool-card {
    padding-inline: 14px;
  }

  .product-kicker {
    font-size: 0.7rem;
  }

  h1 {
    font-size: 1.48rem;
  }

  .field-hint {
    display: none;
  }

  #secret-input {
    padding-inline: 11px;
  }
}

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