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

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: #2c2c2c;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 80px 20px 20px;
  gap: 20px;
}

/* -----------------------
Generic
----------------------- */

.main-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 700px;
}

.main-container {
  background: #f5f0e6;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  min-height: 600px;
}

@media (max-height: 800px) {
  .main-container {
    min-height: 350px;
  }
}

.section-content {
  display: flex;
  flex-direction: column;
}

.section-tabs {
  display: flex;
  background: #e8e0d0;
  border-bottom: 1px solid #d4c9b5;
  width: 100%;
}

.section-tab {
  flex: 1;
  padding: 12px 8px;
  text-align: center;
  font-size: 13px;
  font-weight: bold;
  text-decoration: none;
  color: #7a6a5a;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.section-tab:hover {
  background: #ddd5c5;
}

.section-tab.active {
  color: #8b4513;
  border-bottom-color: #8b4513;
  background: #f5f0e6;
}

.dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: #f5f0e6;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  min-width: 180px;
  display: none;
  overflow: hidden;
}

.dropdown.show {
  display: block;
}

.dropdown-item {
  padding: 12px 16px;
  font-size: 14px;
  color: #5a4a3a;
  cursor: pointer;
}

.dropdown-item:hover {
  background: #e8e0d0;
}

.dropdown-item.username {
  font-weight: bold;
  border-bottom: 1px solid #d4c9b5;
}

.dropdown-item.logout {
  color: #a04040;
}

.dropdown-item.font-controls {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
}

.dropdown-item.font-controls .font-btn {
  width: 32px;
  height: 24px;
  font-size: 12px;
}

.font-btn {
  background: #d4c9b5;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 3px;
  cursor: pointer;
  font-weight: bold;
  color: #5a4a3a;
}

.font-btn:hover {
  background: #c4b9a5;
}

/* -----------------------
Top bar
----------------------- */

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #101010;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  z-index: 100;
}

.top-bar-content {
  width: 100%;
  max-width: 700px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-img {
  width: 32px;
  height: 32px;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 10px;
  color: #888;
  font-size: 14px;
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
}

.nav-tab:hover {
  background: rgba(255,255,255,0.1);
  color: #ccc;
}

.nav-tab.active {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.nav-tab .dot {
  display: inline-block;
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background: #ff6b6b;
  border-radius: 50%;
}

.nav-tab svg, .nav-tab img {
  width: 18px;
  height: 18px;
}

.nav-tab img {
  filter: brightness(0) invert(1);
  opacity: 0.6;
}

.nav-tab:hover img {
  opacity: 0.8;
}

.nav-tab.active img {
  opacity: 1;
}

@media (max-width: 600px) {
  .nav-tab span:not(.dot) {
    display: none;
  }
  .nav-tab {
    gap: 0;
    padding: 6px 8px;
  }
  .nav-tab .dot {
    display: block;
    top: -2px;
    right: -2px;
  }
}

.lang-selector {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
}

.lang-selector:hover {
  background: rgba(255,255,255,0.2);
}

.lang-flag {
  width: 24px;
  height: 16px;
  border-radius: 2px;
  overflow: hidden;
}

.lang-flag img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lang-code {
  color: #fff;
  font-size: 12px;
  font-weight: bold;
}

.lang-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: #f5f0e6;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  min-width: 150px;
  display: none;
  overflow: hidden;
}

.lang-dropdown.show {
  display: block;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: #5a4a3a;
  cursor: pointer;
}

.lang-option:hover {
  background: #e8e0d0;
}

.lang-option .flag {
  width: 24px;
  height: 16px;
  border-radius: 2px;
  overflow: hidden;
}

.lang-option .flag img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-menu {
  position: relative;
}

.user-icon {
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  padding: 5px;
  box-sizing: border-box;
}

.user-icon:hover {
  background: rgba(255,255,255,0.2);
}

.user-icon img {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(1);
  display: block;
}

/* -----------------------
Reader
----------------------- */

.reader-header {
  background: #e8e0d0;
  padding: 12px 24px;
  border-bottom: 1px solid #d4c9b5;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.reader-title {
  font-size: 14px;
  color: #5a4a3a;
  font-weight: bold;
}

.page-info {
  font-size: 13px;
  color: #7a6a5a;
}

.progress-bar {
  background: #d4c9b5;
  height: 4px;
  border-radius: 2px;
}

.progress-fill1 {
  background: #bba543;
  height: 100%;
  border-radius: 2px;
}

.progress-fill2 {
  background: #8b4513;
  height: 100%;
  border-radius: 2px;
}

.reader-content {
  flex: 1;
  padding: 48px 56px;
  font-size: 18px;
  line-height: 1.8;
  color: #111;
}

.reader-content p {
  margin-bottom: 1.5em;
  text-align: justify;
}

@media (max-width: 600px) {
  .reader-content {
    padding: 48px 20px;
  }
}

.reader-content a {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.2s ease;
}
.reader-content a:link,
.reader-content a:visited {
  cursor: pointer;
}

.reader-content a:hover {
  background: #ffe066;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: #8b4513;
}

.reader-content a.open {
  background: #ffe066;
  border-bottom: 2px solid #8b4513;
}

.reader-content a.new {
  color: #117;
  font-weight: bold;
}

.reader-content a.locked {
  color: #666;
}

.reader-content a.learning-new {
  color: #a00;
}

.reader-content a.learning {
  color: #530;
}

.reader-footer {
  background: #e8e0d0;
  padding: 16px 24px;
  border-top: 1px solid #d4c9b5;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-center, .footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-center {
  font-size: 14px;
  color: #5a4a3a;
  font-weight: bold;
}

.nav-btn {
  position: relative;
  background: #8b4513;
  color: #fff;
  border: none;
  padding: 10px 20px;
  font-size: 14px;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn img {
  width: 18px;
  height: 18px;
  display: block;
  filter: brightness(0) invert(1);
}

.nav-btn:hover {
  background: #6d3610;
}

.nav-btn.disabled {
  background: #aaa;
  cursor: not-allowed;
}

.nav-btn .blue-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  background: #15d;
  border-radius: 50%;
}

.unlocked-btn {
  position: relative;
}

.unlocked-btn .unlock-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 10px;
  height: 10px;
  background: #ff4444;
  border-radius: 50%;
  border: 2px solid #8b4513;
}

