:root{
  --bg:#0b1020;
  --panel:rgba(18,25,45,.78);
  --panel-2:rgba(25,34,59,.9);
  --text:#f8fafc;
  --muted:#94a3b8;
  --accent:#38bdf8;
  --accent-2:#6366f1;
  --accent-soft:rgba(56,189,248,.16);
  --border:rgba(148,163,184,.16);
  --danger:#fb7185;
  --success:#34d399;
  --shadow:0 12px 35px rgba(0,0,0,.25);
  --alert:#ff0034b4;
}

[data-theme="light"]{
  --bg:#eef5ff;
  --panel:rgba(255,255,255,.88);
  --panel-2:rgba(248,250,252,.96);
  --text:#0f172a;
  --muted:#64748b;
  --accent:#0284c7;
  --accent-2:#4f46e5;
  --accent-soft:rgba(2,132,199,.11);
  --border:rgba(15,23,42,.10);
  --shadow:0 12px 35px rgba(30,64,175,.10);
  --alert:#ff003480;
}

*{
  box-sizing:border-box;
}
html{
  scroll-behavior:smooth;
}
body{
  margin:0;
  color:var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(
      circle at 12% 14%,
      rgba(56,189,248,.10),
      transparent 25%
    ),
    radial-gradient(
      circle at 87% 18%,
      rgba(99,102,241,.11),
      transparent 27%
    ),
    linear-gradient(
      145deg,
      var(--bg),
      color-mix(in srgb,var(--bg) 82%,#101827)
    );
  min-height:100vh;
  transition:background .3s ease,color .3s ease;
}
body::before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  background-image:
    linear-gradient(
      rgba(255,255,255,.018) 1px,
      transparent 1px
    ),
    linear-gradient(
      90deg,
      rgba(255,255,255,.018) 1px,
      transparent 1px
    );
  background-size:28px 28px;
  mask-image:
    linear-gradient(
      to bottom,
      black,
      transparent 85%
    );
}
.container{
  width:min(1080px,calc(100% - 20px));
  margin:auto;
  padding:14px 0 26px;
}
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:12px;
}
.logo{
  width:44px;
  height:44px;
  border-radius:50%;
  overflow:hidden;
}
.logo img{
  width:100%;
  height:100%;
  object-fit:cover;
}
.brand{
  display:flex;
  align-items:center;
  gap:9px;
}
.brand-mark{
  width:38px;
  height:38px;
  border-radius:11px;
  display:grid;
  place-items:center;
  font-weight:900;
  background:
    linear-gradient(
      135deg,
      var(--accent),
      var(--accent-2)
    );
  color:#fff;
  box-shadow:
    0 8px 20px rgba(59,130,246,.20);
}
.brand h1{
  font-size:1rem;
  margin:0;
  line-height:1.2;
}
.brand p{
  font-size:.72rem;
  color:var(--muted);
  margin:2px 0 0;
}
.tabs{
  display:flex;
  gap:5px;
  padding:5px;
  border:1px solid var(--border);
  background:var(--panel);
  backdrop-filter:blur(18px);
  border-radius:13px;
  box-shadow:var(--shadow);
}
.tab{
  border:0;
  background:transparent;
  color:var(--muted);
  padding:8px 11px;
  border-radius:9px;
  font-size:.78rem;
  font-weight:750;
  cursor:pointer;
  transition:.2s ease;
}
.tab:hover{
  color:var(--text);
}
.tab:active{
  transform:scale(.97);
}
.tab.active{
  color:var(--text);
  background:var(--accent-soft);
  box-shadow:
    inset 0 0 0 1px var(--border);
}
.view{
  display:none;
}
.view.active{
  display:block;
}
.grid{
  display:grid;
  grid-template-columns:1.05fr .95fr;
  gap:12px;
}
.card{
  background:var(--panel);
  backdrop-filter:blur(18px);
  border:1px solid var(--border);
  border-radius:18px;
  padding:14px;
  box-shadow:var(--shadow);
}
.card h2,
.card h3{
  margin:0;
}
.card h2{
  font-size:.95rem;
  line-height:1.3;
}
.sub{
  color:var(--muted);
  font-size:.78rem;
  line-height:1.45;
  margin:5px 0 12px;
}
.row{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  align-items:center;
}
label{
  display:block;
  font-size:.75rem;
  font-weight:750;
  margin-bottom:5px;
}
input,
select,
button,
textarea{
  font:inherit;
}
input,
select,
textarea{
  width:100%;
  border:1px solid var(--border);
  background:var(--panel-2);
  color:var(--text);
  outline:none;
  border-radius:10px;
  padding:9px 10px;
  font-size:.82rem;
  transition:
    border-color .2s ease,
    box-shadow .2s ease;
}
input:focus,
select:focus,
textarea:focus{
  border-color:
    color-mix(
      in srgb,
      var(--accent) 70%,
      transparent
    );
  box-shadow:
    0 0 0 3px var(--accent-soft);
}
.field{
  flex:1;
  min-width:160px;
}
.inline{
  display:flex;
  gap:8px;
  align-items:end;
}
.inline .field{
  min-width:120px;
}
.btn{
  border:0;
  border-radius:10px;
  padding:9px 12px;
  font-size:.8rem;
  font-weight:800;
  cursor:pointer;
  transition:
    transform .15s ease,
    opacity .2s ease,
    filter .2s ease,
    background .2s ease;
}
.btn:hover{
  transform:translateY(-1px);
  filter:brightness(1.04);
}
.btn:active{
  transform:scale(.97);
}
.btn.primary{
  background:
    linear-gradient(
      135deg,
      var(--accent),
      var(--accent-2)
    );
  color:#fff;
}
.btn.secondary{
  background:var(--accent-soft);
  color:var(--text);
  border:1px solid var(--border);
}
.btn.ghost{
  background:transparent;
  color:var(--muted);
  border:1px solid var(--border);
}
.btn.danger{
  background:rgba(244,63,94,.12);
  color:var(--danger);
  border:1px solid rgba(244,63,94,.17);
}
.btn:disabled{
  opacity:.45;
  cursor:not-allowed;
  transform:none;
  filter:none;
}
.mode-toggle{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:6px;
  background:var(--panel-2);
  padding:5px;
  border:1px solid var(--border);
  border-radius:12px;
  margin:10px 0;
}
.mode-toggle button{
  border:0;
  background:transparent;
  color:var(--muted);
  padding:8px;
  border-radius:9px;
  font-size:.78rem;
  font-weight:800;
  cursor:pointer;
}
.mode-toggle button.active{
  background:var(--accent-soft);
  color:var(--text);
}
.number-box{
  display:flex;
  align-items:center;
  gap:6px;
  background:var(--panel-2);
  border:1px solid var(--border);
  border-radius:12px;
  padding:5px;
}
.number-box button{
  width:34px;
  height:34px;
  border:0;
  border-radius:9px;
  background:var(--accent-soft);
  color:var(--text);
  font-size:1rem;
  font-weight:900;
  cursor:pointer;
}
.number-box button:active{
  transform:scale(.94);
}
.number-box input{
  border:0;
  background:transparent;
  text-align:center;
  padding:6px;
  box-shadow:none;
}
.name-list{
  margin-top:10px;
  display:grid;
  gap:6px;
  max-height:460px;
  overflow:auto;
  padding-right:2px;
}
.name-row{
  display:flex;
  gap:6px;
  align-items:center;
}
.name-index{
  width:30px;
  height:30px;
  display:grid;
  place-items:center;
  flex:none;
  border-radius:8px;
  background:var(--accent-soft);
  color:var(--text);
  font-size:.7rem;
  font-weight:900;
}
.name-row input{
  padding:8px 10px;
  font-size:.8rem;
}
.tiny-note{
  font-size:.7rem;
  color:var(--muted);
  margin-top:7px;
}
.status{
  margin-top:9px;
  padding:8px 10px;
  border-radius:10px;
  background:var(--accent-soft);
  color:var(--text);
  font-size:.74rem;
  border:1px solid var(--border);
  line-height:1.4;
}
.wheel-wrap{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:10px;
  min-height:500px;
}
.wheel-stage{
  width:min(380px,82vw);
  aspect-ratio:1/1;
  position:relative;
  display:grid;
  place-items:center;
  filter:
    drop-shadow(
      0 20px 35px rgba(0,0,0,.25)
    );
}
.wheel{
  width:100%;
  height:100%;
  border-radius:50%;
  position:relative;
  overflow:hidden;
  border:
    7px solid
    color-mix(
      in srgb,
      var(--text) 7%,
      transparent
    );
  background:transparent;
  filter:
    drop-shadow(
      0 20px 35px rgba(0,0,0,.25)
    );
}
.wheel canvas{
  width:100%;
  height:100%;
  display:block;
  border-radius:50%;
  transform:rotate(0deg);
  transition:
    transform 4.6s
    cubic-bezier(.17,.88,.18,1);
}
.wheel-center{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  z-index:3;
  width:60px;
  height:60px;
  border-radius:50%;
  display:grid;
  place-items:center;
  background:
    linear-gradient(
      145deg,
      var(--accent-2),
      var(--accent)
    );
  color:#fff;
  font-size:.75rem;
  font-weight:950;
  border:5px solid rgba(255,255,255,.88);
  box-shadow:
    0 8px 22px rgba(30,41,59,.25);
  user-select:none;
  pointer-events:none;
}
.pointer{
  position:absolute;
  z-index:8;
  top:-11px;
  left:50%;
  transform:translateX(-50%);
  width:0;
  height:0;
  border-left:14px solid transparent;
  border-right:14px solid transparent;
  border-top:30px solid var(--danger);
  filter:
    drop-shadow(
      0 6px 8px rgba(0,0,0,.22)
    );
}
.pointer::after{
  content:"";
  position:absolute;
  left:-7px;
  top:-29px;
  width:14px;
  height:8px;
  border-radius:8px;
  background:var(--danger);
}
.wheel-badge{
  position:absolute;
  right:2px;
  bottom:8px;
  z-index:5;
  padding:6px 8px;
  border-radius:9px;
  background:var(--panel);
  border:1px solid var(--border);
  backdrop-filter:blur(12px);
  font-size:.65rem;
  font-weight:800;
  color:var(--muted);
}
.result{
  width:100%;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
}
.result-box{
  background:var(--panel-2);
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px;
  min-height:70px;
}
.result-box .k{
  font-size:.68rem;
  color:var(--muted);
  margin-bottom:4px;
}
.result-box .v{
  font-size:1.1rem;
  font-weight:950;
  overflow-wrap:anywhere;
}
.spin-btn{
  width:100%;
  font-size:.85rem;
  padding:11px;
  border-radius:12px;
}
.history{
  width:100%;
  max-height:150px;
  overflow:auto;
  display:flex;
  flex-wrap:wrap;
  gap:5px;
}
.pill{
  padding:6px 8px;
  border-radius:999px;
  background:var(--accent-soft);
  border:1px solid var(--border);
  font-size:.7rem;
  font-weight:800;
}
.group-tools{
  display:grid;
  grid-template-columns: 1fr 1fr auto;
  gap:8px;
  align-items:end;
  margin:12px 0;
}
.groups-grid{
  display:grid;
  grid-template-columns:
    repeat(
      auto-fit,
      minmax(200px,1fr)
    );
  gap:8px;
}
.group-card{
  background:var(--panel-2);
  border:1px solid var(--border);
  border-radius:14px;
  padding:11px;
}
.group-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:7px;
  margin-bottom:7px;
}
.group-title{
  font-size:.85rem;
  font-weight:950;
}

