@font-face {
  font-family: "Voynich";
  src: url("../assets/Voynich.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #17231d;
  --ink-soft: #536057;
  --forest: #274f3a;
  --forest-dark: #173627;
  --moss: #658067;
  --gold: #b28a45;
  --paper: #f3eddf;
  --paper-light: #faf8f1;
  --line: #d9d0bd;
  --danger: #963e34;
  --success: #2e6b47;
  --shadow: 0 20px 55px rgb(27 37 29 / 12%);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 20%, rgb(178 138 69 / 8%), transparent 28rem),
    #e9e3d7;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgb(178 138 69 / 45%);
  outline-offset: 2px;
}

.hero {
  position: relative;
  min-height: 570px;
  color: #fffdf5;
  overflow: hidden;
  background: var(--forest-dark) url("../assets/manuscrito-voynich.jpg") center 40% / cover no-repeat;
}

.hero__shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgb(14 33 23 / 94%) 0%, rgb(20 47 33 / 82%) 47%, rgb(13 28 21 / 48%) 100%),
    linear-gradient(0deg, rgb(15 30 22 / 60%), transparent 50%);
}

.topbar,
.hero__content {
  position: relative;
  z-index: 1;
  width: min(1160px, calc(100% - 40px));
  margin-inline: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0;
  border-bottom: 1px solid rgb(255 255 255 / 16%);
}

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

.brand__seal {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: #f0dcab;
  border: 1px solid rgb(240 220 171 / 70%);
  border-radius: 50%;
  font-family: Voynich, Georgia, serif;
  font-size: 1.75rem;
  box-shadow: inset 0 0 0 4px rgb(255 255 255 / 7%);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.04rem;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.brand small {
  color: rgb(255 255 255 / 67%);
  font-family: system-ui, sans-serif;
  font-size: .72rem;
  letter-spacing: .08em;
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  color: rgb(255 255 255 / 82%);
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 999px;
  background: rgb(255 255 255 / 7%);
  font-family: system-ui, sans-serif;
  font-size: .78rem;
}

.privacy-badge span {
  color: #a8d3aa;
  font-size: .7rem;
}

.hero__content {
  padding: 94px 0 108px;
}

.eyebrow {
  margin: 0 0 12px;
  color: #d9c18e;
  font-family: system-ui, sans-serif;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 740px;
  margin-bottom: 18px;
  font-size: clamp(2.6rem, 6vw, 5rem);
  font-weight: 400;
  letter-spacing: -.035em;
  line-height: .99;
  text-wrap: balance;
}

.hero__intro {
  max-width: 620px;
  margin-bottom: 34px;
  color: rgb(255 255 255 / 78%);
  font-family: system-ui, sans-serif;
  font-size: 1.06rem;
}

.hero__action {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  color: #203225;
  border-radius: 4px;
  background: #ead9ad;
  font-family: system-ui, sans-serif;
  font-size: .9rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform .2s ease, background .2s ease;
}

.hero__action:hover {
  transform: translateY(-2px);
  background: #f3e5c2;
}

.page-shell {
  position: relative;
  z-index: 2;
  width: min(1160px, calc(100% - 40px));
  margin: -54px auto 70px;
}

.keys-card,
.workspace-card {
  border: 1px solid rgb(113 97 67 / 18%);
  border-radius: 9px;
  background: rgb(250 248 241 / 97%);
  box-shadow: var(--shadow);
}

.keys-card {
  margin-bottom: 22px;
  padding: 26px 30px 28px;
}

.workspace-card {
  padding: 30px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.section-heading > div:first-child {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.step-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--paper-light);
  border-radius: 50%;
  background: var(--forest);
  font-family: system-ui, sans-serif;
  font-size: .78rem;
  font-weight: 700;
}

.text-button,
.small-button,
.view-switch button,
.icon-button {
  cursor: pointer;
  border: 0;
  background: transparent;
}

.text-button {
  padding: 5px 0;
  color: var(--forest);
  border-bottom: 1px solid rgb(39 79 58 / 28%);
  font-family: system-ui, sans-serif;
  font-size: .78rem;
  font-weight: 700;
}

.text-button:hover {
  border-bottom-color: var(--forest);
}

.keys-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 30px;
}

