/* ========================================
   liyu&tomato — 深色主题样式表
   主题色：蓝色（鲤鱼） + 红色（番茄）
   ======================================== */

:root {
  --blue-light: rgba(92, 179, 217, 0.25);
  --blue: #5cb3d9;
  --blue-deep: #4fa3c4;
  --blue-ink: #3a8db0;

  --red-light: rgba(232, 101, 94, 0.25);
  --red: #e8655e;
  --red-deep: #d44a42;
  --red-ink: #b33830;

  --dark-bg: #1a1a1d;
  --dark-surface: #25252a;
  --dark-card: #2d2d33;
  --dark-line: #3d3d44;
  --ink: #e8e8ea;
  --ink-light: #888890;
  --ink-muted: #5a5a62;

  --font-title: 'Microsoft YaHei', '微软雅黑', 'PingFang SC', sans-serif;
  --font-hand: 'Microsoft YaHei', '微软雅黑', 'PingFang SC', sans-serif;
  --font-body: 'Microsoft YaHei', '微软雅黑', 'PingFang SC', sans-serif;

  --header-h: 64px;
  --nav-h: 72px;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-body);
  background: var(--dark-bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; }
svg { display: block; }

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-color: var(--dark-bg);
  background-image:
    repeating-linear-gradient(45deg, rgba(232, 101, 94, 0.06) 0 12px, transparent 12px 32px),
    repeating-linear-gradient(-45deg, rgba(92, 179, 217, 0.06) 0 12px, transparent 12px 32px),
    radial-gradient(circle at 15px 15px, rgba(212, 74, 66, 0.08) 2px, transparent 2px),
    radial-gradient(circle at 45px 45px, rgba(58, 141, 176, 0.08) 2px, transparent 2px);
  background-size: 60px 60px, 60px 60px, 60px 60px, 60px 60px;
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--dark-bg);
  overflow: hidden;
}

.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--dark-surface);
  border-bottom: 2px solid var(--dark-line);
  flex-shrink: 0;
  position: relative;
}

.header-left {
  width: 64px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.header-left svg { width: 58px; height: 25px; }

.header-right {
  width: 64px;
  height: 44px;
  flex-shrink: 0;
}

.header-title {
  font-family: var(--font-title);
  font-size: 20px;
  color: var(--ink);
  letter-spacing: 2px;
}

.app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.app-main::-webkit-scrollbar { width: 0; }

.page-enter { animation: pageIn 0.3s ease; }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.app-nav {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--dark-surface);
  border-top: 2px solid var(--dark-line);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color 0.2s;
  padding: 4px 0;
}
.nav-item.active { color: var(--blue); }
.nav-item.active:nth-child(3) { color: var(--red); }

.nav-icon {
  width: 24px;
  height: 24px;
}
.nav-item span {
  font-size: 12px;
  font-family: var(--font-body);
}

.nav-center {
  position: relative;
}
.nav-center-btn {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--red), var(--blue));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -20px;
  border: 3px solid var(--dark-surface);
  box-shadow: 0 3px 12px rgba(0,0,0,0.4);
  color: white;
  transition: transform 0.2s;
}
.nav-center-btn:active { transform: scale(0.92); }
.nav-center-btn .nav-icon { width: 28px; height: 28px; }

.card {
  background: var(--dark-card);
  border: 2px solid var(--dark-line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  position: relative;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.card.fish-card {
  border-color: var(--blue-deep);
  background: linear-gradient(135deg, var(--dark-card) 0%, rgba(58, 141, 176, 0.1) 100%);
}
.card.fish-card::before {
  content: '';
  position: absolute;
  top: -2px; left: -2px; right: -2px; bottom: -2px;
  border-radius: var(--radius);
  background: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(92,179,217,0.05) 8px, rgba(92,179,217,0.05) 16px);
  pointer-events: none;
  z-index: 0;
}

.card.tomato-card {
  border-color: var(--red-deep);
  background: linear-gradient(135deg, var(--dark-card) 0%, rgba(232, 101, 94, 0.1) 100%);
}
.card.tomato-card::before {
  content: '';
  position: absolute;
  top: -2px; left: -2px; right: -2px; bottom: -2px;
  border-radius: var(--radius);
  background: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(232,101,94,0.05) 8px, rgba(232,101,94,0.05) 16px);
  pointer-events: none;
  z-index: 0;
}

