* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: linear-gradient(135deg, #0B2027 0%, #122C3C 40%, #1B3A4B 100%);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 88vh;
  padding: 0;
  overflow-y: auto;
}
.msg-system.card-correct {
  border: 1px solid #10B981;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
}

.msg-system.card-wrong {
  border: 1px solid #EF4444;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}
#SearchFrameWrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 20, 30, 0.95);
  backdrop-filter: blur(1.5vw);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#SearchFrameWrapper.hidden {
  display: none;
}

#SearchFrame {
  width: 100vw;
  height: 100vh;
  border: none;
}

#CloseFrameButton {
  position: fixed;
  top: 1.1vh;
  left: 4vw;
  z-index: 10000;
}

.translate-wrapper {
  width: 96vw;
  margin: 12vh auto 4vh;
  display: flex;
  flex-direction: column;
  gap: 1vh;
  height: 78vh;
  overflow: hidden;
}

.translate-task {
  padding: 2vh 1vw;
  text-align: center;
  background: var(--bg-glass);
  border: 0.2vw solid var(--card-border);
  border-radius: 2.5vw;
  box-shadow: var(--card-shadow), inset 0 0.1vh 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(1.2vw);
}

.task-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  gap: 1vw;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 2vh;
}

.task-content {
  font-size: 5vw;
  font-weight: 800;
  color: var(--accent-primary);
  line-height: 1.4;
  text-shadow: 0 0 3vw rgba(0, 217, 232, 0.4);
  margin-bottom: 2vh;
}

.chinese-source-controls {
  display: none;
  gap: 1vw;
  flex-wrap: wrap;
}

.chinese-source-controls.visible {
  display: flex;
}

.chinese-control-btn {
  background: var(--btn-secondary-bg);
  border: 0.2vw solid var(--btn-secondary-border);
  border-radius: 1.5vw;
  padding: 1vh 1vw;
  font-size: 2.8vw;
  font-weight: 600;
  color: var(--accent-primary);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 1vw;
}

.chinese-control-btn:hover {
  background: var(--btn-secondary-hover);
  border-color: var(--accent-primary);
  transform: translateY(-0.3vh);
  box-shadow: 0 0.5vh 1.5vw rgba(0, 217, 232, 0.25);
}

.chinese-control-btn:active {
  transform: translateY(0);
}

.source-pinyin-display {
  display: none;
}

.task-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2vw;
  width: 100%;
  justify-content: center;
}

.index-controls {
  display: flex;
  align-items: center;
  gap: 1vw;
  justify-content: center;
  flex-wrap: wrap;
}

.index-display {
  background: rgba(0, 217, 232, 0.08);
  border: 0.2vw solid var(--input-border);
  border-radius: 1.5vw;
  padding: 1vh 0.5vw;
  font-size: 2.75vw;
  font-weight: 700;
  color: var(--accent-primary);
  min-width: 20vw;
  text-align: center;
}