.field {
  display: block;
}

.field__label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  font-size: .92rem;
  font-weight: 700;
}

.field__label small {
  color: var(--ink-soft);
  font-family: system-ui, sans-serif;
  font-size: .7rem;
  font-weight: 600;
}

.input-wrap {
  position: relative;
  display: block;
}

.input-wrap input {
  width: 100%;
  height: 46px;
  padding: 0 48px 0 13px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fffdf7;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .93rem;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.input-wrap input:focus {
  border-color: var(--moss);
  box-shadow: 0 0 0 3px rgb(101 128 103 / 12%);
}

.icon-button {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 31px;
  height: 31px;
  color: var(--ink-soft);
  transform: translateY(-50%);
}

.field__help {
  display: block;
  min-height: 18px;
  margin-top: 7px;
  color: var(--ink-soft);
  font-family: system-ui, sans-serif;
  font-size: .72rem;
}

.key-warning {
  margin: 16px 0 0;
  padding: 9px 12px;
  color: #6b4d1c;
  border-left: 3px solid var(--gold);
  background: rgb(178 138 69 / 9%);
  font-family: system-ui, sans-serif;
  font-size: .78rem;
}

.file-actions {
  display: flex;
  gap: 18px;
}

.sheets-dialog {
  width: min(610px, calc(100% - 28px));
  max-height: min(680px, calc(100vh - 40px));
  padding: 0;
  color: var(--ink);
  border: 1px solid #c9bea8;
  border-radius: 8px;
  background: var(--paper-light);
  box-shadow: 0 28px 85px rgb(8 20 13 / 35%);
}

.sheets-dialog::backdrop {
  background: rgb(10 25 17 / 68%);
  backdrop-filter: blur(2px);
}

.sheets-dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px 18px;
  color: #fffdf5;
  background: var(--forest-dark);
}

.sheets-dialog__header .eyebrow {
  margin-bottom: 4px;
  font-size: .66rem;
}

.sheets-dialog__header h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 500;
}

.dialog-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  cursor: pointer;
  color: #fff;
  border: 1px solid rgb(255 255 255 / 25%);
  border-radius: 50%;
  background: rgb(255 255 255 / 8%);
  font-family: system-ui, sans-serif;
  font-size: 1.3rem;
}

.sheets-dialog__intro {
  margin: 0;
  padding: 20px 26px 10px;
  color: var(--ink-soft);
  font-family: system-ui, sans-serif;
  font-size: .82rem;
}

.sheets-status {
  margin: 0;
  padding: 18px 26px 26px;
  color: var(--ink-soft);
  font-family: system-ui, sans-serif;
  font-size: .82rem;
}

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

.sheets-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  margin: 0;
  padding: 8px 26px 26px;
  overflow-y: auto;
  list-style: none;
}

.sheet-file-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  padding: 13px 15px;
  cursor: pointer;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fffdf8;
  text-align: left;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.sheet-file-button:hover {
  border-color: var(--moss);
  background: #f1f3eb;
  transform: translateY(-1px);
}

.sheet-file-button__name {
  overflow: hidden;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .83rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-file-button__meta {
  flex: 0 0 auto;
  color: var(--ink-soft);
  font-family: system-ui, sans-serif;
  font-size: .68rem;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fffdf8;
}

.editor-panel + .editor-panel {
  border-left: 1px solid var(--line);
}

.editor-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 14px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  background: #f2ede2;
  font-family: system-ui, sans-serif;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.editor-panel textarea {
  display: block;
  width: 100%;
  min-height: 350px;
  padding: 20px;
  resize: vertical;
  color: #263027;
  border: 0;
  background: #fffdf8;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .95rem;
  line-height: 1.7;
}

.editor-panel textarea:focus-visible {
  position: relative;
  outline-offset: -4px;
}

.editor-panel--result textarea {
  background:
    linear-gradient(rgb(255 253 248 / 94%), rgb(255 253 248 / 94%)),
    url("../assets/muestra-voynich.jpg") center / cover;
}

.editor-panel textarea.voynich-mode {
  font-family: Voynich, "Courier New", monospace;
  font-size: 1.7rem;
  letter-spacing: .04em;
  line-height: 1.45;
  word-break: break-all;
}

.view-switch {
  display: flex;
  padding: 2px;
  border: 1px solid #d2c8b5;
  border-radius: 4px;
  background: #e8e1d3;
}

.view-switch button {
  padding: 4px 8px;
  color: #677067;
  border-radius: 3px;
  font-family: system-ui, sans-serif;
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
}

.view-switch button.is-active {
  color: var(--forest-dark);
  background: #fffdf8;
  box-shadow: 0 1px 4px rgb(44 41 31 / 12%);
}

.input-tools,
.result-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 7px 12px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  background: #f7f2e8;
  font-family: system-ui, sans-serif;
  font-size: .7rem;
}

