/* ============================================================
   全站左侧竖排导航栏 + 抽屉
   蓝鸟色系：#30b0f0 / #0040d0 / #a060f0
   ============================================================ */

:root {
  --rail-w: 64px;
  --topbar-h: 114px;
}

/* 汉堡按钮（仅移动端可见） */
.rail-burger {
  display: none;
}

/* ---------- 左栏本体 ---------- */
.left-rail {
  position: fixed;
  left: 0;
  top: var(--topbar-h);
  bottom: 0;
  width: var(--rail-w);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 16px;
  background: #000;
  border-right: 1px solid rgba(0, 64, 208, 0.35);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.left-rail::-webkit-scrollbar {
  width: 0;
}

.rail__divider {
  width: 34px;
  height: 1px;
  margin: 10px 0;
  background: rgba(0, 64, 208, 0.25);
  flex: 0 0 auto;
}

.rail__group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

/* 单个导航项 */
.rail__item {
  position: relative;
  width: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 2px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  color: #ffffff;
  transition: background 0.22s var(--ease), box-shadow 0.22s var(--ease), opacity 0.22s;
}
.rail__icon {
  font-size: 22px;
  line-height: 1;
}
.rail__label {
  font-size: 16px;
  line-height: 1.2;
  color: #d3d7e3;
  white-space: nowrap;
}
.rail__item:hover {
  background: rgba(0, 64, 208, 0.16);
  box-shadow: 0 0 14px rgba(48, 176, 240, 0.22);
}
.rail__item:hover .rail__label {
  color: #ffffff;
}

/* 选中指示条（左缘 3px 亮蓝） */
.rail__item.is-active::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #30b0f0;
}

/* 工作台模式下画布工具禁用态 */
.rail__item--canvas.is-disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: auto;
}
.rail__item--canvas.is-disabled:hover {
  background: transparent;
  box-shadow: none;
}

/* 连接模式激活 */
.rail__item.is-on {
  background: rgba(0, 64, 208, 0.22);
}
.rail__item.is-on::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #30b0f0, #a060f0);
}

/* ---------- 主内容整体右移 + 顶栏占位 ---------- */
.workspace,
.canvas-mode,
#admin-panel {
  margin-left: var(--rail-w);
  padding-top: var(--topbar-h);
}

/* 首页直排版块左移避开窄图标栏（仅 margin，不改其自身 top 占位） */
.home-hero,
.home-billboard {
  margin-left: var(--rail-w);
}

/* ---------- 抽屉 ---------- */
.rail-drawer {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
}
.rail-drawer__mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.rail-drawer__panel {
  position: absolute;
  top: 0;
  left: var(--rail-w);
  bottom: 0;
  width: 340px;
  max-width: 86vw;
  background: #050507;
  border-right: 1px solid rgba(0, 64, 208, 0.45);
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  transform: translateX(-110%);
  transition: transform 0.25s ease;
}
.rail-drawer.is-open .rail-drawer__panel {
  transform: translateX(0);
}
.rail-drawer.is-open .rail-drawer__mask {
  opacity: 1;
}

