:root {
  --bg: #0f1020;
  --bg2: #171935;
  --card: #21244b;
  --card2: #2a2e5f;
  --accent: #ff5da2;
  --accent2: #6c7bff;
  --good: #38d39f;
  --text: #f2f3ff;
  --muted: #a9adcf;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #2a2e6a 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(16px, 4vw, 40px);
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, rgba(15,16,32,0.95), rgba(15,16,32,0.6));
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 42px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); }
.brand h1 { margin: 0; font-size: clamp(20px, 3.5vw, 30px); letter-spacing: .5px; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

main { padding: 8px clamp(16px, 4vw, 40px) 60px; max-width: 1200px; margin: 0 auto; }
.section h2 { margin: 22px 0 4px; font-size: 20px; }
.hint { color: var(--muted); margin: 0 0 18px; font-size: 14px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.card {
  background: linear-gradient(160deg, var(--card), var(--card2));
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 20px 16px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s;
  position: relative;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--accent2); }
.card .thumb { font-size: 54px; line-height: 1; text-align: center; margin: 6px 0 12px; }
.card .title { font-weight: 700; font-size: 16px; }
.card .author { color: var(--muted); font-size: 12px; margin-top: 3px; }
.card .badge {
  position: absolute; top: 10px; right: 10px;
  font-size: 10px; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(108,123,255,.25); color: #c9cfff;
}
.card .badge.own { background: rgba(56,211,159,.22); color: #b6f4dd; }
.card .del {
  position: absolute; bottom: 8px; right: 8px;
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; font-size: 13px; opacity: 0; transition: opacity .12s;
}
.card:hover .del { opacity: .7; }
.card .del:hover { color: var(--accent); opacity: 1; }

.loading { color: var(--muted); padding: 30px; }

.btn {
  border: none; border-radius: 12px; padding: 11px 16px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .1s, filter .1s; color: #fff;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-ghost { background: rgba(255,255,255,.08); }
.btn-ghost:hover { background: rgba(255,255,255,.16); }

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 24px; }

/* Modaly */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(6,7,18,.72);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: 100%;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.play-box { max-width: 720px; }
.make-box { max-width: 1050px; height: min(88vh, 760px); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; font-weight: 700; font-size: 17px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.play-frame {
  width: 100%; height: min(72vh, 620px); border: 0; background: #000; display: block;
}

/* Vibecoding */
.make-body { display: flex; flex: 1; min-height: 0; }
.chat-side {
  width: 42%; min-width: 300px;
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.07);
}
.chat { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 14px; border-radius: 14px; max-width: 92%; font-size: 14px; line-height: 1.45; }
.msg.bot { background: var(--card); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.me { background: linear-gradient(135deg, var(--accent2), #4b57c9); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.working { color: var(--muted); font-style: italic; }
.msg.err { background: #532; color: #ffd7c9; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid rgba(255,255,255,.07); }
.chat-form input {
  flex: 1; padding: 11px 14px; border-radius: 12px; border: 1px solid rgba(255,255,255,.12);
  background: var(--bg); color: var(--text); font-size: 14px;
}
.chat-form input:focus { outline: 2px solid var(--accent2); }
.chat-tips { padding: 0 12px 12px; color: var(--muted); font-size: 11.5px; }

.preview-side { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 12px; gap: 10px; }
.preview-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.preview-frame {
  flex: 1; width: 100%; border: 0; border-radius: 12px; background: #000;
  min-height: 240px;
}
.preview-frame.empty { background: repeating-linear-gradient(45deg, #1b1d3d, #1b1d3d 12px, #191b38 12px, #191b38 24px); }
.save-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.save-row input {
  padding: 9px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12);
  background: var(--bg); color: var(--text); font-size: 13px; flex: 1; min-width: 110px;
}
.emoji-pick {
  font-size: 22px; width: 44px; height: 40px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12); background: var(--bg); cursor: pointer;
}
.emoji-pop {
  position: fixed; z-index: 60; background: var(--card2);
  border: 1px solid rgba(255,255,255,.14); border-radius: 12px; padding: 8px;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; box-shadow: var(--shadow);
}
.emoji-pop.hidden { display: none; }
.emoji-pop button { font-size: 20px; background: transparent; border: none; cursor: pointer; padding: 4px; border-radius: 8px; }
.emoji-pop button:hover { background: rgba(255,255,255,.12); }

@media (max-width: 760px) {
  .make-box { height: 92vh; max-width: 100%; }
  .make-body { flex-direction: column; }
  .chat-side { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid rgba(255,255,255,.07); max-height: 44%; }
  .preview-side { min-height: 0; }
}
