[hidden] { display: none !important; }
:root {
  --bg1: #393849;
  --bg2: #1d1c28;
  --card1: #1b1a26;
  --card2: #383748;
  --text: #ffffff;
  --muted: #a7a6b8;
  --blue: #5552ff;
  --purple: #a855f7;
  --pink: #f04e98;
  --red: #ef5350;
  --bar: #000000;
  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Comfortaa', system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg1), var(--bg2)) fixed;
  min-height: 100vh;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .09;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' fill='none' stroke='%23ffffff' stroke-width='3'%3E%3Cpath d='M30 20l40 20-34 24z'/%3E%3Ccircle cx='150' cy='40' r='18'/%3E%3Crect x='190' y='110' width='34' height='34'/%3E%3Cpath d='M40 150l16 16M56 150l-16 16'/%3E%3Cpath d='M100 120c8-10 16 10 24 0s16 10 24 0'/%3E%3Cpath d='M150 190l30 18-30 18z'/%3E%3Cpath d='M20 220a18 18 0 0 1 36 0'/%3E%3Cpath d='M120 70v30'/%3E%3C/svg%3E");
  background-size: 240px 240px;
}
button, input { font-family: inherit; }
a { color: inherit; }

#splash {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--bg1), var(--bg2)); transition: opacity .3s;
}
#splash img { width: min(60vw, 340px); }
#splash.gone { opacity: 0; pointer-events: none; }

