:root {
  color-scheme: light;
  --color-bg: oklch(1 0 0);
  --color-surface: oklch(0.968 0.006 270);
  --color-surface-strong: oklch(0.935 0.011 270);
  --color-ink: oklch(0.205 0.025 268);
  --color-muted: oklch(0.43 0.025 268);
  --color-faint: oklch(0.59 0.018 268);
  --color-primary: oklch(0.4 0.15 270);
  --color-primary-hover: oklch(0.34 0.145 270);
  --color-primary-soft: oklch(0.93 0.035 270);
  --color-accent: oklch(0.67 0.145 157);
  --color-accent-soft: oklch(0.94 0.04 157);
  --color-danger: oklch(0.54 0.18 28);
  --color-danger-soft: oklch(0.95 0.035 28);
  --color-border: oklch(0.875 0.012 270);
  --color-white: oklch(1 0 0);
  --font-ui: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --z-sticky: 20;
  --z-backdrop: 40;
  --z-modal: 50;
  --z-toast: 60;
  --z-tooltip: 70;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--color-bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--color-ink);
  background: var(--color-bg);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

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

button {
  color: inherit;
}

button,
label,
input[type="checkbox"] {
  -webkit-tap-highlight-color: transparent;
}

button:not(:disabled),
label,
input[type="checkbox"] {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--color-surface-strong);
  color: var(--color-ink);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

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

.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;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: var(--z-tooltip);
  padding: 8px 12px;
  color: var(--color-white);
  background: var(--color-primary);
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transform: translateY(-150%);
  transition:
    opacity 120ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.skip-link:focus {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.app-header {
  min-height: 72px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.header-inner,
.app-footer {
  width: min(100% - 48px, 1440px);
  margin-inline: auto;
}

.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--color-white);
  background: var(--color-primary);
  border-radius: 8px;
}

.brand-mark svg {
  width: 21px;
  height: 21px;
}

.brand h1 {
  font-size: 17px;
  line-height: 1.35;
  font-weight: 700;
}

.brand p {
  margin-top: 1px;
  color: var(--color-muted);
  font-size: 13px;
}

.privacy-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  color: oklch(0.35 0.1 157);
  background: var(--color-accent-soft);
  font-size: 13px;
  font-weight: 650;
}

.workspace {
  width: min(100%, 1440px);
  min-height: calc(100vh - 130px);
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.pane {
  min-width: 0;
  padding: 28px 32px 32px;
}

.input-pane {
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
}

.output-pane {
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

.pane-header {
  min-height: 52px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.pane-header h2 {
  font-size: 18px;
  line-height: 1.35;
  font-weight: 700;
}

.pane-header p {
  max-width: 64ch;
  margin-top: 4px;
  color: var(--color-muted);
  font-size: 13px;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  border: 0;
  transition:
    background-color 160ms cubic-bezier(0.22, 1, 0.36, 1),
    color 160ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 120ms cubic-bezier(0.22, 1, 0.36, 1);
}

.primary-button,
.secondary-button,
.icon-text-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 7px;
  font-weight: 650;
  white-space: nowrap;
}

.primary-button {
  color: var(--color-white);
  background: var(--color-primary);
}

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

.primary-button:active:not(:disabled),
.secondary-button:active:not(:disabled),
.icon-button:active:not(:disabled) {
  transform: translateY(1px);
}

.primary-button:disabled {
  color: var(--color-faint);
  background: var(--color-surface-strong);
}

.secondary-button {
  color: var(--color-muted);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--color-border);
}

.secondary-button:hover:not(:disabled) {
  color: var(--color-ink);
  background: var(--color-bg);
}

.text-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 5px;
  color: var(--color-primary);
  background: transparent;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 650;
}

.text-button:hover {
  color: var(--color-primary-hover);
  background: var(--color-primary-soft);
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 7px;
  color: var(--color-muted);
  background: var(--color-surface);
}

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

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid oklch(0.72 0.11 270);
  outline-offset: 2px;
}

.editor-wrap {
  overflow: hidden;
  background: var(--color-bg);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--color-border);
}

#raw-input {
  width: 100%;
  min-height: 430px;
  display: block;
  resize: vertical;
  padding: 18px;
  border: 0;
  outline: 0;
  color: var(--color-ink);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}

#raw-input::placeholder {
  color: var(--color-muted);
  opacity: 1;
}

.editor-wrap:focus-within {
  box-shadow: inset 0 0 0 2px var(--color-primary);
}

.editor-footer {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 12px 6px 16px;
  color: var(--color-muted);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  font-size: 12px;
}

.sample-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.sample-actions .text-button {
  min-height: 30px;
}

.input-actions {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
}

.input-actions .primary-button {
  min-width: 128px;
}

.input-actions p {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-muted);
  font-size: 12px;
}

.input-actions p svg {
  width: 15px;
  height: 15px;
}

.options-bar {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 12px;
  margin-bottom: 12px;
  border-radius: 7px;
  background: var(--color-surface);
}

.check-control {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-muted);
  font-size: 13px;
  user-select: none;
}

.check-control input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--color-primary);
}

.output-region {
  min-height: 430px;
  flex: 1;
  overflow: auto;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--color-border);
}

.empty-state {
  min-height: 430px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}

.empty-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  color: var(--color-primary);
  background: var(--color-primary-soft);
  border-radius: 8px;
}

.empty-icon svg {
  width: 24px;
  height: 24px;
}

.empty-state h3 {
  font-size: 15px;
  font-weight: 700;
}

.empty-state p {
  max-width: 36ch;
  margin-top: 6px;
  color: var(--color-muted);
  font-size: 13px;
}

.document-preview {
  padding: 6px 20px 20px;
}

.record-section {
  padding: 18px 0 20px;
}

