/* Shared styles for all pages to ensure consistent layout */

html,
body {
  opacity: 0;
  transition: opacity 0.16s ease-in-out;
}

html.loaded,
body.loaded {
  opacity: 1;
}

:root {
  --bg: #000000;
  --panel: #0f0f10;
  --panel-strong: #161617;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #ffffff;
  --success-bg: rgba(34, 197, 94, 0.14);
  --success-line: rgba(34, 197, 94, 0.35);
  --success-text: #bbf7d0;
  --danger-bg: rgba(239, 68, 68, 0.14);
  --danger-line: rgba(239, 68, 68, 0.35);
  --danger-text: #fecaca;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 74px 0 24px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.container {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: 0 20px;
}

.header-controls {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.94);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-title {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--text);
}

.header-controls.center-only {
  justify-content: flex-end;
}

.header,
.header-section {
  text-align: center;
  padding: 64px 20px 32px;
  margin-bottom: 20px;
}

.back-btn,
.language-toggle {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.back-btn:hover,
.language-toggle:hover {
  border-color: var(--line-strong);
  background: var(--panel-strong);
}

.title {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--text);
}

.subtitle {
  margin: 0;
  font-size: 1.1rem;
  color: var(--muted);
}

.glass-card {
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}

.content-section {
  margin: 0 auto 10px;
}

.input-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.input-field {
  width: 100%;
  min-height: 200px;
  padding: 16px 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.input-field:focus {
  border-color: var(--line-strong);
  background: var(--panel-strong);
}

.input-field::placeholder {
  color: var(--muted);
}

.is-hidden {
  display: none;
}

.text-center {
  text-align: center;
}

.btn {
  min-height: 42px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.btn:hover {
  border-color: var(--line-strong);
  background: var(--panel-strong);
}

.btn:disabled {
  cursor: default;
  opacity: 0.72;
}

.btn:focus-visible,
.input-field:focus-visible,
.back-btn:focus-visible,
.language-toggle:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.28);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  body {
    padding-top: 68px;
  }

  .header-controls {
    padding: 10px 14px;
  }

  .container {
    padding: 0 16px;
  }

  .app-title {
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  body {
    padding-top: 64px;
  }

  .container {
    padding: 0 14px;
  }

  .input-field {
    min-height: 184px;
    padding: 14px;
    font-size: 16px;
  }

  .back-btn,
  .language-toggle {
    width: 32px;
    height: 32px;
  }
}

/* ---- Derive ---- */

/* Page-specific styles for brain wallet */

.section-space-lg {
  margin-bottom: 16px;
}

.main-section {
  padding-top: 0;
}

.result-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.generate-btn {
  width: 100%;
}

.input-shell {
  position: relative;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.input-shell:focus-within {
  border-color: var(--line-strong);
  background: var(--panel-strong);
}

.input-shell .input-field {
  margin: 0;
  border: 0;
  background: transparent;
}

.input-shell .input-field:focus {
  border-color: transparent;
  background: transparent;
}

.input-preview,
.input-field-overlay {
  padding: 16px 16px 18px;
  font-family: "JetBrains Mono", "IBM Plex Mono", "Roboto Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: 0.01em;
  tab-size: 2;
}

.input-preview {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  color: var(--text);
  pointer-events: none;
}

.input-preview.is-hidden {
  display: block;
  visibility: hidden;
}

.input-preview-content {
  min-height: 100%;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  transform: translate(0, 0);
}

.input-field-overlay {
  position: relative;
  z-index: 1;
  color: transparent;
  caret-color: var(--text);
  -webkit-text-fill-color: transparent;
}

.input-field-overlay::selection {
  background: rgba(255, 255, 255, 0.16);
}

.input-field-overlay::placeholder {
  -webkit-text-fill-color: var(--muted);
}

.whitespace-mark {
  color: rgba(255, 255, 255, 0.46);
}

.usage-status {
  width: auto;
  min-height: 40px;
  min-width: 216px;
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid var(--line);
}

.usage-status.is-hidden {
  display: none;
}

.usage-status.is-used {
  background: var(--danger-bg);
  border-color: var(--danger-line);
  color: var(--danger-text);
}

.usage-status.is-unused {
  background: var(--success-bg);
  border-color: var(--success-line);
  color: var(--success-text);
}

.usage-status.is-error {
  background: var(--danger-bg);
  border-color: var(--danger-line);
  color: var(--danger-text);
}

.usage-status.is-flash {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.result-guide-link {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.guide-link-btn {
  min-height: 34px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s ease;
}

.guide-link-btn:hover,
.guide-link-btn:focus-visible {
  color: var(--text);
}

.image-container {
  display: flex;
  justify-content: center;
}

.wallet-image {
  display: none;
  width: 100%;
  max-width: 320px;
  background: #000;
  border-radius: 22px;
}

.result-controls {
  width: 100%;
  display: flex;
  justify-content: center;
  padding-top: 2px;
}

.address-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
}

.address-panel.is-hidden {
  display: none;
}

.address-panel-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 0 auto;
}

.address-qr-canvas {
  display: block;
  width: 100px;
  height: auto;
  padding: 6px;
  background: #fff;
  border-radius: 10px;
}

.address-text {
  max-width: 300px;
  padding: 0;
  color: var(--text);
  font-family: "JetBrains Mono", "IBM Plex Mono", "Roboto Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.03em;
  line-height: 1.5;
  text-align: center;
  white-space: normal;
  word-break: break-all;
  cursor: pointer;
  user-select: none;
  opacity: 0.94;
}

.address-text:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.14);
  outline-offset: 4px;
  border-radius: 8px;
}

.guide-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 8px 0 24px;
}

.guide-kicker {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.guide-title {
  margin: 0 0 12px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.guide-lead {
  margin: 0 0 20px;
  max-width: 640px;
  color: rgba(243, 244, 246, 0.8);
  font-size: 15px;
  line-height: 1.7;
}

.guide-flow-card,
.guide-step {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}

.guide-flow-card {
  margin-bottom: 14px;
  padding: 16px 18px;
}

.guide-flow-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.guide-flow {
  margin: 0;
  color: var(--text);
  font-family: "JetBrains Mono", "IBM Plex Mono", "Roboto Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-step {
  padding: 18px;
}

.guide-step-index {
  margin-bottom: 10px;
  color: var(--muted);
  font-family: "JetBrains Mono", "IBM Plex Mono", "Roboto Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.guide-step-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 650;
  line-height: 1.3;
}

.guide-step-copy {
  margin: 0 0 12px;
  color: rgba(243, 244, 246, 0.82);
  font-size: 14px;
  line-height: 1.7;
}

.guide-step-code {
  margin: 0;
  padding: 12px 13px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: "JetBrains Mono", "IBM Plex Mono", "Roboto Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (min-width: 640px) {
  .generate-btn,
  .usage-status {
    min-width: 216px;
  }

  .wallet-image {
    max-width: 324px;
  }

}

@media (max-width: 480px) {
  .result-shell {
    gap: 12px;
  }

  .input-preview,
  .input-field-overlay {
    padding: 14px;
    font-size: 14px;
  }

  .wallet-image {
    max-width: 100%;
  }

  .guide-link-btn {
    font-size: 11px;
    letter-spacing: 0.06em;
  }

  .guide-shell {
    padding-top: 2px;
  }

  .guide-title {
    font-size: 28px;
  }

  .guide-flow-card,
  .guide-step {
    border-radius: 18px;
  }

  .guide-step {
    padding: 16px;
  }

  .address-qr-canvas {
    width: 96px;
  }

  .address-text {
    max-width: 260px;
    font-size: 12px;
  }
}
