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

:root {
  color-scheme: dark;
  --bg: #111312;
  --surface: #191d1a;
  --surface-2: #202720;
  --line: #344033;
  --text: #f3f0e7;
  --muted: #a8b0a2;
  --accent: #e4b85d;
  --accent-2: #8ed0c1;
  --danger: #e06b5d;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(228, 184, 93, 0.18), transparent 30rem),
    linear-gradient(145deg, #111312 0%, #17201c 50%, #151716 100%);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  min-height: 138px;
}

.header-actions {
  display: grid;
  justify-items: end;
  gap: 14px;
}

.header-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  font-size: clamp(2.7rem, 8vw, 7rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.rune-mark {
  color: var(--accent);
  font-family: "Rune Regular", serif;
  font-size: clamp(2.5rem, 8vw, 6.6rem);
  line-height: 1;
  white-space: nowrap;
}

.translator {
  margin-top: 28px;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 29, 26, 0.82);
  box-shadow: var(--shadow);
}

.mode-button {
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.mode-button.active {
  color: #1b1710;
  background: var(--accent);
}

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

.workbench {
  margin-top: 18px;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 29, 26, 0.88);
  box-shadow: var(--shadow);
}

.source-panel {
  order: 1;
}

.output-panel {
  order: 2;
}

.alphabet-panel {
  order: 3;
  grid-column: 1 / -1;
}

.alphabet-toggle {
  display: none;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 52px;
  padding: 0 14px 0 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.panel-heading label,
.panel-heading span {
  overflow-wrap: anywhere;
}

.decode-preference {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(228, 184, 93, 0.05);
}

.decode-preference[hidden] {
  display: none;
}

.decode-group {
  display: grid;
  gap: 8px;
}

.decode-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.decode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 29, 26, 0.82);
}

.decode-option {
  min-width: 82px;
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 0.84rem;
  font-weight: 800;
}

.decode-option.active {
  color: #1b1710;
  background: var(--accent);
}

textarea {
  display: block;
  width: 100%;
  min-height: 320px;
  resize: vertical;
  border: 0;
  outline: 0;
  padding: 18px;
  color: var(--text);
  background: transparent;
  font-size: 1.04rem;
  line-height: 1.6;
}

.output-panel {
  display: flex;
  flex-direction: column;
}

.result-subheading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
  padding: 0 14px 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: rgba(32, 39, 32, 0.64);
  font-size: 0.78rem;
  font-weight: 800;
}

textarea:focus {
  background: rgba(142, 208, 193, 0.06);
}

textarea[readonly] {
  color: #fbf6e6;
}

#primaryOutput {
  flex: 1 1 210px;
  min-height: 210px;
}

.rune-font {
  font-family: "Rune Regular", serif;
  font-size: 2.15rem;
  line-height: 1.45;
}

.secondary-output {
  min-height: 104px;
  color: #ded9cc;
  font-size: 1.06rem;
}

.compact-panel textarea {
  min-height: 172px;
  font-size: 1.22rem;
}

.copy-button,
.install-button,
.help-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 34px;
  border: 1px solid rgba(228, 184, 93, 0.44);
  border-radius: 7px;
  color: var(--text);
  background: rgba(228, 184, 93, 0.09);
  font-weight: 800;
}

.copy-button {
  padding: 0 12px;
}

.help-button {
  padding: 0 14px;
}

.install-button {
  padding: 0 14px;
  color: #1b1710;
  background: var(--accent);
}

.install-button[hidden] {
  display: none;
}

.icon-button {
  color: var(--danger);
  font-size: 1.4rem;
  line-height: 1;
}

.copy-button:hover,
.install-button:hover,
.help-button:hover,
.icon-button:hover,
.decode-option:hover,
.mode-button:hover {
  filter: brightness(1.08);
}

.alphabet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 1px;
  padding: 1px;
  background: var(--line);
}

.alphabet-cell {
  display: grid;
  grid-template-rows: 48px 28px;
  align-items: center;
  justify-items: center;
  min-width: 0;
  background: var(--surface-2);
}

.alphabet-rune {
  color: var(--accent);
  font-family: "Rune Regular", serif;
  font-size: 2rem;
  line-height: 1;
}

.alphabet-letter {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  min-width: 120px;
  max-width: calc(100% - 36px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  pointer-events: none;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 10, 9, 0.72);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.modal-backdrop[hidden] {
  display: none;
}

.help-modal {
  width: min(520px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.modal-heading h2 {
  margin: 0;
  font-size: 1.08rem;
  letter-spacing: 0;
}

.help-content {
  display: grid;
  gap: 12px;
  padding: 18px;
  color: #ded9cc;
  line-height: 1.7;
}

.help-content p {
  margin: 0;
}

.install-content strong {
  color: var(--text);
}

@media (max-width: 760px) {
  body {
    padding-bottom: 78px;
  }

  body.alphabet-open {
    padding-bottom: min(46vh, 340px);
  }

  .app-shell {
    width: min(100% - 24px, 1180px);
    padding: 22px 0;
  }

  .topbar {
    display: block;
    min-height: 0;
  }

  .header-actions {
    justify-items: start;
    margin-top: 16px;
  }

  .header-buttons {
    justify-content: flex-start;
  }

  .rune-mark {
    display: block;
  }

  .decode-preference {
    grid-template-columns: 1fr;
  }

  .decode-switch {
    width: 100%;
  }

  .mode-switch,
  .workbench {
    width: 100%;
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .source-panel {
    order: 1;
  }

  .output-panel {
    order: 2;
  }

  .alphabet-panel {
    position: fixed;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 12px;
    order: 3;
    max-height: min(58vh, 380px);
    z-index: 8;
  }

  .alphabet-toggle {
    display: inline-flex;
  }

  .alphabet-panel:not(.open) .alphabet-grid {
    display: none;
  }

  .alphabet-panel.open .alphabet-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    max-height: min(48vh, 320px);
    overflow-y: auto;
  }

  .alphabet-cell {
    grid-template-rows: 40px 24px;
  }

  .alphabet-rune {
    font-size: 1.68rem;
  }

  .alphabet-letter {
    font-size: 0.68rem;
  }

  textarea {
    min-height: 230px;
  }

  .rune-font {
    font-size: 1.7rem;
  }
}
