/* ============================================================
   I CHING · Estilos · "Arcilla suave"
   Bienestar moderno: salvia + arcilla, bordes blandos, tema claro.
   ============================================================ */
:root {
  --bg:       #ECEAE2;   /* fondo arcilla clara */
  --surface:  #F4F2EC;   /* cards elevadas */
  --fg:       #3A3A34;   /* texto principal */
  --fg-dim:   #807E74;   /* texto secundario */
  --fg-mut:   #9A988E;   /* hints */
  --sage:     #6E7A63;   /* líneas, acción principal */
  --sage-d:   #59634F;   /* salvia honda (hover) */
  --clay:     #A8694A;   /* acento terracota / sello / mutantes */
  --hair:     rgba(58, 58, 52, .12);
  --shadow:   0 6px 22px rgba(58, 58, 52, .07);
  --radius:   18px;
  --maxw:     520px;
  --safe-b:   env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: "Space Grotesk", system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.zh { font-family: "Noto Serif SC", serif; }

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; max-width: var(--maxw); width: 100%; margin: 0 auto;
}
.brand { flex: 1; font-size: 1.15rem; font-weight: 500; letter-spacing: .01em; }
.brand .zh { color: var(--clay); font-size: 1.35rem; }
.seal {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--clay); color: #fff; border: none;
  font-family: "Noto Serif SC", serif; font-size: 1.1rem; cursor: pointer;
  box-shadow: 0 3px 10px rgba(168, 105, 74, .28);
}
.lang {
  background: none; border: 1px solid var(--hair); color: var(--fg-dim);
  border-radius: 999px; padding: 6px 12px; font-size: .75rem; cursor: pointer;
  font-family: inherit; letter-spacing: .08em;
}

