:root {
  --text-color: #ffffff;
  --border-color: #2c2f33;
  --background-color: #23272a;
  --input-background-color: #2c2f33;
  --input-focus-color: #7289da;
  --button-background-color: #7289da;
  --button-hover-color: #5b6eae;
  --toast-background-color: #2c2f33;
  --button-text-color: #ffffff;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  box-sizing: border-box;
}

.container {
  padding: 2rem;
  border-radius: 25px;
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  box-sizing: border-box;
}

.title {
  color: var(--text-color);
  font-size: 1.5rem;
  text-align: center;
  margin-top: 0;
  margin-bottom: 1rem;
  cursor: pointer;
}

.input-group {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.input-group input[type="text"] {
  flex: 3;
  padding: 0.75rem;
  border-radius: 10px;
  font-size: 1rem;
  transition: border-color 0.3s;
  background-color: var(--input-background-color);
  color: var(--text-color);
  text-align: center;
  border: 1px solid var(--input-background-color);
}

.input-group input[type="text"]:focus {
  outline: none;
  border-color: var(--input-focus-color);
}

#toast {
  visibility: hidden;
  display: inline-block;
  background-color: var(--toast-background-color);
  color: var(--text-color);
  text-align: center;
  border-radius: 4px;
  padding: 12px;
  position: fixed;
  z-index: 1;
  left: 50%;
  bottom: 30px;
  font-size: 16px;
  transform: translateX(-50%);
}

#toast.show {
  visibility: visible;
  animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@keyframes fadein {
  from {
    bottom: 0;
    opacity: 0;
  }
  to {
    bottom: 30px;
    opacity: 1;
  }
}

@keyframes fadeout {
  from {
    bottom: 30px;
    opacity: 1;
  }
  to {
    bottom: 0;
    opacity: 0;
  }
}

.button-group button {
  flex: 1;
  padding: 0.75rem 1rem;
}

#passwordText {
  width: 100%;
  height: 20px;
  resize: none;
  padding-right: 40px !important;
  cursor: pointer;
  transition: background-color 0.3s;
}

#passwordText:hover {
  background-color: #36393f;
}

#passwordText:focus {
  background-color: #36393f;
  outline: 2px solid var(--input-focus-color);
}

/* 输入框右侧的操作图标 */
.action-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  cursor: pointer;
  transition: fill 0.3s;
}

.random-icon {
  right: 45px;
  fill: #4caf50;
}

.random-icon:hover {
  fill: #45a049;
}

.clear-icon {
  right: 10px;
  fill: #f44336;
}

.clear-icon:hover {
  fill: #da190b;
}

.copy-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 10px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  transition: fill 0.3s;
  fill: #7289da;
}

.copy-icon:hover {
  fill: #5b6eae;
}

.copy-icon:active {
  fill: #4caf50;
}

/* 历史记录样式 */
.history-section {
  width: 100%;
  margin-top: 3px;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

.history-list {
  display: flex;
  gap: 0.8rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.5rem;
  margin-bottom: -0.5rem;
  /* 隐藏滚动条 */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.history-list::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.history-item-wrapper {
  position: relative;
  flex-shrink: 0;
}

.history-item {
  background-color: var(--input-background-color);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 0.85rem;
  color: var(--text-color);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
  display: block;
}

.history-item:active {
  transform: translateY(-1px);
}

/* 移动端适配 */
@media screen and (max-width: 768px) {
  body {
    padding: 0.5rem;
    align-items: flex-start;
    padding-top: 2rem;
  }

  .container {
    padding: 1.5rem;
    border-radius: 20px;
    margin: 0;
    min-height: auto;
  }

  .title {
    font-size: 1.3rem;
    margin-bottom: 0.8rem;
  }

  .input-group {
    gap: 0.3rem;
  }

  .input-group input[type="text"] {
    padding: 0.6rem;
    font-size: 16px; /* 防止iOS缩放 */
  }

  #passwordText {
    padding-right: 45px !important;
  }

  .action-icon {
    width: 18px;
    height: 18px;
  }

  .random-icon {
    right: 40px;
  }

  .clear-icon {
    right: 8px;
  }

  .copy-icon {
    right: 8px;
    width: 18px;
    height: 18px;
  }

  .history-section {
    margin-top: 0.5rem;
    padding-top: 0.8rem;
  }

  .history-list {
    gap: 0.6rem;
  }

  .history-item {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 16px;
    max-width: 150px;
  }

  #toast {
    bottom: 20px;
    padding: 10px 16px;
    font-size: 14px;
  }
}

/* 小屏幕手机适配 */
@media screen and (max-width: 480px) {
  body {
    padding: 0.3rem;
    padding-top: 1rem;
  }

  .container {
    padding: 1rem;
    border-radius: 16px;
  }

  .title {
    font-size: 1.2rem;
  }

  .input-group input[type="text"] {
    padding: 0.5rem;
    padding-right: 45px;
  }

  #passwordText {
    padding-right: 40px !important;
  }

  .random-icon {
    right: 35px;
  }

  .history-item {
    max-width: 120px;
    font-size: 0.75rem;
  }
}