.rail-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(0, 64, 208, 0.18);
}
.rail-drawer__head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  font-family: var(--font-serif);
}
.rail-drawer__close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(0, 64, 208, 0.3);
  background: transparent;
  color: #d3d7e3;
  cursor: pointer;
  transition: all 0.2s;
}
.rail-drawer__close:hover {
  background: linear-gradient(135deg, #30b0f0, #a060f0);
  color: #fff;
  border-color: transparent;
}

/* ---------- 当前项目自动保存状态 ---------- */
.rd-save-status {
  padding: 12px 18px 10px;
  border-bottom: 1px solid rgba(0, 64, 208, 0.14);
}
.rd-save-status__name {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #fff;
  font-family: 'Noto Serif SC', serif;
  font-size: 15px;
  font-weight: 600;
  padding: 6px 8px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.rd-save-status__name:hover {
  border-color: rgba(48, 176, 240, 0.35);
}
.rd-save-status__name:focus {
  border-color: #30b0f0;
  background: rgba(48, 176, 240, 0.06);
  box-shadow: 0 0 0 2px rgba(48, 176, 240, 0.12);
}
.rd-save-status__meta {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px 0;
}
.rd-save-status__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(48, 176, 240, 0.7);
  flex: 0 0 auto;
  transition: background 0.3s ease;
}
.rd-save-status__dot[data-state='saving'] {
  background: rgba(48, 176, 240, 0.7);
  animation: rd-dot-pulse 1s ease-in-out infinite;
}
.rd-save-status__dot[data-state='success'] {
  background: #22c55e;
}
.rd-save-status__dot[data-state='error'] {
  background: #e94560;
}
.rd-save-status__text {
  font-size: 12px;
  color: #9ca3af;
  letter-spacing: 0.2px;
}
@keyframes rd-dot-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.rail-drawer__actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(0, 64, 208, 0.14);
}
.rd-btn {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  padding: 10px 10px;
  border-radius: 8px;
  border: 1px solid rgba(0, 64, 208, 0.35);
  background: transparent;
  color: #d3d7e3;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.22s var(--ease);
}
.rd-btn:hover {
  border-color: #30b0f0;
  color: #fff;
  background: rgba(48, 176, 240, 0.12);
}
.rd-btn--primary {
  background: linear-gradient(135deg, #30b0f0, #a060f0);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.rd-btn:not(.rd-btn--primary) {
  background: linear-gradient(#050507, #050507) padding-box,
    linear-gradient(135deg, rgba(48, 176, 240, 0.7), rgba(160, 96, 240, 0.7)) border-box;
  border: 1px solid transparent;
}
.rd-btn:not(.rd-btn--primary):hover {
  background: linear-gradient(rgba(48, 176, 240, 0.1), rgba(160, 96, 240, 0.1)) padding-box,
    linear-gradient(135deg, #30b0f0, #a060f0) border-box;
  border: 1px solid transparent;
  color: #fff;
}
.rd-btn--primary {
  background: linear-gradient(135deg, #30b0f0, #a060f0);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.rd-btn--primary:hover {
  background: linear-gradient(135deg, #30b0f0, #a060f0);
  box-shadow: 0 6px 18px rgba(0, 64, 208, 0.4);
}

/* 项目列表 */
.rail-drawer__list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 24px;
}
.rd-empty {
  margin-top: 50px;
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
  line-height: 1.8;
}
.rd-empty .em {
  font-size: 34px;
  display: block;
  margin-bottom: 10px;
  opacity: 0.8;
}

.rd-project {
  position: relative;
  padding: 12px 12px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: #111111;
  border: 1px solid rgba(0, 64, 208, 0.22);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.rd-project:hover {
  border-color: rgba(48, 176, 240, 0.6);
  box-shadow: 0 6px 18px rgba(0, 64, 208, 0.2);
}
.rd-project__name {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  outline: none;
  border-radius: 4px;
  padding: 1px 3px;
  margin-left: -3px;
}
.rd-project__name:focus {
  background: rgba(48, 176, 240, 0.14);
  box-shadow: 0 0 0 1px #30b0f0;
}
.rd-project__meta {
  margin-top: 6px;
  font-size: 11px;
  color: #9ca3af;
}
.rd-project__ops {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}
.rd-pbtn {
  flex: 1;
  padding: 6px 0;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid rgba(0, 64, 208, 0.35);
  background: transparent;
  color: #d3d7e3;
  cursor: pointer;
  transition: all 0.2s;
}
.rd-pbtn:hover {
  border-color: #30b0f0;
  color: #fff;
  background: rgba(48, 176, 240, 0.12);
}
.rd-pbtn--danger:hover {
  border-color: #e94560;
  color: #fff;
  background: rgba(233, 69, 96, 0.14);
}

/* 素材库 Tab */
.rd-tabs {
  display: flex;
  gap: 6px;
  padding: 14px 18px 0;
}
.rd-tab {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 13px;
  padding: 6px 4px 8px;
  position: relative;
  cursor: pointer;
}
.rd-tab.is-active {
  color: #fff;
  font-weight: 600;
}
.rd-tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, #30b0f0, #a060f0);
}

.rd-asset-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px 18px 24px;
  align-content: start;
}
.rd-asset {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0, 64, 208, 0.22);
  background: #0a0a0a;
  cursor: pointer;
}
.rd-asset__thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #111111;
}
.rd-asset__thumb img,
.rd-asset__thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.rd-asset__tag {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 10px;
  color: #fff;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(80, 16, 208, 0.55);
}
.rd-asset__time {
  font-size: 10px;
  color: #9ca3af;
  padding: 6px 8px;
}
.rd-asset__add {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.66);
  color: #fff;
  font-size: 12px;
  gap: 5px;
  opacity: 0;
  transition: opacity 0.2s;
}
.rd-asset:hover .rd-asset__add {
  opacity: 1;
}
.rd-asset__add span {
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #30b0f0, #a060f0);
  font-weight: 600;
}

/* ---------- 画布模式：删除旧工具行后内容贴左栏 ---------- */
.canvas-mode {
  top: var(--topbar-h);
  left: var(--rail-w);
  right: 0;
  bottom: 0;
  position: fixed;
  z-index: 20;
  margin-left: 0;
  padding-top: 0;
}

