/* Base styles that apply to all color schemes */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 100%;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* Full width on mobile devices */
@media (orientation: portrait) and (max-width: 768px) {
  #app {
    max-width: 100%;
  }
}

main {
  flex: 1;
  overflow-y: auto;
}

header,
footer {
  position: sticky;
  flex: 0 0 2.5%;
  display: flex;
  justify-content: space-between;
}

header {
  padding: 10px;
  top: 0;
}

footer {
  padding: 10px;
  gap: 10px;
}

footer textarea {
  flex: 1;
  resize: vertical;
  min-height: 40px;
  border-radius: 4px;
  padding: 8px;
}

footer button {
  padding: 0 16px;
  border-radius: 4px;
  white-space: nowrap;
}

.analysis-container {
  padding: 20px;
}

.analysis-container .sentence-block {
  margin-bottom: 30px;
  padding-bottom: 20px;
}

.analysis-container .sentence-block .japanese-text {
  font-size: 1.5em;
  margin-bottom: 10px;
}

.analysis-container .sentence-block .translation {
  margin-bottom: 20px;
}

.analysis-blocks .part-block {
  border-radius: 8px;
  margin-bottom: 15px;
  padding: 15px;
}

.analysis-blocks .part-block .part-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.analysis-blocks .part-block .part-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 5px 0;
}

.analysis-blocks .part-block .part-details .indent {
  font-family: monospace;
}

.analysis-blocks .part-block .part-details .add-button {
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.8em;
}

.sentences-container {
  position: sticky;
  bottom: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  z-index: 10;
  overflow-y: auto;
}

.sentences-container .sentence-block {
  padding: 5px;
}

.sentences-container .sentence-block .analyze-button {
  font-size: 0.9em;
}

/* Add max-height only when currentAnalysis exists */
.analysis-container + .sentences-container {
  max-height: 20vh;
}

.kanji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 10px;
  padding: 20px;
}

.kanji-grid.collapsed {
  max-height: 85px; /* Approximate height for 1.2 rows of 4 kanji */
  overflow: hidden;
}

.kanji-grid .kanji-card {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2em;
  cursor: pointer;
  transition: transform 0.2s;
}

.kanji-grid .kanji-card:hover {
  transform: scale(1.05);
}

.kanji-grid .kanji-card .reading-count {
  font-size: 0.5em;
  font-family: monospace;
  margin-left: 2.5px;
}

.expand-control {
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 20px;
}

.kanji-details {
  padding: 20px;
}

.kanji-details .reading-block {
  border-radius: 8px;
  margin: 10px 0;
  padding: 15px;
}

.kanji-details .reading-block .reading {
  font-size: 1.2em;
  margin-bottom: 10px;
  cursor: pointer;
}

.kanji-details .reading-block .reading-more {
  font-size: 0.8em;
}

.kanji-details .reading-block .reading-hidden {
  filter: blur(8px);
}

.kanji-details .reading-block .reading-hidden:hover {
  filter: blur(6px);
}

.kanji-details .reading-block .sentence {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
}

.kanji-details .reading-block .sentence ruby {
  font-size: 1.2em;
}

.kanji-details .reading-block .sentence ruby rt {
  font-size: 0.8em;
}

.kanji-details .reading-block .srs-info {
  font-size: 0.85em;
  padding: 4px 0;
}

.kanji-details .reading-block .srs-buttons {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 5px;
  margin-bottom: 5px;
}

.kanji-details .reading-block .srs-buttons button {
  padding: 8px 16px;
  border-radius: 4px;
}

.kanji-details .reading-block .srs-buttons button span {
  font-size: 0.85em;
  margin-left: 2px;
}

.contexts-section {
  margin-top: 25px;
  padding-top: 20px;
}

.contexts-section h4 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 0.9em;
}

.contexts-section .context-item {
  margin-bottom: 5px;
  font-size: 0.9em;
}

.contexts-section .context-item a {
  text-decoration: none;
}

.context-screenshot {
  margin: 20px 0 20px 0;
  text-align: center;
}

.context-screenshot img {
  max-width: 100%;
  max-height: 200px;
}

.context-screenshot a {
  display: block;
  margin-bottom: -20px;
}

