:root {
  --canvas: #f5f4ed;
  --surface: #ffffff;
  --surface-warm: #fffef9;
  --ink: #102d25;
  --muted: #687a73;
  --muted-light: #94a19b;
  --primary: #145b45;
  --primary-dark: #0f3d2e;
  --primary-soft: #e9f2ed;
  --primary-border: #bdd2c7;
  --line: #d7dfda;
  --line-strong: #c7d2cc;
  --terminal: #102b24;
  --terminal-top: #17372e;
  --terminal-text: #c9f1dc;
  --danger: #a33a35;
  --danger-soft: #fbefed;
  --success-soft: #e9f4ec;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--canvas);
  color: var(--ink);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

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

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(20, 91, 69, 0.22);
  outline-offset: 2px;
}

.site-header {
  height: 74px;
  border-top: 2px solid var(--primary-dark);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  animation: header-enter 420ms var(--ease-out) both;
}

.header-inner {
  width: min(1376px, calc(100% - 40px));
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #ffffff;
  font: 700 12px/1 var(--mono);
  letter-spacing: -0.3px;
  transition: transform 220ms var(--ease-spring), background-color 180ms ease;
}

.system-logo {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.system-logo .logo-shield {
  opacity: 0.72;
  stroke-width: 1.45;
}

.system-logo .logo-letter {
  stroke-width: 2;
}

.brand:hover .brand-mark {
  transform: translateY(-2px) rotate(-3deg);
  background: var(--primary-dark);
}

.brand-name {
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.4px;
}

.local-status {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #536860;
  font: 11px/1 var(--mono);
  letter-spacing: 1.25px;
  text-transform: uppercase;
  white-space: nowrap;
}

.header-actions,
.auth-actions,
.user-summary {
  display: flex;
  align-items: center;
}

.header-actions {
  gap: 18px;
}

.auth-actions,
.user-summary {
  gap: 8px;
}

.header-button,
.logout-button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease, transform 140ms ease;
}

.header-button:hover,
.logout-button:hover {
  transform: translateY(-1px);
}

.header-button:active,
.logout-button:active {
  transform: translateY(0) scale(0.97);
}

.login-button,
.logout-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--primary-dark);
}

.login-button:hover,
.logout-button:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
}

.signup-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.signup-button:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font: 750 11px/1 var(--mono);
}

.user-name {
  max-width: 140px;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border: 2px solid #e7efd9;
  border-radius: 50%;
  background: #79aa38;
  box-shadow: 0 0 0 2px #dfeacf;
  animation: status-pulse 2.4s ease-in-out infinite;
}

.page-shell {
  width: min(1492px, calc(100% - 48px));
  margin: 0 auto;
}

.intro {
  padding: 31px 16px 27px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--primary);
  font: 700 11px/1.3 var(--mono);
  letter-spacing: 1.65px;
  text-transform: uppercase;
  animation: content-enter 460ms 80ms var(--ease-out) both;
}

.intro h1 {
  margin: 0;
  color: #082f2f;
  font-size: clamp(34px, 3.25vw, 46px);
  font-weight: 780;
  line-height: 1.12;
  letter-spacing: -2.25px;
  animation: content-enter 520ms 135ms var(--ease-out) both;
}

.intro > p:last-child {
  margin: 11px auto 0;
  color: var(--muted);
  font-size: 15px;
  animation: content-enter 520ms 190ms var(--ease-out) both;
}

.cipher-card {
  margin-bottom: 36px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(20, 55, 42, 0.06);
  animation: card-enter 560ms 230ms var(--ease-out) both;
}

.tool-nav {
  min-height: 76px;
  padding: 0 20px 0 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.tabs {
  align-self: stretch;
  display: flex;
}

.tab {
  position: relative;
  min-width: 182px;
  min-height: 60px;
  padding: 0 24px;
  border: 0;
  border-right: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  background: transparent;
  color: #75847e;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease, transform 140ms ease;
}

.tab::after {
  content: "";
  position: absolute;
  right: 20px;
  bottom: 0;
  left: 20px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--primary);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 240ms var(--ease-out);
}

.tab:hover {
  background: #f7f9f7;
  color: var(--primary-dark);
}