.input-tools span:last-child {
  color: #777267;
  font-style: italic;
}

.result-tools__buttons {
  display: flex;
  gap: 6px;
}

.small-button {
  padding: 6px 8px;
  color: var(--forest);
  border: 1px solid rgb(39 79 58 / 22%);
  border-radius: 3px;
  background: #fffdf8;
  font-size: .7rem;
  font-weight: 700;
}

.small-button:hover:not(:disabled) {
  border-color: var(--forest);
}

.small-button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.primary-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 4px;
  font-family: system-ui, sans-serif;
  font-size: .9rem;
  font-weight: 800;
  transition: transform .15s ease, filter .15s ease;
}

.primary-button:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(0);
}

.primary-button--encrypt {
  color: #fff;
  background: var(--forest);
}

.primary-button--decrypt {
  color: var(--forest-dark);
  border-color: var(--moss);
  background: #eef1e9;
}

.primary-button--clear {
  color: #6c312c;
  border-color: #b97870;
  background: #fbefec;
}

.notice {
  margin: 15px 0 0;
  padding: 11px 13px;
  color: #1f5d3d;
  border: 1px solid rgb(46 107 71 / 25%);
  border-radius: 4px;
  background: rgb(46 107 71 / 8%);
  font-family: system-ui, sans-serif;
  font-size: .82rem;
}

.notice--error {
  color: var(--danger);
  border-color: rgb(150 62 52 / 24%);
  background: rgb(150 62 52 / 7%);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 30px;
}

.info-card {
  padding: 24px;
  border: 1px solid rgb(113 97 67 / 17%);
  border-radius: 7px;
  background: rgb(244 239 228 / 82%);
}

.info-card__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 13px;
  color: #efe2c2;
  border-radius: 50%;
  background: var(--forest);
}

.info-card h3 {
  margin-bottom: 7px;
  font-size: .98rem;
}

.info-card p {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-family: system-ui, sans-serif;
  font-size: .78rem;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 22px max(20px, calc((100% - 1160px) / 2));
  color: rgb(255 255 255 / 58%);
  background: #15251b;
  font-family: system-ui, sans-serif;
  font-size: .72rem;
}

footer p {
  margin: 0;
}

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

[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .hero {
    min-height: 520px;
  }

  .hero__content {
    padding: 80px 0 100px;
  }

  .keys-grid,
  .editor-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .editor-panel + .editor-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .editor-panel textarea {
    min-height: 270px;
  }

  .info-grid {
    gap: 12px;
  }
}

@media (max-width: 560px) {
  .topbar,
  .hero__content,
  .page-shell {
    width: min(100% - 24px, 1160px);
  }

  .privacy-badge {
    display: none;
  }

  .brand strong {
    font-size: .92rem;
  }

  .hero__content {
    padding-top: 62px;
  }

  h1 {
    font-size: 2.7rem;
  }

  .page-shell {
    margin-top: -38px;
  }

  .keys-card,
  .workspace-card {
    padding: 20px 16px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .file-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px 14px;
  }

  .primary-actions {
    grid-template-columns: 1fr;
  }

  .input-tools,
  .result-tools {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .result-tools__buttons {
    width: 100%;
    flex-wrap: wrap;
  }

  footer {
    flex-direction: column;
    gap: 4px;
  }
}

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

  *,
  *::before,
  *::after {
    transition-duration: .01ms !important;
  }
}
