:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei", "Noto Sans TC", system-ui, sans-serif;
  background: #0b0b0b;
  color: #eee;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #0b0b0b; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: fixed;
  inset: 0 0 auto;
  height: 52px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: rgba(20,20,20,.97);
  border-bottom: 1px solid #282828;
  backdrop-filter: blur(10px);
}
.brand { color: #fff; font-weight: 700; text-decoration: none; white-space: nowrap; }
.brand:hover { color: #6cf; }
.search-form { flex: 1; max-width: 430px; }
.search-form input {
  width: 100%;
  border: 1px solid #383838;
  border-radius: 18px;
  padding: 7px 13px;
  color: #eee;
  background: #0f0f0f;
  outline: none;
}
.search-form input:focus { border-color: #6cf; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.top-button, .action-button, .dialog button, .comment-form button {
  border: 1px solid #444;
  border-radius: 18px;
  padding: 7px 13px;
  color: #eee;
  background: #242424;
}
.top-button:hover, .action-button:hover, .dialog button:hover, .comment-form button:hover {
  background: #333;
}

.app-shell { max-width: 1180px; margin: 0 auto; padding: 76px 18px 36px; }
.loading, .empty, .error-panel { padding: 48px 0; color: #aaa; text-align: center; }
.page-title { margin: 0 0 18px; font-size: clamp(22px, 4vw, 32px); }
.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 22px 16px;
}
.work-card { min-width: 0; }
.work-link { display: block; color: inherit; text-decoration: none; }
.cover-wrap { aspect-ratio: 16/9; overflow: hidden; border-radius: 9px; background: #171717; }
.work-cover { width: 100%; height: 100%; object-fit: cover; transition: transform .2s ease; }
.work-link:hover .work-cover { transform: scale(1.025); }
.work-title { margin: 9px 0 4px; font-size: 16px; line-height: 1.4; }
.work-meta { margin: 0; color: #929292; font-size: 13px; }

.player-page { display: grid; grid-template-columns: minmax(0, 680px) minmax(240px, 1fr); gap: 26px; align-items: start; }
.player-column { min-width: 0; }
#player_dock { width: 100%; }
.work-heading { margin: 16px 0 7px; font-size: 24px; }
.work-description { color: #bbb; line-height: 1.7; white-space: pre-wrap; }
.player-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.action-button.active { border-color: #6cf; color: #6cf; background: #203243; }
.side-panel { border-left: 1px solid #242424; padding-left: 22px; }
.side-panel h3 { margin-top: 0; }

.comment-form { display: flex; gap: 8px; margin-bottom: 14px; }
.comment-form textarea {
  flex: 1;
  min-height: 46px;
  resize: vertical;
  border: 1px solid #3b3b3b;
  border-radius: 7px;
  padding: 9px;
  color: #eee;
  background: #101010;
}
.comment { padding: 11px 0; border-bottom: 1px solid #222; }
.comment-head { display: flex; gap: 8px; align-items: center; color: #888; font-size: 12px; }
.comment-name { color: #ddd; font-weight: 700; }
.comment-text { margin: 5px 0 0; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-delete { margin-left: auto; border: 0; color: #aaa; background: transparent; }

.dialog {
  width: min(430px, calc(100vw - 32px));
  border: 1px solid #444;
  border-radius: 12px;
  padding: 22px;
  color: #eee;
  background: #191919;
}
.dialog::backdrop { background: rgba(0,0,0,.72); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog h2 { margin: 0 0 16px; }
.dialog label { display: block; margin: 11px 0; color: #bbb; font-size: 13px; }
.dialog input { display: block; width: 100%; margin-top: 5px; border: 1px solid #444; border-radius: 6px; padding: 9px; color: #eee; background: #101010; }
.dialog-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 16px; }
.icon-button { border: 0 !important; font-size: 24px; background: transparent !important; }
.form-error { min-height: 20px; color: #f77; font-size: 13px; }

@media (max-width: 860px) {
  .player-page { display: block; }
  .side-panel { margin-top: 28px; padding-left: 0; border-left: 0; border-top: 1px solid #242424; padding-top: 20px; }
}
@media (max-width: 600px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand { font-size: 14px; }
  #favorites_btn { display: none; }
  .top-button { padding-inline: 9px; }
  .app-shell { padding-inline: 12px; }
  .work-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 10px; }
}

/* ---------------------------------------------- 頻道 / 系列 / 個人資料 */
.entity-header { margin-bottom: 22px; }
.entity-banner {
  height: clamp(110px, 20vw, 210px);
  border-radius: 12px;
  background-size: cover;
  background-position: center;
  margin-bottom: 14px;
}
.entity-bar { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.entity-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  background: #1c1c1c;
  flex: none;
}
.entity-info { min-width: 0; flex: 1; }
.entity-info .page-title { margin: 0 0 6px; }
.entity-meta { margin: 0 0 4px; color: #999; font-size: 14px; }
.entity-desc { margin: 8px 0 0; color: #bbb; white-space: pre-wrap; }
.entity-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.subscribe-button.active { border-color: #6cf; color: #6cf; }

.section-title { margin: 26px 0 10px; font-size: 16px; color: #ddd; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip {
  border: 1px solid #383838;
  border-radius: 16px;
  padding: 5px 13px;
  color: #ccc;
  text-decoration: none;
  font-size: 13.5px;
  background: #161616;
}
a.chip:hover { border-color: #6cf; color: #6cf; }

.meta-link { color: #9cf; text-decoration: none; }
.meta-link:hover { text-decoration: underline; }

.profile-card {
  display: flex;
  gap: 16px;
  align-items: center;
  background: #141414;
  border: 1px solid #262626;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 18px;
}

.inline-editor {
  display: grid;
  gap: 12px;
  max-width: 520px;
  background: #141414;
  border: 1px solid #262626;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}
.inline-editor .field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #999; }
.inline-editor input[type="text"], .inline-editor input:not([type]), .inline-editor textarea {
  border: 1px solid #383838;
  border-radius: 8px;
  padding: 7px 11px;
  background: #0f0f0f;
  color: #eee;
  outline: none;
  font: inherit;
}
.inline-editor textarea { min-height: 84px; resize: vertical; }
.inline-editor input:focus, .inline-editor textarea:focus { border-color: #6cf; }
.inline-editor button { justify-self: start; }

/* ---------------------------------------------- 帳號頭像選單 */
.account-menu-wrap { position: relative; }
.avatar-button {
  border: 1px solid #444;
  background: transparent;
  border-radius: 50%;
  padding: 2px;
  line-height: 0;
}
.avatar-button:hover, .avatar-button[aria-expanded="true"] { border-color: #6cf; }
.avatar-img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: #222;
  display: block;
}
.avatar-img.lg { width: 46px; height: 46px; }

.account-menu {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  width: 286px;
  background: #191919;
  border: 1px solid #333;
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(0,0,0,.6);
  z-index: 1200;
  overflow: hidden;
}
.account-menu-head {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid #2a2a2a;
}
.account-menu-id { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.account-menu-id strong { color: #fff; font-size: 14px; }
.account-menu-id span {
  color: #999;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.role-tag {
  align-self: flex-start;
  border: 1px solid #3a3a3a;
  border-radius: 9px;
  padding: 0 7px;
  font-size: 11px;
  color: #aaa;
  margin-top: 2px;
}
.role-tag.admin { border-color: #f6a; color: #f6a; }
.role-tag.moderator { border-color: #6cf; color: #6cf; }

.account-menu-others:not(:empty) { border-bottom: 1px solid #2a2a2a; padding: 6px 0; }
.account-menu-label { color: #777; font-size: 11.5px; padding: 4px 14px 6px; }
.account-row { display: flex; align-items: center; }
.account-pick {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  background: transparent;
  border: none;
  color: #ddd;
  padding: 7px 14px;
  text-align: left;
}
.account-pick:hover { background: #242424; }
.account-pick-text { min-width: 0; display: flex; flex-direction: column; }
.account-pick-text strong { font-size: 13px; color: #eee; }
.account-pick-text span {
  font-size: 11.5px;
  color: #888;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-remove {
  border: none;
  background: transparent;
  color: #777;
  font-size: 17px;
  padding: 0 12px;
  align-self: stretch;
}
.account-remove:hover { color: #f88; background: #241a1a; }

.account-menu-list { padding: 6px 0; display: flex; flex-direction: column; }
.menu-item {
  border: none;
  background: transparent;
  color: #ddd;
  text-align: left;
  padding: 9px 14px;
  font-size: 13.5px;
  text-decoration: none;
  display: block;
}
.menu-item:hover { background: #242424; }
.menu-item.danger { color: #f99; }
.menu-item.danger:hover { background: #2a1c1c; }

.auth-hint {
  margin: 0 0 4px;
  color: #9cf;
  font-size: 12.5px;
}
.form-error.ok { color: #7d9; }
