:root{
  --bg:#0b0f17;
  --card:#121826;
  --muted:#9aa4b2;
  --text:#e7edf5;
  --line:#222b3d;
  --cta:#ff7e00;
  --good:#38d39f;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 10;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  border-bottom:1px solid var(--line);
  background: rgba(11,15,23,.92);
  backdrop-filter: blur(10px);
}

.brand{ font-weight:700; letter-spacing:.5px; }
.top-actions{ display:flex; gap:8px; }

.chip{
  border:1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding:8px 12px;
  border-radius:999px;
  cursor:pointer;
}
.chip.is-active{
  border-color: rgba(255,126,0,.55);
  background: rgba(255,126,0,.12);
}

.app{ padding: 14px 16px 40px; max-width: 980px; margin: 0 auto; }
.view{ display:none; }
.view.is-active{ display:block; }

.section-title h1{ margin: 6px 0 4px; font-size: 22px; }
.section-title p{ margin:0; color: var(--muted); font-size: 13px; }

.story-rail{
  margin-top:14px;
  display:flex;
  gap:12px;
  overflow:auto;
  padding: 6px 2px 10px;
}
.story-bubble{
  min-width: 72px;
  text-align:center;
  cursor:pointer;
}
.story-ring{
  width: 64px;
  height: 64px;
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(from 90deg, #ff7e00, #ff2d55, #7c3aed, #ff7e00);
  margin: 0 auto;
}
.story-ring .inner{
  width:100%;
  height:100%;
  border-radius:50%;
  background: #0e1422;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:700;
}
.story-name{
  margin-top:6px;
  font-size: 12px;
  color: var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:72px;
}

.cards{ margin-top: 12px; }
.h2{ margin: 16px 0 10px; font-size: 16px; }

.group-list{
  display:grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 820px){
  .group-list{ grid-template-columns: 1fr 1fr; }
}

.group-card{
  border:1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  display:flex;
  gap: 12px;
}
.group-card .thumb{
  width: 64px; height: 64px;
  border-radius: 14px;
  background: #0e1422;
  display:flex; align-items:center; justify-content:center;
  font-weight: 800;
}
.group-card .meta{ flex:1; min-width:0; }
.group-card .title{
  font-weight:700;
  display:flex;
  gap:10px;
  align-items:baseline;
}
.badge{
  font-size: 11px;
  color: var(--good);
  border:1px solid rgba(56,211,159,.35);
  background: rgba(56,211,159,.08);
  padding: 2px 8px;
  border-radius: 999px;
}
.group-card .sub{
  margin-top:6px;
  color: var(--muted);
  font-size: 13px;
}
.group-card .row{
  margin-top:10px;
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}
.group-card .open{
  margin-left:auto;
  align-self:flex-start;
  border:none;
  background: rgba(255,126,0,.14);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  cursor:pointer;
}

.viewer{
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #000;
  display:flex;
  flex-direction:column;
}
.viewer.is-hidden{ display:none; }

.viewer-top{
  padding: 12px 12px 8px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
}
.viewer-meta{ display:flex; gap:10px; align-items:center; }
.avatar{
  width: 38px; height: 38px;
  border-radius: 12px;
  background: #121826;
  display:flex; align-items:center; justify-content:center;
  font-weight: 900;
}
.viewer-name{ font-weight: 700; }
.viewer-info{ color: rgba(255,255,255,.7); font-size: 12px; margin-top: 2px; }

.iconbtn{
  border:1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.06);
  color: #fff;
  width: 38px; height: 38px;
  border-radius: 12px;
  cursor:pointer;
}

.progress{
  padding: 0 12px 8px;
}
.progress-bar{
  height: 3px;
  width: 0%;
  border-radius: 99px;
  background: #fff;
  opacity: .9;
}

.viewer-stage{
  position: relative;
  flex: 1;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}
.viewer-stage img{
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.viewer-caption{
  position:absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  color:#fff;
  text-shadow: 0 1px 14px rgba(0,0,0,.55);
  font-weight: 650;
  letter-spacing: .2px;
}

.tapzone{
  position:absolute;
  top:0; bottom:0;
  width: 50%;
  border: none;
  background: transparent;
  cursor:pointer;
}
.tapzone.left{ left:0; }
.tapzone.right{ right:0; }

.viewer-actions{
  display:flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(8px);
}
.cta{
  flex:1;
  border:none;
  background: var(--cta);
  color:#111;
  padding: 14px 14px;
  border-radius: 14px;
  font-weight: 800;
  cursor:pointer;
}
.ghost{
  flex:1;
  border:1px solid rgba(255,255,255,.24);
  background: rgba(255,255,255,.06);
  color:#fff;
  padding: 14px 14px;
  border-radius: 14px;
  font-weight: 700;
  cursor:pointer;
}

.toast{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 92px;
  background: rgba(18,24,38,.9);
  border: 1px solid rgba(255,255,255,.12);
  color:#fff;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
}
.toast.is-hidden{ display:none; }

.modal{
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0,0,0,.55);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 18px;
}
.modal.is-hidden{ display:none; }
.modal-card{
  width: min(420px, 100%);
  border:1px solid rgba(255,255,255,.12);
  background: rgba(18,24,38,.98);
  border-radius: 18px;
  padding: 16px;
}
.modal-title{ font-weight: 900; font-size: 18px; }
.modal-text{ margin-top: 10px; color: var(--muted); font-size: 13px; line-height:1.5; }
.modal-actions{ margin-top: 14px; display:flex; gap:10px; }

.match-list{
  margin-top: 10px;
  display:flex;
  flex-direction: column;
  gap: 10px;
}
.match-item{
  border:1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  display:flex;
  align-items:center;
  gap: 12px;
  cursor:pointer;
}
.match-item .pill{
  margin-left:auto;
  font-size: 12px;
  color: var(--muted);
}

.chat{
  margin-top: 14px;
  border:1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  overflow:hidden;
}
.chat.is-hidden{ display:none; }
.chat-head{
  padding: 12px 12px;
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:center;
  gap: 10px;
}
.link{
  border:none;
  background: transparent;
  color: rgba(255,255,255,.86);
  cursor:pointer;
  padding: 8px 6px;
}
.chat-title{ font-weight: 800; }
.chat-log{
  height: min(52vh, 520px);
  overflow:auto;
  padding: 12px;
  display:flex;
  flex-direction: column;
  gap: 8px;
}
.msg{
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 14px;
}
.msg.me{
  margin-left:auto;
  background: rgba(255,126,0,.18);
  border: 1px solid rgba(255,126,0,.35);
}
.msg.them{
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
}
.chat-form{
  display:flex;
  gap: 10px;
  padding: 12px;
  border-top:1px solid var(--line);
}
.chat-form input{
  flex:1;
  border: 1px solid rgba(255,255,255,.12);
  background: #0e1422;
  color:#fff;
  border-radius: 12px;
  padding: 12px 12px;
  outline: none;
}
.chat-form button{
  border:none;
  background: var(--cta);
  color:#111;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 900;
  cursor:pointer;
}
