:root {
  --bg: #f2ede1;
  --bg-card: #fbf8f2;
  --bg-card-hover: #f5f0e4;
  --accent: #6b2c2c;
  --accent2: #b5924f;
  --gold: #b5924f;
  --gold-soft: #e3d3a8;
  --gold-ink: #5b4a20;
  --seal: #1c1a16;
  --seal-text: #f2ede1;
  --text: #2b2620;
  --text-dim: #7a7263;
  --text-faint: #a89f8c;
  --border: #ddd4bf;
  --live: #b5342a;
  font-family: 'Zen Kaku Gothic New', -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #17130f;
  --bg-card: #211c15;
  --bg-card-hover: #2a231a;
  --accent: #c96a4f;
  --accent2: #cda15c;
  --gold: #cda15c;
  --gold-soft: #4a3d24;
  --gold-ink: #cda15c;
  --seal: #f0e8d8;
  --seal-text: #17130f;
  --text: #f0e8d8;
  --text-dim: #b6a98e;
  --text-faint: #87795f;
  --border: #3d3427;
  --live: #e0472b;
}

h1, h2, h3 {
  font-family: 'Shippori Mincho', 'Yu Mincho', serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.brand-mark { flex-shrink: 0; }
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.brand-ja {
  font-family: 'Shippori Mincho', 'Yu Mincho', serif;
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.brand-ja-small {
  font-size: 0.5em;
  font-weight: 500;
  letter-spacing: 0;
  opacity: 0.7;
  margin: 0 1px;
}
.brand-en {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: var(--text-faint);
  margin-top: 4px;
}

.icon-inline {
  display: inline-flex;
  vertical-align: -2px;
}
.icon-inline svg { width: 100%; height: 100%; }

.nav-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.nav-pill.active {
  background: var(--seal);
  color: var(--seal-text);
  border: 1px solid var(--seal);
}
.nav-pill.inactive {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.nav-pill.inactive:hover { border-color: var(--accent); }

.avatar-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  flex-shrink: 0;
}
.theme-toggle-btn:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle-btn .icon-inline { width: 16px; height: 16px; }

.name-chip {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-dim);
}

.topbar .user-box {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-dim);
}

.points-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: 20px;
  padding: 5px 14px;
  color: var(--gold-ink);
  font-weight: 700;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: white;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--live);
  color: white;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

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

.channel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
  display: block;
}
.channel-card:hover { background: var(--bg-card-hover); }

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--live);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.live-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.channel-card h3 {
  margin: 8px 0 4px;
  font-size: 16px;
}
.channel-card .meta {
  color: var(--text-dim);
  font-size: 13px;
}

.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 60px 20px;
}

.form-card {
  max-width: 360px;
  margin: 60px auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}
.form-card h2 { margin-top: 0; }
.form-card label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin: 14px 0 6px;
}
.form-card input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.form-card .btn { width: 100%; margin-top: 20px; }
.form-error {
  color: var(--live);
  font-size: 13px;
  margin-top: 10px;
  min-height: 1em;
}
.form-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-dim);
}
.form-switch a { color: var(--accent); text-decoration: underline; cursor: pointer; }

.studio {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  margin-top: 20px;
}
@media (max-width: 720px) {
  .studio { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.mic-level {
  height: 10px;
  border-radius: 6px;
  background: var(--bg);
  overflow: hidden;
  margin-top: 10px;
  border: 1px solid var(--border);
}
.mic-level-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  transition: width 0.08s linear;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 14px;
}

.chat-box {
  height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px;
}
.chat-msg { font-size: 13px; line-height: 1.4; }
.chat-msg .u { color: var(--accent); font-weight: 600; margin-right: 6px; }
.chat-msg.gift { color: var(--gold-ink); }
.chat-msg.system { color: var(--text-dim); font-style: italic; }

.chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.chat-input-row input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.item-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.item-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  text-align: center;
  min-width: 64px;
}
.item-btn:hover { border-color: var(--accent); }
.item-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.item-btn .em { display: block; width: 24px; height: 24px; margin: 0 auto; color: var(--accent); }
.item-btn .em svg { width: 100%; height: 100%; }
.item-btn .cost { color: var(--gold-ink); }

