/* Khazana v9 round 10: appearance styles, profile, duplicate merge, animated brain. */

/* ---------- styles chosen in Appearance (all use the % sliders) ---------- */
:root { --gl9: .6; --glow9: .4; --depth9: .5; --brand2: var(--brand); }
:root[data-style9="liquid"] .card, :root[data-style9="liquid"] .w12 > .card, :root[data-style9="liquid"] .rv, :root[data-style9="liquid"] .sheet {
  background: color-mix(in srgb, var(--surface) calc(100% - var(--gl9) * 45%), transparent);
  -webkit-backdrop-filter: blur(calc(var(--gl9) * 26px)) saturate(170%); backdrop-filter: blur(calc(var(--gl9) * 26px)) saturate(170%);
  border-color: color-mix(in srgb, #fff calc(var(--glow9) * 60%), var(--line));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, calc(var(--glow9) * .7)), 0 calc(var(--depth9) * 18px) calc(var(--depth9) * 40px) rgba(0, 0, 0, calc(var(--depth9) * .16)); }
:root[data-style9="clear"] .card, :root[data-style9="clear"] .rv { box-shadow: 0 calc(var(--depth9) * 10px) calc(var(--depth9) * 24px) rgba(0, 0, 0, calc(var(--depth9) * .12)); }
:root[data-style9="neon"] .card, :root[data-style9="neon"] .rv {
  background: color-mix(in srgb, var(--surface) calc(100% - var(--gl9) * 35%), transparent);
  border: 1px solid color-mix(in srgb, var(--brand) calc(30% + var(--glow9) * 60%), transparent);
  box-shadow: 0 0 calc(var(--glow9) * 22px) color-mix(in srgb, var(--brand) calc(var(--glow9) * 55%), transparent), 0 calc(var(--depth9) * 12px) calc(var(--depth9) * 26px) rgba(0, 0, 0, calc(var(--depth9) * .2)); }
:root[data-style9="neon"] .btn.primary { box-shadow: 0 0 calc(var(--glow9) * 18px) color-mix(in srgb, var(--brand) 70%, transparent); }
:root[data-style9="mineral"] .card, :root[data-style9="mineral"] .rv {
  background: linear-gradient(160deg, color-mix(in srgb, var(--surface) 92%, #8a8578), var(--surface));
  border: 1px solid color-mix(in srgb, var(--ink) calc(8% + var(--depth9) * 20%), transparent);
  -webkit-backdrop-filter: blur(calc(var(--gl9) * 10px)); backdrop-filter: blur(calc(var(--gl9) * 10px)); box-shadow: none; }
:root[data-style9="soft"] .card, :root[data-style9="soft"] .rv { border-color: transparent; border-radius: 22px;
  background: color-mix(in srgb, var(--brand-soft) calc(var(--glow9) * 70%), var(--surface));
  box-shadow: 0 calc(var(--depth9) * 14px) calc(var(--depth9) * 34px) color-mix(in srgb, var(--brand) 14%, transparent); }
:root[data-style9="paper"] body { background: color-mix(in srgb, #f4e9d8 calc(var(--glow9) * 60%), var(--bg)); }
:root[data-style9="paper"][data-theme="dark"] body { background: color-mix(in srgb, #2a2218 calc(var(--glow9) * 60%), var(--bg)); }
:root[data-style9="paper"] .card, :root[data-style9="paper"] .rv { box-shadow: none; border-color: color-mix(in srgb, var(--ink) calc(6% + var(--depth9) * 12%), transparent); }

/* backgrounds */
:root[data-bg9="aurora"] body { background-image: radial-gradient(60% 40% at 10% 0%, color-mix(in srgb, var(--brand) 14%, transparent), transparent 70%), radial-gradient(50% 40% at 100% 10%, color-mix(in srgb, var(--brand2) 12%, transparent), transparent 70%); background-attachment: fixed; }
:root[data-bg9="mesh"] body { background-image: radial-gradient(at 20% 20%, color-mix(in srgb, var(--brand) 16%, transparent) 0, transparent 50%), radial-gradient(at 80% 30%, color-mix(in srgb, var(--brand2) 14%, transparent) 0, transparent 50%), radial-gradient(at 50% 90%, color-mix(in srgb, var(--brand) 10%, transparent) 0, transparent 50%); background-attachment: fixed; }
:root[data-mix9="1"] .btn.primary, :root[data-mix9="1"] .nav .add-tab .plus { background: linear-gradient(135deg, var(--brand), var(--brand2)); }

/* ---------- Appearance page ---------- */
.lk9 { margin-top: 12px; }
.lk9 h3 { margin-bottom: 8px; }
.st9-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.st9 { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.st9[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.st9 b { font-size: 14px; } .st9 small { font-size: 11.5px; color: var(--muted); }
.st9-pv { display: flex; gap: 4px; width: 100%; height: 38px; margin-bottom: 6px; padding: 5px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--brand2)); }
.st9-pv i { flex: 1; border-radius: 6px; background: rgba(255, 255, 255, .85); }
.st9-liquid .st9-pv i { background: rgba(255, 255, 255, .4); backdrop-filter: blur(4px); border: 1px solid rgba(255, 255, 255, .7); }
.st9-neon .st9-pv { background: #0b0b12; } .st9-neon .st9-pv i { background: transparent; border: 1.5px solid var(--brand); box-shadow: 0 0 8px var(--brand); }
.st9-mineral .st9-pv { background: linear-gradient(135deg, #8a8578, #57534e); } .st9-mineral .st9-pv i { background: #e7e5e4; }
.st9-soft .st9-pv i { background: var(--brand-soft); border-radius: 10px; } .st9-paper .st9-pv { background: #f4e9d8; } .st9-paper .st9-pv i { background: #fffaf2; border: 1px solid #e4d5bd; }
.sl9-box { display: grid; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.sl9 { display: grid; gap: 4px; }
.sl9 > span { display: flex; justify-content: space-between; font-size: 14px; }
.sl9 output { font-weight: 750; color: var(--brand-text); font-variant-numeric: tabular-nums; }
.sl9 input[type="range"] { width: 100%; accent-color: var(--brand); height: 28px; }
.sl9 small { color: var(--muted); font-size: 12px; }
.sw9-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.sw9 { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; text-align: left; cursor: pointer; min-width: 0; }
.sw9 span { width: 22px; height: 22px; flex: none; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.sw9[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); font-weight: 700; }
.mk9 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mk9 .btn { position: relative; justify-content: center; }
.mk9 input[type="color"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* ---------- profile ---------- */
.pf9 { margin: 12px 0; }
.pf9-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.pf9-ph { position: relative; width: 88px; height: 88px; flex: none; border-radius: 50%; overflow: visible; cursor: pointer; display: grid; place-items: center; background: linear-gradient(145deg, color-mix(in srgb, var(--brand) 60%, #fff), var(--brand)); color: var(--brand-ink); font-size: 34px; font-weight: 800; }
.pf9-ph img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.pf9-ph input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.pf9-ph em { position: absolute; right: -2px; bottom: -2px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 15px; background: var(--surface); box-shadow: 0 2px 8px rgba(0, 0, 0, .2); pointer-events: none; }
.pf9-f { flex: 1 1 220px; display: grid; gap: 10px; min-width: 0; }
.tb9-av span.has-ph { background-size: cover !important; background-position: center !important; }

/* ---------- duplicates ---------- */
.dpb9 { display: flex; align-items: center; gap: 12px; width: 100%; margin: 4px 0 14px; padding: 12px 14px; border-radius: 16px; font: inherit; text-align: left; cursor: pointer;
  border: 1.5px solid color-mix(in srgb, var(--brand) 45%, transparent); background: color-mix(in srgb, var(--brand) 10%, var(--surface)); color: var(--ink); }
.dpb9 > span:first-child { font-size: 22px; }
.dpb9 b { display: block; font-size: 14.5px; } .dpb9 small { display: block; font-size: 12.5px; color: var(--muted); }
.dpb9 > span:nth-child(2) { flex: 1; min-width: 0; }
.dpb9-go { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); font-weight: 750; font-size: 13px; }
.dp9-list { display: grid; gap: 8px; margin-top: 10px; }
.dp9 { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.dp9-h { flex: 1; min-width: 0; } .dp9-h b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .dp9-h small { font-size: 12px; color: var(--muted); }

/* ---------- tabs: Home, Review, +, Tools, AI ---------- */
@media (max-width: 959px) { .nav .badge { left: calc(50% + 4px); } }

/* ---------- brain splash and pull-to-refresh ---------- */
.sp9 { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: var(--bg); transition: opacity .5s ease; }
.sp9.out { opacity: 0; pointer-events: none; }
.sp9-b, .pr9-b { position: relative; display: grid; place-items: center; }
.sp9-b img { width: 180px; height: 180px; filter: drop-shadow(0 18px 40px color-mix(in srgb, var(--brand) 40%, transparent)); }
.sp9.out .sp9-b img { transform: translateY(-38vh) scale(.22); transition: transform .55s cubic-bezier(.5, 0, .2, 1); }
.sp9-ring { position: absolute; inset: -18px; border-radius: 50%; border: 3px solid var(--brand); opacity: 0; animation: sp9-ring 1.4s ease-out infinite; }
.sp9-ring.r2 { animation-delay: .45s; }
@keyframes sp9-in { 0% { transform: scale(1.9); opacity: 0; filter: blur(6px); } 40% { opacity: 1; filter: blur(0); } 70% { transform: scale(.94); } 100% { transform: scale(1); } }
@keyframes sp9-ring { 0% { transform: scale(.7); opacity: .7; } 100% { transform: scale(1.35); opacity: 0; } }
.pr9 { position: fixed; left: 50%; top: 50%; z-index: 150; transform: translate(-50%, -50%) scale(.6); opacity: 0; pointer-events: none; transition: opacity .2s, transform .3s cubic-bezier(.2, .9, .2, 1.2); }
.pr9.hint { opacity: calc(var(--pull, 0px) / 140px); transform: translate(-50%, -50%) scale(calc(.5 + var(--pull, 0px) / 280px)); }
.pr9.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.pr9-b img { width: 96px; height: 96px; border-radius: 24px; box-shadow: 0 14px 40px color-mix(in srgb, var(--brand) 45%, transparent); animation: pr9-think 1.1s ease-in-out infinite; }
@keyframes pr9-think { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.06) rotate(-2deg); } }
@media (prefers-reduced-motion: reduce) { .sp9 { display: none; } .pr9-b img, .sp9-ring { animation: none; } }

/* duplicates: open and compare copies */
.dp9 .dp9-h { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; background: none; border: 0; padding: 0; text-align: left; color: inherit; cursor: pointer; font: inherit; }
.dp9 .dp9-h .cover { width: 56px; height: 56px; flex: none; border-radius: 10px; overflow: hidden; }
.dp9-t { min-width: 0; display: grid; }
.dp9-t b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp9-t small { font-size: 12px; color: var(--muted); }
.dp9-see { font-size: 12px; font-weight: 600; color: var(--accent, #e85d11); margin-top: 2px; }
.dc9-back { display: inline-block; margin-bottom: 6px; font-weight: 600; }
.dc9-grid { display: grid; gap: 12px; margin-top: 10px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .dc9-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dc9 { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 8px; min-width: 0; align-content: start; }
.dc9-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.dc9-top small { color: var(--muted); }
.dc9-vid { width: 100%; max-height: 420px; border-radius: 10px; background: #000; display: block; }
.dc9-cov .cover { width: 100%; aspect-ratio: 4 / 5; max-height: 360px; border-radius: 10px; overflow: hidden; display: block; }
.dc9-cov .cover img { width: 100%; height: 100%; object-fit: cover; }
.dc9-ti { font-size: 15px; margin: 0; }
.dc9-dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: 13px; }
.dc9-dl dt { color: var(--muted); } .dc9-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.dc9-sum { font-size: 13px; line-height: 1.5; margin: 0; white-space: pre-line; max-height: 180px; overflow: auto; }
.dc9-act { display: flex; flex-wrap: wrap; gap: 8px; }
