:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #6f6f68;
  --line: #deded8;
  --line-strong: #b9b9b1;
  --accent: #1f5eff;
  --accent-dark: #1647c7;
  --danger: #b42318;
  --code-bg: #111315;
  --code-text: #edf2ef;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 30px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: "Azeret Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

main {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 72px;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 750;
  letter-spacing: -0.035em;
}

h1 {
  font-size: clamp(2.8rem, 7vw, 5.2rem);
  line-height: 0.95;
}

h2 {
  font-size: clamp(1.7rem, 3.6vw, 2.7rem);
  line-height: 1;
}

.lede {
  max-width: 470px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

.grid-section {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 18px;
  margin-top: 28px;
}

.section-label {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-top: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 700;
}

.tool-card { padding: clamp(22px, 4vw, 34px); }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.message-head { align-items: center; }

.mode-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #f2f2ee;
}

.mode-btn {
  min-height: 34px;
  padding: 0 14px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.mode-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.mode-panel { display: none; }
.mode-panel.active { display: block; }

.form-grid, .two-col, .output-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.wide { grid-column: 1 / -1; }
.passline { margin: 16px 0; }

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

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: 500 0.92rem/1.55 "Azeret Mono", ui-monospace, monospace;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input, select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 180px;
  padding: 12px;
  resize: vertical;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 94, 255, 0.14);
}

button {
  cursor: pointer;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: 700 0.82rem/1 "Azeret Mono", ui-monospace, monospace;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

button:hover { transform: translateY(-1px); }
button:disabled { cursor: wait; opacity: 0.65; transform: none; }

.primary {
  padding: 0 18px;
  margin-top: 16px;
  background: var(--accent);
  color: #fff;
}

.primary:hover { background: var(--accent-dark); }

.ghost {
  padding: 0 14px;
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.ghost:hover { background: #f2f2ee; }

.output-grid { margin-top: 18px; }
.output-box { min-width: 0; }
.output-box.solo { margin-top: 18px; }

.output-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px 9px 12px;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: #f2f2ee;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.output-title button {
  min-height: 30px;
  padding: 0 10px;
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.72rem;
}

.output-box textarea {
  min-height: 260px;
  border-radius: 0 0 10px 10px;
  background: var(--code-bg);
  color: var(--code-text);
}

.output-box.solo textarea { min-height: 210px; }
.decrypted textarea {
  background: var(--surface);
  color: var(--text);
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  min-width: 240px;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--text);
  color: #fff;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  transform: translate(-50%, 150%);
  transition: transform 180ms ease;
}

#toast.show { transform: translate(-50%, 0); }

.reveal { animation: rise 300ms ease both; }
.grid-section:nth-of-type(2) { animation-delay: 50ms; }
.grid-section:nth-of-type(3) { animation-delay: 100ms; }

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

@media (max-width: 820px) {
  main { width: min(100% - 24px, 1040px); padding-top: 24px; }
  .app-header, .grid-section, .form-grid, .two-col, .output-grid { grid-template-columns: 1fr; }
  .app-header { display: grid; align-items: start; }
  .section-label { margin-top: 0; }
  .card-head { flex-direction: column; }
  .message-head { align-items: flex-start; }
  .mode-switch { width: 100%; }
  .mode-btn { flex: 1; }
  .wide { grid-column: auto; }
}
