:root {
  --vault-canvas: #f2f6f3;
  --vault-surface: #ffffff;
  --vault-raised: #f8fbf9;
  --vault-inset: #edf5f0;
  --ink-primary: #15251d;
  --ink-secondary: #4f6258;
  --ink-tertiary: #687b71;
  --ink-muted: #899990;
  --signal: #16865c;
  --signal-strong: #0f704c;
  --signal-soft: rgba(22, 134, 92, 0.1);
  --danger: #bd3e38;
  --line: rgba(24, 55, 39, 0.14);
  --line-soft: rgba(24, 55, 39, 0.08);
  --line-focus: #16865c;
  --radius-control: 10px;
  --radius-panel: 18px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --font-interface: "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --font-mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-family: var(--font-interface);
  color: var(--ink-primary);
  background: var(--vault-canvas);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--vault-canvas);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--vault-canvas);
  color: var(--ink-primary);
}

button,
input {
  font: inherit;
}

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

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

.app-shell {
  width: min(1184px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(22, 134, 92, 0.28);
  border-radius: 10px;
  background: var(--signal-soft);
}

.brand-mark::before,
.brand-mark span {
  content: "";
  position: absolute;
  border: 1px solid var(--signal);
}

.brand-mark::before {
  width: 12px;
  height: 14px;
  border-radius: 3px;
  bottom: 7px;
}

.brand-mark span {
  width: 8px;
  height: 8px;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  top: 6px;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-copy small {
  color: var(--ink-tertiary);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.local-status {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 600;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 4px var(--signal-soft);
}

.workspace {
  align-self: center;
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(460px, 1.12fr);
  gap: 16px;
  padding: 48px 0;
}

.entry-panel,
.code-panel {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(24, 55, 39, 0.1);
  border-radius: var(--radius-panel);
  background: var(--vault-surface);
  box-shadow: 0 1px 2px rgba(22, 49, 35, 0.04), 0 16px 40px rgba(22, 49, 35, 0.06);
}

.entry-panel {
  padding: 32px;
}

.code-panel {
  display: flex;
  flex-direction: column;
  padding: 32px;
  background: var(--vault-raised);
  transition: border-color 180ms var(--ease-out), background-color 180ms var(--ease-out);
}

.code-panel.is-active {
  border-color: rgba(22, 134, 92, 0.28);
}

.section-index {
  position: absolute;
  top: 24px;
  right: 28px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.section-heading {
  max-width: 390px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--signal);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  text-wrap: pretty;
}

h1 {
  max-width: 320px;
  margin: 0;
  font-size: clamp(28px, 3vw, 38px);
  font-weight: 650;
  line-height: 1.18;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.section-description {
  margin: 18px 0 0;
  color: var(--ink-secondary);
  font-size: 13px;
  line-height: 1.75;
}

.section-description code {
  color: var(--ink-primary);
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.secret-form {
  display: grid;
  gap: 12px;
  padding: 20px;
  border: 1px solid rgba(22, 134, 92, 0.2);
  border-radius: 14px;
  background: #f1f9f5;
  box-shadow: 0 0 0 4px rgba(22, 134, 92, 0.04);
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.field-row label {
  color: var(--ink-primary);
  font-size: 13px;
  font-weight: 700;
}

.field-status {
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
}

.field-status.is-loaded {
  color: var(--signal);
}

.secret-control {
  position: relative;
}

.secret-control input {
  width: 100%;
  height: 60px;
  padding: 0 52px 0 16px;
  border: 2px solid rgba(22, 134, 92, 0.58);
  border-radius: var(--radius-control);
  outline: none;
  background: #ffffff;
  color: var(--ink-primary);
  caret-color: var(--signal);
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.035em;
  box-shadow: 0 2px 8px rgba(20, 75, 48, 0.05);
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), background-color 160ms var(--ease-out);
}

.secret-control input::placeholder {
  color: #667a6f;
  opacity: 1;
}

.secret-control input:hover {
  border-color: var(--signal);
}

.secret-control input:focus {
  border-color: var(--line-focus);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(22, 134, 92, 0.13), 0 4px 12px rgba(20, 75, 48, 0.08);
}

.secret-control input[disabled] {
  color: var(--ink-tertiary);
  cursor: not-allowed;
}

.icon-button {
  position: absolute;
  top: 8px;
  right: 6px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-tertiary);
  cursor: pointer;
  transition: color 140ms var(--ease-out), background-color 140ms var(--ease-out), transform 120ms var(--ease-out);
}

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

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.field-footer {
  min-height: 40px;
}

.field-footer p {
  margin: 0;
  font-size: 11px;
  line-height: 1.6;
}

#secret-help {
  color: var(--ink-secondary);
}

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

.error-message:not(:empty) + #secret-help,
.error-message:not(:empty) {
  display: block;
}

.form-actions {
  min-height: 48px;
}

.primary-button,
.secondary-button,
.copy-button {
  min-height: 48px;
  border-radius: var(--radius-control);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 150ms var(--ease-out), border-color 150ms var(--ease-out), color 150ms var(--ease-out), transform 120ms var(--ease-out), opacity 150ms var(--ease-out);
}

.primary-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--signal);
  background: var(--signal);
  color: #07110c;
}

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

.primary-button:disabled {
  border-color: var(--line);
  background: #e5ece8;
  color: #73837a;
  cursor: not-allowed;
}

.primary-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  transition: transform 150ms var(--ease-out);
}

