.workspacePage {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  :global {
    .qwenpaw-card {
      border-radius: 0px;
    }
  }
}

.pageHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  padding: 20px;
  border-bottom: 1px solid #eae9e7;
  flex-shrink: 0;
}

.breadcrumbHeader {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  flex: 1;
}

.workspaceInfo {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.breadcrumbParent {
  color: #999;
  font-weight: 400;
}

.breadcrumbSeparator {
  color: #ccc;
  margin: 0 4px;
}

.breadcrumbCurrent {
  color: #333;
  font-weight: 600;
  font-size: 20px;
}

.workspacePath {
  margin: 0;
  font-size: 12px;
  color: rgba(20, 20, 19, 0.85);
  font-family: monospace;
  margin-left: 12px;
  border-radius: 2px;
  background: rgba(239, 240, 243, 0.8);
  padding: 0px 4px;

  :global(.dark-mode) & {
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.08);
  }
}

.actionButtons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.content {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.fileListPanel {
  width: 400px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.cardBody {
  padding: 16px;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: auto;
}

.cardContainer {
  flex: 1;
  min-height: 0;
}

.headerRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.sectionTitle {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.infoText {
  margin: 0;
  margin-bottom: 12px;
  font-size: 12px;
  color: #999;
  flex-shrink: 0;
}

.divider {
  height: 1px;
  background-color: #e8e8e8;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.scrollContainer {
  flex: 1;
  min-height: 0;
  overflow: auto;

  &::-webkit-scrollbar {
    display: none;
  }

  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.fileEditor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  width: 50%;
}

.editorCard {
  height: 100% !important;

  :global {
    .qwenpaw-card-body {
      height: 100%;

      .qwenpaw-spark-card-wrapper {
        height: 100%;
      }

      .qwenpaw-spark-content {
        height: 100%;
      }

      .agentscope-runtime-webui-spark-card-wrapper {
        height: 100%;

        .agentscope-runtime-webui-spark-content {
          height: 100%;
        }
      }

      .spark-card-wrapper {
        height: 100%;

        .spark-content {
          height: 100%;
          overflow: hidden;
        }
      }
    }
  }
}

.editorHeader {
  padding: 16px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.fileName {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.filePath {
  font-size: 12px;
  color: #999;
  font-family: monospace;
}

.buttonGroup {
  display: flex;
  gap: 8px;
  align-items: center;
}

.editorContent {
  padding: 16px;
  height: calc(100% - 96px);
  overflow: hidden;

  textarea {
    font-family: monospace;
    font-size: 13px;
    resize: vertical;
    height: 100%;
  }
}

.contentLabel {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 20px;
}

.markdownViewer {
  flex: 1;
  height: calc(100% - 20px);
  overflow: auto;
  border: 1px solid #e8e8e8;
  padding: 16px;
  border-radius: 8px;
  max-width: 100%;

  :global(.x-markdown) {
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  :global {
    pre {
      border-radius: 6px;
      overflow-x: auto;
      height: auto;
      margin: 0;

      code {
        background: transparent;
        padding: 0;
        margin: 0;
        font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo,
          monospace;
        font-size: 13px;
        line-height: 1.6;
        white-space: pre-wrap;
        word-break: break-word;
      }
    }

    table {
      border-collapse: collapse;
      width: auto;
      margin: 1em 0;
      display: table !important;
      max-width: 100%;
      overflow-x: auto;

      thead,
      tbody,
      tfoot {
        display: table-header-group;
      }

      tbody {
        display: table-row-group;
      }

      tr {
        display: table-row;
      }

      th,
      td {
        display: table-cell;
        border: 1px solid #d0d7de;
        padding: 8px 12px;
        text-align: left;
      }

      th {
        background: #f6f8fa;
        font-weight: 600;
      }

      tr:nth-child(2n) {
        background: #f6f8fa;
      }
    }
  }
}

.textarea {
  font-family: monospace;
  font-size: 13px;
  resize: vertical;
  height: min(100%, clamp(280px, 50vh, 640px));
  min-height: min(240px, 100%);
  max-height: 100%;
}

.markdownToggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggleLabel {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}

.emptyState {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  height: calc(100% - 20px);
}

.buttonGroup {
  display: flex;
  align-items: center;
}

.copyButton {
  border-radius: 4px;
}

.fileItem {
  padding: 12px;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  background-color: #fff;
  transition: all 0.2s;

  &:hover:not(.selected) {
    border-color: #d9d9d9;
    background-color: #fafafa;
  }

  &.selected {
    border: 1px solid #ff7f16;
  }
}

.fileItemHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fileInfo {
  flex: 1;
  min-width: 0;
}

.fileItemActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 12px;
}

.dragHandle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  flex-shrink: 0;
  margin-right: 8px;
  color: #bbb;
  cursor: grab;
  font-size: 14px;
  transition: color 0.2s;

  &:active {
    cursor: grabbing;
  }

  &:hover {
    color: #ff7f16;
  }
}

.dragging {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  border-color: #ff7f16 !important;
}

.enabledBadge {
  color: #52c41a;
  font-size: 8px;
  margin-right: 6px;
  vertical-align: middle;
}

.fileActions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fileItemName {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.fileItemMeta {
  font-size: 12px;
  color: #999;
}

.expandIcon {
  font-size: 12px;
  color: #999;
  margin-left: 8px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}

.dailyMemoryList {
  margin-left: 16px;
  margin-top: -4px;
  margin-bottom: 8px;
}

.dailyMemoryItem {
  padding: 10px;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  background-color: #fff;
  transition: all 0.2s;

  &:hover:not(.selected) {
    border-color: #d9d9d9;
    background-color: #fafafa;
  }

  &.selected {
    border: 1px solid #ff7f16;
  }
}

.memoryFolderItem {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 58px;
  padding: 10px;
  margin-bottom: 6px;
  color: #666;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.dailyMemoryName {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}

.memoryInlineToggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
  color: #999;
  background: transparent;
  border: none;
  cursor: pointer;
}

.dailyMemoryMeta {
  font-size: 11px;
  color: #999;
}

.attribution {
  height: 20px;
  font-size: 11px;
  color: #bbb;
  text-align: center;
  flex-shrink: 0;
}

/* ─── Dark mode ─────────────────────────────────────────────────────────────── */
:global(.dark-mode) {
  .pageHeader {
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }

  .breadcrumbParent {
    color: rgba(255, 255, 255, 0.35);
  }

  .breadcrumbSeparator {
    color: rgba(255, 255, 255, 0.2);
  }

  .breadcrumbCurrent {
    color: rgba(255, 255, 255, 0.85);
  }

  .infoText {
    color: rgba(255, 255, 255, 0.3);
  }

  .divider {
    background-color: rgba(255, 255, 255, 0.08);
  }

  /* File list items */
  .fileItem {
    background-color: #2a2a2a;
    border-color: rgba(255, 255, 255, 0.1);

    &:hover:not(.selected) {
      border-color: rgba(255, 255, 255, 0.2);
      background-color: #333;
    }

    &.selected {
      border-color: #ff7f16;
      background-color: rgba(97, 92, 237, 0.15);
    }
  }

  .fileItemName {
    color: rgba(255, 255, 255, 0.85);
  }

  .fileItemMeta {
    color: rgba(255, 255, 255, 0.35);
  }

  .expandIcon {
    color: rgba(255, 255, 255, 0.3);
  }

  .dragHandle {
    color: rgba(255, 255, 255, 0.2);

    &:hover {
      color: #ff7f16;
    }
  }

  .dragging {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border-color: #ff7f16 !important;
    background-color: rgba(97, 92, 237, 0.15) !important;
  }

  /* Daily memory items */
  .dailyMemoryItem {
    background-color: #2a2a2a;
    border-color: rgba(255, 255, 255, 0.1);

    &:hover:not(.selected) {
      border-color: rgba(255, 255, 255, 0.2);
      background-color: #333;
    }

    &.selected {
      border-color: #ff7f16;
      background-color: rgba(97, 92, 237, 0.15);
    }
  }

  .dailyMemoryName {
    color: rgba(255, 255, 255, 0.85);
  }

  .memoryFolderItem {
    color: rgba(255, 255, 255, 0.65);
  }

  .memoryInlineToggle {
    color: rgba(255, 255, 255, 0.35);
  }

  .dailyMemoryMeta {
    color: rgba(255, 255, 255, 0.35);
  }

  /* Editor area */
  .editorHeader {
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }

  .fileName {
    color: rgba(255, 255, 255, 0.85);
  }

  .filePath {
    color: rgba(255, 255, 255, 0.35);
  }

  .markdownViewer {
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.85);
    background: #1f1f1f;

    :global(.x-markdown) {
      background: transparent !important;
      color: inherit !important;
    }

    :global {
      pre {
        background: #2a2a2a;
        border-color: rgba(255, 255, 255, 0.1);

        code {
          color: rgba(255, 255, 255, 0.85);
        }
      }

      table {
        th,
        td {
          border-color: rgba(255, 255, 255, 0.15);
        }

        th {
          background: #2a2a2a;
          color: rgba(255, 255, 255, 0.85);
        }

        tr:nth-child(2n) {
          background: rgba(255, 255, 255, 0.04);
        }
      }
    }
  }

  .toggleLabel {
    color: rgba(255, 255, 255, 0.45);
  }

  .emptyState {
    color: rgba(255, 255, 255, 0.3);
  }

  .sectionTitle {
    color: rgba(255, 255, 255, 0.85);
  }

  .attribution {
    color: rgba(255, 255, 255, 0.2);
  }

  /* Textarea inside editor */
  .textarea,
  .editorContent textarea {
    background: #2a2a2a !important;
    color: rgba(255, 255, 255, 0.85) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
  }

  /* Mobile toolbar */
  .mobileToolbar {
    background: #2a2a2a;
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }

  .mobileToolbarTitle {
    color: rgba(255, 255, 255, 0.85);
  }

  .saveStatus {
    color: rgba(255, 255, 255, 0.45);
  }
}

@media (max-width: 768px) {
  .pageHeader {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;

    [class*="leading"] {
      width: 100%;
    }
  }

  .breadcrumbHeader {
    flex-wrap: wrap;
  }

  .workspacePath {
    margin-left: 0;
    margin-top: 4px;
    width: 100%;
    word-break: break-all;
    box-sizing: border-box;
  }

  .workspaceInfo {
    width: 100%;
    justify-content: flex-start;
  }

  .actionButtons {
    flex-wrap: wrap;
    width: 100%;
  }

  .content {
    flex-direction: column;
  }

  .fileListPanel {
    width: 100%;
    height: auto;
    flex: 1;
    border-right: none;

    &,
    * {
      -webkit-tap-highlight-color: transparent !important;
    }
  }

  .fileItemHeader {
    gap: 4px;
    align-items: center;
  }

  .fileItem {
    touch-action: manipulation;

    &:active:not(.selected) {
      background-color: #f0f0f0;
    }

    :global(.dark-mode) &:active:not(.selected) {
      background-color: #3a3a3a;
    }
  }

  .fileItemActions {
    align-self: center;
    display: flex;
    align-items: center;
  }

  .expandIcon {
    order: -1;
    margin-left: 0;
    margin-right: 4px;
    width: 28px;
    height: 28px;
    font-size: 12px;
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: #999;
    position: relative;

    &::before {
      content: "";
      position: absolute;
      inset: -8px;
    }

    &:active {
      color: #333;
    }

    :global(.dark-mode) & {
      color: rgba(255, 255, 255, 0.45);

      &:active {
        color: rgba(255, 255, 255, 0.85);
      }
    }
  }

  .dailyMemoryItem {
    touch-action: manipulation;

    &:active:not(.selected) {
      background-color: #f0f0f0;
    }

    :global(.dark-mode) &:active:not(.selected) {
      background-color: #3a3a3a;
    }
  }

  .content.mobileShowEditor {
    .fileListPanel {
      display: none;
    }

    > .fileEditor {
      display: flex;
      width: 100%;
      height: 100%;
      min-height: 0;
    }
  }

  .fileEditor {
    display: none;
  }

  .editorCard {
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
  }

  .mobileToolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
    background: #fff;
  }

  .mobileToolbarTitle {
    font-weight: 600;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
  }

  .editorHeaderCompact {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 12px;
  }

  .fileMetaCompact {
    width: 100%;
  }

  .filePath {
    word-break: break-all;
    white-space: normal;
    line-height: 1.4;
  }

  .buttonGroup {
    width: 100%;
    justify-content: flex-end;
  }

  .contentLabel {
    flex-wrap: nowrap;
    gap: 8px;
    white-space: nowrap;

    .buttonGroup {
      width: auto;
      flex-shrink: 0;
    }
  }

  .saveStatus {
    font-size: 12px;
    color: #8c8c8c;
    margin-right: 8px;
  }

  .editorContent {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    overflow: hidden;

    .textarea {
      flex: 1;
      min-height: 240px;

      textarea {
        min-height: 240px;
      }
    }
  }

  .markdownViewer {
    flex: 1;
    min-height: 0;
    overflow: auto;
  }
}
