/* ============================================================
   meowcafe.cn —— 猫咖虚拟主播站
   设计约束：弱服务器 / 少云端交互
     - 纯 CSS 变量驱动个性化，改设置不触发网络请求
     - backdrop-filter 只在卡片上用，避免大面积重绘
   ============================================================ */

:root {
  --accent: #f4a261;
  --accent-2: #e9c46a;
  --accent-3: #e76f51;
  --live: #ff4d6d;
  --text: #f6f1ea;
  --text-dim: #b9b0a4;
  --text-faint: #867e74;

  --card-alpha: 0.48;
  --card-blur: 14px;
  --overlay-alpha: 0.10;

  --radius: 18px;
  --radius-sm: 10px;
  --gap: 16px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.34);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', 'Source Han Sans SC', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;
}

* { box-sizing: border-box; }

/* 必须放在所有组件样式之前，且带 !important：
   HTML 的 hidden 属性本质是 display:none，但任何显式声明 display 的规则
   （比如 .live-cover{display:block} / .primary-btn{display:inline-flex}）
   都会把它覆盖掉，导致 hidden 元素照样显示。 */
[hidden] { display: none !important; }

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

body {
  font-family: var(--font);
  color: var(--text);
  background: #14110f;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------------- 背景层 ---------------- */

.bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-color: #14110f;
  background-image:
    radial-gradient(1100px 620px at 12% -8%, rgba(244, 162, 97, 0.20), transparent 62%),
    radial-gradient(900px 560px at 92% 8%, rgba(231, 111, 81, 0.16), transparent 60%),
    radial-gradient(760px 620px at 50% 108%, rgba(138, 177, 125, 0.12), transparent 62%);
  background-size: cover;
  background-position: center;
  transition: background-image 0.4s ease;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(10, 8, 7, var(--overlay-alpha));
  pointer-events: none;
}

/* ---------------- 布局骨架 ---------------- */

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 22px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(244, 162, 97, 0.5);
  background: rgba(255, 255, 255, 0.06);
  flex: none;
}

.brand-text { min-width: 0; }

.brand-text h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.ghost-btn {
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}

.ghost-btn:hover {
  background: rgba(244, 162, 97, 0.18);
  border-color: rgba(244, 162, 97, 0.5);
}

/* ---------------- 卡片网格 ---------------- */

.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.18fr);
  grid-template-areas:
    'live      calendar'
    'weekly    calendar'
    'updates   calendar'
    'playlist  playlist';
  align-items: start;
}

[data-module='live']     { grid-area: live; }
[data-module='weekly']   { grid-area: weekly; }
[data-module='updates']  { grid-area: updates; }
[data-module='calendar'] { grid-area: calendar; }
[data-module='playlist'] { grid-area: playlist; }

.card[hidden] { display: none !important; }

.card {
  background: rgba(28, 24, 21, var(--card-alpha));
  backdrop-filter: blur(var(--card-blur)) saturate(1.25);
  -webkit-backdrop-filter: blur(var(--card-blur)) saturate(1.25);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
}

.card-sub {
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------------- 直播状态 ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge.live {
  background: rgba(255, 77, 109, 0.2);
  color: #ff8098;
  border: 1px solid rgba(255, 77, 109, 0.42);
}

.badge.live::before { animation: pulse 1.5s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.8); }
}

.badge.off {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-faint);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.badge.replay {
  background: rgba(109, 142, 160, 0.22);
  color: #9fc2d6;
  border: 1px solid rgba(109, 142, 160, 0.45);
}

.live-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: rgba(0, 0, 0, 0.35);
  display: block;
  margin-bottom: 12px;
}

.live-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.live-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.live-meta b {
  color: var(--text);
  font-family: var(--mono);
  font-weight: 600;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #241a12;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.18s, transform 0.18s;
}

.primary-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

.stale-note {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-faint);
}

/* ---------------- 日历 ---------------- */

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

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  font-family: inherit;
}

.icon-btn:hover { background: rgba(244, 162, 97, 0.18); }

.cal-month {
  font-size: 15px;
  font-weight: 600;
  min-width: 116px;
  text-align: center;
}

.cal-month small {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-dim);
}

.cal-weekdays,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.cal-weekdays {
  margin-bottom: 6px;
}

.cal-weekdays span {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 3px 0;
}

