:root {
  --primary: #2c3e50;
  --border: #e0e0e0;
  --header-h: 80px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  overflow: hidden;
  background: #fff;
}

header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: #f8f9fa;
  flex-shrink: 0;
  z-index: 10;
}

.toolbar {
  display: flex;
  gap: 10px;
}

button {
  padding: 6px 14px;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

button:hover {
  background: #f0f0f0;
  border-color: #bbb;
}

button.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

button:disabled {
  opacity: 0.7;
  cursor: wait;
  background: #eee;
}

.main-area {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.editor-pane {
  width: 50%;
  height: 100%;
  border-right: 2px solid #000;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 8px 12px;
  gap: 8px;
}

.editor-toolbar button {
  padding: 4px 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
}

#code {
  border: none;
  outline: none;
}

.CodeMirror {
  height: 100%;
  font-family: 'Fira Code', Consolas, monospace;
  font-size: 15px;
  line-height: 1.6;
}

.preview-pane {
  width: 50%;
  height: 100%;
  overflow-y: auto;
  background: #fff;
  transition: width 0.3s ease;
}

.preview-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px;
  transition: max-width 0.3s ease;
}

.markdown-body {
  line-height: 1.8;
  color: #333;
}

.markdown-body h1,
.markdown-body h2 {
  border-bottom: 1px solid #eaecef;
  padding-bottom: 0.3em;
}

.markdown-body pre {
  background: #f6f8fa;
  padding: 16px;
  border-radius: 6px;
  overflow: auto;
}

.markdown-body code {
  background: rgba(27, 31, 35, 0.05);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: monospace;
}

.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
}

.markdown-body table th,
.markdown-body table td {
  border: 1px solid #dfe2e5;
  padding: 6px 13px;
}

.markdown-body table tr:nth-child(2n) {
  background-color: #f6f8fa;
}

.markdown-body img {
  max-width: 100%;
}

.markdown-body details.md-details {
  border: 1px solid #dfe2e5;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8f9fa;
  margin: 16px 0;
}

.markdown-body details.md-details > summary {
  cursor: pointer;
  font-weight: 600;
  user-select: none;
}

.markdown-body details.md-details[open] > summary {
  margin-bottom: 8px;
}

.markdown-body .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 0;
}

.mermaid {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

.drawio-diagram {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

.drawio-wrap {
  width: 100%;
  max-width: 1100px;
  border: 2px dashed #d0d7de;
  border-radius: 14px;
  padding: 12px;
  background: #f8fafc;
}

.drawio-banner {
  font-size: 14px;
  color: #334155;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.drawio-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 6px 0;
}

.drawio-btn {
  padding: 6px 10px;
  border: 1px solid #d0d7de;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}

.drawio-btn:hover {
  background: #f3f4f6;
}

.drawio-capture {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px;
  overflow: auto;
}

.drawio-frame {
  display: inline-block;
  background: #fff;
  max-width: 100%;
  overflow: auto;
}

.drawio-xml {
  margin-top: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 12px;
}

.drawio-xml-box {
  position: relative;
  margin-top: 10px;
}

.drawio-copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 10px;
  border: 1px solid #d0d7de;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  color: #111827;
}

.drawio-copy-btn:hover {
  background: #f3f4f6;
}

.drawio-xml > summary {
  cursor: pointer;
  font-weight: 600;
  color: #334155;
  user-select: none;
}

.drawio-xml-pre {
  margin: 10px 0 0 0;
  max-height: 280px;
  overflow: auto;
  background: #ffffff;
  color: #111827;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  font-size: 12px;
  line-height: 1.5;
}

.drawio-xml-pre code {
  color: inherit;
}

.drawio-placeholder,
.drawio-error {
  font-size: 13px;
  color: #666;
  background: #f8f9fa;
  border: 1px dashed #d0d7de;
  border-radius: 8px;
  padding: 10px 12px;
}

.drawio-error {
  color: #b42318;
  border-color: #f2c0c0;
  background: #fff5f5;
}

body.wide-mode .editor-pane {
  width: 0;
  opacity: 0;
  overflow: hidden;
  border: none;
}

body.wide-mode .preview-pane {
  width: 100%;
}

body.wide-mode .preview-content {
  max-width: 95%;
  padding: 30px 50px;
}

#exit-wide-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 999;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.wide-mode #exit-wide-btn {
  display: block;
}

@media print {
  header,
  .editor-pane,
  #exit-wide-btn {
    display: none !important;
  }

  .preview-pane {
    width: 100%;
    display: block;
  }

  .preview-content {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
}

/* 自定义确认弹窗 - 现代化设计 */
.inline-confirm {
  position: fixed;
  background: rgba(255, 255, 255, 0.98);
  border: none;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  min-width: 205px;
  font-size: 14px;
  animation: confirmPop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  backdrop-filter: blur(8px);
  box-sizing: border-box;
}

@keyframes confirmPop {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.inline-confirm .confirm-text {
  margin-bottom: 8px;
  color: #1a1a2e;
  font-weight: 500;
  line-height: 1.2;
  position: relative;
  text-align: center;
  white-space: nowrap;
  margin-bottom: 10px;
}

.inline-confirm .confirm-text::before {
  position: absolute;
  left: 0;
  top: -2px;
  font-size: 18px;
}

.inline-confirm .confirm-buttons {
  display: flex;
  gap: 8px;
  width: 100%;
  margin: 0;
}

.inline-confirm .confirm-buttons button {
  flex: 1;
  height: 36px;
  padding: 0;
  font-size: 13px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  box-sizing: border-box;
}

.inline-confirm .confirm-btn-yes {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(238, 90, 90, 0.3);
}

.inline-confirm .confirm-btn-yes:hover {
  background: linear-gradient(135deg, #ee5a5a 0%, #e74c3c 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(238, 90, 90, 0.4);
}

.inline-confirm .confirm-btn-yes:active {
  transform: translateY(0);
}

.inline-confirm .confirm-btn-no {
  background: #f1f2f6;
  color: #57606f;
}

.inline-confirm .confirm-btn-no:hover {
  background: #dfe4ea;
  color: #2f3542;
}
