/**
 * ==============================================
 * Global and Root Styles
 * ==============================================
 */

:root {
  --theme-color: #ff6b6b;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: url('wallpaper.jpg') center/cover no-repeat fixed;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}



/**
 * ==============================================
 * Main Container
 * ==============================================
 */

.container {
  position: relative;
  background: white;
  padding: 36px 32px;
  border-radius: 32px;
  box-shadow: 0 0px 8px rgba(0,0,0,0.1);
  width: 380px;
  max-width: 90vw;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  backdrop-filter: blur(7px); /* 高斯模糊 */
}


/**
 * ==============================================
 * Header
 * ==============================================
 */

.header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.header h1 {
  margin-left: 7px;
  font-size: 20px;
  color: #5e5e5e;
  font-weight: 800;
}

/* 我的注释 */
.settings-panel p {
  text-align: left;
}

/**
 * ==============================================
 * Buttons
 * ==============================================
 */

.icon-btn {
  background: #fff;
  border: 2px solid #ddd;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.icon-btn:hover {
  background: #f8f8f8;
}

.control-group {
  display: flex;
  gap: 12px;
  margin: 5px 0;
  justify-content: center;
  align-items: center;
}

.control-btn {
  margin: 12px 0;
  padding: 12px 36px;
  font-size: 16px;
  background: #ff6b6b;
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(105, 105, 105, 0.3);
  transition: all 0.3s;
  font-weight: 500;
}

.control-btn.paused {
  background: #ffa8a8;
}

.control-btn:hover {
  background: #ff5252;
  transform: translateY(-2px);
}

#start-btn {
  color: #fff !important;
  font-weight: 600;
  text-align: center;
}

.reset-btn {
  background: #cccccc !important;
  color: white !important;
  display: none;
}

.reset-btn:hover {
  background: #bbbbbb !important;
}

.reset-btn.show {
  display: inline-block !important;
}

#reset-btn {
  width: 100px !important;
  padding: 12px 20px !important;
  font-size: 16px !important;
  background: #cccccc !important;
  color: white !important;
  display: none;
  border-radius: 50px !important;
  border: none !important;
  cursor: pointer;
}

#reset-btn:hover {
  background: #bbbbbb !important;
}

#reset-btn.show {
  display: inline-block !important;
}

.small-btn {
  padding: 6px 12px;
  font-size: 13px;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
}

.small-btn:hover {
  background: #e0e0e0;
}


/**
 * ==============================================
 * Avatar and Progress Ring
 * ==============================================
 */

.avatar-wrapper {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 20px auto;
}

.avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(105, 105, 105, 0.3);
  transition: transform 0.2s;
}

.avatar:hover {
  transform: translate(-50%, -50%) scale(1.08);
}

.progress-ring {
  position: absolute;
  top: 0;
  left: 0;
  transform: rotate(-90deg);
}

.progress-ring__circle,
.progress-ring__circle-bg {
  stroke-dasharray: 527;
  stroke-dashoffset: 0;
}

.progress-ring__circle {
  transition: stroke-dashoffset 1s linear;
  stroke-linecap: round;
}


/**
 * ==============================================
 * Timer and Task Elements
 * ==============================================
 */

.digital-timer {
  font-family: 'Orbitron', sans-serif;
  font-size: 36px;
  font-weight: 700;
  color: var(--theme-color);
  letter-spacing: 3px;
  margin: 11px 0;
  text-shadow: 0 0 10px rgba(105, 105, 105, 0.3);
}

.thinking {
  margin-top: 8px;
  margin-bottom: 5px;
  font-size: 15px;
  color: #ff8e8e;
  min-height: 24px;
  font-weight: 500;
}

#thinking {
  min-height: 24px;
  transition: all 0.3s ease;
}

.task-input {
  margin: 16px 0;
  width: 100%;
  max-width: 300px;
}

.task-input input {
  width: 100%;
  padding: 8px 15px;
  border: 2px solid #d2d2d2;
  border-radius: 50px;
  font-size: 15px;
  color: #ff6b6b;
  background: #fff8f8;
  outline: none;
  text-align: center;
  transition: all 0.3s;
  box-shadow: 0 0 0 4px rgba(105, 105, 105, 0.3);
}

.task-input input:focus {
  border-color: #ff6b6b;
  background: white;
  box-shadow: 0 0 0 4px rgba(105, 105, 105, 0.3);
}

.task-input input::placeholder {
  color: #bbbbbb;
}


circle {
    stroke: rgb(233, 233, 233);
    stroke-width: 6;
    fill: transparent;
    r: 84;
    cx: 90;
    cy: 90;
}