.count-badge{
  font-size:.65rem;
  color:var(--muted);
  padding:4px 6px;
  border-radius:999px;
  background:var(--accent-soft);
}
.member{
  display:flex;
  align-items:center;
  gap:7px;
  padding:6px 0;
  border-bottom:1px solid var(--border);
  font-size:.78rem;
}
.member:last-child{
  border-bottom:0;
}
.member-num{
  width:22px;
  color:var(--muted);
  font-size:.68rem;
}
.empty{
  padding:22px 10px;
  text-align:center;
  color:var(--muted);
  font-size:.76rem;
}
.toast{
  position:fixed;
  left:50%;
  bottom:18px;
  transform:translate(-50%,20px);
  opacity:0;
  pointer-events:none;
  background:var(--text);
  color:var(--bg);
  padding:9px 12px;
  border-radius:11px;
  font-size:.76rem;
  font-weight:850;
  transition:.25s;
  z-index:50;
  box-shadow:var(--shadow);
  max-width:
    calc(100vw - 30px);
  text-align:center;
}
.toast.show{
  opacity:1;
  transform:
    translate(-50%,0);
}
@media (max-width:900px){
  .grid{
    grid-template-columns:1fr;
  }
  .wheel-wrap{
    min-height:unset;
  }
}
@media (max-width:640px){
  .container{
    width:calc(100% - 14px);
    padding-top:9px;
  }
  .topbar{
    align-items:flex-start;
    flex-direction:column;
    gap:8px;
  }
  .brand-mark{
    width:34px;
    height:34px;

    border-radius:9px;
  }
  .brand h1{
    font-size:.9rem;
  }
  .brand p{
    font-size:.68rem;
  }
  .tabs{
    width:100%;
    gap:3px;
    overflow:auto;
    -webkit-overflow-scrolling:touch;
  }
  .tab{
    flex:1;
    min-width:max-content;
    white-space:nowrap;
    padding:8px 7px;
    font-size:.7rem;
  }
  .card{
    padding:11px;
    border-radius:15px;
  }
  .card h2{
    font-size:.88rem;
  }
  .sub{
    font-size:.72rem;
  }
  .field{
    min-width:130px;
  }
  .wheel-stage{
    width:min(320px,84vw);
  }
  .wheel-wrap{
    min-height:unset;
  }
  .group-tools{
    grid-template-columns:1fr 1fr;
  }
  .group-tools .btn{
    grid-column:1/-1;
  }
  .groups-grid{
    grid-template-columns:1fr;
  }
  .result{
    grid-template-columns:1fr 1fr;
  }
  .result-box .v{
    font-size:1rem;
  }
}

