:root {
  --bg: #f6f1e7;
  --surface: #fcf9f2;
  --surface-alt: #efe7d8;
  --ink: #1f1b18;
  --ink-muted: #665d53;
  --border: #ddd3c2;
  --accent: #b5382b;
  --accent-hover: #962c21;
  --gold: #a67c37;
  --shadow: 0 12px 32px rgba(31, 27, 24, 0.07);
  --radius: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg);
  background-image: radial-gradient(circle at 18% 12%, rgba(166, 124, 55, 0.08), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(181, 56, 43, 0.05), transparent 45%);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(246, 241, 231, 0.88);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
  gap: 16px;
}

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

.brand-seal {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--surface);
  display: grid;
  place-items: center;
  font-size: 20px;
  font-family: Georgia, serif;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
}

.brand-text small {
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.header-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.header-nav a,
.btn-link {
  font-size: 0.92rem;
  color: var(--ink-muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 2px;
  font-family: inherit;
  white-space: nowrap;
  transition: color 0.2s;
}

.header-nav a:hover,
.btn-link:hover {
  color: var(--accent);
}

/* Hero */
.hero {
  padding-top: 44px;
  padding-bottom: 24px;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 10px;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}

h1,
h2,
h3 {
  font-family: "Cormorant Garamond", Georgia, serif;
  line-height: 1.2;
  margin-top: 0;
}

.hero h1 {
  font-size: clamp(2.1rem, 4.5vw, 3.1rem);
  margin-bottom: 12px;
}

.hero-subtitle {
  max-width: 640px;
  margin: 0 auto 28px;
  color: var(--ink-muted);
  font-size: 1.03rem;
}

/* Oracle Form Card */
.oracle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  text-align: left;
}

.input-label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 0.98rem;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 92px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fffdf8;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(181, 56, 43, 0.14);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.suggestions-label {
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.chip {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.82rem;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, border-color 0.2s;
}

.chip:hover {
  background: #e6dcc9;
  border-color: #c8bca7;
}

.form-error {
  margin: 12px 0 0;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
}

.form-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.privacy-inline {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-outline-sm {
  font-family: inherit;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s, background-color 0.2s, border-color 0.2s;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 13px 24px;
  font-size: 1rem;
}

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

.btn-primary:active {
  transform: translateY(1px);
}

/* Casting animation */
.casting-section {
  padding: 16px 20px 28px;
}

.casting-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.casting-title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 18px;
}

.casting-lines {
  width: 180px;
  height: 150px;
  margin: 0 auto 14px;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  gap: 13px;
}

.cast-line {
  height: 11px;
  display: flex;
  justify-content: space-between;
  opacity: 0;
  transform: translateY(6px);
  animation: fadeLineIn 0.22s ease forwards;
}

.cast-line.yang::before {
  content: "";
  width: 100%;
  height: 100%;
  background: var(--ink);
  border-radius: 3px;
}

.cast-line.yin::before,
.cast-line.yin::after {
  content: "";
  width: 43%;
  height: 100%;
  background: var(--ink);
  border-radius: 3px;
}

@keyframes fadeLineIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.casting-sub {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

/* Result section */
.result-section {
  padding-top: 10px;
  padding-bottom: 32px;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.asked-question {
  padding-bottom: 18px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.asked-label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.asked-question blockquote {
  margin: 0;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink);
}

.hexagram-showcase {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
  margin-bottom: 28px;
}

.hexagram-figure {
  margin: 0;
  text-align: center;
}

.hexagram-figure img {
  width: 100%;
  max-width: 780px;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 26px rgba(31, 27, 24, 0.1);
  display: block;
  margin: 0 auto;
}

.meta-top-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.number-badge {
  display: inline-block;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 999px;
}

.luck-badge {
  display: inline-block;
  background: var(--ink);
  color: var(--surface);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 4px 12px;
  border-radius: 999px;
}

.hex-title {
  font-size: clamp(1.9rem, 3.5vw, 2.5rem);
  margin-bottom: 6px;
}

.hex-chinese {
  margin: 0 0 8px;
  font-size: 1.05rem;
  color: var(--ink-muted);
}

.hex-trigrams {
  margin: 0 0 14px;
  font-size: 0.92rem;
  color: var(--gold);
  font-weight: 500;
}

.hex-essence {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 500;
  padding: 12px 14px;
  background: var(--surface-alt);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
}

/* Interpretation below image */
.interpretation {
  border-top: 1px solid var(--border);
  padding-top: 24px;
  display: grid;
  gap: 18px;
}

.interp-block h3 {
  font-size: 1.35rem;
  margin-bottom: 6px;
}

.interp-block p {
  margin: 0;
  color: var(--ink);
  font-size: 1.02rem;
}

.interp-advice {
  background: #f5efe3;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}

.result-actions {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn-secondary {
  background: var(--ink);
  color: var(--surface);
  border: none;
  padding: 12px 20px;
  font-size: 0.95rem;
}

.btn-secondary:hover {
  background: #352e29;
}

.btn-secondary.copied {
  background: #2c6e49;
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 12px 18px;
  font-size: 0.95rem;
}

.btn-ghost:hover {
  background: var(--surface-alt);
}

.ai-hint {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

/* History section */
.history-section {
  padding-top: 8px;
  padding-bottom: 32px;
}

.history-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}

.history-header h2 {
  font-size: 1.55rem;
  margin-bottom: 2px;
}

.history-header p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.history-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-outline-sm {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 8px 14px;
  font-size: 0.86rem;
}

.btn-outline-sm:hover {
  background: var(--surface-alt);
}

.btn-link-muted {
  background: none;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  font-size: 0.86rem;
  text-decoration: underline;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

.history-item:hover {
  border-color: var(--accent);
  background: #fffdf8;
}

.history-item-q {
  font-weight: 500;
  font-size: 0.95rem;
}

.history-item-hex {
  font-size: 0.86rem;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

/* Guide Section (O que é o I Ching) */
.guide-section {
  padding-top: 16px;
  padding-bottom: 18px;
}

.guide-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.guide-card h2 {
  font-size: 1.9rem;
  margin-bottom: 12px;
}

.guide-card p {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 1rem;
}

.guide-card p:last-child {
  margin-bottom: 0;
}

/* Info section */
.info-section {
  padding-top: 24px;
  padding-bottom: 56px;
}

.info-section h2 {
  text-align: center;
  font-size: 1.85rem;
  margin-bottom: 22px;
}

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

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.info-step {
  display: inline-block;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}

.info-card h3 {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.info-card p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-muted);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  background: var(--surface-alt);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.footer-inner p {
  margin: 0;
}

.footer-note a {
  color: var(--ink);
  font-weight: 500;
}

.footer-share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.share-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

.share-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.share-btn:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}

/* Consent Banner (Primeira visita) */
.consent-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: flex;
  justify-content: center;
}

.consent-banner[hidden] {
  display: none;
}

.consent-inner {
  width: 100%;
  max-width: 880px;
  background: var(--ink);
  color: var(--surface);
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.consent-inner p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  flex: 1 1 240px;
  min-width: 0;
}

.consent-inner a {
  color: #f4c752;
  text-decoration: underline;
}

.consent-btn {
  padding: 10px 18px;
  font-size: 0.9rem;
  white-space: nowrap;
}

/* Privacy Page */
.privacy-page {
  padding-top: 36px;
  padding-bottom: 56px;
}

.privacy-article h1 {
  font-size: clamp(2rem, 4vw, 2.7rem);
  margin-bottom: 6px;
}

.privacy-article h2 {
  font-size: 1.45rem;
  margin-top: 24px;
  margin-bottom: 8px;
}

.privacy-updated {
  color: var(--ink-muted);
  font-size: 0.92rem;
  margin-bottom: 20px;
}

.dpo-box {
  background: var(--surface-alt);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 14px 18px;
  margin: 14px 0 24px;
}

.dpo-box p {
  margin: 4px 0;
}

.dpo-box a {
  color: var(--accent);
  font-weight: 600;
}

.privacy-back {
  margin-top: 12px;
}

.privacy-back .btn-primary {
  text-decoration: none;
}

/* Catalog Modal */
.catalog-dialog {
  width: min(860px, 94vw);
  max-height: 85vh;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
}

.catalog-dialog::backdrop {
  background: rgba(31, 27, 24, 0.52);
  backdrop-filter: blur(3px);
}

.catalog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.catalog-header h2 {
  margin: 0;
  font-size: 1.7rem;
}

.btn-close {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}

.catalog-sub {
  margin: 6px 0 18px;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
}

.catalog-item {
  text-align: left;
  background: #fffdf8;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 0.2s, transform 0.1s;
}

.catalog-item:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.catalog-num {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.85rem;
  min-width: 24px;
}

.catalog-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
}

@media (max-width: 720px) {
  .container {
    padding: 0 14px;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .header-nav {
    width: 100%;
    gap: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
  }

  .header-nav a,
  .header-nav .btn-link {
    font-size: 0.85rem;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--ink);
  }

  .hero {
    padding-top: 28px;
  }

  .hexagram-showcase {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .meta-top-row {
    justify-content: center;
  }

  .hex-essence {
    text-align: left;
  }

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

  .oracle-card,
  .result-card,
  .guide-card {
    padding: 18px;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary,
  .btn-secondary,
  .btn-ghost {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .consent-banner {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .consent-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
  }

  .consent-inner p {
    flex: none;
    font-size: 0.85rem;
  }

  .consent-btn {
    width: 100%;
    justify-content: center;
  }

  .catalog-dialog {
    padding: 16px;
  }

  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}
