/* Atlas AI · 页内接入窗口
   与图鉴同一套纸感配色（paper / sage / clay / blue），只新增面板与控件。 */

.ai-toplink {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.ai-toplink:hover { color: var(--focus); text-decoration: underline; }
.topbar-links { display: flex; align-items: center; gap: 18px; }

.ai-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 46px;
  padding: 0 18px 0 14px;
  border: 1px solid #2b3a45;
  border-radius: 100px;
  background: #2f3d47;
  color: #f7f4ea;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .01em;
  box-shadow: 0 10px 24px #1d242b3d;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}
.ai-launcher:hover { transform: translateY(-2px); background: #26333c; }
.ai-launcher:active { transform: translateY(0); }
.ai-launcher-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #96d3ad; box-shadow: 0 0 0 4px #96d3ad26;
}

.ai-scrim {
  position: fixed; inset: 0; z-index: 50;
  background: #20262b42;
  opacity: 0; pointer-events: none;
  transition: opacity .24s ease;
}
.ai-scrim.on { opacity: 1; pointer-events: auto; }

.ai-panel {
  position: fixed; z-index: 51; top: 0; right: 0; height: 100%;
  width: min(540px, 100vw);
  display: flex; flex-direction: column;
  background: #f4f2ea;
  border-left: 1px solid #d9d7cc;
  box-shadow: -22px 0 54px #1b232a2b;
  transform: translateX(102%);
  transition: transform .32s cubic-bezier(.32,.72,.28,1);
  font-size: 13px;
  color: var(--ink);
}
.ai-panel.open { transform: none; }
.ai-panel, .ai-panel * { box-sizing: border-box; }

.ai-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid #e2e0d6;
}
.ai-eyebrow {
  margin: 0 0 3px; font-size: 10px; letter-spacing: .18em;
  text-transform: uppercase; color: #7c817e;
}
.ai-head h2 { margin: 0; font-size: 21px; letter-spacing: -.02em; font-weight: 720; }
.ai-head-actions { display: flex; align-items: center; gap: 10px; }
.ai-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: #5d6560;
  background: #e9e7dd; border-radius: 100px; padding: 5px 10px;
  white-space: nowrap;
}
.ai-status i { width: 6px; height: 6px; border-radius: 50%; background: #79a98c; }
.ai-status[data-busy="1"] i { background: #c9a24a; animation: ai-pulse 1.1s infinite ease-in-out; }
@keyframes ai-pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.ai-icon {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid #d8d6cb; background: #faf9f5;
  font-size: 14px; line-height: 1; cursor: pointer;
}
.ai-icon:hover { background: #eceade; }

.ai-tabs {
  display: flex; gap: 4px; padding: 10px 14px 0;
  border-bottom: 1px solid #e2e0d6;
}
.ai-tabs button {
  position: relative;
  flex: 1; min-width: 0;
  padding: 9px 4px 11px;
  border: 0; background: none; cursor: pointer;
  font-size: 12.5px; font-weight: 620; color: #6b7173;
  border-bottom: 2px solid transparent;
}
.ai-tabs button[aria-selected="true"] { color: #2f3d47; border-bottom-color: #2f3d47; }
.ai-tabs button:hover { color: #2f3d47; }
.ai-badge {
  display: inline-block; min-width: 17px; padding: 0 5px;
  margin-left: 4px; border-radius: 100px;
  background: #dfe4e0; color: #4b5a52;
  font-size: 10.5px; line-height: 17px; font-variant-numeric: tabular-nums;
}

.ai-body { flex: 1; min-height: 0; display: flex; }
.ai-view { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.ai-view[hidden] { display: none !important; }

/* ---------- 指令台 ---------- */
.ai-log {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex; flex-direction: column; gap: 9px;
  scroll-behavior: smooth;
}
.ai-msg {
  max-width: 93%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: ai-in .22s ease-out;
}
@keyframes ai-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.ai-msg.user { align-self: flex-end; background: #2f3d47; color: #f8f5ec; border-bottom-right-radius: 5px; }
.ai-msg.bot { align-self: flex-start; background: #fbfaf6; border: 1px solid #e0ded3; border-bottom-left-radius: 5px; }
.ai-msg.bot code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  background: #eceae1; padding: 1px 4px; border-radius: 4px; font-size: 11.5px;
}
.ai-msg.sys { align-self: center; background: none; color: #787d79; font-size: 11.5px; padding: 1px; }
.ai-msg b { font-weight: 700; }
.ai-msg .ai-plan { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.ai-msg .ai-plan li { display: flex; gap: 7px; font-size: 12px; color: #4f5a56; }
.ai-msg .ai-plan span { color: #8b8f8b; min-width: 15px; font-variant-numeric: tabular-nums; }

.ai-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 16px 0; }
.ai-chip {
  border: 1px solid #dcdace; background: #faf9f5; color: #4d5654;
  border-radius: 100px; padding: 6px 11px; font-size: 11.5px; cursor: pointer;
  max-width: 100%; text-align: left;
}
.ai-chip:hover { background: #e9edf0; border-color: #cbd5db; }

.ai-compose {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid #e6e4da;
  background: #f4f2ea;
}
.ai-compose textarea {
  flex: 1; min-height: 44px; max-height: 120px;
  resize: none; padding: 11px 13px;
  border: 1px solid #d8d6ca; border-radius: 14px;
  background: #fbfaf6; font: inherit; line-height: 1.5;
  outline: none;
}
.ai-compose textarea:focus { border-color: #8fa2b0; box-shadow: 0 0 0 3px #cfdae24d; }
.ai-compose button {
  height: 44px; padding: 0 16px; border: 0; border-radius: 14px;
  background: #2f3d47; color: #f8f5ec; font-weight: 650; cursor: pointer;
}
.ai-compose button:hover { background: #26333c; }
.ai-compose button:disabled { opacity: .5; cursor: default; }

/* ---------- 模板库 ---------- */
.ai-filters {
  display: flex; gap: 8px; padding: 12px 16px 8px;
}
.ai-filters input, .ai-filters select {
  height: 38px; border: 1px solid #d8d6ca; border-radius: 10px;
  background: #fbfaf6; padding: 0 11px; font: inherit; font-size: 12.5px; outline: none;
}
.ai-filters input { flex: 1; min-width: 0; }
.ai-filters input:focus, .ai-filters select:focus { border-color: #8fa2b0; box-shadow: 0 0 0 3px #cfdae24d; }

.ai-tpl-list { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 12px 12px; }
.ai-tpl {
  display: grid; grid-template-columns: 104px minmax(0,1fr) auto;
  align-items: center; gap: 10px;
  padding: 7px; border-radius: 12px;
  border: 1px solid transparent;
}
.ai-tpl:hover { background: #faf9f4; border-color: #e2e0d5; }
.ai-tpl canvas {
  width: 104px; height: 52px; border-radius: 7px;
  background: #151d26; display: block;
}
.ai-tpl-main { min-width: 0; }
.ai-tpl-main b { display: block; font-size: 13px; font-weight: 650; line-height: 1.3; }
.ai-tpl-main span {
  display: block; margin-top: 3px; font-size: 10.5px; color: #7a807c;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-tpl-add {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid #d5d8d0; background: #eef0e8; color: #3b4a43;
  font-size: 15px; line-height: 1; cursor: pointer;
}
.ai-tpl-add:hover { background: #dfe7dd; border-color: #bccbbe; }
.ai-more {
  margin: 0 16px 16px; height: 38px;
  border: 1px dashed #cfcdc1; border-radius: 10px;
  background: none; color: #6a716c; cursor: pointer; font-size: 12px;
}
.ai-more:hover { background: #eeeee5; }

/* ---------- 时间线 ---------- */
.ai-view[data-view="timeline"] { overflow-y: auto; padding-bottom: 8px; }
/* 预览框贴着画幅尺寸（由 fitStage 写入 canvas 行内宽高），不再留大片空黑边 */
.ai-stage {
  flex: 0 0 auto;
  width: fit-content; max-width: calc(100% - 32px);
  margin: 12px auto 0;
  border-radius: 14px; overflow: hidden;
  background: #101a26;
  box-shadow: 0 10px 24px #101a2626, 0 0 0 1px #ffffff14 inset;
  line-height: 0;
}
.ai-stage canvas { display: block; width: auto; height: auto; max-width: 100%; }

.ai-transport {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px 4px;
}
.ai-transport button {
  width: 38px; height: 34px; border-radius: 9px;
  border: 1px solid #d8d6ca; background: #faf9f5; cursor: pointer; font-size: 12px;
}
.ai-transport button:hover { background: #ecebe1; }
.ai-transport input[type="range"] { flex: 1; min-width: 0; accent-color: #4e6b89; }
.ai-transport span {
  font-size: 11px; color: #6e7571; font-variant-numeric: tabular-nums; min-width: 78px; text-align: right;
}

.ai-format {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 8px 16px 10px;
}
.ai-format-label { font-size: 11px; color: #7c817d; }
.ai-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: #e6e4da; }
.ai-seg button {
  border: 0; background: none; padding: 4px 9px; border-radius: 7px;
  font-size: 11px; color: #5f6662; cursor: pointer;
}
.ai-seg button[aria-pressed="true"] { background: #fbfaf6; color: #2f3d47; box-shadow: 0 1px 3px #2b2b2414; font-weight: 650; }
.ai-format select {
  height: 30px; border: 1px solid #d8d6ca; border-radius: 8px;
  background: #fbfaf6; padding: 0 8px; font-size: 11.5px;
}

.ai-clips { display: grid; gap: 6px; padding: 2px 12px 8px; }
.ai-clip {
  display: grid; grid-template-columns: 92px minmax(0,1fr) auto;
  gap: 9px; align-items: center;
  padding: 7px; border-radius: 12px;
  background: #fbfaf6; border: 1px solid #e3e1d6;
}
.ai-clip canvas { width: 92px; height: 46px; border-radius: 6px; background: #151d26; display: block; }
.ai-clip-main { min-width: 0; display: grid; gap: 5px; }
.ai-clip-title {
  font-size: 12px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-clip-title span { font-weight: 400; color: #8a8f8b; font-size: 10.5px; margin-left: 5px; }
.ai-clip-fields { display: flex; gap: 6px; }
.ai-clip-fields input {
  height: 26px; border: 1px solid #e0ded3; border-radius: 7px;
  background: #fffef9; padding: 0 7px; font: inherit; font-size: 11px; min-width: 0;
}
.ai-clip-fields .ai-clip-duration { width: 62px; flex: 0 0 62px; }
.ai-clip-fields .ai-clip-text { flex: 1; }
.ai-clip-tools { display: grid; grid-template-columns: repeat(2, 26px); gap: 3px; }
.ai-clip-tools button {
  width: 26px; height: 24px; border-radius: 6px;
  border: 1px solid #e0ded3; background: #f4f2e9; font-size: 10.5px; cursor: pointer; color: #5b615d;
}
.ai-clip-tools button:hover { background: #e7e5da; }
.ai-clip-tools button[data-act="del"] { grid-column: 1 / -1; width: auto; }
.ai-empty { margin: 6px 18px 12px; color: #8b8f8b; font-size: 12px; line-height: 1.6; }
.ai-empty[hidden] { display: none; }

.ai-export {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 10px 16px 0; padding: 10px 12px;
  border-radius: 12px; background: #eae8de;
}
.ai-export label { font-size: 11.5px; color: #5f6762; display: inline-flex; align-items: center; gap: 5px; }
.ai-export select {
  height: 30px; border: 1px solid #d5d3c7; border-radius: 8px; background: #fbfaf6; font-size: 11.5px;
}
.ai-export button {
  height: 32px; padding: 0 12px; border-radius: 9px; border: 0;
  background: #2f3d47; color: #f8f5ec; font-size: 12px; font-weight: 620; cursor: pointer;
}
.ai-export button.secondary { background: #fbfaf6; color: #364540; border: 1px solid #d5d3c7; }
.ai-export button:hover { filter: brightness(1.05); }
.ai-export button:disabled { opacity: .5; cursor: default; }

.ai-progress { margin: 9px 18px 0; display: flex; align-items: center; gap: 9px; }
.ai-progress[hidden] { display: none; }
.ai-progress > div { flex: 1; height: 5px; border-radius: 100px; background: #dddacd; overflow: hidden; }
.ai-progress i { display: block; height: 100%; width: 0; background: #4e6b89; transition: width .15s linear; }
.ai-progress span { font-size: 10.5px; color: #6e7571; font-variant-numeric: tabular-nums; min-width: 84px; text-align: right; }

.ai-warn {
  margin: 9px 16px 4px; padding: 8px 10px;
  border-radius: 9px; background: #f4e8da; color: #7d5535;
  font-size: 11px; line-height: 1.6;
}
.ai-warn[hidden] { display: none; }

/* ---------- 外接 ---------- */
.ai-view[data-view="bridge"] { overflow-y: auto; padding-bottom: 10px; }
.ai-bridge { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 0; }
.ai-hint { margin: 0; font-size: 11.5px; line-height: 1.65; color: #7a807c; }
.ai-field { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: #6e7571; }
.ai-field > span { font-weight: 600; letter-spacing: .02em; }
.ai-field select,
.ai-field input {
  height: 34px; padding: 0 10px; border-radius: 9px;
  border: 1px solid #d8d6ca; background: #fbfaf6; color: #2b3a34;
  font-size: 12.5px; font-family: inherit;
}
.ai-field input::placeholder { color: #a8aca5; }
.ai-bridge-actions { display: flex; gap: 8px; }
.ai-bridge-actions button {
  flex: 1; height: 34px; border-radius: 9px; cursor: pointer;
  border: 1px solid #cfd8d0; background: #e9efe6; color: #33453c;
  font-size: 12.5px; font-weight: 600;
}
.ai-bridge-actions button.secondary { background: #f6f5ee; border-color: #dcdad0; color: #4d5a54; font-weight: 500; }
.ai-picks { display: flex; flex-direction: column; gap: 6px; }
.ai-pick {
  display: grid; grid-template-columns: minmax(0,1fr) 58px 26px;
  align-items: center; gap: 8px;
  padding: 7px 8px 7px 10px; border-radius: 10px;
  background: #fbfaf6; border: 1px solid #e4e2d7;
}
.ai-pick-main { min-width: 0; }
.ai-pick-main b { display: block; font-size: 12.5px; font-weight: 650; color: #2b3a34; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-pick-main span { display: block; margin-top: 2px; font-size: 10.5px; color: #8a908b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-pick-dur {
  width: 58px; height: 26px; padding: 0 4px; text-align: center;
  border-radius: 7px; border: 1px solid #dcdacf; background: #fff; color: #33453c;
  font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.ai-pick-del {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 1px solid #e0ded3; background: #f4f2ea; color: #8a908b; font-size: 11px;
}
.ai-pick-del:hover { background: #f1e2da; color: #8a5140; border-color: #e2c9bd; }
.ai-check { display: flex; align-items: center; gap: 7px; font-size: 11px; color: #6e7571; }
.ai-check input { accent-color: #4e6b89; }

/* ---------- 接入 ---------- */
.ai-view[data-view="api"] { overflow-y: auto; padding: 14px 16px 22px; gap: 12px; }
.ai-card {
  background: #fbfaf6; border: 1px solid #e2e0d5; border-radius: 14px; padding: 13px 14px;
}
.ai-card h3 { margin: 0 0 4px; font-size: 13.5px; letter-spacing: -.01em; }
.ai-card p { margin: 0 0 9px; color: #5f6662; font-size: 11.5px; line-height: 1.6; }
.ai-card pre {
  margin: 0 0 9px; padding: 10px 11px; max-height: 190px; overflow: auto;
  background: #efeee6; border-radius: 9px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10.8px; line-height: 1.55; color: #37403c; white-space: pre;
}
.ai-card .ai-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-card button {
  height: 30px; padding: 0 11px; border-radius: 8px;
  border: 1px solid #d6d4c8; background: #f1efe6; font-size: 11.5px; cursor: pointer; color: #3c4a44;
}
.ai-card button:hover { background: #e6eaf0; border-color: #c8d3db; }
.ai-card .ai-meta { margin: 2px 0 0; font-size: 10.5px; color: #8b8f8b; }
.ai-note { margin: 0; padding: 9px 11px; border-left: 2px solid #b6c5b8; background: #eef1e9; border-radius: 0 8px 8px 0; font-size: 11.5px; color: #4f5a53; line-height: 1.6; }

@media (max-width: 640px) {
  .ai-panel { width: 100%; border-left: 0; }
  .ai-head h2 { font-size: 19px; }
  .ai-tabs button { font-size: 11.5px; padding-inline: 2px; }
  .ai-status { display: none; }
  .ai-launcher { right: 14px; bottom: 14px; }
  .ai-tpl { grid-template-columns: 78px minmax(0,1fr) auto; }
  .ai-tpl canvas { width: 78px; height: 40px; }
  .ai-stage canvas { max-height: 32vh; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-panel, .ai-scrim, .ai-msg, .ai-launcher { transition: none !important; animation: none !important; }
}