.tab:active {
  transform: translateY(1px);
}

.tab.active {
  border-right-color: var(--line);
  background: #f4f8f5;
  color: var(--primary-dark);
}

.tab.active::after {
  transform: scaleX(1);
}

.tab-icon {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: #7d8c86;
  transition: transform 220ms var(--ease-spring), background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.tab:hover .tab-icon {
  transform: translateY(-2px);
}

.tab.active .tab-icon {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
  transform: scale(1.04);
}

.tab-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.tab small {
  margin-right: 7px;
  color: #9da8a3;
  font: 10px/1 var(--mono);
}

.operation-switch {
  min-width: 210px;
  padding: 4px;
  border-radius: 9px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #edf0ed;
}

.mode {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #64756e;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 140ms ease;
}

.mode:hover {
  color: var(--primary-dark);
}

.mode:active {
  transform: scale(0.98);
}

.mode.active {
  border-color: #d9e0dc;
  background: var(--surface);
  color: var(--primary);
  animation: control-pop 200ms var(--ease-spring);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.panel {
  min-width: 0;
  padding: 30px 32px 32px;
}

.cipher-card.interface-changing .panel {
  animation: panel-refresh 280ms var(--ease-out);
}

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

.result-panel {
  background: var(--surface-warm);
}

.step-label {
  margin: 0 0 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #8c9a94;
  font: 700 10px/1 var(--mono);
  letter-spacing: 1.45px;
  text-transform: uppercase;
}

.step-label span {
  color: #6d8279;
}

.step-label i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #a4afa9;
}

.field-heading,
.option-heading,
.matrix-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.field-heading {
  min-height: 32px;
  margin-bottom: 8px;
}

.field-heading label,
.option-heading label {
  color: #0c2c24;
  font-size: 15px;
  font-weight: 750;
}

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

.text-button,
.copy-button {
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.text-button {
  padding: 0 8px;
  border-radius: 6px;
}

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

.example-button {
  min-height: 34px;
  border: 1px solid var(--primary-border);
  background: #f5f9f6;
}

textarea,
.keyword-input,
#shift-number {
  border: 1px solid var(--line-strong);
  background: #fcfdfb;
  color: #102d25;
  font-family: var(--mono);
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

textarea::placeholder,
input::placeholder {
  color: #8e9b95;
}

#message {
  width: 100%;
  min-height: 132px;
  padding: 16px 17px;
  border-radius: 9px;
  outline: 0;
  resize: vertical;
  line-height: 1.65;
}

#message:hover,
.keyword-input:hover,
#shift-number:hover {
  border-color: #aebdb5;
}

#message:focus,
.keyword-input:focus,
#shift-number:focus {
  border-color: #5a927c;
  box-shadow: 0 0 0 3px rgba(20, 91, 69, 0.1);
}

.character-count {
  margin-top: 6px;
  color: #8c9a94;
  font: 10px/1.4 var(--mono);
  text-align: right;
}

.character-count span {
  color: #647b71;
}

.cipher-options {
  padding-top: 20px;
  animation: options-enter 280ms var(--ease-out);
}

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

.option-heading p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.shift-heading output {
  min-width: 48px;
  color: var(--primary);
  font: 750 30px/1 var(--mono);
  text-align: right;
}

.shift-heading output.is-updating {
  animation: number-pop 240ms var(--ease-spring);
}

.range-row {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto 64px;
  align-items: center;
  gap: 10px;
}

.range-row > span {
  color: #8a9992;
  font: 10px/1 var(--mono);
}

#shift {
  width: 100%;
  height: 30px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

#shift::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 10px;
  background: #dce5e0;
}

#shift::-webkit-slider-thumb {
  width: 19px;
  height: 19px;
  margin-top: -7px;
  appearance: none;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  transition: transform 120ms ease;
}

#shift:hover::-webkit-slider-thumb,
#shift:active::-webkit-slider-thumb {
  transform: scale(1.12);
}

#shift::-moz-range-track {
  height: 5px;
  border-radius: 10px;
  background: #dce5e0;
}

#shift::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

#shift-number {
  width: 64px;
  height: 44px;
  padding: 0 6px;
  border-radius: 7px;
  outline: 0;
  color: var(--primary-dark);
  text-align: center;
}

