/* Fuelle — estética sumi-e: papel cálido, tinta jade, niebla. */
:root {
  --paper: #f4f1e8;
  --paper-2: #e7ece7;
  --mist: rgba(255, 255, 255, 0.55);
  --ink: #28342f;
  --ink-soft: #5d6b64;
  --jade: #3a6e63;
  --jade-deep: #2c5750;
  --jade-soft: #6fa093;
  --line: rgba(40, 52, 47, 0.12);
  --danger: #a8584c;
  --shadow: 0 10px 30px rgba(40, 60, 54, 0.14);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* El atributo hidden debe ganarle a cualquier display (flex/grid) de abajo. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
}

body { overscroll-behavior: none; }

/* ----------------- Intro ----------------- */
.intro {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.4rem; text-align: center; padding: 2rem;
  background: radial-gradient(120% 90% at 50% 30%, var(--paper) 0%, var(--paper-2) 75%);
  transition: opacity 0.65s ease;
}
.intro.hide { opacity: 0; pointer-events: none; }
.intro-ripple { position: relative; width: 160px; height: 160px; margin-bottom: 1rem; }
.intro-ripple span {
  position: absolute; inset: 0; margin: auto; width: 28px; height: 28px;
  border: 2px solid var(--jade-soft); border-radius: 50%;
  animation: ripple 3.4s ease-out infinite; opacity: 0;
}
.intro-ripple span:nth-child(2) { animation-delay: 1.1s; }
.intro-ripple span:nth-child(3) { animation-delay: 2.2s; }
@keyframes ripple {
  0% { transform: scale(0.3); opacity: 0.9; }
  100% { transform: scale(5.2); opacity: 0; }
}
.intro-zh { font-size: 2.4rem; color: var(--jade-deep); letter-spacing: 0.3em; margin: 0; }
.intro-text { font-size: 1.15rem; color: var(--ink); margin: 0.2rem 0 0; }
.intro-by { color: var(--ink-soft); margin: 0 0 1.4rem; font-style: italic; }
.intro-actions { display: flex; flex-direction: column; align-items: center; gap: 0.7rem; }
.intro-why-link {
  background: none; border: 0; cursor: pointer; padding: 0.2rem 0.4rem;
  font: inherit; font-size: 0.86rem; color: var(--jade); text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: var(--jade-soft);
}
.intro-why-link:hover { color: var(--jade-deep); }
.intro-why {
  max-width: 30rem; margin: 1.4rem auto 0; text-align: left;
  color: var(--ink-soft); font-size: 0.92rem; line-height: 1.6;
  background: rgba(58, 110, 99, 0.06); border: 1px solid var(--line);
  border-radius: 14px; padding: 1rem 1.2rem;
  animation: intro-why-in 0.4s ease;
}
.intro-why p { margin: 0 0 0.7rem; }
.intro-why strong { color: var(--jade-deep); font-weight: 600; }
.intro-why-list { margin: 0 0 0.7rem; padding-left: 1.1rem; }
.intro-why-list li { margin: 0.3rem 0; }
.intro-why-end { font-style: italic; margin: 0; color: var(--ink); }
@keyframes intro-why-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .intro-why { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  .intro-ripple span { animation: none; opacity: 0.4; }
}

/* ----------------- App shell ----------------- */
.app { display: flex; flex-direction: column; height: 100%; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.1rem 0.5rem;
}
.view-title { font-size: 1.4rem; font-weight: 600; margin: 0; color: var(--jade-deep); }
.icon-btn {
  border: none; background: var(--mist); width: 40px; height: 40px; border-radius: 50%;
  font-size: 1.2rem; cursor: pointer; color: var(--ink); box-shadow: var(--shadow);
}
.content { flex: 1; overflow-y: auto; position: relative; -webkit-overflow-scrolling: touch; }
.view { padding: 0.5rem 1.1rem 7rem; }
#view-cauce { padding: 0; height: 100%; }

/* ----------------- Fuelle: escena del cauce (canvas) ----------------- */
.cauce-wrap { position: relative; width: 100%; height: 100%; }
#cauce-canvas { display: block; width: 100%; height: 100%; touch-action: manipulation; }
.empty {
  text-align: center; color: var(--ink-soft); margin: 2.5rem auto; max-width: 22rem;
  line-height: 1.6;
}
#cauce-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}

