/* 应用级双页：任务填写 | 创作工作室 */

.app-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.app-nav button {
  min-height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.app-nav button.active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 88%, #000), color-mix(in srgb, var(--accent) 80%, #000));
  color: #fff;
}

.app-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app-view[hidden] {
  display: none !important;
}

/* —— 任务填写：整页滚动，三区分明 —— */
html.app-view-compose {
  height: auto;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: auto;
}

body.app-view-compose {
  overflow: visible;
  height: auto;
  min-height: 100dvh;
  overscroll-behavior: auto;
}

body.app-view-compose .app-view,
body.app-view-compose #appViewCompose {
  flex: none;
  min-height: auto;
  overflow: visible;
}

body.app-view-studio {
  overflow: hidden;
  height: 100dvh;
}

body.app-view-play {
  overflow: hidden;
  height: 100dvh;
}

html.app-view-play {
  overflow: hidden;
  height: 100dvh;
}

body.app-view-play .app-view,
body.app-view-play #appViewPlay {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

html.app-view-studio {
  overflow: hidden;
  height: 100dvh;
}

.todo-page {
  flex: none;
  min-height: auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 12px 24px;
}

.todo-page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 0 12px;
  margin-bottom: 4px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.todo-page-head h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.todo-page-head .todo-output-summary {
  flex: 1;
  min-width: 140px;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

.todo-page-head .todo-output-summary:empty {
  display: none;
}

.todo-page-head .btn {
  flex-shrink: 0;
}

.todo-page-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 分区卡片 */
.todo-zone {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.todo-zone-basic {
  border-left: 3px solid var(--primary);
}

.todo-zone-mvu {
  border-left: 3px solid var(--accent);
}

.todo-zone-content {
  border-left: 3px solid color-mix(in srgb, var(--ok) 70%, var(--accent));
}

.todo-zone-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.todo-zone-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}

.todo-zone-inner {
  padding: 14px 16px 16px;
}

.todo-zone-mvu .todo-zone-inner {
  padding-top: 12px;
}

.platform-mode-hint {
  margin: 0;
  flex: 1;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

.todo-fields-grid {
  display: grid;
  gap: 10px 14px;
}

.todo-fields-grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.todo-fields-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.todo-sub-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.todo-sub-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.todo-page .field {
  margin-bottom: 0;
}

.todo-page .field span {
  font-size: 12px;
  color: var(--text-muted);
}

.todo-page .field input,
.todo-page .field select,
.todo-page .field textarea {
  min-height: 36px;
  padding: 8px 10px;
  font-size: 13px;
}

.todo-page .field textarea {
  min-height: 56px;
  resize: vertical;
}

.todo-page .field.inline {
  margin-bottom: 0;
}

.todo-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.todo-chips label,
.todo-chips .todo-chip-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.todo-chips input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--primary);
}

.todo-mvu-toolbar {
  margin-bottom: 12px;
}

.todo-mvu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.todo-mvu-vars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.todo-mvu-var-card {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
}

.todo-mvu-var-card .field {
  margin: 0;
}

.todo-mvu-var-card .todo-mvu-var-del {
  align-self: end;
  margin-bottom: 2px;
}

.todo-content-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) 1fr 1fr;
  gap: 14px;
  padding: 0;
}

.todo-panel-box {
  min-width: 0;
}

.todo-panel-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.todo-panel-title:not(:first-child) {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.todo-chars-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.todo-page .todo-char-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.todo-page .todo-char-card .field {
  margin-bottom: 8px;
}

.todo-page .todo-char-card .field:last-of-type {
  margin-bottom: 0;
}

.todo-page .todo-char-del {
  margin-top: 6px;
}

body.platform-tavern #lightExtrasGroup,
body.platform-light #tavernExtrasGroup {
  display: none !important;
}

.light-extras-group {
  margin: 0;
  padding: 0;
  border: none;
}

/* —— 创作工作室：左文件 | 中编辑 | 右 TK —— */
.studio-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(168px, 220px) minmax(0, 1fr) minmax(280px, 380px);
  grid-template-areas: "files editor chat";
  gap: 10px;
  padding: 10px;
}

.studio-files-panel {
  grid-area: files;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.studio-editor-panel {
  grid-area: editor;
  min-height: 0;
  min-width: 0;
  height: 100%;
}

.studio-layout .chat-panel {
  grid-area: chat;
  min-height: 0;
  height: 100%;
}

.studio-files-panel .file-tree {
  flex: 1;
  width: 100%;
  min-width: 0;
  max-height: none;
  border-right: none;
  border-top: 1px solid var(--border);
}

.studio-files-head h2 {
  font-size: 14px;
}

.studio-editor-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-editor-panel .workspace-files-pane,
.studio-editor-panel .workspace-web-preview-pane,
.studio-editor-panel .workspace-preview-pane {
  flex: 1;
  min-height: 0;
}

.studio-editor-panel .file-editor-wrap {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.studio-editor-panel .code-editor-shell {
  flex: 1;
  min-height: 0;
}

.studio-editor-panel .file-editor-area {
  min-height: 0;
}

@media (max-width: 1100px) {
  .todo-fields-grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .todo-content-grid {
    grid-template-columns: 1fr;
  }

  .todo-mvu-var-card {
    grid-template-columns: 1fr;
  }

  .studio-layout {
    grid-template-columns: minmax(140px, 180px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(260px, 38vh);
    grid-template-areas:
      "files editor"
      "files chat";
  }
}

@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
  }

  .app-nav {
    order: 3;
    width: 100%;
    justify-content: stretch;
  }

  .app-nav button {
    flex: 1;
    padding: 0 8px;
    font-size: 12px;
  }

  .todo-page {
    padding: 0 8px 20px;
  }

  .todo-fields-grid.cols-4,
  .todo-fields-grid.cols-2 {
    grid-template-columns: 1fr;
  }

  .todo-page-head .btn {
    width: 100%;
  }

  .studio-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(120px, 22vh) minmax(280px, 1fr) minmax(240px, 34vh);
    grid-template-areas:
      "files"
      "editor"
      "chat";
    padding: 6px;
    gap: 6px;
  }

  .studio-files-panel .file-tree {
    border-top: none;
    max-height: none;
  }
}
