/* 浅色模式（默认） */
:root {
    --bg: #f9fafb;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --primary: #4f46e5;
    --primary-light: #ede9fe;
    --primary-dark: #4338ca;
    --accent: #10b981;
    --shadow: rgba(0, 0, 0, 0.05);
    --copy-bg: #f8fafc;
}

/* 深色模式 */
[data-theme="dark"] {
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --primary: #818cf8;
    --primary-light: #312e81;
    --primary-dark: #6366f1;
    --accent: #34d399;
    --shadow: rgba(0, 0, 0, 0.2);
    --copy-bg: #1e293b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background 0.2s ease, color 0.2s ease, border 0.2s ease;
}

body {
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.page-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.page-header h1 {
    color: var(--primary);
    font-size: 2.2rem;
    margin-bottom: 8px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.theme-toggle:hover {
    background: var(--primary);
    color: white;
}

.main-content {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.left-panel, .right-panel {
    flex: 1;
    min-width: 350px;
    background-color: var(--card);
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow);
    padding: 25px;
    border: 1px solid var(--border);
}

/* ========================== 全新分区布局 ========================== */
.panel-section {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.panel-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.panel-title {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.button-row {
    display: flex;
    gap: 10px;
}
.button-row .btn {
    flex: 1;
    padding: 10px 12px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-add {
    background: var(--primary);
    color: white;
}
.btn-delete {
    background: #ef4444;
    color: white;
}
.btn:hover {
    opacity: 0.9;
}

/* ========================== 基础控件 ========================== */
.template-select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    background: var(--card);
    color: var(--text);
    cursor: pointer;
}
.template-select:focus {
    outline: none;
    border-color: var(--primary);
}

.input-group {
    margin-bottom: 20px;
}

.input-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text);
}

input#title, textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    background: var(--card);
    color: var(--text);
}

input#title:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

textarea {
    min-height: 120px;
    max-height: 400px;
    resize: vertical;
    line-height: 1.8;
    overflow-y: auto;
}

.word-count {
    text-align: right;
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 5px;
    font-weight: 600;
}

.total-word-count {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background-color: var(--primary-light);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    margin-top: 15px;
}

/* ========================== 复制 & 导出 ========================== */
/* ========================== Full Text 已经移动到右侧 ========================== */
.full-text-group {
  margin-top: 10px;
}
.full-text-container {
  position: relative;
}
#full-text {
  width: 100%;
  min-height: 140px;
  max-height: 200px;
  padding: 12px 15px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: var(--copy-bg);
  color: var(--text);
  resize: vertical;
  line-height: 1.6;
}

#copy-btn {
  position: absolute;
  right: 14px;
  top: 12px;
  padding: 7px 11px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
#export-btn {
  position: absolute;
  right: 74px;
  top: 12px;
  padding: 7px 11px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
#copy-btn:hover, #export-btn:hover {
  opacity: 0.9;
}

#copy-toast {
  position: absolute;
  right: 10px;
  bottom: 10px;
  background-color: var(--accent);
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  opacity: 0;
}
#copy-toast.show {
  opacity: 1;
}

.submit-btn {
    width: 100%;
    padding: 14px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
}
.submit-btn:hover {
    background-color: var(--primary-dark);
}

/* ========================== 右侧结果区 ========================== */
.chart-wrapper {
    display: flex;
    justify-content: center;
    padding: 10px 0 20px;
}
.score-display, .suggestions {
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    background-color: var(--card);
    border: 1px solid var(--border);
}
.card-title {
    color: var(--text);
    font-size: 1.2rem;
    margin-bottom: 15px;
}
.score-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-radius: 6px;
    background-color: var(--copy-bg);
}
.score-label {
    color: var(--text-muted);
    font-weight: 500;
}
.score-value {
    color: var(--text);
    font-weight: 600;
    font-size: 1.1rem;
}
.total-score {
    grid-column: 1 / -1;
    background-color: var(--primary-light);
    border: 1px solid var(--border);
}
.total-score .score-label {
    color: var(--primary);
    font-size: 1.1rem;
}
.total-score .score-value {
    color: var(--primary);
    font-size: 1.3rem;
}
.suggestions ul {
    margin-left: 20px;
    margin-top: 10px;
}
.suggestions li {
    margin-bottom: 8px;
    color: var(--text);
}
.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 15px 0;
}

/* ========================== 响应式 ========================== */
@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
    }
    .score-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================== 区块选中高亮 ========================== */
.input-group.selected {
    border: 2px solid var(--primary);
    background: var(--primary-light);
    border-radius: 8px;
    padding: 8px;
}

/* ========================== 历史弹窗 ========================== */
.history-btn {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: none;
    background: #6366f1;
    color: white;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.history-btn:hover {
    opacity: 0.9;
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    display: none;
}
.modal-overlay.show {
    display: flex;
}
.modal-box {
    background: var(--card);
    color: var(--text);
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    border-radius: 12px;
    padding: 20px;
    overflow: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text);
}
.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.history-item {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.history-title {
    font-weight: 600;
}
.history-time {
    font-size: 12px;
    color: #888;
}
.history-btn-view {
    padding: 6px 12px;
    background: #6366f1;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.modal-view-box textarea {
    width: 100%;
    height: 300px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    resize: none;
}
.load-to-editor-btn {
    padding: 8px 14px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.modal-close-btn {
    padding: 8px 14px;
    background: #666;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.history-btn-delete { padding:6px 10px; background:#ef4444; color:white; border:none; border-radius:6px; cursor:pointer; }
.history-clear-all { padding:6px 12px; background:#666; color:white; border:none; border-radius:6px; cursor:pointer; }

/* 拖拽排序悬浮样式 */
.sortable-ghost {
    background: var(--primary-light) !important;
    border: 2px dashed var(--primary) !important;
    opacity: 0.7 !important;
}

/* 拖拽手柄样式 */
.drag-handle {
  position: absolute;
  left: 8px;
  top: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: grab;
  border-radius: 4px;
  transition: all 0.2s;
  z-index: 10;
}
.drag-handle:hover {
  background: var(--primary-light);
  color: var(--primary);
  cursor: grab;
}
.drag-handle:active {
  cursor: grabbing;
}

/* 给 input-group 加相对定位，让手柄绝对定位生效 */
.input-group {
  position: relative;
  padding-left: 36px !important; /* 给手柄留出空间 */
}
/* 规则按钮样式 */
.rules-btn {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.rules-btn:hover {
  opacity: 0.9;
}

/* 规则弹窗样式 */
.rules-modal-box {
  max-width: 800px;
  max-height: 85vh;
}
.rules-content {
  line-height: 1.8;
  color: var(--text);
}
.rules-content h4 {
  color: var(--primary);
  margin: 16px 0 8px;
  font-size: 1.1rem;
}
.rules-content ul {
  margin-left: 20px;
  margin-bottom: 12px;
}
.rules-content li {
  margin-bottom: 6px;
  color: var(--text);
}
.rules-close-btn {
  width: 100%;
  padding: 12px;
  margin-top: 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.rules-close-btn:hover {
  background: var(--primary-dark);
}

