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

[hidden] { display: none !important; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f5f5;
  color: #222;
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

.screen {
  min-height: 100vh;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

/* 登录页 */
#login-page {
  justify-content: center;
  align-items: center;
  background: #fafafa;
}
.login-box {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
}
.login-box h1 {
  font-size: 26px;
  text-align: center;
  margin-bottom: 12px;
  color: #333;
}
#phone-input {
  width: 100%;
  padding: 16px;
  font-size: 20px;
  border: 2px solid #ddd;
  border-radius: 10px;
  outline: none;
}
#phone-input:focus { border-color: #4CAF50; }
#login-btn {
  width: 100%;
  padding: 16px;
  font-size: 20px;
  background: #4CAF50;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
#login-btn:active { background: #43A047; }

/* 顶栏 */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px 16px;
  border-bottom: 1px solid #eee;
  margin-bottom: 16px;
}
.user-area {
  display: flex;
  align-items: center;
  gap: 8px;
}
#user-phone { font-size: 18px; color: #333; font-weight: 600; }
.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: #f0f0f0;
  color: #666;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { background: #e0e0e0; }
#logout-btn {
  padding: 8px 16px;
  font-size: 16px;
  background: #eee;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

/* 模态框 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  padding: 16px;
}
.modal-box {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 90vh;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-head h3 {
  font-size: 18px;
  color: #333;
}
.modal-close {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  line-height: 1;
}
#prompt-input {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  border: 2px solid #ddd;
  border-radius: 8px;
  outline: none;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
  min-height: 160px;
}
#prompt-input:focus { border-color: #4CAF50; }
.modal-tip {
  font-size: 13px;
  color: #888;
  line-height: 1.5;
  background: #f9f9f9;
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 3px solid #4CAF50;
}
.modal-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.btn-secondary {
  padding: 10px 20px;
  font-size: 15px;
  background: #f5f5f5;
  color: #666;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.btn-primary {
  padding: 10px 20px;
  font-size: 15px;
  background: #4CAF50;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.btn-primary:active { background: #43A047; }
.btn-secondary:active { background: #e0e0e0; }

/* 表单 */
.form-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 24px;
}
.field-label {
  font-size: 16px;
  color: #666;
  margin-top: 4px;
}
#record-date,
#content-input {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  border: 2px solid #ddd;
  border-radius: 10px;
  outline: none;
  background: #fff;
}
#record-date { cursor: pointer; }
#content-input { resize: vertical; min-height: 80px; font-family: inherit; }
#content-input::placeholder { color: #999; opacity: 1; font-size: 16px; }
#record-date:focus, #content-input:focus { border-color: #4CAF50; }

