:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-sidebar: rgba(13, 19, 33, 0.95);
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-subtle: rgba(22, 31, 50, 0.5);
  --bg-input: rgba(15, 23, 42, 0.9);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-focus: #6366f1;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.28);
  --accent-light: #818cf8;
  --accent-bg: rgba(99, 102, 241, 0.12);

  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.12);
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.12);
  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  --sidebar-width: 280px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-sidebar: rgba(255, 255, 255, 0.95);
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-card-subtle: rgba(241, 245, 249, 0.85);
  --bg-input: #ffffff;

  --border-color: rgba(0, 0, 0, 0.08);
  --border-subtle: rgba(0, 0, 0, 0.04);
  --border-focus: #4f46e5;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --accent-primary: #4f46e5;
  --accent-hover: #4338ca;
  --accent-glow: rgba(79, 70, 229, 0.2);
  --accent-light: #6366f1;
  --accent-bg: rgba(79, 70, 229, 0.08);

  --shadow-card: 0 10px 30px -10px rgba(15, 23, 42, 0.08), 0 0 1px 1px rgba(0, 0, 0, 0.04);
}

/* Light Theme Component Overrides */
[data-theme="light"] .portal-header {
  background: rgba(255, 255, 255, 0.88);
}

[data-theme="light"] .brand-name {
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .sidebar {
  background: var(--bg-sidebar);
}

[data-theme="light"] .sidebar-search-input {
  background: #ffffff;
  border-color: var(--border-color);
  color: var(--text-primary);
}

[data-theme="light"] .sidebar-search-input:focus {
  background: #ffffff;
}

[data-theme="light"] .nav-item {
  color: var(--text-secondary);
}

[data-theme="light"] .nav-item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
}

[data-theme="light"] .nav-item.active {
  background: var(--accent-bg);
  border-color: rgba(79, 70, 229, 0.25);
  color: var(--accent-primary);
}

[data-theme="light"] .btn-secondary {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
  border-color: var(--border-color);
}

[data-theme="light"] .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
  border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .tool-btn {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text-secondary);
  border-color: var(--border-color);
}

[data-theme="light"] .tool-btn:hover {
  background: rgba(0, 0, 0, 0.07);
  color: var(--text-primary);
}

[data-theme="light"] .theme-select {
  background: #ffffff;
  border-color: var(--border-color);
  color: var(--text-primary);
}

[data-theme="light"] .pane-header {
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

[data-theme="light"] .pane-title {
  color: var(--text-primary);
}

[data-theme="light"] .editor-textarea {
  color: #0f172a;
}

[data-theme="light"] .preview-container {
  background: #ffffff;
  color: #334155;
}

[data-theme="light"] .preview-container h1,
[data-theme="light"] .preview-container h2,
[data-theme="light"] .preview-container h3,
[data-theme="light"] .preview-container h4,
[data-theme="light"] .preview-container h5,
[data-theme="light"] .preview-container h6 {
  color: #0f172a;
}

[data-theme="light"] .preview-container h1 {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .preview-container h2 {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .preview-container a {
  color: #4f46e5;
}

[data-theme="light"] .preview-container blockquote {
  background: rgba(79, 70, 229, 0.05);
  color: #475569;
}

[data-theme="light"] .preview-container code:not(pre code) {
  background: rgba(0, 0, 0, 0.05);
  color: #e11d48;
}

[data-theme="light"] .preview-container pre {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

[data-theme="light"] .preview-container pre code {
  color: #0f172a;
}

[data-theme="light"] .preview-container table {
  border-color: #e2e8f0;
}

[data-theme="light"] .preview-container th,
[data-theme="light"] .preview-container td {
  border-color: #e2e8f0;
}

[data-theme="light"] .preview-container th {
  background: #f1f5f9;
  color: #0f172a;
}

[data-theme="light"] .preview-container tr:nth-child(even) {
  background: #f8fafc;
}

[data-theme="light"] .diff-container {
  background: #ffffff;
  border-color: var(--border-color);
}

[data-theme="light"] .diff-row {
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .diff-row.equal {
  color: #64748b;
}

[data-theme="light"] .diff-row.insert {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

[data-theme="light"] .diff-row.delete {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

[data-theme="light"] .studio-drawer {
  background: rgba(255, 255, 255, 0.95);
}

[data-theme="light"] .toc-item-link.level-1 {
  color: #0f172a;
}

[data-theme="light"] .toc-item-link:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #0f172a;
}

[data-theme="light"] .toast-msg {
  background: rgba(15, 23, 42, 0.95);
  color: #fff;
}

/* Theme Toggle Button Icons */
[data-theme="light"] #themeToggleBtn .theme-icon-sun {
  display: none !important;
}
[data-theme="light"] #themeToggleBtn .theme-icon-moon {
  display: block !important;
}
[data-theme="dark"] #themeToggleBtn .theme-icon-sun {
  display: block !important;
}
[data-theme="dark"] #themeToggleBtn .theme-icon-moon {
  display: none !important;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

/* 背景氛围光晕 */
.bg-decorations {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.aurora-orb-1 {
  position: absolute;
  top: -15%;
  left: 20%;
  width: 55vw;
  height: 55vw;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, rgba(99, 102, 241, 0) 70%);
  filter: blur(90px);
  border-radius: 50%;
}

.aurora-orb-2 {
  position: absolute;
  top: 40%;
  right: -10%;
  width: 45vw;
  height: 45vw;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.1) 0%, rgba(168, 85, 247, 0) 70%);
  filter: blur(100px);
  border-radius: 50%;
}

/* 顶部导航 Header */
.portal-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(9, 13, 22, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  height: 64px;
}

.header-inner {
  max-width: 1720px;
  height: 100%;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.menu-toggle-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 16px var(--accent-glow);
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  background: var(--accent-bg);
  color: var(--accent-light);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 999px;
  font-weight: 600;
  margin-left: 0.5rem;
}

/* 按钮通用 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-success {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}
.btn-success:hover {
  background: rgba(16, 185, 129, 0.25);
  color: #fff;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  font-size: 0.78rem;
  padding: 0.3rem 0.65rem;
}

.btn-icon {
  padding: 0.4rem;
  width: 32px;
  height: 32px;
}

/* 主布局 */
.app-layout {
  display: flex;
  max-width: 1720px;
  margin: 0 auto;
  min-height: calc(100vh - 64px);
  position: relative;
  z-index: 1;
}

/* 左侧 Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--border-color);
  background: var(--bg-sidebar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
  height: calc(100vh - 64px);
  position: sticky;
  top: 64px;
}

.sidebar-search {
  position: relative;
}

.sidebar-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.sidebar-search-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  transition: var(--transition);
}
.sidebar-search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  transition: var(--transition);
  border: 1px solid transparent;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-bg);
  border-color: rgba(99, 102, 241, 0.25);
  color: #fff;
  font-weight: 600;
}
.nav-icon {
  display: flex;
  align-items: center;
  color: var(--accent-light);
}

/* 主内容区域 */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
}