.mapping-chips {
  margin-top: 13px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.mapping-chip {
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: #f7f8f6;
  color: #7b8983;
  font: 700 13px/1 var(--mono);
  transition: transform 150ms ease, border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

.mapping-chip:hover {
  transform: translateY(-2px);
}

.mapping-chips.is-updating .mapping-chip {
  animation: mapping-pop 240ms var(--ease-spring);
}

.mapping-chips.is-updating .mapping-chip:nth-child(2) {
  animation-delay: 35ms;
}

.mapping-chips.is-updating .mapping-chip:nth-child(3) {
  animation-delay: 70ms;
}

.mapping-chip span {
  color: #a1aca7;
}

.mapping-chip b {
  color: #52675e;
}

.mapping-chip.featured {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.mapping-chip.featured span,
.mapping-chip.featured b {
  color: var(--primary);
}

.required-mark {
  color: var(--danger);
}

.required-label {
  color: #788981;
  font: 10px/1 var(--mono);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.keyword-input {
  width: 100%;
  height: 48px;
  padding: 0 15px;
  border-radius: 8px;
  outline: 0;
  text-transform: uppercase;
}

.keyword-input[aria-invalid="true"] {
  border-color: #bd6963;
  background: #fffafa;
}

.field-error {
  min-height: 18px;
  margin: 4px 0 0;
  color: var(--danger);
  font-size: 11px;
}

.matrix-heading {
  margin: 8px 0 7px;
  color: var(--primary);
  font: 700 10px/1.3 var(--mono);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.matrix-heading span:last-child {
  color: #6f827a;
  font-size: 9px;
}

.matrix {
  overflow: hidden;
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.matrix span {
  min-width: 0;
  min-height: 40px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  background: #fcfdfb;
  color: #183d31;
  font: 12px/1 var(--mono);
  transition: background-color 160ms ease, color 160ms ease;
  animation: matrix-cell-enter 220ms var(--ease-out) both;
  animation-delay: calc(var(--cell-index, 0) * 7ms);
}

.matrix .key {
  background: var(--primary);
  color: #ffffff;
  font-weight: 750;
}

.process-button {
  width: 100%;
  min-height: 52px;
  margin-top: 22px;
  padding: 0 20px;
  border: 1px solid var(--primary);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 750;
  cursor: pointer;
  overflow: hidden;
  transition: background-color 180ms ease, border-color 180ms ease, transform 140ms ease;
}

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

.process-button:hover:not(:disabled) .process-icon {
  transform: translateX(4px);
}

.process-button:active:not(:disabled) {
  transform: translateY(1px) scale(0.995);
}

.process-button:disabled {
  border-color: #b9c5bf;
  background: #b9c5bf;
  color: #f2f5f3;
  cursor: not-allowed;
}

.process-icon,
.process-icon svg {
  width: 19px;
  height: 19px;
}

.process-icon {
  transition: transform 220ms var(--ease-spring);
}

.process-button.is-complete .process-icon {
  animation: action-complete 420ms var(--ease-out);
}

.process-icon svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.form-message {
  min-height: 19px;
  margin: 7px 0 0;
  color: #7b8b84;
  font-size: 11px;
  text-align: center;
}

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

.shortcut {
  margin: 2px 0 0;
  color: #98a49f;
  font-size: 10px;
  text-align: center;
}

kbd {
  padding: 1px 4px;
  border: 1px solid #d5dcd8;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #f7f8f6;
  font: 9px/1.2 var(--mono);
}

.result-heading {
  margin-bottom: 8px;
}

.copy-button {
  min-width: 96px;
  padding: 0 10px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  transition: background-color 180ms ease, color 180ms ease, transform 140ms ease;
}

.copy-button:hover:not(:disabled) {
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.copy-button:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
}

.copy-button.copied {
  background: var(--primary-soft);
  color: var(--primary-dark);
  animation: copied-pop 280ms var(--ease-spring);
}

.copy-button:disabled {
  color: #a0aaa5;
  cursor: not-allowed;
}

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

.result-terminal {
  overflow: hidden;
  border: 1px solid #24483e;
  border-radius: 10px;
  background: var(--terminal);
  transition: border-color 220ms ease, transform 220ms ease;
}

.terminal-bar {
  height: 40px;
  padding: 0 14px;
  border-bottom: 1px solid #2c5046;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--terminal-top);
  color: #82a497;
  font: 9px/1 var(--mono);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.terminal-dots {
  display: flex;
  gap: 5px;
}

.terminal-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #527469;
}

.terminal-dots i:first-child {
  background: #78aa91;
}

.result-terminal textarea {
  display: block;
  width: 100%;
  min-height: 262px;
  padding: 20px;
  border: 0;
  outline: 0;
  resize: vertical;
  background: transparent;
  color: var(--terminal-text);
  font: 14px/1.75 var(--mono);
  letter-spacing: 0.5px;
}

.result-terminal textarea::placeholder {
  color: #719184;
}

.result-terminal.has-result textarea {
  animation: result-reveal 360ms var(--ease-out);
}

.result-terminal.has-result {
  animation: terminal-ready 480ms var(--ease-out);
}

@keyframes result-reveal {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-note {
  min-height: 38px;
  margin: 10px 0 12px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 11px;
  transition: color 180ms ease, background-color 180ms ease, padding 180ms ease;
}

.result-note.success,
.result-note.warning {
  padding: 9px 11px;
  border-radius: 7px;
}

.result-note.success {
  background: var(--success-soft);
  color: #315f49;
}

.result-note.warning {
  background: var(--danger-soft);
  color: var(--danger);
}

.info-card {
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #f7f9f6;
  transition: border-color 180ms ease, transform 180ms ease;
}

.info-card:hover {
  border-color: var(--primary-border);
  transform: translateY(-1px);
}

.info-icon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 1px solid var(--primary-border);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--primary);
  font: 700 12px/1 var(--mono);
}

.info-card b {
  color: var(--primary);
  font: 700 10px/1.3 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.info-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

body.auth-open {
  overflow: hidden;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 20px;
  display: grid;
  place-items: center;
}

.auth-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 30, 24, 0.58);
  animation: auth-backdrop-enter 220ms ease-out both;
}

.auth-dialog {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  padding: 28px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(6, 29, 22, 0.2);
  animation: auth-dialog-enter 300ms var(--ease-out) both;
}

.auth-modal.is-closing .auth-backdrop {
  animation: auth-backdrop-exit 180ms ease-in both;
}

.auth-modal.is-closing .auth-dialog {
  animation: auth-dialog-exit 180ms ease-in both;
}

.auth-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: transparent;
  color: #71827a;
  cursor: pointer;
  transition: color 180ms ease, background-color 180ms ease, transform 140ms ease;
}

.auth-close:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
  transform: rotate(4deg);
}

.auth-close svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.9;
}

.auth-brand {
  min-height: 48px;
  padding-right: 52px;
  display: flex;
  align-items: center;
  gap: 11px;
}

.auth-brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #ffffff;
  font: 750 11px/1 var(--mono);
}