#bar {
  position: sticky; top: 0; z-index: 10; height: calc(64px + var(--safe-top)); padding-top: var(--safe-top);
  display: flex; align-items: center; justify-content: space-between; background: var(--bar);
}
#barTitle { flex: 1; text-align: center; font-size: 22px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bar-logo { height: 30px; vertical-align: middle; }
.bar-right { display: flex; }
.icon-btn { background: none; border: 0; color: #fff; width: 56px; height: 56px; display: grid; place-items: center; cursor: pointer; padding: 0; }
.icon-btn svg { width: 28px; height: 28px; }

#menu { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); }
.menu-panel {
  width: min(82vw, 320px); height: 100%; background: var(--card1); padding: calc(24px + var(--safe-top)) 22px 22px;
  display: flex; flex-direction: column; gap: 4px; animation: slidein .2s ease-out;
}
.menu-logo { width: 150px; margin: 0 0 18px 4px; }
.menu-panel a { text-decoration: none; padding: 14px 6px; font-size: 17px; border-bottom: 1px solid #2c2b3b; }
@keyframes slidein { from { transform: translateX(-100%); } }

main { max-width: 560px; margin: 0 auto; padding: 22px 20px calc(110px + var(--safe-bottom)); position: relative; }
.page-logo { display: block; width: 170px; margin: 0 auto 14px; }
h1 { font-size: 30px; font-weight: 700; margin: 6px 0 14px; line-height: 1.2; }
h2 { font-size: 22px; margin: 18px 0 10px; }
.sub { color: var(--muted); text-align: center; font-size: 19px; margin: 0 0 18px; }
p.body { font-size: 19px; line-height: 1.45; white-space: pre-line; }

/* home */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.tile {
  aspect-ratio: 9 / 15.5; border-radius: var(--radius); background: linear-gradient(180deg, var(--card1), var(--card2));
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 30px 12px 26px;
  text-decoration: none; text-align: center; font-size: 17px; line-height: 1.25; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.tile svg { width: 62%; height: auto; margin-top: 8%; }
.tile:active { transform: scale(.98); }

/* forms */
.field { margin: 0 0 20px; position: relative; }
.field label { display: block; color: var(--muted); font-size: 15px; margin-bottom: 8px; }
.input-row { display: flex; gap: 10px; align-items: stretch; }
.input-row input {
  flex: 1; min-width: 0; font-size: 19px; padding: 14px 16px; border-radius: 14px; border: 2px solid #4a495d;
  background: #15141e; color: #fff; outline: none;
}
.input-row input:focus { border-color: var(--blue); }
.input-row input.ok { border-color: #3bd38a; }
.toggle { display: flex; border-radius: 14px; overflow: hidden; border: 2px solid #4a495d; flex: none; }
.toggle button {
  background: #15141e; color: var(--muted); border: 0; font-size: 18px; font-weight: 700; padding: 0 16px; min-width: 64px; cursor: pointer;
}
.toggle button.on[data-g="M"] { background: var(--blue); color: #fff; }
.toggle button.on[data-g="F"] { background: var(--purple); color: #fff; }
.toggle.wide { width: 100%; }
.toggle.wide button { flex: 1; padding: 14px 0; }
.suggest {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 5; margin-top: 4px; background: #15141e; border: 2px solid var(--blue);
  border-radius: 14px; max-height: 260px; overflow-y: auto; list-style: none; padding: 4px 0; margin-left: 0;
}
.suggest li { padding: 12px 16px; font-size: 18px; cursor: pointer; }
.suggest li:hover, .suggest li.active { background: #26254a; }
.hint { color: var(--muted); font-size: 14px; margin-top: 6px; }
.err { color: #ff8a8a; font-size: 15px; margin-top: 6px; min-height: 1em; }

.btn {
  display: block; width: 100%; border: 0; border-radius: 18px; background: var(--blue); color: #fff; font-size: 19px;
  padding: 18px; cursor: pointer; text-align: center; text-decoration: none; margin: 12px 0;
}
.btn.secondary { background: #2c2b3b; }
.btn-row { display: flex; gap: 12px; }
.btn-row .btn { flex: 1; }
.fixed-bottom { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 20px calc(14px + var(--safe-bottom)); background: linear-gradient(transparent, var(--bg2) 35%); z-index: 4; }
.fixed-bottom .btn { max-width: 520px; margin: 0 auto; }

/* A to Z browser */
.az { display: flex; overflow-x: auto; gap: 6px; padding: 6px 0 10px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.az::-webkit-scrollbar { display: none; }
.az button {
  flex: none; width: 44px; height: 44px; border-radius: 12px; border: 0; background: #2c2b3b; color: #fff; font-size: 18px;
  font-weight: 700; cursor: pointer; scroll-snap-align: center;
}
.az button.on { background: var(--blue); }
.az-nav { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 8px; color: var(--muted); }
.az-nav button { background: #2c2b3b; border: 0; color: #fff; border-radius: 12px; width: 48px; height: 40px; font-size: 20px; cursor: pointer; }

/* name lists */
.list { list-style: none; padding: 0; margin: 0; }
.list > li { border-bottom: 1px solid #3a394c; }
.list .row { display: flex; align-items: center; gap: 8px; }
.az-list a.name { text-decoration: none; display: block; }
.list .name { flex: 1; background: none; border: 0; color: #fff; text-align: left; font-size: 21px; padding: 16px 4px; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.list .name .chev { width: 18px; height: 18px; transition: transform .2s; flex: none; display: grid; }
.list .name .chev svg { width: 18px; height: 18px; }
.compat-link.fav { font-size: 26px; color: #c9b8ff; }
.list li.open .name .chev { transform: rotate(180deg); }
.list .desc { font-size: 17px; line-height: 1.45; color: #e6e5f0; padding: 0 4px 16px 32px; display: none; }
.list li.open .desc { display: block; }
.compat-link { flex: none; width: 46px; height: 46px; border-radius: 12px; border: 0; background: none; color: var(--pink); cursor: pointer; display: grid; place-items: center; }
.compat-link svg { width: 26px; height: 26px; }
.tag { display: inline-block; padding: 8px 18px; border-radius: 10px; font-size: 18px; }
.tag.M { background: var(--blue); }
.tag.F { background: var(--purple); }
.tag.blue { background: var(--blue); }
.rule { height: 4px; width: 50%; background: var(--purple); border: 0; margin: 22px 0; border-radius: 2px; }
.rule.white { background: #fff; }

/* compat results */
.pair { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 10px 0 6px; }
.pair .who { font-size: 28px; word-break: break-word; }
.pair .who.right { text-align: right; }
.pair .who .tag { margin-top: 10px; font-size: 16px; }
.pair svg { width: 90px; height: 90px; color: var(--red); }
.score { font-size: 54px; font-weight: 700; margin: 6px 0 12px; }

/* kiss marry avoid header */
.kma-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 10px; touch-action: pan-y; }
.kma-head button.arrow { background: #2c2b3b; border: 0; color: #fff; border-radius: 12px; width: 48px; height: 48px; font-size: 22px; cursor: pointer; }
.kma-title { flex: 1; text-align: center; }
.kma-title svg { width: 76px; height: 76px; color: var(--blue); display: block; margin: 0 auto 6px; }
.kma-title .t { font-size: 26px; font-weight: 700; }
.kma-dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 8px; }
.kma-dots span { width: 9px; height: 9px; border-radius: 50%; background: #4a495d; }
.kma-dots span.on { background: var(--purple); }
.for-line { text-align: center; color: var(--muted); margin-bottom: 8px; }

/* favourites */
.fav-group h2 { display: flex; justify-content: space-between; align-items: baseline; }
.fav-group h2 small { color: var(--muted); font-size: 14px; }
.fav-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #3a394c; font-size: 18px; }
.fav-item a { text-decoration: none; flex: 1; }
.fav-item button { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; width: 40px; }
.empty { color: var(--muted); text-align: center; margin-top: 40px; font-size: 18px; }

.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; }
.modal-card { background: var(--card1); width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto; border-radius: 24px 24px 0 0; padding: 18px 22px calc(28px + var(--safe-bottom)); position: relative; }
.modal-close { position: absolute; right: 6px; top: 6px; font-size: 32px; }
.modal-body h2 { margin-top: 8px; padding-right: 40px; }
.modal-body h3 { font-size: 16px; color: var(--purple); margin: 20px 0 6px; letter-spacing: .04em; }
.modal-body p { font-size: 16px; line-height: 1.5; }
.modal-body a { color: #b9a0ff; }

#toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-bottom)); transform: translateX(-50%); background: #fff; color: #111; padding: 12px 20px; border-radius: 12px; font-size: 16px; z-index: 40; max-width: 90vw; text-align: center; }
.loading { text-align: center; color: var(--muted); margin-top: 40px; }
textarea { width: 100%; min-height: 90px; font-family: inherit; font-size: 17px; padding: 12px 14px; border-radius: 14px; border: 2px solid #4a495d; background: #15141e; color: #fff; }