/**
 * ==============================================
 * Stats
 * ==============================================
 */

.stats {
  margin-top: 0px;
  font-size: 14px;
  color: #ff8e8e;
  font-weight: 500;
}


/**
 * ==============================================
 * Settings Panel
 * ==============================================
 */

.settings-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 340px;
  background: white;
  border: 1px solid #eee;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  display: none;
  z-index: 100;
}

#appearance-panel {
  right: 100px;
}

.settings-panel h3 {
  margin: 20px 0 9px !important;
  font-size: 16px;
  color: #333;
  font-weight: 600;
}

.setting-item {
  margin: 12px 0;
  text-align: left;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-item label {
  font-weight: 500;
  color: #555;
}

.setting-item input[type="url"],
.setting-item input[type="password"],
.setting-item input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  margin-top: 6px;
}

.setting-row {
  display: flex;
  align-items: center;
  gap:10px;
  margin-top: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  flex-wrap: nowrap;
}

.setting-row label {
  width: 95px;
  text-align: right;
  font-weight: 500;
  flex-shrink: 0;
}

.setting-row input[type="color"] {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.setting-row input[type="range"] {
  flex: 1;
  min-width: 100px;
}

element.style {
    width: 80px;
}

#opacity-value {
  min-width: 40px;
  font-size: 13px;
  color: #666;
  text-align: center;
  flex-shrink: 0;
}

#bg-select {
  padding: 6px;
  border-radius: 8px;
  border: 1px solid #ddd;
}

#work-minutes {
  width: 70px;
  text-align: center;
  padding: 6px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
}


/**
 * ==============================================
 * Avatar and Cropper
 * ==============================================
 */

#avatar-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#avatar-preview img {
  box-shadow: 0 0px 8px rgba(0,0,0,0.1);
  transition: transform 0.2s;
}

#avatar-preview img:hover {
  transform: scale(1.1);
}

#reset-avatar-btn {
  background: #f8d7da !important;
  color: #721c24 !important;
  border: 1px solid #f5c6cb !important;
  padding: 8px 16px !important;
  font-size: 14px !important;
  border-radius: 12px !important;
  cursor: pointer;
}

#reset-avatar-btn:hover {
  background: #f1b0b7 !important;
}

.cropper-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.cropper-container {
  background: white;
  border-radius: 20px;
  padding: 20px;
  width: 340px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  text-align: center;
}

.cropper-container h3 {
  margin-bottom: 16px;
  color: #333;
  font-size: 18px;
}

.cropper-wrapper {
  position: relative;
  width: 240px;
  height: 240px;
  margin: 0 auto 16px;
  overflow: hidden;
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow: 0 0 0 1px #ddd;
}

#cropper-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: move;
  transition: none;
}

.cropper-mask {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.cropper-circle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 140px;
  height: 140px;
  border: 3px solid var(--theme-color);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}

.cropper-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

#zoom-slider {
  width: 80%;
}

.cropper-controls .btn-group {
  margin-top: 8px;
}

#reset-avatar {
  margin-right: 8px;
  background: #f0f0f0;
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
}

#reset-avatar:hover {
  background: #e0e0e0;
}


/**
 * ==============================================
 * History Panel
 * ==============================================
 */

#history-list {
  max-height: 300px;
  overflow-y: auto;
  text-align: left;
  font-size: 14px;
  margin: 10px 0;
  padding-right: 8px;
}

.history-item {
  padding: 8px 0;
  border-bottom: 1px dashed #eee;
  color: #666;
}

.history-item:last-child {
  border-bottom: none;
}

/* ==================== 人设字数限制样式：开始 ==================== */

.textarea-wrapper {
  position: relative;
  margin-bottom: 16px;
}

#personality {
  width: 100%;
  height: 120px;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 12px;
  font-size: 14px;
  resize: none;
  box-sizing: border-box;
  transition: border-color 0.3s;
}

#personality.warning {
  border-color: #ff6b6b !important;
  box-shadow: 0 0 8px rgba(105, 105, 105, 0.3);
}

.char-count {
  position: absolute;
  right: 12px;
  bottom: 8px;
  font-size: 12px;
  color: #888;
  pointer-events: none;
  transition: color 0.3s;
}

.char-count.warning {
  color: #ff6b6b !important;
  font-weight: 600;
}

/* ==================== 历史复制按钮样式 ==================== */
#copy-history {
  background: #4CAF50 !important;
  color: white !important;
}
#copy-history:hover {
  background: #45a049 !important;
}
#copy-history:active {
  transform: scale(0.95);
}