.cal-weekdays span.weekend { color: #d98b8b; }

.day {
  position: relative;
  border: 1px solid transparent;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  padding: 5px 3px 6px;
  min-height: 54px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.day:hover { background: rgba(255, 255, 255, 0.09); }

.day.out {
  opacity: 0.32;
}

.day.today {
  border-color: rgba(244, 162, 97, 0.62);
}

.day.selected {
  background: rgba(244, 162, 97, 0.2);
  border-color: var(--accent);
}

.day .num {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.day .sub {
  display: block;
  font-size: 10px;
  color: var(--text-faint);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day .sub.festival { color: var(--accent-3); }

.day .dots {
  display: flex;
  gap: 3px;
  justify-content: center;
  margin-top: 4px;
  min-height: 6px;
}

.day .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

/* 当天详情 */

.day-detail {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.day-detail h4 {
  margin: 0 0 4px;
  font-size: 14px;
}

.day-detail .solar {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 11px;
}

.entry {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  margin-bottom: 7px;
  border-left: 3px solid var(--entry-color, var(--accent));
}

.entry .etitle {
  font-size: 13.5px;
  font-weight: 600;
}

.entry .enote {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.entry .etime {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--mono);
  flex: none;
}

.empty {
  font-size: 12.5px;
  color: var(--text-faint);
  padding: 8px 0;
}

/* ---------------- 周表 ---------------- */

.week-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.week-row {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.week-row:hover { background: rgba(255, 255, 255, 0.08); }
.week-row.today { background: rgba(244, 162, 97, 0.14); }

.week-row .wd {
  flex: none;
  width: 44px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.45;
}

.week-row .wd b {
  display: block;
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
}

.week-row .wc {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tag-color, #888) 26%, transparent);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--tag-color, #888) 52%, transparent);
  white-space: nowrap;
}

/* ---------------- 动态 ---------------- */

.dyn {
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.045);
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: background 0.15s;
}

.dyn:hover { background: rgba(255, 255, 255, 0.09); }

.dyn .dhead {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-bottom: 5px;
}

.dyn .dtext {
  font-size: 13px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.dyn .dimages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 5px;
  margin-top: 8px;
}

.dyn .dimages img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.3);
}

/* ---------------- 最新消息 ---------------- */

/* 自动同步的直播间公告 */
.notice {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: rgba(244, 162, 97, 0.10);
  border-left: 3px solid var(--accent);
  margin-bottom: 9px;
}

.notice .nlabel {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 5px;
}

.notice .nbody {
  font-size: 13.5px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
}

.space-link {
  display: block;
  margin-top: 12px;
  padding: 9px;
  text-align: center;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.space-link:hover {
  background: rgba(244, 162, 97, 0.16);
  color: var(--text);
}

/* ---------------- 歌单 ---------------- */

.playlist-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 16px;
}

.player-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.player-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.player-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  padding: 20px;
}

.now-playing {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
  min-height: 22px;
}

.now-playing b { color: var(--accent); }

.track-list {
  max-height: 330px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 4px;
}

.track {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  width: 100%;
  transition: background 0.15s, border-color 0.15s;
}

.track:hover { background: rgba(255, 255, 255, 0.09); }
.track.active {
  background: rgba(244, 162, 97, 0.17);
  border-color: rgba(244, 162, 97, 0.5);
}

.track .idx {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  width: 20px;
  flex: none;
}

.track .tinfo { min-width: 0; flex: 1; }

.track .ttitle {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track .tnote {
  font-size: 11.5px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------- 纯享模式 ---------------- */

body.zen .topbar-actions,
body.zen .card-head .cal-nav { opacity: 0; pointer-events: none; }

body.zen .shell { padding-top: 14px; }

.zen-hint {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(20, 17, 15, 0.78);
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 50;
}

body.zen .zen-hint { opacity: 1; }

/* ---------------- 设置面板 ---------------- */

dialog {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(28, 24, 21, 0.94);
  backdrop-filter: blur(22px);
  color: var(--text);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: min(86vh, 820px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.dlg-head h3 { margin: 0; font-size: 16px; }

.dlg-body {
  padding: 16px 20px;
  overflow-y: auto;
  max-height: calc(86vh - 130px);
}

.dlg-foot {
  padding: 12px 20px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

fieldset {
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  margin: 0 0 14px;
}

legend {
  font-size: 12px;
  color: var(--accent);
  padding: 0 7px;
  letter-spacing: 0.06em;
}

.field {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 10px;
  font-size: 13px;
}

.field:last-child { margin-bottom: 0; }

.field > label:first-child {
  flex: none;
  width: 96px;
  color: var(--text-dim);
}

.field input[type='text'],
.field input[type='password'],
.field input[type='date'],
.field input[type='time'],
.field select {
  flex: 1;
  min-width: 0;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.field input[type='range'] { flex: 1; accent-color: var(--accent); }

/* 非 .field 容器里的行内输入框（管理面板用） */
.inline-input {
  flex: 1;
  min-width: 0;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.field input[type='file'] {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-dim);
}

.field .val {
  width: 46px;
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 0;
}

.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

.module-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 16px;
}

.btn {
  padding: 8px 15px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.btn:hover { background: rgba(255, 255, 255, 0.13); }

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #241a12;
  font-weight: 700;
  border: none;
}

.btn.danger {
  border-color: rgba(231, 111, 81, 0.5);
  color: #ffb4a0;
}

.hint {
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.55;
  margin: 7px 0 0;
}

.admin-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  margin-bottom: 6px;
  font-size: 13px;
}

/* ---------------- Toast ---------------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(14px);
  background: rgba(28, 24, 21, 0.96);
  border: 1px solid rgba(244, 162, 97, 0.42);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 100;
  max-width: calc(100vw - 40px);
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 响应式 ---------------- */

@media (max-width: 980px) {
  .grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'live' 'calendar' 'weekly' 'updates' 'playlist';
  }
  .playlist-wrap { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .shell { padding: 16px 13px 50px; }
  .card { padding: 14px; border-radius: 15px; }
  .day { min-height: 46px; }
  .day .sub { font-size: 9px; }
  .brand-text p { display: none; }
  .module-toggles { grid-template-columns: 1fr; }
  .field > label:first-child { width: 74px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