.card > * { position: relative; z-index: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: var(--font-title);
  font-size: 16px;
  border: 2px solid var(--dark-line);
  border-radius: 14px;
  background: var(--dark-surface);
  color: var(--ink);
  transition: all 0.15s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.btn:active { transform: scale(0.96); box-shadow: 0 1px 3px rgba(0,0,0,0.2); }

.btn-blue {
  background: var(--blue-deep);
  color: white;
  border-color: var(--blue-ink);
}
.btn-blue:active { background: var(--blue-ink); }

.btn-red {
  background: var(--red-deep);
  color: white;
  border-color: var(--red-ink);
}
.btn-red:active { background: var(--red-ink); }

.btn-small {
  padding: 6px 14px;
  font-size: 14px;
}

.btn-fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 28px;
  padding: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-muted);
}
.empty-state p {
  font-size: 16px;
  font-family: var(--font-hand);
}

.message-list { padding-bottom: 80px; }

.msg-card {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.msg-avatar { width: 36px; height: 36px; flex-shrink: 0; }
.msg-avatar svg { width: 100%; height: 100%; }
.msg-author {
  font-family: var(--font-title);
  font-size: 15px;
}
.msg-time {
  font-size: 12px;
  color: var(--ink-muted);
  margin-left: auto;
}

.msg-content {
  font-family: var(--font-hand);
  font-size: 18px;
  line-height: 1.6;
  padding: 8px 4px;
  word-break: break-word;
}

.msg-mood {
  font-size: 20px;
}

.msg-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.msg-action-btn {
  font-size: 13px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 8px;
  transition: background 0.2s;
}
.msg-action-btn:active { background: rgba(255,255,255,0.05); }
.msg-action-btn.liked { color: var(--red); }

.msg-input-bar {
  position: fixed;
  bottom: var(--nav-h);
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--dark-surface);
  border-top: 2px solid var(--dark-line);
  padding: 10px 14px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  z-index: 40;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
}
.msg-input-bar textarea {
  flex: 1;
  border: 2px solid var(--dark-line);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 16px;
  resize: none;
  max-height: 100px;
  min-height: 40px;
  background: var(--dark-card);
  color: var(--ink);
  line-height: 1.5;
}
.msg-input-bar textarea:focus {
  outline: none;
  border-color: var(--blue);
}
.msg-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
  border: 2px solid var(--blue-ink);
}
.msg-send-btn:active { transform: scale(0.96); }

.msg-input-bar.tomato-bar textarea:focus {
  border-color: var(--red);
}
.msg-input-bar.tomato-bar .msg-send-btn {
  background: var(--red);
  border-color: var(--red-ink);
}

.msg-mood-picker {
  display: flex;
  gap: 6px;
  padding: 0 14px 8px;
  max-width: 480px;
  margin: 0 auto;
}
.mood-emoji {
  font-size: 22px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 8px;
  transition: transform 0.15s;
}
.mood-emoji:active { transform: scale(1.3); }
.mood-emoji.selected {
  background: var(--blue-light);
  transform: scale(1.15);
}

.todo-list { padding-bottom: 80px; }

.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--dark-card);
  border: 2px solid var(--dark-line);
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.todo-check {
  width: 28px;
  height: 28px;
  border: 2px solid var(--dark-line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
.todo-check.checked {
  background: var(--blue);
  border-color: var(--blue-ink);
}
.todo-check.checked svg { display: block; }
.todo-check svg { display: none; width: 18px; height: 18px; color: white; }

.todo-text {
  flex: 1;
  font-family: var(--font-hand);
  font-size: 18px;
  line-height: 1.4;
  word-break: break-word;
}
.todo-item.done .todo-text {
  text-decoration: line-through;
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
  color: var(--ink-muted);
}

.todo-assignee {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.todo-assignee svg { width: 100%; height: 100%; }

.todo-delete {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--red);
  font-size: 18px;
  cursor: pointer;
  border-radius: 8px;
  flex-shrink: 0;
}
.todo-delete:active { background: var(--red-light); }

.todo-section-title {
  font-family: var(--font-title);
  font-size: 16px;
  color: var(--ink);
  margin: 16px 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.todo-section-title::after {
  content: '';
  flex: 1;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--dark-line) 0 6px, transparent 6px 12px);
}

.todo-progress {
  background: var(--dark-card);
  border: 2px solid var(--dark-line);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.todo-progress-bar {
  height: 16px;
  background: var(--dark-surface);
  border: 2px solid var(--dark-line);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 6px;
}
.todo-progress-fill {
  height: 100%;
  background: repeating-linear-gradient(45deg, var(--blue) 0 10px, var(--blue-deep) 10px 20px);
  transition: width 0.4s ease;
  border-radius: 8px;
}
.todo-progress-text {
  font-family: var(--font-title);
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.todo-progress-fish {
  width: 24px;
  height: 20px;
  transition: margin-left 0.4s ease;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding-bottom: 80px;
}

.photo-card {
  background: var(--dark-card);
  border: 2px solid var(--dark-line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  cursor: pointer;
  position: relative;
  transition: transform 0.15s;
}
.photo-card:active { transform: scale(0.97); }

.photo-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--dark-surface);
  display: block;
}

.photo-caption {
  padding: 8px 10px;
  font-family: var(--font-hand);
  font-size: 14px;
  color: var(--ink);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-meta {
  padding: 0 10px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-muted);
}
.photo-meta svg { width: 16px; height: 16px; }

.photo-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--red);
  font-size: 16px;
  cursor: pointer;
}

