:root {
  --paper: #f4fafc;
  --water: #7ec7d8;
  --deep: #1f6d86;
  --ink: #163246;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  color: var(--ink);
  background: var(--paper) url("Img/bg.jpg") center / cover no-repeat;
  font-family: "Zen Maru Gothic", sans-serif;
}

.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 18px 20px 0;
}

.top-spacer { justify-self: end; }

.pill,
.top h1,
.back,
.emote-open,
.actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--deep);
  color: var(--paper);
  font: inherit;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.top h1 { justify-self: center; font-size: 22px; }

.back { justify-self: start; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  height: calc(100vh - 72px);
  padding: 12px 16px 16px;
}

.pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 18px;
  background: rgb(244 250 252 / 62%);
  border: 1px solid rgb(31 109 134 / 22%);
  border-radius: 20px;
  box-shadow: 0 12px 30px rgb(22 50 70 / 10%);
}

.emote-open, .actions button {
  width: auto;
  border: 0;
  border-radius: 999px;
  background: var(--deep);
  color: var(--paper);
  font-weight: 700;
  padding: 8px 16px;
  cursor: pointer;
}

.empty {
  width: 100%;
  margin: 8px 0;
  text-align: center;
  color: var(--deep);
}

.clip-head {
  margin-top: 8px;
  padding: 8px 10px;
  color: var(--deep);
  font-size: 13px;
  font-weight: 700;
  background: rgb(126 199 216 / 28%);
  border-radius: 10px 10px 0 0;
}

.clip-list {
  flex: 1;
  overflow: auto;
  margin-top: 0;
  padding: 8px;
  background: rgb(255 255 255 / 28%);
  border-radius: 0 0 12px 12px;
}

.search, .form label, .emote-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
}

input, textarea, button { font: inherit; color: var(--ink); }

.search input, .form input, .form textarea, .emote-search {
  border: 1px solid rgb(31 109 134 / 35%);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgb(255 255 255 / 92%);
}

.picks { margin-top: 8px; }

.picks button {
  border: 1px solid var(--deep);
  border-radius: 10px;
  background: white;
  padding: 8px 10px;
  cursor: pointer;
}

.picked-name, .end-preview, .status, .empty, .emote-status { margin: 8px 0; }

.clip-head[hidden] { display: none; }

.clip-head, .clip-row {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.5fr;
  gap: 8px;
  align-items: center;
}

.clip-head {
  margin-top: 8px;
  padding: 8px 10px;
  color: var(--deep);
  font-size: 13px;
  font-weight: 700;
  background: rgb(126 199 216 / 28%);
  border-radius: 10px 10px 0 0;
}

.clip-list {
  flex: 1;
  overflow: auto;
  margin-top: 0;
  padding: 8px;
  background: rgb(255 255 255 / 28%);
  border-radius: 0 0 12px 12px;
}

.clip-row {
  width: 100%;
  margin: 0 0 8px;
  padding: 10px;
  text-align: left;
  background: rgb(244 250 252 / 90%);
  border: 1px solid rgb(126 199 216 / 80%);
  border-radius: 12px;
  cursor: pointer;
}

.clip-row span:first-child { font-weight: 700; }

.form { overflow: auto; }

.time {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
  border: 1px solid rgb(126 199 216 / 90%);
  border-radius: 12px;
}

.time label input { width: 100%; }

.line { min-height: 120px; }

.emote-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form .actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.actions button {
  background: var(--deep);
  color: var(--paper);
  border: 0;
  border-radius: 999px;
  font-weight: 700;
}

.text-button {
  width: auto;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--deep);
  background: white;
  cursor: pointer;
}

.emote-row { display: flex; align-items: center; gap: 10px; }
.emote-chosen { display: flex; align-items: center; gap: 10px; }

.emote-chosen img, .emote-grid img { width: 72px; height: 72px; object-fit: contain; }

.emote-panel {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 45%);
  display: grid;
  place-items: center;
  padding: 24px;
}

.emote-panel[hidden] { display: none; }

.emote-card {
  width: min(880px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: rgb(255 255 255 / 94%);
  border-radius: 18px;
}

.emote-head { display: flex; justify-content: space-between; align-items: center; }

.emote-head h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
}

.emote-search { margin-top: 10px; }

.emote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  overflow: auto;
  min-height: 0;
}

.emote-grid button {
  padding: 8px;
  text-align: center;
  background: var(--paper);
  border: 1px solid rgb(31 109 134 / 25%);
  border-radius: 12px;
  cursor: pointer;
}

.emote-preview { display: grid; justify-items: center; gap: 8px; }
.emote-preview[hidden] { display: none; }
.emote-preview img {
  width: 220px;
  height: 220px;
  object-fit: contain;
  background: #163246;
  border-radius: 12px;
}

.emote-preview.is-loading img {
  background:
    linear-gradient(90deg, rgb(255 255 255 / 0%), rgb(255 255 255 / 22%), rgb(255 255 255 / 0%)) center / 40% 100% no-repeat,
    #163246;
  animation: emote-loading 1s linear infinite;
}

.emote-preview.is-loading .emote-preview-name::after {
  content: "";
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-left: 8px;
  border: 2px solid var(--deep);
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -1px;
  animation: emote-spin 0.7s linear infinite;
}

@keyframes emote-loading {
  from { background-position: -40% 0, 0 0; }
  to { background-position: 140% 0, 0 0; }
}

@keyframes emote-spin { to { transform: rotate(360deg); } }

.player-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 80%);
}

.player-layer[hidden] { display: none; }

.player {
  width: min(520px, calc(100% - 48px));
  padding: 24px;
  color: var(--ink);
  background: var(--paper);
  border-radius: 18px;
}

.player__title {
  margin: 0;
  font-family: "Shippori Mincho", serif;
  font-size: 28px;
}

.player__stage {
  height: 360px;
  margin: 16px 0;
  background: #163246;
  border-radius: 12px;
}

.player__anim { width: 100%; height: 100%; object-fit: contain; }

.player__line { margin: 0 0 16px; }

.player__controls { display: flex; align-items: center; gap: 8px; }

.player__controls button {
  height: 44px;
  margin: 0;
  padding: 0 16px;
  color: var(--paper);
  background: var(--deep);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.player__controls [data-act="detail"] { margin-left: auto; }

.player__seek { display: flex; gap: 8px; align-items: center; margin: 0 0 12px; }
.player__seek input { flex: 1; }
.player__seek span { color: var(--deep); font-size: 14px; }

.warn { min-height: 0; margin: 4px 0 8px; color: #b42318; font-weight: 700; }
.warn:empty { display: none; }

.result-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 45%);
}
.result-layer[hidden] { display: none; }
.result-card {
  width: min(420px, calc(100% - 48px));
  padding: 24px;
  background: var(--paper);
  border-radius: 18px;
  text-align: center;
}
.result-actions { display: flex; justify-content: center; gap: 8px; }
.result-actions button {
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--deep);
  color: var(--paper);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.icon-button {
  width: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-button img { width: 20px; height: 20px; filter: brightness(0) invert(1); }
.volume-icon { width: 20px; height: 20px; }
.volume-slider { width: 90px; }
.volume-text { width: 42px; color: var(--deep); font-size: 14px; }

@media (max-width: 800px) {
  .split { grid-template-columns: 1fr; height: auto; }
  .clip-list { min-height: 240px; }
}
