:root {
  --primary-color: #4a6fa5;
  --secondary-color: #334e68;
  --background-color: #f8f9fa;
  --text-color: #334e68;
  --border-color: #d9e2ec;
  --added-color: #31a354;
  --added-bg: #e6f5ee;
  --removed-color: #e53935;
  --removed-bg: #fbe9e7;
  --chunk-color: #8a008b;
  --header-height: 60px;
}

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

html, body {
  background: var(--background-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  font-size: 14px;
  color: var(--text-color);
  height: 100%;
  line-height: 1.5;
}

body {
  padding-top: var(--header-height);
  display: flex;
  flex-direction: column;
}

.container {
  display: flex;
  height: calc(100% - var(--header-height));
  width: 100%;
}

.panel {
  flex: 1;
  padding: 10px;
  height: 100%;
  position: relative;
}

textarea, #result {
  width: 100%;
  height: 100%;
  padding: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: white;
  resize: none;
  overflow: auto;
}

#result {
  white-space: pre-wrap;
  background-color: white;
}

h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-color);
}

del {
  text-decoration: none;
  color: var(--removed-color);
  background: var(--removed-bg);
  padding: 1px 0;
}

ins {
  background: var(--added-bg);
  color: var(--added-color);
  text-decoration: none;
  padding: 1px 0;
}

.chunk-header {
  color: var(--chunk-color);
  text-decoration: none;
  font-weight: bold;
}

#settings {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: white;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.title-section {
  flex: 1;
}

.options-section {
  display: flex;
  align-items: center;
}

#settings label {
  margin-left: 15px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

#settings input[type="radio"] {
  margin-right: 5px;
}

.links-section {
  margin-left: 20px;
}

.source {
  color: var(--primary-color);
  text-decoration: none;
  margin-left: 15px;
  font-size: 14px;
  transition: color 0.2s;
}

.source:hover {
  color: var(--secondary-color);
  text-decoration: underline;
}

textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.2);
}

/* Responsive design */
@media (max-width: 768px) {
  :root {
    --header-height: auto;
  }
  
  body {
    padding-top: 180px; /* Increased to prevent settings from overlapping content */
  }
  
  .container {
    flex-direction: column;
    height: auto;
    min-height: calc(100% - 140px);
  }
  
  .panel {
    height: auto;
    min-height: 200px;
    margin-bottom: 15px;
    flex-shrink: 0;
  }
  
  body {
    overflow-y: auto;
  }
  
  #settings {
    flex-direction: column;
    height: auto;
    padding: 15px;
    align-items: flex-start;
  }
  
  .title-section, .options-section, .links-section {
    width: 100%;
    margin: 5px 0;
  }
  
  h1 {
    font-size: 16px;
    margin-bottom: 8px;
  }
  
  .options-section {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-between;
    width: 100%;
    margin: 10px 0;
    overflow-x: auto;
    padding-bottom: 5px; /* Space for potential scrollbar */
  }
  
  .options-section label {
    white-space: nowrap;
    flex: 1;
    text-align: center;
    padding: 8px 5px;
  }
  
  #settings label {
    margin-left: 0;
    padding: 8px 0;
  }
  
  .links-section {
    display: flex;
    flex-wrap: wrap;
    margin-top: 10px;
  }
  
  .source {
    margin: 5px 15px 5px 0;
    padding: 5px 0;
  }
  
  textarea, #result {
    font-size: 16px; /* Larger font for better readability on mobile */
    padding: 10px;
    height: auto;
    min-height: 180px;
    max-height: 300px;
    overflow-y: auto;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  body {
    padding-top: 200px; /* Increased to prevent settings from overlapping content on small screens */
    height: auto;
    min-height: 100%;
  }
  
  .container {
    height: auto;
    min-height: calc(100% - 160px);
  }
  
  /* Keep options in a single row even on very small screens */
  .options-section label {
    padding: 8px 3px;
    font-size: 13px;
  }
  
  .panel {
    min-height: 150px;
  }
  
  /* Make radio buttons and links more touch-friendly */
  #settings input[type="radio"] {
    width: 16px;
    height: 16px;
    margin-right: 8px;
  }
  
  .source {
    padding: 8px 0;
    display: inline-block;
  }
}

/* Hero section - ensure it takes at least full viewport height */
.hero {
  min-height: 100vh; /* 至少占满首屏 */
  display: flex;
  flex-direction: column;
}

/* SEO intro section - ensure it's below the fold */
.seo-intro {
  margin-top: 20px;
  padding: 40px;
  background-color: white;
  border-top: 1px solid var(--border-color);
}

.seo-intro h1 {
  margin-bottom: 20px;
}

.seo-intro h2 {
  margin: 25px 0 15px;
  color: var(--primary-color);
}

.seo-intro p, .seo-intro ul {
  margin-bottom: 15px;
  line-height: 1.6;
}

.seo-intro ul {
  padding-left: 20px;
}

.seo-intro li {
  margin-bottom: 8px;
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
  body {
    padding-top: 140px; /* Increased to prevent settings from overlapping content in landscape mode */
    height: auto;
    min-height: 100%;
    overflow-y: auto;
  }
  
  .container {
    height: auto;
    min-height: calc(100% - 100px);
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .panel {
    width: calc(50% - 10px);
    height: auto;
    min-height: 150px;
    margin: 0 5px 10px 5px;
  }
  
  .panel:nth-child(3) {
    width: calc(100% - 10px);
  }
  
  .options-section {
    justify-content: flex-start;
  }
  
  .options-section label {
    margin-right: 20px;
  }

  .hero {
    min-height: 100vh; /* 至少占满首屏 */
  }
}