@media (max-width:380px){

  .container{
    width:calc(100% - 10px);
  }
  .card{
    padding:9px;
  }
  .tab{
    font-size:.66rem;
    padding:7px 6px;
  }
  .wheel-stage{
    width:min(290px,82vw);
  }
  .wheel-center{
    width:54px;
    height:54px;
    font-size:.68rem;
  }
  .result{
    grid-template-columns:1fr;
  }
  .group-tools{
    grid-template-columns:1fr;
  }
  .group-tools .btn{
    grid-column:auto;
  }
}
.export-buttons{
  display:flex;
  gap:8px;
  margin-top:12px;
}

.export-buttons .btn{
  flex:1;
}
.btn-png {
  border-color: rgba(34, 197, 94, .35);
}

.btn-png:hover {
  background: rgba(34, 197, 94, .12);
}

.btn-png:active {
  transform: scale(.98);
}

@media(max-width:640px){
  .export-buttons{
    flex-direction:column;
  }
}

footer {
      margin-top: 24px;
      padding-top: 20px;
      border-top: 1px solid var(--border);
      color: var(--muted);
      font-size: 10.5px;
      line-height: 1.6;
      text-align:center;
    }

    footer strong {
      color: var(--text);
      font-weight: 700;
    }
    
   .datetime {
      margin-top: 3px;
      font-size: 10px;
      color: var(--muted);
      opacity: 0.85;
    }
    .copyright {
      margin-top: 4px;
    }

.security-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(
      circle at 50% 20%,
      rgba(56,189,248,.12),
      transparent 35%
    ),
    var(--bg);
  backdrop-filter: blur(20px);
}

.security-card {
  width: min(390px, 100%);
  padding: 28px 22px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.security-card h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.security-card p {
  margin: 0 auto 18px;
  max-width: 300px;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.5;
}

.security-card .btn {
  width: 100%;
}

.security-status {
  min-height: 18px;
  margin-top: 12px;
  color: var(--muted);
  font-size: .72rem;
}

.security-screen.hidden {
  display: none;
}
hr {
  border: none;
  height: 2px;
  background: #91919124;
}
.title-editor {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 10px 0 14px;
}

.title-editor input {
  flex: 1;
  min-width: 0;
}

.title-editor button {
  flex: 0 0 auto;
  width: auto;
  white-space: nowrap;
}