.nav-btn {
  background: var(--btn-secondary-bg);
  border: 0.2vw solid var(--btn-secondary-border);
  border-radius: 1.5vw;
  padding: 0.7vh 3vw;
  font-size: 3.2vw;
  font-weight: 600;
  color: var(--accent-primary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.nav-btn:hover {
  background: var(--btn-secondary-hover);
  border-color: var(--accent-primary);
  transform: translateY(-0.3vh);
  box-shadow: 0 0.5vh 1.5vw rgba(0, 217, 232, 0.25);
}

.nav-btn:active {
  transform: translateY(0);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nav-btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

.btn-goto {
  background: rgba(0, 217, 232, 0.15);
  color: var(--accent-primary);
  border: 0.2vw solid var(--btn-secondary-border);
}

.btn-goto:hover {
  background: rgba(0, 217, 232, 0.22);
  border-color: var(--accent-primary);
  box-shadow: 0 0.5vh 2vw rgba(0, 217, 232, 0.3);
  transform: translateY(-0.3vh);
}

.jump-control {
  display: flex;
  align-items: center;
  gap: 1vw;
  background: rgba(0, 217, 232, 0.08);
  border: 0.2vw solid var(--input-border);
  border-radius: 1.5vw;
  padding: 0.3vh 1vw;
}

.jump-btn {
  background: var(--btn-primary-bg);
  border: none;
  color: var(--btn-primary-text);
  cursor: pointer;
  padding: 0.8vh 3vw;
  border-radius: 1.2vw;
  font-size: 3.2vw;
  font-weight: 700;
  transition: all 0.3s ease;
  box-shadow: 0 0.3vh 1vw rgba(0, 217, 232, 0.3);
}

.jump-btn:hover {
  background: var(--btn-primary-hover);
  box-shadow: 0 0.5vh 1.5vw rgba(0, 217, 232, 0.5);
  transform: translateY(-0.3vh);
}

.jump-input {
  width: 11vw;
  background: var(--input-bg);
  border: 0.2vw solid var(--input-border);
  color: var(--accent-primary);
  padding: 0.8vh 2vw;
  border-radius: 1.2vw;
  font-size: 3.2vw;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: all 0.3s ease;
}

.jump-input:focus {
  border-color: var(--input-border-focus);
  box-shadow: 0 0 1vw rgba(0, 217, 232, 0.4);
  background: rgba(0, 217, 232, 0.12);
}

.jump-input::placeholder {
  color: var(--input-placeholder);
}

.jump-input::-webkit-outer-spin-button,
.jump-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.jump-input[type=number] {
  -moz-appearance: textfield;
}

.translate-chat {
  flex: 1;
  background: var(--bg-dark);
  border-radius: 2.5vw;
  border: 0.2vw solid var(--card-border);
  padding: 2vh 4vw;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5vh;
  box-shadow: inset 0 0.1vh 0 rgba(0, 217, 232, 0.1), var(--card-shadow);
  min-height: 0;
}

.translate-chat::-webkit-scrollbar {
  width: 1.5vw;
}

.translate-chat::-webkit-scrollbar-track {
  background: rgba(0, 217, 232, 0.05);
  border-radius: 1.2vw;
}

.translate-chat::-webkit-scrollbar-thumb {
  background: rgba(0, 217, 232, 0.3);
  border-radius: 1.2vw;
}

.translate-chat::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 217, 232, 0.5);
}

.message {
  max-width: 85%;
  padding: 1vh 2vw;
  border-radius: 2.5vw;
  font-size: 5vw;
  line-height: 1;
  font-weight: 600;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(1vh);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg-user {
  align-self: flex-end;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  box-shadow: 0 1vh 3vw rgba(0, 217, 232, 0.45);
  border-bottom-right-radius: 0.5vw;
}

.msg-system {
  align-self: flex-start;
  background: rgba(0, 217, 232, 0.10);
  border: 0.2vw solid var(--card-border);
  color: var(--text-primary);
  font-size: 5vw;
  letter-spacing: 0.1vw;
  box-shadow: inset 0 0.1vh 0 rgba(0, 217, 232, 0.15);
  border-bottom-left-radius: 0.5vw;
  display: flex;
  flex-direction: column;
  gap: 1.5vh;
  position: relative;
}

.msg-system-content {
  flex: 1;
}

.msg-system-buttons {
  display: flex;
  gap: 1.5vw;
  flex-wrap: wrap;
}

.msg-btn {
  background: rgba(0, 217, 232, 0.2);
  border: 0.2vw solid var(--btn-secondary-border);
  border-radius: 1.2vw;
  padding: 0.6vh 2.5vw;
  font-size: 3vw;
  font-weight: 600;
  color: var(--accent-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.msg-btn:hover {
  background: rgba(0, 217, 232, 0.3);
  transform: scale(1.05);
}

.pinyin-display {
  font-size: 3.5vw;
  color: rgba(0, 217, 232, 0.7);
  margin-top: 1vh;
  font-weight: 400;
  letter-spacing: 0.08vw;
}

.translate-input {
  display: grid;
  grid-template-columns: 1fr 0.5fr;
  grid-template-rows: auto auto;
  gap: 0.7vh 1vw;
  width: 100%;
}

.translate-input #GotoBtn {
  grid-column: 1;
  grid-row: 1;
}

.translate-input #ShowAnswerBtn {
  grid-column: 2;
  grid-row: 1;
}

.translate-input input {
  grid-column: 1;
  grid-row: 2;
  width: 100%;
  height: 6vh;
  border-radius: 2vw;
  background: var(--input-bg);
  border: 0.2vw solid var(--input-border);
  padding: 0 4vw;
  font-size: 3.8vw;
  color: var(--input-text);
  outline: none;
  transition: all 0.3s ease;
}

.translate-input #SendBtn {
  grid-column: 2;
  grid-row: 2;
}

.translate-input input:focus {
  background: rgba(0, 217, 232, 0.12);
  border-color: var(--input-border-focus);
  box-shadow: 0 0 0 0.5vw rgba(0, 217, 232, 0.1);
}

.translate-input input::placeholder {
  color: var(--input-placeholder);
}

.control-btn {
  padding: 1.5vh 4vw;
  border: none;
  border-radius: 2vw;
  font-size: 3.5vw;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 100%;
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--accent-primary);
  border: 0.2vw solid var(--btn-secondary-border);
}