/* ===== Layout ===== */
#app { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 8px 18px 100px; }
.view { animation: fade .5s ease; }
.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Ritual de consulta ===== */
.ritual {
  text-align: center;
  min-height: calc(100vh - 178px);
  min-height: calc(100dvh - 178px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ritual .prompt, .ritual .question-input { width: 100%; }
.prompt { font-size: 1.4rem; color: var(--fg); margin-bottom: 22px; font-weight: 500; }
.question-input {
  width: 100%; background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--radius); padding: 15px 18px; color: var(--fg);
  font-family: inherit; font-size: 1.05rem; text-align: center; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.question-input:focus { outline: none; border-color: var(--sage); }
.question-input::placeholder { color: var(--fg-mut); }

.method { display: inline-flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 999px; margin-bottom: 30px; box-shadow: var(--shadow); }
.method-opt {
  background: none; border: none; color: var(--fg-dim); font-family: inherit;
  font-size: .9rem; padding: 9px 20px; border-radius: 999px; cursor: pointer; transition: .25s;
}
.method-opt.is-active { background: var(--sage); color: #fff; font-weight: 500; }

.hex-stage { min-height: 132px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; margin-bottom: 18px; }

/* Acuarela estacional + haiku clásico rotativo (sobre el botón) */
.haiku-art { width: 188px; height: 72px; margin: 0 auto 12px; opacity: .9; }
.haiku-art svg { width: 100%; height: 100%; display: block; }
.haiku { margin-bottom: 30px; min-height: 96px; display: flex; flex-direction: column; justify-content: center; }
.haiku-lines span { display: block; font-size: 1.2rem; line-height: 1.55; color: var(--fg); }
.haiku-author { margin-top: 10px; font-size: .85rem; color: var(--clay); font-style: italic; }

.cast-btn {
  background: var(--sage); color: #fff; border: none;
  padding: 16px 46px; border-radius: 999px; font-family: inherit;
  font-size: 1.1rem; font-weight: 500; letter-spacing: .02em; cursor: pointer;
  box-shadow: 0 6px 18px rgba(110, 122, 99, .32); transition: transform .15s, background .2s;
}
.cast-btn:hover { background: var(--sage-d); }
.cast-btn:active { transform: scale(.96); }
.cast-btn:disabled { opacity: .5; }
.contempl-note { color: var(--fg-mut); margin-top: 18px; font-size: .9rem; }

/* ===== Glifo del hexagrama (6 líneas, en píldora) ===== */
.glyph { display: flex; flex-direction: column-reverse; gap: 9px; }
.gline { width: 120px; height: 12px; display: flex; gap: 14px; justify-content: center; }
.gline .seg { background: var(--sage); border-radius: 999px; height: 100%; transition: background .3s; }
.gline.yang .seg { width: 120px; }
.gline.yin  .seg { width: 53px; }
.gline.changing .seg { background: var(--clay); }
.gline.casting { animation: pulse .6s ease; }
@keyframes pulse { 0% { opacity: .15; transform: scaleX(.6); } 100% { opacity: 1; transform: none; } }

/* ===== Resultado ===== */
.result-head { text-align: center; padding: 14px 0 8px; }
.result-num { color: var(--clay); letter-spacing: .2em; font-size: .78rem; font-weight: 500; }
.result-name { font-size: 1.7rem; margin: 5px 0; font-weight: 500; line-height: 1.2; }
.result-name .zh { color: var(--clay); }
.result-pinyin { color: var(--fg-dim); font-style: italic; }
.trigram-row { display: flex; justify-content: center; gap: 30px; margin: 16px 0; color: var(--fg-dim); font-size: .9rem; }
.trigram-row b { display: block; font-size: 1.9rem; color: var(--fg); }

.card {
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: 16px; padding: 18px; margin: 14px 0; box-shadow: var(--shadow);
}
.card h3 { color: var(--clay); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 8px; font-weight: 500; }
.card p { font-size: 1.05rem; line-height: 1.55; }
.todo { color: var(--fg-mut); font-style: italic; }

.transform-arrow { text-align: center; color: var(--clay); font-size: 1.5rem; margin: 8px 0; }
.result-actions { display: flex; gap: 10px; margin-top: 20px; }
.result-actions button {
  flex: 1; padding: 14px; border-radius: 14px; font-family: inherit; font-size: 1rem; cursor: pointer; border: 1px solid var(--hair);
  background: var(--surface); color: var(--fg); transition: .2s;
}
.result-actions .primary { background: var(--sage); color: #fff; border-color: var(--sage); font-weight: 500; }
.result-actions .primary:hover { background: var(--sage-d); }

/* ===== Diario ===== */
.view-title { font-size: 1.5rem; margin: 10px 0 18px; font-weight: 500; }

/* ===== Barra de sincronización ===== */
.sync-bar { margin-bottom: 16px; }
.sync-off, .sync-on {
  background: var(--surface); border: 1px solid var(--hair); border-radius: 16px;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.sync-off p { color: var(--fg-dim); font-size: .92rem; line-height: 1.45; margin-bottom: 12px; }
.sync-row { display: flex; gap: 8px; }
.sync-row input {
  flex: 1; background: var(--bg); border: 1px solid var(--hair); border-radius: 12px;
  padding: 11px 14px; color: var(--fg); font-family: inherit; font-size: 1rem; text-align: center;
}
.sync-row input:focus { outline: none; border-color: var(--sage); }
.sync-row button {
  background: var(--sage); color: #fff; border: none; border-radius: 12px;
  padding: 0 20px; font-family: inherit; font-size: .95rem; cursor: pointer;
}
.sync-msg { color: var(--clay); font-size: .85rem; margin-top: 8px; min-height: 1em; }
.sync-on { display: flex; align-items: center; justify-content: space-between; }
.sync-on span { color: var(--sage-d); font-size: .92rem; }
.sync-on span i { font-style: normal; margin-right: 4px; }
.sync-link { background: none; border: none; color: var(--fg-dim); font-family: inherit; font-size: .85rem; cursor: pointer; text-decoration: underline; }

.diary-list { display: flex; flex-direction: column; gap: 12px; }
.diary-item {
  background: var(--surface); border: 1px solid var(--hair); border-radius: 16px;
  padding: 15px 16px; display: flex; gap: 14px; align-items: center; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .15s;
}
.diary-item:active { transform: scale(.99); }
.diary-item .mini-glyph { font-size: 1.7rem; color: var(--clay); min-width: 1.7rem; text-align: center; }
.diary-item .meta { flex: 1; }
.diary-item .d-name { font-size: 1.1rem; color: var(--fg); font-weight: 500; }
.diary-item .d-date { color: var(--fg-dim); font-size: .82rem; margin-top: 2px; }
.diary-item .d-go { color: var(--fg-mut); font-size: 1.6rem; line-height: 1; padding-left: 6px; }
.diary-empty { color: var(--fg-mut); text-align: center; padding-top: 34px; }

/* Fecha de una lectura reabierta desde el diario */
.saved-meta { text-align: center; color: var(--fg-dim); font-size: .9rem; padding: 6px 0 2px; }

/* ===== Tabbar ===== */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: center; gap: 8px;
  padding: 10px 0 calc(10px + var(--safe-b));
  background: rgba(244, 242, 236, .9); backdrop-filter: blur(12px);
  border-top: 1px solid var(--hair);
}
.tab {
  background: none; border: none; color: var(--fg-dim); font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 26px; cursor: pointer; font-size: .72rem;
}
.tab span { font-size: 1.3rem; }
.tab.is-active { color: var(--clay); }
