:root {
  --primary-color: #3498db;
  --secondary-color: #ff6666;
  --background-color: #f5f6fa;
  --text-color: #2c3e50;
  --card-background: #ffffff;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --inactive-color: #95a5a6;
  --answer-background: #f1f1fa;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  padding-bottom: 80px;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 30px;
}

header h1 {
  color: var(--primary-color);
  font-size: 2.5em;
  margin: 20px 0;
}

#category-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 30px;
}

#category-nav button {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  background-color: var(--inactive-color);
  color: white;
  cursor: pointer;
  transition: background-color 0.3s;
}

#category-nav button:hover {
  background-color: #7f8c8d;
}

#category-nav button.active {
  background-color: var(--primary-color);
}

#category-nav button.active:hover {
  background-color: #2980b9;
}

#question-card {
  background-color: var(--card-background);
  border-radius: 10px;
  padding: 30px;
  margin-bottom: 40px;
  box-shadow: 0 4px 6px var(--shadow-color);
  cursor: pointer;
  transition: background-color 0.2s;
}

#question-card:hover {
  background-color: var(--background-color);
}

#question-content {
}

#question-content h3 {
  display: inline;
  vertical-align: middle;
}

#answer-section {
  border-radius: 5px;
  padding: 0;
  margin-top: 30px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  cursor: default;
  border-top: 2px solid var(--shadow-color);
}

#answer-section.hidden {
  display: none;
}

.controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--card-background);
  padding: 15px;
  box-shadow: 0 -2px 10px var(--shadow-color);
  display: flex;
  gap: 10px;
  justify-content: center;
  z-index: 1000;
}

.controls button {
  padding: 12px 24px;
  border: none;
  border-radius: 5px;
  background-color: var(--primary-color);
  color: white;
  cursor: pointer;
  transition: all 0.3s;
  min-width: 150px;
}

.controls button:hover {
  background-color: #2980b9;
  transform: translateY(-2px);
}

/* Markdown 内容样式 */
#question-content h1,
#question-content h2,
#question-content h3 {
  margin: 15px 0;
}

#question-content p {
  margin: 10px 0;
}

#question-content code {
  background-color: #f0f0f0;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
}

#question-content pre {
  background-color: #f0f0f0;
  padding: 15px;
  border-radius: 5px;
  overflow-x: auto;
  margin: 15px 0;
}

#answer-content {
  max-width: 100%;
  overflow-x: auto;
}

/* Markdown 内容样式 */
#answer-content h1,
#answer-content h2,
#answer-content h3,
#answer-content h4,
#answer-content h5,
#answer-content h6 {
  margin: 1em 0 0.6em;
  line-height: 1.4;
  color: var(--text-color);
}

#answer-content h4 {
  font-size: 1.2em;
}
#answer-content h5 {
  font-size: 1.1em;
}
#answer-content h6 {
  font-size: 1em;
}

#answer-content p {
  margin: 0.8em 0;
  line-height: 1.6;
}

#answer-content ul,
#answer-content ol {
  margin: 0.5em 0;
  padding-left: 2em;
}

#answer-content li {
  margin: 0.3em 0;
}

#answer-content code {
  background-color: #f0f0f0;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
}

#answer-content pre {
  background-color: #f0f0f0;
  padding: 1em;
  border-radius: 5px;
  overflow-x: auto;
  margin: 1em 0;
}

#answer-content pre code {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 0.9em;
  line-height: 1.5;
}

#answer-content blockquote {
  margin: 1em 0;
  padding-left: 1em;
  border-left: 4px solid var(--primary-color);
  color: #666;
}

#answer-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  display: block;
  overflow-x: auto;
}

#answer-content th,
#answer-content td {
  border: 1px solid #ddd;
  padding: 8px 12px;
  text-align: left;
}

#answer-content th {
  background-color: #f5f5f5;
}

#answer-content img {
  max-width: 100%;
  height: auto;
  margin: 1em 0;
}

#answer-content strong {
  font-weight: 600;
}

#answer-content em {
  font-style: italic;
}

/* 调整列表样式 */
#answer-content ul {
  list-style-type: disc;
}

#answer-content ul ul {
  list-style-type: circle;
}

#answer-content ul ul ul {
  list-style-type: square;
}

#answer-content ol {
  list-style-type: decimal;
}

#answer-content ol ol {
  list-style-type: lower-alpha;
}