.btn-secondary:hover {
  background: var(--btn-secondary-hover);
  border-color: var(--accent-primary);
  box-shadow: 0 0.5vh 2vw rgba(0, 217, 232, 0.25);
  transform: translateY(-0.3vh);
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  box-shadow: var(--btn-primary-shadow);
}

.btn-primary:hover {
  background: var(--btn-primary-hover);
  box-shadow: 0 0.8vh 3vw rgba(0, 217, 232, 0.6);
  transform: translateY(-0.3vh);
}

.btn-primary:active {
  transform: translateY(0);
}

.save-btn {
  background: rgba(16, 185, 129, 0.15);
  border: 0.2vw solid rgba(16, 185, 129, 0.3);
  color: var(--btn-success-text);
  cursor: pointer;
  padding: 0vh 2.5vw;
  border-radius: 1.5vw;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
  min-width: 8vw;
  min-height: 8vw;
}

.save-btn:hover {
  background: var(--btn-success-bg);
  transform: translateY(-0.3vh);
  box-shadow: 0 0.8vh 2.5vw rgba(16, 185, 129, 0.4);
}

.save-btn:active {
  transform: translateY(0);
}

.save-btn.saved {
  background: var(--btn-success-bg);
  border-color: rgba(16, 185, 129, 0.6);
  box-shadow: 0 0.8vh 3vw rgba(16, 185, 129, 0.5);
}

.save-icon {
  width: 3vw;
  height: 4vw;
  fill: currentColor;
  filter: drop-shadow(0 0.3vh 0.6vw rgba(16, 185, 129, 0.3));
}

/* Disclaimer Container - Mobil First */
#DisclaimerContainer {
  position: fixed;
  top: 8vh;
  left: 0;
  width: 100vw;
  padding: 0.5vh 0vw;
  backdrop-filter: blur(2vw);
  border-bottom: 0.2vw solid var(--card-border);
  z-index: 100;
}

#DisclaimerText {
  font-size: 1.75vw;
  color: var(--text-secondary);
  line-height: 1.4;
  text-align: center;
  opacity: 0.7;
}