.record-section + .record-section {
  border-top: 1px solid var(--color-border);
}

.record-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.record-title h3 {
  font-size: 14px;
  font-weight: 700;
}

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

.field-row {
  min-height: 48px;
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--color-surface-strong);
}

.field-row:first-of-type {
  border-top: 0;
}

.field-label {
  color: var(--color-muted);
  font-size: 13px;
}

.field-value {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--color-ink);
  font-family: var(--font-mono);
  font-size: 13px;
}

.field-value.is-masked {
  color: var(--color-faint);
  letter-spacing: 0;
}

.copy-field-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: var(--color-muted);
  background: transparent;
}

.copy-field-button:hover {
  color: var(--color-primary);
  background: var(--color-primary-soft);
}

.copy-field-button svg {
  width: 16px;
  height: 16px;
}

.record-notes {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.totp-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 0.7fr) auto;
  align-items: center;
  gap: 18px;
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: var(--color-primary-soft);
}

.totp-info,
.totp-timing {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.totp-label,
.totp-countdown {
  color: var(--color-muted);
  font-size: 12px;
}

.totp-code {
  min-width: 8ch;
  color: var(--color-primary);
  font-family: var(--font-mono);
  font-size: 24px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.totp-code.is-masked {
  color: var(--color-faint);
  font-size: 19px;
}

.totp-code.is-error {
  color: var(--color-danger);
  font-family: var(--font-ui);
  font-size: 14px;
}

.totp-progress {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border: 0;
  border-radius: 3px;
  color: var(--color-primary);
  background: oklch(0.86 0.03 270);
}

.totp-progress::-webkit-progress-bar {
  background: oklch(0.86 0.03 270);
  border-radius: 3px;
}

.totp-progress::-webkit-progress-value {
  background: var(--color-primary);
  border-radius: 3px;
}

.totp-progress::-moz-progress-bar {
  background: var(--color-primary);
  border-radius: 3px;
}

.totp-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.totp-copy {
  min-height: 36px;
  background: var(--color-bg);
}

.totp-external-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.totp-external-link:hover {
  color: var(--color-primary-hover);
  background: var(--color-bg);
}

.totp-external-link svg {
  width: 15px;
  height: 15px;
}

.note-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 6px;
  color: oklch(0.32 0.07 157);
  background: var(--color-accent-soft);
  font-size: 12px;
  line-height: 1.55;
}

.note-line svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 2px;
}

.warning-list {
  display: grid;
  gap: 5px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 7px;
  color: oklch(0.42 0.14 28);
  background: var(--color-danger-soft);
  font-size: 12px;
}

.warning-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

.warning-item svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.app-footer {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--color-muted);
  font-size: 12px;
}

.app-footer .text-button svg {
  width: 15px;
  height: 15px;
}

dialog {
  width: min(92vw, 520px);
  padding: 0;
  border: 0;
  border-radius: 10px;
  color: var(--color-ink);
  background: var(--color-bg);
  box-shadow: 0 8px 24px oklch(0.12 0.02 268 / 0.18);
}

dialog::backdrop {
  background: oklch(0.12 0.02 268 / 0.48);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--color-border);
}

.dialog-header h2 {
  font-size: 18px;
}

.dialog-header p {
  margin-top: 4px;
  color: var(--color-muted);
  font-size: 13px;
}

.dialog-content {
  display: grid;
  gap: 12px;
  padding: 20px 22px 8px;
  color: var(--color-muted);
  font-size: 14px;
}

dialog form {
  display: flex;
  justify-content: flex-end;
  padding: 16px 22px 22px;
}

.dialog-confirm {
  min-width: 92px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: var(--z-toast);
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  color: var(--color-white);
  background: oklch(0.26 0.07 157);
  border-radius: 7px;
  box-shadow: 0 6px 8px oklch(0.12 0.02 268 / 0.18);
  font-size: 13px;
  font-weight: 650;
  transform: translateX(-50%);
}

.toast.is-error {
  background: var(--color-danger);
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .input-pane {
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  #raw-input,
  .output-region,
  .empty-state {
    min-height: 360px;
  }
}

@media (max-width: 620px) {
  .header-inner,
  .app-footer {
    width: min(100% - 32px, 1440px);
  }

  .header-inner {
    min-height: 68px;
  }

  .brand p,
  .privacy-state span {
    display: none;
  }

  .privacy-state {
    width: 38px;
    height: 38px;
    justify-content: center;
    padding: 0;
  }

  .pane {
    padding: 22px 16px 24px;
  }

  .pane-header {
    min-height: 48px;
    gap: 12px;
  }

  .pane-header p {
    font-size: 12px;
  }

  .output-heading {
    align-items: center;
  }

  .output-heading p {
    max-width: 22ch;
  }

  #raw-input,
  .output-region,
  .empty-state {
    min-height: 320px;
  }

  #raw-input {
    padding: 14px;
    font-size: 13px;
  }

  .editor-footer {
    align-items: flex-start;
    padding-left: 12px;
  }

  .sample-actions > span {
    display: none;
  }

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

  .input-actions .primary-button {
    width: 100%;
  }

  .input-actions p {
    justify-content: center;
  }

  .options-bar {
    gap: 14px;
    padding: 4px 10px;
    flex-wrap: wrap;
  }

  .field-row {
    grid-template-columns: 82px minmax(0, 1fr) 36px;
  }

  .totp-panel {
    grid-template-columns: minmax(0, 1fr) minmax(110px, 0.8fr);
    gap: 12px;
  }

  .totp-actions {
    grid-column: 1 / -1;
    align-items: stretch;
    justify-content: space-between;
  }

  .document-preview {
    padding-inline: 14px;
  }

  .app-footer {
    min-height: 72px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
  }
}

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