.photo-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.photo-viewer img {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 12px;
  border: 2px solid var(--dark-line);
}
.photo-viewer-caption {
  color: var(--ink);
  font-family: var(--font-hand);
  font-size: 18px;
  margin-top: 12px;
  text-align: center;
}
.photo-viewer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  color: white;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--red);
  color: white;
  font-size: 28px;
  border: 2px solid var(--red-ink);
  box-shadow: 0 4px 12px rgba(232,101,94,0.3);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-fab:active { transform: scale(0.96); }
.upload-fab input { display: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--dark-card);
  border: 2px solid var(--dark-line);
  border-radius: 16px;
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  font-family: var(--font-title);
  font-size: 22px;
  text-align: center;
  margin-bottom: 16px;
  color: var(--ink);
}

.identity-picker {
  display: flex;
  gap: 16px;
  justify-content: center;
}
.identity-option {
  text-align: center;
  cursor: pointer;
  padding: 12px;
  border-radius: 16px;
  transition: background 0.2s;
}
.identity-option:active { background: var(--dark-surface); }
.identity-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  border: 2px solid var(--dark-line);
}
.fish-avatar { background: var(--blue-light); }
.tomato-avatar { background: var(--red-light); }
.identity-avatar svg { width: 60px; height: 60px; }
.identity-option p {
  font-family: var(--font-title);
  font-size: 16px;
}

.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-family: var(--font-hand);
  font-size: 16px;
  color: var(--ink-muted);
  margin-bottom: 4px;
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  border: 2px solid var(--dark-line);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 16px;
  background: var(--dark-surface);
  color: var(--ink);
  font-family: var(--font-body);
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--blue);
}
.form-textarea { resize: vertical; min-height: 80px; }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.form-actions .btn { flex: 1; }

.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 80px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--dark-card);
  color: var(--ink);
  padding: 10px 20px;
  border-radius: 20px;
  font-family: var(--font-hand);
  font-size: 16px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  white-space: nowrap;
  border: 1px solid var(--dark-line);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--dark-bg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.loading-overlay.hide {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
.loading-fish svg {
  width: 80px;
  height: 50px;
  animation: swim 1.5s ease-in-out infinite;
}
@keyframes swim {
  0%, 100% { transform: translateX(-10px) rotate(-3deg); }
  50% { transform: translateX(10px) rotate(3deg); }
}
.loading-text {
  font-family: var(--font-hand);
  font-size: 18px;
  color: var(--ink-muted);
}

.settings-section {
  margin-bottom: 20px;
}
.settings-section-title {
  font-family: var(--font-title);
  font-size: 18px;
  color: var(--ink);
  margin-bottom: 10px;
  padding-left: 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--dark-card);
  border: 2px solid var(--dark-line);
  border-radius: 14px;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.settings-label {
  font-family: var(--font-hand);
  font-size: 17px;
  color: var(--ink);
}
.settings-value {
  font-size: 14px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-family: var(--font-body);
}
.status-badge.online {
  background: rgba(74, 184, 118, 0.2);
  color: #4ab876;
}
.status-badge.offline {
  background: var(--dark-surface);
  color: var(--ink-muted);
}

.settings-help {
  font-family: var(--font-hand);
  font-size: 14px;
  color: var(--ink-muted);
  line-height: 1.6;
  padding: 12px 16px;
  background: var(--dark-card);
  border: 2px dashed var(--dark-line);
  border-radius: 12px;
  margin-top: 8px;
}
.settings-help code {
  background: var(--dark-surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
  color: var(--red);
}

.sql-block {
  background: var(--dark-surface);
  color: #a8e0a8;
  padding: 14px;
  border-radius: 12px;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  margin-top: 8px;
  white-space: pre;
  border: 1px solid var(--dark-line);
}

@supports (padding: max(0px)) {
  .app-header { padding-top: max(16px, env(safe-area-inset-top)); }
}

.nav-item, .btn, .todo-check, .photo-card { -webkit-user-select: none; user-select: none; }