/* 自定义上传按钮 */
.upload-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  font-size: 18px;
  color: #4CAF50;
  background: #E8F5E9;
  border: 2px dashed #4CAF50;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
}
.upload-btn:active { background: #d8efd9; }
.upload-btn input[type=file] {
  display: none;
}
.upload-tip {
  font-size: 12px;
  color: #888;
  text-align: center;
  margin-top: -4px;
}
.thumb-preview {
  display: flex;
  flex-direction: row;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.thumb-preview img {
  flex: 0 0 auto;
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  background: #eee;
}

/* 按钮行 */
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.btn-row button {
  flex: 1;
  padding: 16px;
  font-size: 20px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: #fff;
}
.btn-ai { background: #2196F3; }
.btn-ai:active { background: #1976D2; }
.btn-save { background: #4CAF50; }
.btn-save:active { background: #43A047; }
.btn-row button:disabled {
  background: #90CAF9 !important;
  cursor: not-allowed;
  opacity: 0.85;
}
.btn-save:disabled {
  background: #A5D6A7 !important;
}

/* AI 回复框 */
.ai-reply {
  margin-top: 12px;
  padding: 14px;
  background: #E3F2FD;
  border-left: 4px solid #2196F3;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.7;
  color: #333;
  word-break: break-word;
  max-height: 60vh;
  overflow-y: auto;
}
.ai-reply p { margin: 0 0 8px 0; }
.ai-reply p:last-child { margin-bottom: 0; }
.ai-reply h1, .ai-reply h2, .ai-reply h3 {
  margin: 10px 0 6px 0;
  color: #1565C0;
  line-height: 1.3;
}
.ai-reply h1 { font-size: 20px; }
.ai-reply h2 { font-size: 18px; }
.ai-reply h3 { font-size: 16px; }
.ai-reply strong { color: #0D47A1; }
.ai-reply ul {
  margin: 6px 0;
  padding-left: 22px;
}
.ai-reply li { margin: 2px 0; }
.ai-reply code {
  background: rgba(33,150,243,0.15);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 14px;
  font-family: Menlo, Consolas, monospace;
}
.ai-reply pre {
  background: rgba(0,0,0,0.06);
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 14px;
  margin: 6px 0;
}
.ai-reply pre code { background: transparent; padding: 0; }

/* 历史 */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.section-title {
  font-size: 20px;
  color: #333;
}
.date-filter {
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  color: #555;
  outline: none;
  cursor: pointer;
  min-width: 130px;
  text-align: center;
}
.date-filter:focus { border-color: #4CAF50; }
.sentinel { height: 1px; }
.hist-end {
  text-align: center;
  color: #bbb;
  font-size: 13px;
  padding: 16px 0;
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 40px;
}
.empty {
  text-align: center;
  color: #999;
  padding: 32px 0;
}
.record-card {
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
  border: 1px solid #f0f0f0;
  animation: cardIn 0.25s ease;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.record-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px dashed #eee;
}
.date-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.rel-label {
  background: #E8F5E9;
  color: #2E7D32;
  font-size: 12px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 10px;
}
.date-text {
  color: #555;
  font-weight: 500;
  font-size: 14px;
}
.record-time {
  font-size: 12px;
  color: #aaa;
}
.record-time::before { content: '·'; margin-right: 6px; color: #ccc; }
.record-content {
  font-size: 17px;
  line-height: 1.65;
  color: #333;
  white-space: pre-wrap;
  word-break: break-word;
}
.record-feedback {
  margin-top: 4px;
  padding: 12px;
  background: #E3F2FD;
  border-left: 3px solid #2196F3;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.6;
  color: #333;
  word-break: break-word;
}
.feedback-label {
  font-size: 12px;
  font-weight: bold;
  color: #1565C0;
  margin-bottom: 6px;
}
.feedback-body p { margin: 0 0 6px 0; }
.feedback-body p:last-child { margin-bottom: 0; }
.feedback-body h1, .feedback-body h2, .feedback-body h3 {
  margin: 8px 0 4px 0;
  color: #1565C0;
  line-height: 1.3;
}
.feedback-body h1 { font-size: 18px; }
.feedback-body h2 { font-size: 17px; }
.feedback-body h3 { font-size: 15px; }
.feedback-body strong { color: #0D47A1; }
.feedback-body ul { margin: 4px 0; padding-left: 22px; }
.feedback-body li { margin: 2px 0; }
.feedback-body code {
  background: rgba(33,150,243,0.15);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
  font-family: Menlo, Consolas, monospace;
}
.feedback-body pre {
  background: rgba(0,0,0,0.06);
  padding: 8px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 13px;
  margin: 4px 0;
}
.thumbs {
  display: flex;
  flex-direction: row;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.thumbs img {
  flex: 0 0 auto;
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 12px;
  cursor: pointer;
  background: #eee;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.img-count {
  font-size: 13px;
  color: #999;
  padding-left: 2px;
}
.del-btn {
  padding: 4px 12px;
  font-size: 12px;
  background: #fff;
  color: #f44336;
  border: 1px solid #f44336;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.del-btn:active { background: #f44336; color: #fff; }

/* 原图查看 */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  cursor: zoom-out;
  padding: 16px;
}
#lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  touch-action: pinch-zoom;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:active { background: rgba(255,255,255,0.4); }