/* ----------------- Valores (lista) ----------------- */
.values-hint { color: var(--ink-soft); font-size: 0.92rem; line-height: 1.5; margin: 0.6rem 0 1rem; }
.values-hint strong { color: var(--jade-deep); }
.values-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.value-card {
  display: flex; align-items: center; gap: 0.8rem;
  background: var(--mist); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.8rem 0.9rem; box-shadow: var(--shadow); cursor: pointer;
  backdrop-filter: blur(6px);
}
.value-rank {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 0.95rem;
  box-shadow: inset 0 -3px 8px rgba(0,0,0,0.12);
}
.value-main { flex: 1; min-width: 0; }
.value-name { font-weight: 600; font-size: 1.05rem; display: flex; align-items: center; gap: 0.4rem; }
.value-name .source-tag {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--jade-deep); background: rgba(58, 110, 99, 0.14); padding: 0.1rem 0.4rem; border-radius: 999px;
}
.value-why { color: var(--ink-soft); font-size: 0.86rem; margin-top: 0.15rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.value-moves { display: flex; flex-direction: column; gap: 0.2rem; }
.move-btn {
  border: 1px solid var(--line); background: #fff8; color: var(--ink); border-radius: 8px;
  width: 30px; height: 24px; font-size: 0.8rem; cursor: pointer; line-height: 1;
}
.move-btn:disabled { opacity: 0.3; cursor: default; }

/* ----------------- FAB ----------------- */
.fab {
  position: fixed; right: 1.1rem; bottom: calc(5.2rem + var(--safe-b)); z-index: 20;
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 1.9rem; line-height: 1; color: #fff;
  background: radial-gradient(circle at 35% 30%, var(--jade-soft), var(--jade) 70%);
  box-shadow: 0 8px 22px rgba(44, 87, 80, 0.4);
}
.fab:active { transform: scale(0.94); }

/* ----------------- Tabbar ----------------- */
.tabbar {
  display: flex; border-top: 1px solid var(--line);
  background: rgba(247, 244, 236, 0.92); backdrop-filter: blur(10px);
  padding-bottom: var(--safe-b);
}
.tab {
  flex: 1; border: none; background: none; padding: 0.6rem 0 0.7rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  color: var(--ink-soft); font-size: 0.78rem;
}
.tab.is-active { color: var(--jade-deep); }
.tab-ico { font-size: 1.25rem; line-height: 1; }

/* ----------------- Modales (sheets) ----------------- */
.sheet {
  border: none; border-radius: 22px 22px 0 0; padding: 0; width: 100%; max-width: 560px;
  margin: auto auto 0; background: var(--paper); color: var(--ink); box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(28, 40, 36, 0.4); backdrop-filter: blur(2px); }
.sheet-form { padding: 1.3rem 1.2rem calc(1.3rem + var(--safe-b)); display: flex; flex-direction: column; gap: 0.9rem; }
.sheet-head { margin-bottom: 0.2rem; }
.sheet-title { margin: 0; font-size: 1.25rem; color: var(--jade-deep); }
.sheet-sub { margin: 0.2rem 0 0; color: var(--ink-soft); font-size: 0.85rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field > span { font-size: 0.85rem; color: var(--ink-soft); }
.input {
  width: 100%; border: 1px solid var(--line); background: #fffc; border-radius: 12px;
  padding: 0.7rem 0.8rem; font: inherit; color: var(--ink); resize: vertical;
}
.input:focus { outline: 2px solid var(--jade-soft); border-color: transparent; }
.hint-sm { font-size: 0.8rem; color: var(--ink-soft); margin: 0; }

/* Sincronización */
.sync-box {
  display: flex; flex-direction: column; gap: 0.7rem;
  background: rgba(58, 110, 99, 0.06); border: 1px solid var(--line);
  border-radius: 14px; padding: 0.9rem 1rem;
}
.sync-title { margin: 0; font-size: 1rem; color: var(--jade-deep); }
.sync-msg {
  margin: 0; font-size: 0.8rem; color: var(--jade-deep);
  background: rgba(58, 110, 99, 0.1); border-radius: 8px; padding: 0.4rem 0.6rem;
}
.sheet-sep { border: none; border-top: 1px solid var(--line); margin: 0.2rem 0; width: 100%; }

.color-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 -3px 6px rgba(0,0,0,0.15); }
.swatch.sel { border-color: var(--ink); transform: scale(1.12); }

/* ----------------- Botones ----------------- */
.btn {
  border: none; border-radius: 12px; padding: 0.65rem 1.1rem; font: inherit; font-weight: 600;
  cursor: pointer; transition: transform 0.05s ease;
}
.btn:active { transform: scale(0.97); }
.btn-sm { padding: 0.45rem 0.8rem; font-size: 0.88rem; }
.btn-primary { background: var(--jade); color: #fff; }
.btn-ghost { background: transparent; color: var(--jade-deep); border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(168, 88, 76, 0.4); }
.spacer { flex: 1; }
.sheet-actions { display: flex; align-items: center; gap: 0.5rem; }

/* ----------------- Toast / banner ----------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(6.5rem + var(--safe-b)); transform: translateX(-50%);
  background: var(--jade-deep); color: #fff; padding: 0.6rem 1rem; border-radius: 999px;
  box-shadow: var(--shadow); z-index: 60; font-size: 0.9rem; max-width: 90vw; text-align: center;
}
.update-banner {
  position: fixed; left: 50%; bottom: calc(1rem + var(--safe-b)); transform: translateX(-50%);
  display: flex; gap: 0.8rem; align-items: center; z-index: 60;
  background: #fff; color: var(--ink); padding: 0.6rem 0.9rem; border-radius: 14px; box-shadow: var(--shadow);
}