.auth-brand-mark .system-logo {
  width: 24px;
  height: 24px;
}

.auth-brand strong,
.auth-brand span:last-child {
  display: block;
}

.auth-brand strong {
  color: var(--ink);
  font-size: 14px;
}

.auth-brand span:last-child {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
}

.auth-tabs {
  margin: 22px 0;
  padding: 4px;
  border-radius: 9px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #edf0ed;
}

.auth-tab {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #6c7d75;
  font-weight: 750;
  cursor: pointer;
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease, transform 140ms ease;
}

.auth-tab:hover {
  color: var(--primary-dark);
}

.auth-tab:active {
  transform: scale(0.98);
}

.auth-tab.active {
  border-color: #d7dfda;
  background: var(--surface);
  color: var(--primary);
  animation: control-pop 200ms var(--ease-spring);
}

.auth-form {
  animation: auth-form-enter 240ms var(--ease-out);
}

.auth-copy {
  margin-bottom: 20px;
}

.auth-eyebrow {
  margin: 0 0 5px;
  color: var(--primary);
  font: 700 9px/1.3 var(--mono);
  letter-spacing: 1.25px;
  text-transform: uppercase;
}

.auth-copy h2 {
  margin: 0;
  color: var(--ink);
  font-size: 25px;
  line-height: 1.2;
  letter-spacing: -0.8px;
}