/* 工具容器视图 */
.tool-view {
  display: none;
  flex-direction: column;
  flex: 1;
  padding: 1.25rem;
}
.tool-view.active {
  display: flex;
}

/* Markdown Studio 顶部操作栏 */
.studio-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.85rem;
  backdrop-filter: blur(8px);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 0.25rem;
}

.tool-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: var(--transition);
}
.tool-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: var(--border-color);
}

.theme-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

/* Studio 核心工作台：双栏编辑器与预览 */
.studio-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  flex: 1;
  min-height: calc(100vh - 180px);
}

.studio-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  backdrop-filter: blur(8px);
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.85rem;
  background: rgba(15, 23, 42, 0.65);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.pane-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* 源码编辑器 Textarea */
.editor-textarea {
  flex: 1;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-primary);
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-word;
}
.editor-textarea::selection {
  background: rgba(99, 102, 241, 0.4);
}

/* 预览区域 Container */
.preview-container {
  flex: 1;
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.8;
  color: #e2e8f0;
  word-break: break-word;
  background: rgba(15, 23, 42, 0.35);
}

/* Markdown 预览元素精美排版 */
.preview-container h1,
.preview-container h2,
.preview-container h3,
.preview-container h4,
.preview-container h5,
.preview-container h6 {
  color: #fff;
  font-weight: 700;
  line-height: 1.35;
  margin-top: 1.5em;
  margin-bottom: 0.6em;
  scroll-margin-top: 20px;
}

.preview-container h1 {
  font-size: 1.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 0.4em;
  margin-top: 0.5em;
}
.preview-container h2 {
  font-size: 1.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.3em;
}
.preview-container h3 { font-size: 1.2rem; }
.preview-container h4 { font-size: 1.05rem; }

.preview-container p {
  margin: 0.9em 0;
}

.preview-container a {
  color: #818cf8;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.preview-container a:hover {
  color: #a5b4fc;
}

.preview-container blockquote {
  background: rgba(99, 102, 241, 0.08);
  border-left: 4px solid var(--accent-primary);
  padding: 0.75rem 1rem;
  margin: 1em 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: #cbd5e1;
}

.preview-container code:not(pre code) {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  color: #f43f5e;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.88em;
}

.preview-container pre {
  background: #0b0f19;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin: 1.2em 0;
  overflow-x: auto;
  position: relative;
}

.preview-container pre code {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.6;
  color: #f1f5f9;
}

.preview-container ul,
.preview-container ol {
  padding-left: 1.75rem;
  margin: 0.8em 0;
}

.preview-container li {
  margin-bottom: 0.35em;
}

.preview-container table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 0.88rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.preview-container th,
.preview-container td {
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border-color);
  text-align: left;
}

.preview-container th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  color: #fff;
}

.preview-container tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.preview-container img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 1em 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.preview-container hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2em 0;
}