.primary-button:hover:not(:disabled) svg {
  transform: translateX(2px);
}

.secondary-button {
  width: 100%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-secondary);
}

.secondary-button:hover {
  border-color: rgba(22, 134, 92, 0.28);
  background: var(--signal-soft);
  color: var(--ink-primary);
}

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line-soft);
}

.privacy-note svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--signal);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.privacy-note div {
  display: grid;
  gap: 4px;
}

.privacy-note strong {
  color: var(--ink-primary);
  font-size: 11px;
  font-weight: 600;
}

.privacy-note span {
  color: var(--ink-tertiary);
  font-size: 10px;
  line-height: 1.5;
}

.code-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.code-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.session-state {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-tertiary);
  font-size: 10px;
}

.session-state span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-muted);
}

.session-state b {
  font-weight: 600;
}

.code-panel.is-active .session-state {
  border-color: rgba(22, 134, 92, 0.25);
  color: var(--signal);
}

.code-panel.is-active .session-state span {
  background: var(--signal);
  box-shadow: 0 0 0 4px var(--signal-soft);
}

.code-stage {
  flex: 1;
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: center;
  gap: 28px;
  min-height: 230px;
  padding: 32px 0 24px;
}

.time-orbit {
  position: relative;
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
}

.orbit-ring {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--vault-inset);
  box-shadow: inset 0 0 0 8px rgba(24, 55, 39, 0.025);
}

.orbit-ring::before,
.orbit-ring::after {
  content: "";
  position: absolute;
  inset: 8px 45px;
  border-top: 4px solid var(--ink-muted);
  border-bottom: 4px solid var(--ink-muted);
}

.orbit-ring::after {
  inset: 45px 8px;
  border: 0;
  border-left: 4px solid var(--ink-muted);
  border-right: 4px solid var(--ink-muted);
}

.orbit-marker {
  position: absolute;
  inset: 0;
  transform: rotate(0deg);
  transition: transform 90ms linear;
}

.orbit-marker i {
  position: absolute;
  top: -3px;
  left: calc(50% - 4px);
  width: 8px;
  height: 8px;
  border: 2px solid var(--vault-raised);
  border-radius: 50%;
  background: var(--ink-muted);
}

.code-panel.is-active .orbit-marker i {
  background: var(--signal);
  box-shadow: 0 0 0 4px rgba(22, 134, 92, 0.12);
}

.time-readout {
  position: relative;
  display: grid;
  place-items: center;
  gap: 0;
}