/* Light mode styles */
/* @media (prefers-color-scheme: light) {
  body {
    background-color: #ffffff;
    color: #333;
  }

  button {
    color: #333;
    border: 1px solid #ddd;
    background: #f5f5f5;
  }

  button:hover {
    background: #e9e9e9;
    cursor: pointer;
  }

  a {
    color: #0066cc;
    text-decoration: none;
  }

  a:hover {
    text-decoration: underline;
  }

  header,
  footer {
    background-color: #f5f5f5;
    border-bottom: 1px solid #ddd;
  }

  footer textarea {
    border: 1px solid #ddd;
    background: #fff;
  }

  footer button {
    background: #e0e0e0;
    border: 1px solid #ccc;
    color: #333;
  }

  .analysis-container {
    color: #333;
  }

  .analysis-container .sentence-block {
    border-bottom: 1px solid #ddd;
  }

  .analysis-container .translation {
    color: #666;
  }

  .analysis-blocks .part-block {
    background: #f5f5f5;
    border: 1px solid #ddd;
  }

  .analysis-blocks .part-block .part-details {
    color: #666;
  }

  .analysis-blocks .part-block .part-details .add-button {
    background: #e0e0e0;
    color: #333;
    border: 1px solid #ccc;
  }

  .sentences-container {
    background: #f5f5f5;
    border-top: 1px solid #ddd;
  }

  .sentences-container .analyze-button {
    color: #666;
  }

  .kanji-grid .kanji-card {
    background: #f5f5f5;
    border: 1px solid #ddd;
    color: #333;
  }

  .kanji-grid .kanji-overdue {
    background: #fff0f0;
    border-color: #ffcaca;
  }

  .kanji-grid .kanji-selected {
    background: #e6ffe6;
    border-color: #b3d9b3;
  }

  .kanji-details .reading-block {
    background: #f5f5f5;
    border: 1px solid #ddd;
  }

  .kanji-details .reading-block .reading-more {
    color: #666;
  }

  .kanji-details .reading-block .sentence ruby rt {
    color: #666;
  }

  .kanji-details .reading-block .srs-info {
    color: #666;
  }

  .kanji-details .reading-block .srs-buttons .correct {
    background: #2a9d8f;
    color: white;
    border: none;
  }

  .kanji-details .reading-block .srs-buttons .pre-correct {
    background: #e0e0e0;
    color: #333;
  }

  .kanji-details .reading-block .srs-buttons .wrong {
    background: #e76f51;
    color: white;
    border: none;
  }

  .kanji-details .reading-block .srs-buttons .pre-wrong {
    background: #e0e0e0;
    color: #333;
  }

  .kanji-details .reading-block .srs-buttons button span {
    color: rgba(0, 0, 0, 0.7);
  }

  .contexts-section {
    border-top: 1px dashed #999;
  }

  .contexts-section h4 {
    color: #666;
  }

  .context-screenshot a {
    color: #666;
  }
} */

/* Dark mode styles */
/* @media (prefers-color-scheme: dark) { */
body {
  background-color: #333;
  color: #fff;
}

button {
  color: #fff;
  border: none;
  background: none;
}

button:hover {
  cursor: pointer;
}

a {
  color: #fff;
}

header,
footer {
  background-color: #333;
  border-bottom: 1px solid #444;
}

footer textarea {
  background: #444;
  border: 1px solid #555;
  color: #fff;
}

footer button {
  background: #4a4a4a;
  color: white;
}

.analysis-container {
  color: #fff;
}

.analysis-container .sentence-block {
  border-bottom: 1px solid #555;
}

.analysis-container .translation {
  color: #aaa;
}

.analysis-blocks .part-block {
  background: #444;
  border: 1px solid #555;
}

.analysis-blocks .part-block .part-details {
  color: #aaa;
}

.analysis-blocks .part-block .part-details .add-button {
  background: #666;
  color: white;
}

.sentences-container {
  background: #333;
  border-top: 1px solid #444;
}

.sentences-container .analyze-button {
  color: #aaa;
}

.kanji-grid .kanji-card {
  background: #444;
  color: #fff;
}

.kanji-grid .kanji-overdue {
  background: #664444;
}

.kanji-grid .kanji-selected {
  background: #446644;
}

.kanji-details .reading-block {
  background: #444;
  border: 1px solid #555;
}

.kanji-details .reading-block .reading-more {
  color: #aaa;
}

.kanji-details .reading-block .sentence ruby rt {
  color: #aaa;
}

.kanji-details .reading-block .srs-info {
  color: #888;
}

.kanji-details .reading-block .srs-buttons .correct {
  background: #2a9d8f;
  color: white;
}

.kanji-details .reading-block .srs-buttons .pre-correct {
  background: #333;
  color: white;
}

.kanji-details .reading-block .srs-buttons .wrong {
  background: #e76f51;
  color: white;
}

.kanji-details .reading-block .srs-buttons .pre-wrong {
  background: #333;
  color: white;
}

.kanji-details .reading-block .srs-buttons button span {
  color: rgba(255, 255, 255, 0.7);
}

.contexts-section {
  border-top: 1px dashed #666;
}

.contexts-section h4 {
  color: #aaa;
}

.context-screenshot a {
  color: #888;
}
/* } */