/* 抽屉大纲与统计面板 */
.drawer-toggle-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.studio-drawer {
  position: fixed;
  right: -340px;
  top: 64px;
  width: 320px;
  height: calc(100vh - 64px);
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  z-index: 40;
  transition: right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 1rem;
}
.studio-drawer.open {
  right: 0;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.6rem;
}

.toc-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.toc-item-link {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toc-item-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}
.toc-item-link.level-1 { font-weight: 700; color: #fff; }
.toc-item-link.level-2 { padding-left: 1rem; }
.toc-item-link.level-3 { padding-left: 1.5rem; font-size: 0.78rem; }
.toc-item-link.level-4 { padding-left: 2rem; font-size: 0.75rem; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-light);
}

/* 其它工具通用面板 (HTML2MD, Table, Diff, Pangu, Frontmatter) */
.tool-header-block {
  margin-bottom: 1.25rem;
}
.tool-header-title {
  font-size: 1.35rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tool-header-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  backdrop-filter: blur(8px);
}

.grid-two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.input-box {
  width: 100%;
  min-height: 380px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  outline: none;
  resize: vertical;
}
.input-box:focus {
  border-color: var(--border-focus);
}

/* Diff 视图样式 */
.diff-container {
  display: flex;
  flex-direction: column;
  background: #0b0f19;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  overflow-x: auto;
  max-height: 520px;
}

.diff-row {
  display: flex;
  padding: 0.15rem 0.5rem;
  line-height: 1.5;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}
.diff-row.insert {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}
.diff-row.delete {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}
.diff-row.equal {
  color: #94a3b8;
}

.diff-line-no {
  width: 45px;
  flex-shrink: 0;
  color: var(--text-muted);
  user-select: none;
}
.diff-sign {
  width: 20px;
  flex-shrink: 0;
  font-weight: 700;
}
.diff-text {
  flex: 1;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Toast 提示与变体 */
.toast-msg {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.95);
  color: #fff;
  border: 1px solid rgba(99, 102, 241, 0.4);
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.toast-msg.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-msg.toast-warning {
  border-color: rgba(245, 158, 11, 0.7);
  background: rgba(28, 22, 12, 0.96);
  color: #fef3c7;
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.3);
}

.toast-msg.toast-error {
  border-color: rgba(239, 68, 68, 0.7);
  background: rgba(35, 14, 14, 0.96);
  color: #fee2e2;
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.3);
}

.toast-msg.toast-success {
  border-color: rgba(16, 185, 129, 0.7);
  background: rgba(12, 28, 20, 0.96);
  color: #d1fae5;
  box-shadow: 0 10px 30px rgba(16, 185, 129, 0.3);
}

/* 输入框空校验高亮与微抖动动画 */
@keyframes inputShakeHighlight {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.input-error-highlight {
  border-color: #f59e0b !important;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.35) !important;
  animation: inputShakeHighlight 0.38s ease-in-out;
}

/* 打印 PDF 专用样式 (@media print) */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .portal-header,
  .sidebar,
  .studio-toolbar,
  .pane-header,
  .editor-textarea,
  .studio-drawer,
  .bg-decorations,
  .toast-msg,
  .menu-toggle-btn {
    display: none !important;
  }
  .app-layout {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }
  .tool-view {
    display: none !important;
  }
  .tool-view.active {
    display: block !important;
    padding: 0 !important;
  }
  .studio-workspace {
    display: block !important;
  }
  .studio-pane:first-child {
    display: none !important;
  }
  .studio-pane:last-child {
    border: none !important;
    background: #fff !important;
    box-shadow: none !important;
  }
  .preview-container {
    background: #fff !important;
    color: #111 !important;
    padding: 0 !important;
    font-size: 12pt !important;
    line-height: 1.6 !important;
  }
  .preview-container h1,
  .preview-container h2,
  .preview-container h3 {
    color: #000 !important;
    page-break-after: avoid;
    break-after: avoid;
  }
  .preview-container table,
  .preview-container pre,
  .preview-container img,
  .preview-container blockquote {
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .preview-container table {
    border: 1px solid #ddd !important;
  }
  .preview-container th,
  .preview-container td {
    border: 1px solid #ddd !important;
    color: #000 !important;
  }
  .preview-container pre {
    background: #f8fafc !important;
    color: #1e293b !important;
    border: 1px solid #e2e8f0 !important;
  }
  .preview-container pre code {
    color: #1e293b !important;
  }
}

/* 响应式断点 */
@media (max-width: 1024px) {
  .studio-workspace {
    grid-template-columns: 1fr;
  }
  .grid-two-cols {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .menu-toggle-btn {
    display: flex;
  }
  .sidebar {
    position: fixed;
    left: -280px;
    z-index: 60;
    transition: left 0.28s ease;
  }
  .sidebar.open {
    left: 0;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.6);
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 55;
  }
  .sidebar-backdrop.show {
    display: block;
  }
}