.effect-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}
.effect-icon {
  position: absolute;
  bottom: -40px;
  width: 40px;
  height: 40px;
  color: var(--accent);
  animation: floatUp 3.2s ease-in forwards;
}
.effect-icon svg { width: 100%; height: 100%; }
@keyframes floatUp {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(-92vh) scale(1.2); opacity: 0; }
}

.effect-petal {
  position: absolute;
  top: -30px;
  width: 22px;
  height: 22px;
  color: var(--accent);
  animation: sakuraFall linear forwards;
}
.effect-petal svg { width: 100%; height: 100%; }
@keyframes sakuraFall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  8% { opacity: 1; }
  100% { transform: translate(var(--drift), 108vh) rotate(340deg); opacity: 0.3; }
}

.effect-spark {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: fireworksBurst 1.1s ease-out forwards;
}
@keyframes fireworksBurst {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.3); opacity: 0; }
}

.listen-header {
  text-align: center;
  margin-top: 10px;
}
.display-name-banner {
  background: linear-gradient(90deg, rgba(107,44,44,0.12), rgba(181,146,79,0.12));
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  font-size: 13px;
  text-align: center;
  color: var(--text);
}
.display-name-banner a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}

.listen-hero {
  height: 220px;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-card);
  position: relative;
}
.listen-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,0.6) 100%);
}

.follow-btn {
  border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
}
.follow-btn.not-following {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: white;
}
.follow-btn.following {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.visibility-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--gold-soft);
  color: var(--gold-ink);
  margin-left: 6px;
  vertical-align: middle;
}

.section-label {
  font-size: 13px;
  color: var(--text-dim);
  margin: 24px 0 4px;
  font-weight: 600;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 30px 20px;
  color: var(--text-dim);
  font-size: 12px;
}
.site-footer a { color: var(--text-dim); text-decoration: underline; }

.listen-header .avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 32px;
}

@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 10px 14px;
  }
  .brand { gap: 8px; }
  .brand-en { display: none; }
  .brand-ja { font-size: 17px; }
  .brand-mark { width: 28px !important; height: 28px !important; }
  .brand-mark span { font-size: 13px !important; }

  .topbar .user-box {
    width: 100%;
    flex-wrap: wrap;
    row-gap: 6px;
    gap: 6px 8px;
    font-size: 12px;
  }
  .topbar .nav-pill {
    padding: 6px 12px;
    font-size: 12px;
  }
  .topbar .points-badge {
    padding: 4px 10px;
    font-size: 12px;
  }
  .topbar .avatar-badge {
    width: 26px;
    height: 26px;
    font-size: 11px;
  }
  .topbar .topbar-username {
    display: none;
  }
  .topbar .theme-toggle-btn {
    width: 26px;
    height: 26px;
  }
  .topbar .navlink-muted {
    font-size: 11px !important;
    padding-left: 10px !important;
  }

  .container {
    padding: 18px 14px 40px;
  }
  .section-label { margin: 18px 0 4px; }
  .channel-grid { grid-template-columns: 1fr; }

  .form-card {
    margin: 32px auto;
    padding: 22px 18px;
    max-width: 100%;
  }

  .studio { gap: 14px; margin-top: 14px; }
  .panel { padding: 16px; }

  .listen-hero { height: 160px; }
  .listen-header .avatar { width: 68px; height: 68px; font-size: 24px; }
  .listen-header h2 { font-size: 19px; }

  .chat-box { height: 240px; }

  .item-row { gap: 6px; }
  .item-btn { min-width: 58px; padding: 7px 8px; font-size: 11px; }

  .site-footer { gap: 16px; padding: 22px 16px; flex-wrap: wrap; }

  .display-name-banner { padding: 10px 14px; font-size: 12px; }
}