/* ---------- 响应式三档 ---------- */
@media (max-width: 1024px) {
  :root {
    --topbar-h: 96px;
  }
  .topbar__brand { height: 52px; }
  .topbar__logo { height: 46px; }
}

@media (max-width: 768px) {
  :root {
    --topbar-h: 87px;
  }
  .topbar__brand { height: 42px; }
  .topbar__logo { height: 38px; }
}

@media (max-width: 767px) {
  :root {
    --rail-w: 56px;
  }
  .left-rail {
    padding-top: 10px;
  }
  .rail__item {
    width: 48px;
    padding: 7px 2px;
  }
  .rail__icon {
    font-size: 20px;
  }
  .rail__label {
    display: none;
  }
  .rail__divider {
    width: 26px;
  }
  .rail-drawer__panel {
    width: 80vw;
  }
}

@media (max-width: 560px) {
  :root {
    --topbar-h: 81px;
  }
  .topbar__brand { height: 36px; }
  /* 最小断点放不下整条：只保留灵鸟，文字不挤压 */
  .topbar__logo { display: none; }
  .topbar__logo-bird {
    display: block;
    height: 36px;
  }
}

/* ========== 移动端：rail 变抽屉（≤768px） ========== */
@media (max-width: 768px) {
  /* 主内容左移归零，rail 独立成抽屉（不占位） */
  :root {
    --rail-w: 0px;
  }
  .rail-burger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    margin: 0 8px 0 2px;
    border: 1px solid rgba(0, 64, 208, 0.35);
    border-radius: 8px;
    background: #0a0a0a;
    color: #ffffff;
    font-size: 20px;
    line-height: 1;
    transition: all 0.2s var(--ease);
  }
  .rail-burger:hover {
    background: linear-gradient(135deg, #30b0f0, #a060f0);
    border-color: transparent;
  }
  /* 抽屉本体：全高、固定宽度、横向菜单、高于 topbar */
  .left-rail {
    top: 0;
    bottom: 0;
    width: 240px;
    max-width: 82vw;
    height: 100vh;
    align-items: stretch;
    padding: 16px 12px 20px;
    z-index: 1300;
    background: rgba(4, 4, 8, 0.98);
    border-right: 1px solid rgba(0, 64, 208, 0.45);
    transform: translateX(-110%);
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
    box-shadow: none;
  }
  body.rail-open .left-rail {
    transform: translateX(0);
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.75);
  }
  /* 菜单项横向铺满整行 */
  .rail__group {
    align-items: stretch;
    gap: 4px;
  }
  .rail__item {
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
  }
  .rail__icon {
    width: 26px;
    text-align: center;
    font-size: 20px;
  }
  .rail__label {
    display: flex;
    font-size: 13px;
    color: #d3d7e3;
  }
  .rail__divider {
    width: 100%;
  }
  .rail__item.is-on::before {
    left: -12px;
  }
  .workspace,
  .canvas-mode,
  #admin-panel {
    margin-left: 0;
  }
  .rail-drawer__panel {
    left: 0;
  }
  .topbar {
    flex-wrap: wrap;
    align-content: flex-start;
    height: auto;
    min-height: var(--topbar-h);
    padding: 8px 12px;
    gap: 6px;
  }
  .topbar__right {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    row-gap: 4px;
    max-width: 100%;
  }
}

/* ========== 桌面端：窄图标条 + 悬停浮层展开（不挤压主内容） ========== */
@media (min-width: 769px) {
  .left-rail {
    width: var(--rail-w);
    transition: width 0.22s cubic-bezier(.22,.9,.28,1), box-shadow 0.22s;
  }
  .rail__item {
    width: 50px;
    padding: 9px 4px;
    gap: 4px;
  }
  .rail__label {
    display: none;
  }
  .rail__divider {
    width: 28px;
  }
  /* 悬停 / 键盘聚焦：浮层展开显示文字，盖在主内容上不挤压 */
  .left-rail:hover,
  .left-rail:focus-within {
    width: 178px;
    align-items: flex-start;
    padding-left: 14px;
    padding-right: 12px;
    box-shadow: 18px 0 44px rgba(0, 0, 0, 0.62);
  }
  .left-rail:hover .rail__item,
  .left-rail:focus-within .rail__item {
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
  }
  .left-rail:hover .rail__label,
  .left-rail:focus-within .rail__label {
    display: block;
    font-size: 13px;
  }
  .left-rail:hover .rail__divider,
  .left-rail:focus-within .rail__divider {
    width: 100%;
  }
}