@media (min-width: 768px) {
  body {
    min-height: 86vh;
  }

  #CloseFrameButton {
    top: 2vh;
    left: 2vw;
  }   

  .translate-wrapper {
    width: 92vw;
    margin: 14vh auto 2vh;
    gap: 1vh;
    height: 78vh;
    overflow: hidden;
  }

  .translate-task {
    padding: 2vh 2vw;
    border-radius: 1.5vw;
    border-width: 0.15vw;
  }

  .task-header {
    gap: 1.5vw;
    margin-bottom: 1.8vh;
  }

  .task-content {
    font-size: 4vw;
    margin-bottom: 1.8vh;
  }

  .chinese-control-btn {
    padding: 0.9vh 2vw;
    font-size: 1.5vw;
    border-radius: 0.8vw;
    border-width: 0.15vw;
    gap: 0.5vw;
  }

  .index-controls {
    gap: 1.2vw;
  }

  .index-display {
    padding: 0.9vh 2.5vw;
    font-size: 1.6vw;
    min-width: 10vw;
    border-radius: 0.8vw;
    border-width: 0.15vw;
  }

  .nav-btn {
    padding: 1vh 2.5vw;
    font-size: 1.4vw;
    border-radius: 0.8vw;
    border-width: 0.15vw;
  }

  .jump-control {
    gap: 0.8vw;
    padding: 0.6vh 1.2vw;
    border-radius: 0.8vw;
    border-width: 0.15vw;
  }

  .jump-btn {
    padding: 0.8vh 1.8vw;
    font-size: 1.4vw;
    border-radius: 0.7vw;
  }

  .jump-input {
    width: 7vw;
    padding: 0.8vh 1.2vw;
    font-size: 1.4vw;
    border-radius: 0.7vw;
    border-width: 0.15vw;
  }

  .translate-chat {
    border-radius: 1.5vw;
    border-width: 0.15vw;
    padding: 2.5vh 3vw;
    gap: 2vh;
    min-height: 0;
  }

  .translate-chat::-webkit-scrollbar {
    width: 0.6vw;
  }

  .translate-chat::-webkit-scrollbar-track {
    border-radius: 0.8vw;
  }

  .translate-chat::-webkit-scrollbar-thumb {
    border-radius: 0.8vw;
  }

  .message {
    max-width: 80%;
    padding: 1.5vh 2.5vw;
    border-radius: 1.5vw;
    font-size: 1.8vw;
    line-height: 1.4;
  }

  .msg-user {
    border-bottom-right-radius: 0.4vw;
  }

  .msg-system {
    font-size: 1.8vw;
    border-width: 0.15vw;
    border-bottom-left-radius: 0.4vw;
    gap: 1.2vw;
  }

  .msg-system-buttons {
    gap: 1vw;
  }

  .msg-btn {
    padding: 0.7vh 1.8vw;
    font-size: 1.3vw;
    border-radius: 0.7vw;
    border-width: 0.15vw;
  }

  .pinyin-display {
    font-size: 1.5vw;
    margin-top: 0.8vh;
  }

  .translate-input {
    grid-template-columns: auto auto 1fr auto;
    grid-template-rows: auto;
    gap: 1.5vw;
  }

  .translate-input #GotoBtn {
    grid-column: 1;
    grid-row: 1;
  }

  .translate-input #ShowAnswerBtn {
    grid-column: 2;
    grid-row: 1;
  }

  .translate-input input {
    grid-column: 3;
    grid-row: 1;
    height: 6vh;
    border-radius: 1.2vw;
    border-width: 0.15vw;
    padding: 0 2.5vw;
    font-size: 1.6vw;
  }

  .translate-input #SendBtn {
    grid-column: 4;
    grid-row: 1;
  }

  .control-btn {
    padding: 1.5vh 3vw;
    border-radius: 1.2vw;
    font-size: 1.5vw;
    width: auto;
  }

  .btn-secondary {
    border-width: 0.15vw;
  }

  .save-btn {
    padding: 0.9vh 1.5vw;
    border-radius: 0.8vw;
    border-width: 0.15vw;
    min-width: 4.5vw;
    min-height: 4.5vw;
  }

  .save-icon {
    width: 2vw;
    height: 2vw;
  }

  #DisclaimerContainer {
    top: 10vh;
    padding: 0.5vh 1vw;
    border-width: 0.1vw;
  }

  #DisclaimerText {
    font-size: 1.5vw;
  }  
}