.time-readout strong {
  color: var(--ink-primary);
  font-family: var(--font-mono);
  font-size: 25px;
  font-variant-numeric: tabular-nums;
  font-weight: 620;
  letter-spacing: -0.06em;
  line-height: 1;
}

.time-readout small {
  margin-top: 3px;
  color: var(--ink-tertiary);
  font-size: 9px;
}

.code-display-wrap {
  min-width: 0;
}

.code-value {
  display: flex;
  align-items: baseline;
  gap: 0.34em;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: clamp(40px, 5.4vw, 66px);
  font-variant-numeric: tabular-nums;
  font-weight: 620;
  letter-spacing: 0.055em;
  line-height: 1;
  white-space: nowrap;
  transition: color 180ms var(--ease-out), opacity 120ms var(--ease-out), transform 120ms var(--ease-out);
}

.code-value.is-changing {
  opacity: 0.25;
  transform: translateY(3px);
}

.code-panel.is-active .code-value {
  color: var(--ink-primary);
}

.code-caption {
  margin: 14px 0 0;
  color: var(--ink-tertiary);
  font-size: 11px;
  line-height: 1.5;
}

.timing-rail {
  height: 18px;
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  align-items: end;
  gap: 3px;
  margin-bottom: 22px;
}

.timing-rail span {
  display: block;
  height: 4px;
  border-radius: 1px;
  background: var(--line);
}

.timing-rail span:nth-child(5n) {
  height: 8px;
}

.timing-rail span.is-remaining {
  background: rgba(22, 134, 92, 0.62);
}

.code-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
}

.copy-button {
  min-width: 142px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink-secondary);
}

.copy-button:hover:not(:disabled) {
  border-color: rgba(22, 134, 92, 0.36);
  background: var(--signal-soft);
  color: var(--signal);
}

.copy-button:disabled {
  color: var(--ink-muted);
  cursor: not-allowed;
  opacity: 0.55;
}

.copy-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.code-meta {
  display: flex;
  align-items: center;
  gap: 22px;
  margin: 0;
}

.code-meta div {
  display: grid;
  gap: 3px;
}

.code-meta dt {
  color: var(--ink-muted);
  font-size: 9px;
}

.code-meta dd {
  margin: 0;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
}

.footer-bar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid var(--line-soft);
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.footer-bar p {
  margin: 0;
}

.footer-bar p:first-child span {
  margin-right: 6px;
  color: var(--signal);
  font-size: 7px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border: 1px solid rgba(22, 134, 92, 0.22);
  border-radius: var(--radius-control);
  background: #153d2c;
  color: #d8f7e8;
  box-shadow: 0 12px 40px rgba(17, 46, 32, 0.22);
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.97);
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.noscript-message {
  position: fixed;
  inset: auto 24px 24px;
  padding: 14px 16px;
  border: 1px solid rgba(189, 62, 56, 0.28);
  border-radius: var(--radius-control);
  background: #fff1ef;
  color: var(--danger);
  font-size: 12px;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .app-shell {
    width: min(680px, calc(100% - 32px));
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 32px 0;
  }

  .code-panel {
    min-height: 440px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 24px, 480px);
  }

  .topbar {
    height: 80px;
  }

  .brand-copy small {
    display: none;
  }

  .local-status {
    padding: 0 10px;
    font-size: 10px;
  }

  .entry-panel,
  .code-panel {
    padding: 24px 20px;
    border-radius: 15px;
  }

  .section-index {
    top: 19px;
    right: 20px;
  }

  h1 {
    max-width: 260px;
    font-size: 29px;
  }

  .section-heading {
    margin-bottom: 28px;
  }

  .code-header {
    padding-right: 0;
  }

  .code-stage {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 20px;
    min-height: 278px;
    padding: 28px 0 20px;
    text-align: center;
  }

  .code-value {
    justify-content: center;
    font-size: clamp(38px, 13vw, 56px);
  }

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

  .copy-button {
    width: 100%;
  }

  .code-meta {
    justify-content: space-between;
  }

  .footer-bar {
    min-height: 88px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
    justify-content: center;
  }
}

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