/* ==================== 历史记录分组样式：开始 ==================== */
.history-date {
  font-weight: 600;
  color: var(--theme-color);
  margin: 16px 0 8px 0;
  font-size: 15px;
  padding-left: 4px;
  border-left: 3px solid var(--theme-color);
}

.history-item {
  margin: 6px 0 6px 16px;
  font-size: 14px;
  color: #555;
}

#copy-today, #copy-all {
  font-size: 13px;
  padding: 0px 4px;
}

/*
#copy-today {
  background: #d0d0d0 !important;
  color: #000000 !important;
  border: 0.5px solid #2d2d2d !important;
  padding: 2px 5px !important;
  font-size: 12px !important;
  border-radius: 4px !important;
  cursor: pointer;
}

#copy-all {
  background: #000000 !important;
  color: #ffffff !important;
  border: 0.5px solid #2d2d2d !important;
  padding: 2px 5px !important;
  font-size: 12px !important;
  border-radius: 4px !important;
  cursor: pointer;
}
*/

.task-input input {
  background-color: rgba(var(--theme-rgb), 0.1);
  border: 1.5px solid var(--theme-color);
  color: var(--theme-color);
  transition: all 0.3s ease;
}

/* ==================== API 面板按钮区 ==================== */
#api-panel .api-panel-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

#api-panel .api-panel-footer .btn-group {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* 状态文字（统一） */
#api-panel #api-status {
  font-size: 0.9em;
  font-weight: bold;
  text-align: center;
  margin: 0;
  transition: color 0.3s ease;
}

/* 不同状态用类控制 */
.status-pending  { color: #ff9800; } /* 连接中… */
.status-success  { color: #4caf50; } /* √ 已连接 */
.status-failure  { color: #f44336; } /* × 连接失败 */
.status-default  { color: #999; }    /* 未测试 */

/* 手机端：按钮垂直 + 居中 */
@media (max-width: 480px) {
  #api-panel .api-panel-footer .btn-group {
    flex-direction: column;
    width: 100%;
    align-items: center;     /* 水平居中 */
    gap: 8px;                /* 可选：按钮间距更清晰 */
  }
  #api-panel .api-panel-footer button {
    width: 100%;
    max-width: 200px;
    margin: 0 auto;          /* 保险起见，双重居中 */
  }
}


/* ---------- 页面底部声明 ---------- */
.page-footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.85rem;
  color: #888;
  line-height: 1.4;
}
.page-footer a {
  color: var(--theme-color, #303030);
  text-decoration: none;
}
.page-footer a:hover {
  text-decoration: underline;
}
.page-footer .license {
  font-size: 0.8rem;
}



input[type="checkbox"] {
  cursor: pointer;
}




/* ==================== 手机端优化 ==================== */
@media (max-width: 480px) {
  /* 已有三个面板的优化 */
  #appearance-panel,
  #settings-panel,
  #history-panel {
    position: fixed !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: 90% !important;
    max-width: 320px !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
    top: 10vh !important;
    padding: 16px !important;
    box-sizing: border-box !important;
  }

  /* 【新增】API 面板手机端优化 */
  #api-panel {
    position: fixed !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: 90% !important;
    max-width: 320px !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
    top: 10vh !important;
    padding: 16px !important;
    box-sizing: border-box !important;
  }

  /* API 面板内部输入框优化 */
  #api-panel .setting-item input,
  #api-panel .setting-item textarea {
    font-size: 14px !important;
    padding: 6px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* API 面板按钮组：垂直排列，居中 */
  #api-panel .api-panel-footer {
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
    margin-top: 12px !important;
  }

  #api-panel .api-panel-footer button {
    width: 160px !important;
    margin: 4px 0 !important;
  }

  /* 状态提示文字在手机上也换行不挤 */
  #api-panel #api-status {
    margin-left: 0 !important;
    margin-top: 4px !important;
    font-size: 0.85em !important;
  }

  /* 其余你原来的手机优化保持不变 */
  .control-group {
    flex-direction: column !important;
    align-items: center !important;
  }

  .control-group button {
    width: 160px !important;
    margin: 6px 0 !important;
  }

  .setting-item input,
  .setting-item select {
    font-size: 14px !important;
    padding: 6px !important;
  }

  body {
    font-size: 14px !important;
  }

  .digital-timer {
    font-size: 2.8rem !important;
  }

  .avatar-wrapper {
    width: 140px !important;
    height: 140px !important;
  }

  /* 关键：只改容器大小，不动 SVG 内部 */ 
  .progress-ring {
    width: 140px !important;
    height: 140px !important;
  }

  .avatar {
    width: 110px !important;
    height: 110px !important;
  }
}