@media (min-width: 1024px), (orientation: landscape) {
  body {
    min-height: 100vh;
    overflow: hidden;
  }

  #CloseFrameButton {
    top: 2.3vh;
  }

  .translate-wrapper {
    width: 85vw;
    margin: 12vh auto 0;
    gap: 1.8vh;
    overflow: hidden;
  }

  .translate-task {
    padding: 2vh 2vw;
    border-radius: 1vw;
    border-width: 0.1vw;
  }

  .task-header {
    gap: 1.2vw;
    margin-bottom: 1.5vh;
  }

  .task-content {
    font-size: 2.2vw;
    margin-bottom: 1.5vh;
  }

  .chinese-control-btn {
    padding: 0.8vh 1.5vw;
    font-size: 1.1vw;
    border-radius: 0.6vw;
    border-width: 0.1vw;
    gap: 0.4vw;
  }

  .index-controls {
    gap: 1vw;
  }

  .index-display {
    padding: 0.8vh 2vw;
    font-size: 1.2vw;
    min-width: 8vw;
    border-radius: 0.6vw;
    border-width: 0.1vw;
  }

  .nav-btn {
    padding: 0.9vh 2vw;
    font-size: 1.1vw;
    border-radius: 0.6vw;
    border-width: 0.1vw;
  }

  .jump-control {
    gap: 0.6vw;
    padding: 0.5vh 1vw;
    border-radius: 0.6vw;
    border-width: 0.1vw;
  }

  .jump-btn {
    padding: 0.7vh 1.5vw;
    font-size: 1.1vw;
    border-radius: 0.5vw;
  }

  .jump-input {
    width: 5vw;
    padding: 0.7vh 1vw;
    font-size: 1.1vw;
    border-radius: 0.5vw;
    border-width: 0.1vw;
  }

  .translate-chat {
    padding: 2vh 2.5vw;
    border-radius: 1vw;
    border-width: 0.1vw;
    gap: 1.8vh;
    min-height: 0;
  }

  .translate-chat::-webkit-scrollbar {
    width: 0.5vw;
  }

  .translate-chat::-webkit-scrollbar-track {
    border-radius: 0.6vw;
  }

  .translate-chat::-webkit-scrollbar-thumb {
    border-radius: 0.6vw;
  }

  .message {
    max-width: 75%;
    padding: 1.3vh 2vw;
    border-radius: 1.2vw;
    font-size: 1.4vw;
    line-height: 1.5;
  }

  .msg-user {
    border-bottom-right-radius: 0.3vw;
  }

  .msg-system {
    font-size: 1.4vw;
    border-width: 0.1vw;
    border-bottom-left-radius: 0.3vw;
    gap: 1vw;
  }

  .msg-system-buttons {
    gap: 0.8vw;
  }

  .msg-btn {
    padding: 0.6vh 1.5vw;
    font-size: 1vw;
    border-radius: 0.5vw;
    border-width: 0.1vw;
  }

  .pinyin-display {
    font-size: 1.2vw;
    margin-top: 0.6vh;
  }

  .translate-input {
    gap: 1.2vw;
  }

  .translate-input input {
    height: 5.5vh;
    border-radius: 1vw;
    border-width: 0.1vw;
    padding: 0 2vw;
    font-size: 1.3vw;
  }

  .control-btn {
    padding: 1.3vh 2.5vw;
    border-radius: 1vw;
    font-size: 1.2vw;
  }

  .btn-secondary {
    border-width: 0.1vw;
  }

  .save-btn {
    padding: 0vh 1.2vw;
    border-radius: 0.6vw;
    border-width: 0.1vw;
    min-width: 2.5vw;
    min-height: 2.5vw;
  }

  .save-icon {
    width: 1.3vw;
    height: 1.3vw;
  }

  #DisclaimerContainer {
    top: 96.5vh;
    border-bottom: none;
    padding: 0.5vh 1vw;
    border-width: 0.08vw;
  }

  #DisclaimerText {
    font-size: 0.9vw;
    line-height: 1.5;
  }  
}

@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
    html, body {
        overflow: auto;
    }
}