/* -----------------------
Open word
----------------------- */

.openword-card {
  background: #f5f0e6;
  padding: 20px 24px;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  position: relative;
}

.openword-card-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 20px;
  color: #7a6a5a;
  cursor: pointer;
}

.openword-card-close:hover {
  color: #5a4a3a;
}

.openword-title {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.openword-title a {
  text-decoration: none;
  cursor: pointer;
}
.openword-title a:link,
.openword-title a:visited {
  cursor: pointer;
}

.openword-title a:hover {
  background: #700;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: #8b4513;
}

.openword-word {
  font-size: 24px;
  font-weight: bold;
  color: #8b4513;
}

.openword-state {
  font-size: 14px;
  font-weight: bold;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
}

.openword-state.locked {
  background: #666;
}

.openword-state.learning-new {
  background: #a00;
}

.openword-state.learning {
  background: #530;
}

.openword-state.mastered {
  background: #000;
}

.openword-links {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  justify-content: center;
  align-items: center;
}

.openword-links a {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0ebe0;
  transition: background 0.2s;
}

.openword-links a:hover {
  background: #d4c9b5;
}

.openword-links img {
  width: 24px;
  height: 24px;
}

.openword-lang-selector {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  background: #f0ebe0;
  font-size: 16px;
  font-weight: bold;
  color: #5a4a3a;
}

.openword-lang-selector:hover {
  background: #d4c9b5;
}

.openword-lang-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #f5f0e6;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  display: none;
  z-index: 10;
}

.openword-lang-dropdown.show {
  display: block;
}

.openword-lang-option {
  padding: 8px 12px;
  font-size: 12px;
  color: #5a4a3a;
  cursor: pointer;
  white-space: nowrap;
}

.openword-lang-option:hover {
  background: #e8e0d0;
}

.openword-occurrences {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.openword-occurrence-count {
  font-size: 13px;
  color: #7a6a5a;
}

.openword-nav-btn {
  background: #8b4513;
  color: #fff;
  border: none;
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
}

.openword-nav-btn:hover {
  background: #6d3610;
}

.openword-nav-btn.disabled {
  background: #aaa;
  cursor: not-allowed;
}

/* -----------------------
Library
----------------------- */

.doc-list {
  padding: 16px;
  width: 100%;
}

.doc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: #fff;
  border-radius: 4px;
  border-left: 3px solid #8b4513;
  font-size: 16px;
  color: #333;
  text-decoration: none;
}

.doc-item:hover {
  background: #f5f5f5;
}

.doc-item-link {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.doc-item-left {
  display: flex;
  align-items: center;
}

.doc-item-link:hover {
  background: #f5f5f5;
  border-radius: 4px;
  margin: -8px -12px;
  padding: 8px 12px;
}

.doc-item-title {
  color: #5a4a3a;
  font-weight: bold;
}

.doc-icon {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  filter: brightness(0) invert(0.4);
}

.doc-progress {
  color: #8b4513;
  font-weight: bold;
}

.doc-actions {
  position: relative;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: 8px;
}

.three-dots {
  width: 20px;
  height: 20px;
  opacity: 0.5;
}

.three-dots:hover {
  opacity: 1;
}

.doc-dropdown {
  right: 0;
  z-index: 10;
}

/* -----------------------
Level
----------------------- */

.level-top {
  background: #e8e0d0;
  padding: 16px 24px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.level-top span {
  color: #666;
}

.level-top-btn {
  position: relative;
  background: #8b4513;
  color: #fff;
  border: none;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: bold;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.level-top-btn:hover {
  background: #6d3610;
}

.level-top-btn .dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 10px;
  height: 10px;
  background: #ff4444;
  border-radius: 50%;
  border: 2px solid #8b4513;
}

.level-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
}

.level-table th, .level-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #d4c9b5;
}

