* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #eef1f8;
  color: #1b1f2a;
}

/* —— 应用壳：主区域尽量高 —— */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid #e4e9f2;
  z-index: 20;
}

.app-topbar__left,
.app-topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.app-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.btn-drawer {
  border: 1px solid #d4dbe8;
  border-radius: 8px;
  padding: 8px 14px;
  background: #f0f3fa;
  color: #1b1f2a;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn-drawer:hover {
  background: #e4eaf7;
}

.user-pill {
  font-size: 13px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-main {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}

/* —— 中央播放区：占满剩余视口 —— */
.player-stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 10px 12px;
  gap: 8px;
}

.player-stage.is-playing {
  padding-top: 6px;
  gap: 4px;
}

.player-stage.is-playing .player-chrome {
  flex-shrink: 0;
  min-height: auto;
}

.player-stage.is-playing .player-hint {
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-stack {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-stage.is-playing .player-canvas {
  min-height: max(480px, calc(100dvh - 120px));
}

.player-playbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid #dce3f0;
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.player-playbar[hidden] {
  display: none !important;
}

.player-playbar .btn-play {
  font-weight: 600;
  padding: 10px 20px;
}

.player-playbar__hint {
  font-size: 12px;
  line-height: 1.4;
  flex: 1;
  min-width: 200px;
}

.player-chrome {
  flex-shrink: 0;
  min-height: 1.25rem;
}

.player-hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

.player-canvas {
  flex: 1;
  min-height: 0;
  position: relative;
  /* 非播放：占位与 #player 叠放 */
  display: grid;
  grid-template: 1fr / 1fr;
  /* 尽量占满视口，给 OnlyOffice 明确高度基准 */
  min-height: max(480px, calc(100dvh - 72px));
  border: 1px solid #dce3f0;
  border-radius: 14px;
  overflow: hidden;
  background: #f8faff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* 播放中：整栏 flex，#player 吃掉全部高度，工具栏/缩略条随编辑器在画布内 */
.player-canvas.is-playing {
  display: flex;
  flex-direction: column;
}

#player,
#player-placeholder {
  grid-area: 1 / 1;
  min-width: 0;
  min-height: 100%;
}

#player {
  position: relative;
  z-index: 1;
}

.player-canvas.is-playing #player {
  grid-area: auto;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

.player-canvas.is-playing #player-placeholder {
  display: none;
}

.player-placeholder {
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.player-placeholder__inner {
  max-width: 420px;
}

.player-placeholder__title {
  margin: 0 0 10px;
  font-size: 1.15rem;
  font-weight: 600;
  color: #2a3348;
}

.player-placeholder__text {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: #687086;
}

/* OnlyOffice iframe 常见结构：撑满占位 */
.player-canvas.is-playing #player iframe {
  width: 100% !important;
  height: 100% !important;
  border: 0;
  display: block;
}

/* —— 抽屉与遮罩 —— */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 80;
}

.drawer-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: min(400px, 88vw);
  max-width: 100%;
  background: #fff;
  z-index: 90;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(15, 23, 42, 0.12);
  transition: transform 0.22s ease;
}

.drawer--left {
  left: 0;
  transform: translateX(-100%);
  border-right: 1px solid #e4e9f2;
}

.drawer--left.drawer--open {
  transform: translateX(0);
}

.drawer--right {
  right: 0;
  transform: translateX(100%);
  border-left: 1px solid #e4e9f2;
}

.drawer--right.drawer--open {
  transform: translateX(0);
}

.drawer__head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #e4e9f2;
  background: #fafbff;
}

.drawer__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.drawer__close {
  border: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #eef1f8;
  color: #1b1f2a;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.drawer__close:hover {
  background: #e2e8f4;
}

.drawer__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 20px;
}

.drawer-section {
  margin-top: 16px;
}

.drawer-section:first-child {
  margin-top: 0;
}

.drawer-section__h {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: #4f566b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.drawer-note {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
}

.drawer-note code {
  font-size: 12px;
  background: #f0f3fa;
  padding: 2px 6px;
  border-radius: 4px;
}

.drawer-status {
  margin: 8px 0 0;
  font-size: 13px;
}

.upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.upload-form input[type="file"] {
  max-width: 100%;
  font-size: 13px;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  background: #2f61ff;
  color: white;
  cursor: pointer;
  font-size: 14px;
}

button.btn-secondary {
  background: #e8ecf5;
  color: #1b1f2a;
}

button.btn-secondary:hover {
  background: #d9e0f0;
}

.muted {
  color: #687086;
}

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

.item {
  border: 1px solid #e4e9f2;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #fff;
}

.item-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  align-items: center;
}

button.btn-danger {
  background: #c53b3b;
}

button.btn-danger:hover {
  background: #a83232;
}

.item .meta {
  overflow: hidden;
  min-width: 0;
}

.item .name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item .time {
  font-size: 12px;
  color: #687086;
}

.admin-card .form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.admin-card .form-row input {
  border: 1px solid #e4e9f2;
  border-radius: 8px;
  padding: 9px 11px;
  min-width: 120px;
  font-size: 14px;
}

.users-table-wrap {
  margin-top: 10px;
  overflow-x: auto;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.users-table th,
.users-table td {
  border: 1px solid #e4e9f2;
  padding: 7px 9px;
  text-align: left;
}

.users-table th {
  background: #f6f8fc;
}

/* 登录页 */
.page-narrow {
  max-width: 420px;
  margin: 0 auto;
  padding: 24px;
}

.page-narrow .card > h1 {
  text-align: center;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
  border: 1px solid #e4e9f2;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}

.form-stack button {
  width: 100%;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: #4f566b;
}

.field input {
  border: 1px solid #e4e9f2;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
}