#answer-content ol ol ol {
  list-style-type: lower-roman;
}

.search-box {
  margin-bottom: 20px;
  position: relative;
}

#search-input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--inactive-color);
  border-radius: 5px;
  font-size: 16px;
  transition: border-color 0.3s;
}

#search-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

#search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-background);
  border-radius: 5px;
  box-shadow: 0 4px 6px var(--shadow-color);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
}

#search-results.hidden {
  display: none;
}

.search-result-item {
  padding: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--background-color);
  transition: background-color 0.2s;
}

.search-result-item:hover {
  background-color: var(--background-color);
}

.search-result-item:last-child {
  border-bottom: none;
}

.category-tag {
  display: inline-block;
  padding: 2px 8px;
  background-color: var(--primary-color);
  color: white;
  border-radius: 3px;
  font-size: 0.8em;
  margin-right: 8px;
  margin-top: 4px;
  vertical-align: middle;
}

/* 确保其他标题样式正常 */
#question-content h1,
#question-content h2,
#question-content h4,
#question-content h5,
#question-content h6 {
  margin: 15px 0;
  display: block;
}

.favorite-btn {
  background-color: var(--secondary-color) !important;
}

#show-favorites {
  background-color: var(--secondary-color);
}

/* 弹窗样式 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background-color: var(--card-background);
  border-radius: 10px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

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

.modal-header h2 {
  margin: 0;
  color: var(--text-color);
}

.close-modal {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-color);
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.close-modal:hover {
  background-color: var(--background-color);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* 收藏列表样式 */
.favorite-item {
  background-color: var(--background-color);
  border-radius: 5px;
  padding: 15px;
  margin-bottom: 15px;
  position: relative;
  cursor: pointer;
}

.favorite-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.favorite-item-header .title-section {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1;
}

.favorite-item-header .title-section h3 {
  display: inline;
  margin: 0;
}

.favorite-item .answer {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--shadow-color);
  display: none;
}

.favorite-item .answer.show {
  display: block;
}

/* 收藏列表中的 Markdown 样式 */
.favorite-item .answer h1,
.favorite-item .answer h2,
.favorite-item .answer h3,
.favorite-item .answer h4,
.favorite-item .answer h5,
.favorite-item .answer h6 {
  margin: 1em 0 0.6em;
  line-height: 1.4;
  color: var(--text-color);
}

.favorite-item .answer h4 {
  font-size: 1.2em;
}

.favorite-item .answer h5 {
  font-size: 1.1em;
}

.favorite-item .answer h6 {
  font-size: 1em;
}

.favorite-item .answer p {
  margin: 0.8em 0;
  line-height: 1.6;
}

.favorite-item .answer ul,
.favorite-item .answer ol {
  margin: 0.5em 0;
  padding-left: 2em;
}

.favorite-item .answer li {
  margin: 0.3em 0;
}

.favorite-item .answer code {
  background-color: #f0f0f0;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
}

.favorite-item .answer pre {
  background-color: #f0f0f0;
  padding: 1em;
  border-radius: 5px;
  overflow-x: auto;
  margin: 1em 0;
}

.favorite-item .answer pre code {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 0.9em;
  line-height: 1.5;
}

.favorite-item .answer blockquote {
  margin: 1em 0;
  padding-left: 1em;
  border-left: 4px solid var(--primary-color);
  color: #666;
}

.favorite-item .answer table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  display: block;
  overflow-x: auto;
}

.favorite-item .answer th,
.favorite-item .answer td {
  border: 1px solid #ddd;
  padding: 8px 12px;
  text-align: left;
}

.favorite-item .answer th {
  background-color: #f5f5f5;
}

.favorite-item .answer img {
  max-width: 100%;
  height: auto;
  margin: 1em 0;
}

.favorite-item .answer strong {
  font-weight: 600;
}

.favorite-item .answer em {
  font-style: italic;
}

.question-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.question-header #question-content {
  flex: 1;
  margin-right: 40px;
}

.favorite-btn {
  background: none !important;
  border: none !important;
  font-size: 26px !important;
  color: var(--secondary-color) !important;
  cursor: pointer;
  height: 30px;
  line-height: 30px;
  min-width: auto !important;
  transition: transform 0.2s !important;
}

.favorite-btn:hover {
  transform: scale(1.2) !important;
}