.level-table th {
  background: #e8e0d0;
  font-weight: bold;
  color: #5a4a3a;
  font-size: 13px;
}

.level-table td {
  color: #333;
  font-size: 14px;
}

.level-table tr:last-child td {
  border-bottom: none;
}

.level-table a {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.unlock-btn {
  background: #f4e9d5;
  border-radius: 3px;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

.unlock-btn.unlocked {
  background: #c4e9c5;
}

.unlock-btn:hover {
  background: #e4d9c5;
}

.unlock-btn.disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* -----------------------
Word list
----------------------- */

.word-list-header {
  padding: 16px 24px;
  background: #e8e0d0;
}

.word-list-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: bold;
  color: #5a4a3a;
}

.word-list {
  padding: 16px;
  width: 100%;
}

.word-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: #fff;
  border-radius: 4px;
  border-left: 3px solid #8b4513;
  font-size: 14px;
  color: #333;
  text-decoration: none;
}

.word-list-item:hover {
  background: #f5f5f5;
}

.word-list-item-link {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.word-list-item .stars {
  float: right;
  color: #8b4513;
}

.word-list-footer {
  display: flex;
  padding-bottom: 24px;
  justify-content: center;
  align-items: center;
  color: #666;
}

/* -----------------------
Review
----------------------- */

.review-header {
  padding: 16px 24px;
  background: #e8e0d0;
  border-bottom: 1px solid #d4c9b5;
}

.review-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: bold;
  color: #5a4a3a;
}

.review-list {
  padding: 16px;
  width: 100%;
}

.review-list-item {
  padding: 8px 12px;
  margin-bottom: 8px;
  background: #fff;
  border-radius: 4px;
  border-left: 3px solid #8b4513;
  font-size: 14px;
  color: #333;
}

.review-list-item .review-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: center;
}

.review-list-item .review-actions a {
  text-decoration: none;
  color: inherit;
}
.review-list-item .review-actions a:link,
.review-list-item .review-actions a:visited {
  cursor: pointer;
}

.review-list-item .action-btn {
  background: #e4c9b5;
  border: none;
  width: 58px;
  height: 58px;
  border-radius: 30px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}

.review-list-item .action-btn.forgot:hover {
  background: #e47975;
}

.review-list-item .action-btn.remember:hover {
  background: #c4e9a5;
}

.review-list-item .action-btn img {
  width: 60px;
  height: 60px;
}

.review-list-item:last-child {
  margin-bottom: 0;
}

.review-list-item .stars {
  float: right;
  color: #8b4513;
}

.review-list-item.word-current {
  padding: 16px;
  font-size: 16px;
}

.review-list-item.word-current .word-text {
  font-weight: bold;
  font-size: 18px;
}

.review-empty-text {
  display: flex;
  justify-content: center;
  color: #666;
}

.review-list-footer {
  display: flex;
  padding-bottom: 24px;
  justify-content: center;
  align-items: center;
  color: #666;
}

/* -----------------------
Login and signup
----------------------- */

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

.login-box {
  width: 100%;
  max-width: 360px;
  margin-top: 20px;
  margin-bottom: 20px;
  padding: 40px 32px;
  background: #f5f0e6;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
}

.login-header h1 {
  font-size: 24px;
  color: #5a4a3a;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 14px;
  color: #7a6a5a;
  font-style: italic;
}

.login-message {
  background: #ffebeb;
  color: #c04040;
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-size: 14px;
  text-align: center;
  border: 1px solid #e8a0a0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: bold;
  color: #5a4a3a;
}

.form-group input {
  padding: 12px 14px;
  font-size: 15px;
  border: 1px solid #d4c9b5;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font-family: Georgia, 'Times New Roman', serif;
}

.form-group input:focus {
  outline: none;
  border-color: #8b4513;
  box-shadow: 0 0 0 2px rgba(139,69,19,0.2);
}

.form-group input::placeholder {
  color: #aaa;
}

.login-btn {
  margin-top: 8px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: bold;
  background: #8b4513;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.login-btn:hover {
  background: #6d3610;
}

.login-btn:disabled {
  background: #aaa;
  cursor: not-allowed;
  opacity: 0.7;
}

.login-links {
  margin-top: 24px;
  text-align: center;
  font-size: 13px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.login-links a {
  color: #8b4513;
  text-decoration: none;
}

.login-links a:hover {
  text-decoration: underline;
}

.login-links .divider {
  color: #d4c9b5;
}

.forgot-link, .signup-link, .login-link {
  color: #7a6a5a !important;
}

.forgot-link:hover, .signup-link:hover, .login-link {
  color: #5a4a3a !important;
}