.auth-copy > p:last-child {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.auth-field {
  margin-bottom: 15px;
}

.auth-field > label {
  margin-bottom: 7px;
  display: block;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

.auth-field input:not([type="checkbox"]) {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: 0;
  background: #fcfdfb;
  color: var(--ink);
  font-family: var(--sans);
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.auth-field input:not([type="checkbox"]):hover {
  border-color: #aebdb5;
}

.auth-field input:not([type="checkbox"]):focus {
  border-color: #5a927c;
  box-shadow: 0 0 0 3px rgba(20, 91, 69, 0.1);
}

.auth-field input[aria-invalid="true"] {
  border-color: #bd6963;
  background: #fffafa;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 68px !important;
}

.password-toggle {
  position: absolute;
  top: 2px;
  right: 3px;
  min-width: 58px;
  height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--primary);
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}

.password-toggle:hover {
  background: var(--primary-soft);
}

.check-row {
  min-height: 44px;
  margin: 3px 0 5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #5e7168;
  font-size: 11px;
  cursor: pointer;
}

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

.password-strength {
  margin-top: 7px;
}

.strength-track {
  height: 4px;
  overflow: hidden;
  border-radius: 8px;
  display: block;
  background: #e4e9e6;
}

.strength-track i {
  width: 0;
  height: 100%;
  display: block;
  background: #a33a35;
  transition: width 220ms var(--ease-out), background-color 180ms ease;
}

.password-strength[data-level="1"] .strength-track i {
  width: 25%;
}

.password-strength[data-level="2"] .strength-track i {
  width: 50%;
  background: #a36f35;
}

.password-strength[data-level="3"] .strength-track i {
  width: 75%;
  background: #668a3a;
}

.password-strength[data-level="4"] .strength-track i {
  width: 100%;
  background: var(--primary);
}

.password-strength small {
  margin-top: 5px;
  display: block;
  color: #7b8b84;
  font-size: 9px;
}

.auth-message {
  min-height: 19px;
  margin: 3px 0 8px;
  color: var(--danger);
  font-size: 11px;
}

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

.auth-submit {
  width: 100%;
  min-height: 50px;
  padding: 0 18px;
  border: 1px solid var(--primary);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 750;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, transform 140ms ease;
}

.auth-submit:hover:not(:disabled) {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.auth-submit:active:not(:disabled) {
  transform: translateY(0) scale(0.99);
}

.auth-submit:disabled {
  cursor: wait;
  opacity: 0.78;
}

.auth-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  display: none;
}

.auth-submit.is-loading .auth-spinner {
  display: block;
  animation: auth-spin 700ms linear infinite;
}

.auth-switch {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.auth-switch button {
  min-height: 40px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 750;
  cursor: pointer;
}

.auth-switch button:hover {
  text-decoration: underline;
}

.auth-security-note {
  margin: 18px 0 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background: #f7f9f6;
  color: #6c7e76;
  font-size: 9px;
}

.auth-security-note svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--primary);
  stroke-width: 1.8;
}

@keyframes auth-backdrop-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes auth-backdrop-exit {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes auth-dialog-enter {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes auth-dialog-exit {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

@keyframes auth-form-enter {
  from {
    opacity: 0;
    transform: translateX(6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

@keyframes header-enter {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes content-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes status-pulse {
  0%, 100% {
    box-shadow: 0 0 0 2px #dfeacf;
  }
  50% {
    box-shadow: 0 0 0 5px rgba(121, 170, 56, 0.14);
  }
}

@keyframes control-pop {
  from {
    opacity: 0.72;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes panel-refresh {
  from {
    opacity: 0.56;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes options-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes number-pop {
  0% {
    opacity: 0.6;
    transform: scale(0.82);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes mapping-pop {
  0% {
    transform: translateY(2px) scale(0.96);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes matrix-cell-enter {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes action-complete {
  0% {
    opacity: 1;
    transform: translateX(0);
  }
  44% {
    opacity: 0;
    transform: translateX(12px);
  }
  45% {
    opacity: 0;
    transform: translateX(-10px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes copied-pop {
  0% {
    transform: scale(0.94);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes terminal-ready {
  0% {
    border-color: #24483e;
    transform: scale(0.997);
  }
  45% {
    border-color: #4c8a74;
    transform: scale(1);
  }
  100% {
    border-color: #24483e;
    transform: scale(1);
  }
}

.hidden {
  display: none !important;
}

footer {
  padding: 0 20px 30px;
  color: #7f8e87;
  font-size: 10px;
  text-align: center;
  animation: content-enter 520ms 720ms var(--ease-out) both;
}

@media (max-width: 767px) {
  .site-header {
    height: 68px;
  }

  .header-inner {
    width: calc(100% - 24px);
    gap: 12px;
  }

  .brand {
    gap: 9px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

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

  .local-status {
    gap: 7px;
    font-size: 9px;
    letter-spacing: 0.8px;
  }

  .local-status span:last-child,
  .user-name {
    display: none;
  }

  .header-actions {
    gap: 6px;
  }

  .auth-actions,
  .user-summary {
    gap: 5px;
  }

  .header-button,
  .logout-button {
    padding: 0 8px;
    font-size: 11px;
  }

  .user-avatar {
    width: 36px;
    height: 36px;
  }

  .auth-modal {
    padding: 12px;
  }

  .auth-dialog {
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }

  .page-shell {
    width: calc(100% - 24px);
  }

  .intro {
    padding: 26px 6px 22px;
  }

  .intro h1 {
    font-size: clamp(29px, 9vw, 38px);
    letter-spacing: -1.5px;
  }

  .intro > p:last-child {
    max-width: 430px;
    margin-top: 9px;
    font-size: 13px;
  }

  .cipher-card {
    border-radius: 11px;
  }

  .tool-nav {
    min-height: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .tabs {
    width: 100%;
    min-height: 62px;
  }

  .tab {
    min-width: 0;
    min-height: 62px;
    flex: 1;
    padding: 0 10px;
    gap: 8px;
  }

  .tab:first-child {
    border-right-color: var(--line);
  }

  .tab-icon {
    width: 28px;
    height: 28px;
  }

  .tab small {
    display: none;
  }

  .operation-switch {
    width: calc(100% - 24px);
    min-width: 0;
    margin: 12px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel {
    padding: 24px 20px 26px;
  }

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

  #message {
    min-height: 150px;
  }

  .result-terminal textarea {
    min-height: 190px;
  }

  .process-button {
    min-height: 54px;
  }

  .text-button,
  .copy-button {
    min-height: 44px;
  }
}

@media (max-width: 420px) {
  .page-shell {
    width: calc(100% - 16px);
  }

  .auth-modal {
    padding: 8px;
  }

  .auth-dialog {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 22px 16px 18px;
    border-radius: 12px;
  }

  .auth-close {
    top: 8px;
    right: 8px;
  }

  .auth-brand {
    padding-right: 42px;
  }

  .auth-tabs {
    margin: 18px 0;
  }

  .auth-copy h2 {
    font-size: 23px;
  }

  .intro {
    padding: 22px 6px 19px;
  }

  .eyebrow {
    font-size: 9px;
  }

  .intro h1 {
    font-size: 29px;
  }

  .panel {
    padding: 21px 14px 24px;
  }

  .field-heading {
    gap: 8px;
  }

  .field-heading label,
  .option-heading label {
    font-size: 14px;
  }

  .field-actions {
    gap: 1px;
  }

  .text-button {
    padding: 0 6px;
    font-size: 11px;
  }

  .example-button {
    padding: 0 8px;
  }

  .option-heading p {
    max-width: 190px;
  }

  .range-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  #shift-number {
    width: 100%;
    grid-column: 1 / -1;
  }

  .mapping-chip {
    padding: 0 5px;
    gap: 5px;
    font-size: 11px;
  }

  .matrix-heading {
    gap: 6px;
    font-size: 9px;
  }

  .matrix span {
    min-height: 44px;
    font-size: 11px;
  }

  .shortcut {
    display: none;
  }

  .copy-button {
    min-width: 86px;
    padding-right: 4px;
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
