/* === CSS Variables & Reset === */
:root {
  --color-primary: #f97316;
  --color-primary-light: #fed7aa;
  --color-primary-dark: #c2410c;
  --color-bg: #fff7ed;
  --color-surface: #ffffff;
  --color-text: #1c1917;
  --color-text-muted: #78716c;
  --color-border: #e7e5e4;
  --color-danger: #ef4444;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-info: #3b82f6;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --topbar-h: 56px;
  --bottom-nav-h: 64px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  font-size: inherit;
}

input, select {
  font-family: inherit;
  font-size: inherit;
}

a { color: var(--color-primary); text-decoration: none; }

/* === App Layout === */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* === Topbar (desktop) === */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 24px;
  align-items: center;
  justify-content: space-between;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo { font-size: 28px; line-height: 1; }

.app-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
}

.topbar-nav {
  display: flex;
  gap: 4px;
}

.nav-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--color-text-muted);
  transition: all 0.2s;
}

.nav-btn:hover { background: var(--color-bg); color: var(--color-text); }
.nav-btn.active { background: var(--color-primary-light); color: var(--color-primary-dark); font-weight: 600; }

.reminder-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  background: var(--color-danger);
  color: white;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

/* === Main Content === */
.main-content {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--bottom-nav-h) + 16px);
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.view {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Bottom Nav (mobile) === */
.bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 100;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--color-text-muted);
  font-size: 11px;
  transition: color 0.2s;
  position: relative;
}

.tab-btn.active { color: var(--color-primary); }
.tab-icon { font-size: 22px; line-height: 1; }

.tab-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  background: var(--color-danger);
  color: white;
  border-radius: 8px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* === Common Components === */
.view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.view-header h2 {
  font-size: 22px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}

.section { margin-bottom: 24px; }

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--color-text);
}

.subtitle {
  color: var(--color-text-muted);
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* === Buttons === */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 20px;
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--color-primary-dark); }

.btn-text {
  padding: 8px 12px;
  color: var(--color-primary);
  font-weight: 500;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.btn-text:hover { background: var(--color-primary-light); }

.btn-back {
  padding: 8px 12px;
  color: var(--color-text-muted);
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.btn-back:hover { background: var(--color-border); }

.btn-danger {
  padding: 10px 20px;
  background: var(--color-danger);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
}

.btn-danger:hover { opacity: 0.9; }

.quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--color-text);
  transition: all 0.2s;
}

.quick-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }

.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* === Alert Cards === */
.alert-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.alert-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.alert-card.urgent { border-left: 4px solid var(--color-danger); }
.alert-card.upcoming { border-left: 4px solid var(--color-warning); }

.alert-icon { font-size: 28px; line-height: 1; }

.alert-count {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}

.alert-card.urgent .alert-count { color: var(--color-danger); }
.alert-card.upcoming .alert-count { color: var(--color-warning); }

.alert-label {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* === Reminder List === */
.reminder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reminder-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.reminder-item.overdue { border-left: 4px solid var(--color-danger); }
.reminder-item.today { border-left: 4px solid var(--color-warning); }
.reminder-item.upcoming { border-left: 4px solid var(--color-info); }
.reminder-item.expired { border-left: 4px solid var(--color-text-muted); opacity: 0.7; }
.reminder-item.upcoming.coming { border-left: 4px dashed var(--color-info); }

.reminder-status {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.reminder-body { flex: 1; min-width: 0; }

.reminder-text {
  font-size: 14px;
  font-weight: 500;
}

.reminder-date {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.reminder-cat {
  font-size: 11px;
  color: var(--color-primary);
  padding: 2px 6px;
  background: var(--color-primary-light);
  border-radius: 4px;
}

.reminder-actions { flex-shrink: 0; }

.btn-done {
  padding: 6px 12px;
  background: var(--color-success);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
}

.btn-done:hover { opacity: 0.85; }

/* === Cat Grid === */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.cat-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
}

.cat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.cat-card-avatar {
  height: 120px;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-bg));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}

.cat-card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cat-card-body {
  padding: 14px;
}

.cat-card-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.cat-card-meta {
  font-size: 12px;
  color: var(--color-text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-card-age {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  margin-top: 6px;
}

.cat-card-next {
  font-size: 11px;
  color: var(--color-danger);
  margin-top: 4px;
}

/* === Cat Detail === */
.cat-detail-content { display: flex; flex-direction: column; gap: 16px; }

.detail-profile {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.detail-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  flex-shrink: 0;
  overflow: hidden;
}

.detail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-info { flex: 1; }

.detail-name {
  font-size: 22px;
  font-weight: 700;
}

.detail-meta {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-meta span {
  background: var(--color-bg);
  padding: 2px 8px;
  border-radius: 4px;
}

.detail-age {
  margin-top: 6px;
  font-size: 14px;
  color: var(--color-primary);
  font-weight: 600;
}

/* === Weight Section === */
.detail-weight {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.weight-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.weight-header h3 {
  font-size: 16px;
  margin: 0;
}

.weight-latest {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  flex-wrap: wrap;
}

.weight-latest.empty {
  color: var(--color-text-muted);
  font-size: 14px;
}

.weight-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.weight-trend {
  font-size: 13px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.weight-trend.up { color: var(--color-danger); background: #fef2f2; }
.weight-trend.down { color: var(--color-success); background: #f0fdf4; }
.weight-trend.flat { color: var(--color-text-muted); background: var(--color-bg); }

.weight-date {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-left: auto;
}

/* Weight History */
.weight-history {
  margin-top: 12px;
  border-top: 1px solid var(--color-border);
  padding-top: 10px;
}

.weight-history-title {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.weight-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
}

.wh-date {
  color: var(--color-text-muted);
  min-width: 90px;
}

.wh-value {
  font-weight: 500;
  flex: 1;
}

.wh-delete {
  color: var(--color-text-muted);
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}

.wh-delete:hover {
  color: var(--color-danger);
  background: #fef2f2;
}

/* Weight Form Inline */
.weight-form-inline {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.weight-form-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.weight-input {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
}

.weight-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

#weight-record-date { width: 130px; }
#weight-record-value { width: 90px; }
#weight-record-unit { width: 60px; }

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

/* === Cat Stats === */
.detail-stats {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}

.detail-stats h3 {
  font-size: 16px;
  margin-bottom: 10px;
}

.stat-bars { display: flex; flex-direction: column; gap: 6px; }
.stat-row { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 2px 4px; border-radius: 4px; transition: background 0.2s; }
.stat-row:hover { background: var(--color-bg); }
.stat-icon { font-size: 16px; width: 24px; text-align: center; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--color-text-muted); width: 42px; flex-shrink: 0; }
.stat-bar-wrap { flex: 1; min-width: 40px; }
.stat-bar { height: 8px; background: var(--color-border); border-radius: 4px; overflow: hidden; }
.stat-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; min-width: 2px; }
.stat-val { font-size: 13px; font-weight: 700; width: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.stat-tip { font-size: 11px; color: var(--color-text-muted); padding: 0 4px 0 74px; max-height: 0; overflow: hidden; transition: max-height 0.3s, padding 0.3s; }
.stat-tip.show { max-height: 40px; padding-bottom: 4px; }

/* === Achievements === */
.detail-achievements {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.detail-achievements h3 {
  font-size: 16px;
  margin-bottom: 10px;
}

.achievement-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.achi-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #fcd34d;
}

.achi-group {
  margin-bottom: 8px;
}

.achi-group-title {
  display: block;
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.training-progress {
  display: inline-block;
  width: 80px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  vertical-align: middle;
  margin-left: 8px;
}

.training-dot {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), #fbbf24);
  border-radius: 2px;
  transition: width 0.3s;
}

.training-dot.filled { background: linear-gradient(90deg, var(--color-success), #34d399); }

/* === Training Progress === */
.detail-training {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.detail-training h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

.training-item {
  margin-bottom: 14px;
}

.training-item:last-child { margin-bottom: 0; }

.training-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.training-name {
  font-size: 13px;
  font-weight: 500;
}

.training-count {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 600;
}

#cat-detail-name {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}

.training-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.training-status {
  font-size: 12px;
  color: var(--color-text-muted);
}

.btn-finish {
  font-size: 12px !important;
  color: var(--color-success) !important;
}

.detail-timeline {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.detail-timeline h3 {
  font-size: 16px;
  margin-bottom: 14px;
}

.timeline { display: flex; flex-direction: column; gap: 0; }

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.timeline-dot.overdue { background: var(--color-danger); }
.timeline-dot.today { background: var(--color-warning); }
.timeline-dot.upcoming { background: var(--color-info); }
.timeline-dot.done { background: var(--color-success); }

.timeline-body { flex: 1; }

.timeline-text { font-size: 14px; }
.timeline-date { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

/* === Form === */
.cat-form {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 4px; }

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500 !important;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
}

.avatar-preview {
  margin-top: 8px;
}

.avatar-preview img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-primary-light);
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* === Knowledge === */
.knowledge-stages {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.stage-btn {
  padding: 8px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--color-text);
  transition: all 0.2s;
}

.stage-btn:hover { border-color: var(--color-primary); }
.stage-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.knowledge-content { display: flex; flex-direction: column; gap: 12px; }

.knowledge-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.knowledge-card .k-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.knowledge-card .k-category {
  font-size: 11px;
  color: var(--color-primary);
  text-transform: uppercase;
  font-weight: 600;
}

.knowledge-card .k-body {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 8px;
  line-height: 1.7;
}

/* === Settings === */
.settings-content {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}

.setting-item:last-child { border-bottom: none; }

.setting-label { font-size: 14px; font-weight: 500; }

.setting-item input[type="number"] {
  width: 60px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  text-align: center;
}

.user-uuid {
  font-size: 11px;
  background: var(--color-bg);
  padding: 4px 8px;
  border-radius: 4px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === Tip Cards === */
.tip-cards { display: flex; flex-direction: column; gap: 8px; }

.tip-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.tip-card:hover { box-shadow: var(--shadow-md); }

.tip-card-title {
  font-size: 14px;
  font-weight: 700;
}

.tip-card-body {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* === Chat View === */
.chat-cat-info {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}

.chat-cat-header {
  font-size: 14px;
  color: var(--color-text);
}

.health-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.health-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  border-radius: 12px;
  font-size: 12px;
  cursor: default;
}

.chat-messages {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 10px;
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}

.chat-msg {
  margin-bottom: 14px;
}

.chat-msg:last-child { margin-bottom: 0; }

.chat-role {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--color-text-muted);
}

.chat-user .chat-role { color: var(--color-primary); }
.chat-assistant .chat-role { color: var(--color-info); }

.chat-text {
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.chat-text h3, .chat-text h4 {
  margin: 10px 0 4px;
  font-size: 15px;
}

.chat-text ul, .chat-text ol {
  margin: 4px 0;
  padding-left: 20px;
}

.chat-text li { margin: 2px 0; }

.chat-text code {
  background: var(--color-bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 13px;
}

.chat-text p { margin: 4px 0; }

/* Chat Welcome */
.chat-welcome {
  text-align: center;
  padding: 20px 10px;
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.welcome-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
}

.welcome-hints {
  text-align: left;
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.hint-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--color-primary);
}

.hint-item {
  font-size: 13px;
  color: var(--color-text-muted);
  padding: 4px 0;
}

.hint-item b {
  color: var(--color-text);
}

.welcome-note {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.chat-input-area {
  display: flex;
  gap: 8px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 10px;
  box-shadow: var(--shadow-sm);
}

#chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
}

#chat-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* === Share Dialog === */
.share-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: flex-end;
}

.share-modal, .img-preview-modal {
  background: var(--color-surface);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.share-modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

.share-options { display: flex; flex-direction: column; gap: 8px; }

.share-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
  text-align: left;
  font-size: 14px;
}

.share-option:hover { background: var(--color-bg); }

.share-icon { font-size: 24px; }
.share-label { font-weight: 600; flex: 1; }
.share-desc { font-size: 12px; color: var(--color-text-muted); }

.share-close {
  display: block;
  width: 100%;
  margin-top: 12px;
  text-align: center;
}

/* === Detail Share Button === */
.detail-share {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 12px 0;
  padding: 10px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
}

.share-label-text {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-right: 4px;
}

/* === Shared Landing Page === */
.shared-landing {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
}

.shared-card {
  background: var(--color-surface);
  border-radius: 16px;
  padding: 24px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  text-align: center;
}

.shared-header { font-size: 20px; font-weight: 700; color: var(--color-primary); margin-bottom: 16px; }
.shared-cat-name { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.shared-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 14px; }
.shared-meta span { font-size: 12px; color: var(--color-text-muted); background: var(--color-bg); padding: 2px 8px; border-radius: 8px; }
.shared-subtitle { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.shared-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 14px; }
.shared-cta p { color: var(--color-text-muted); margin-bottom: 10px; }
.shared-footer { font-size: 11px; color: var(--color-text-muted); margin-top: 16px; }

/* === Demo Banner === */
.demo-banner {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  text-align: center;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  border: 1px solid #fcd34d;
}

/* === Toast === */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  max-width: 320px;
}

.toast.success { background: var(--color-success); }
.toast.error { background: var(--color-danger); }
.toast.info { background: var(--color-info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* === Responsive: Desktop === */
@media (min-width: 768px) {
  .topbar { display: flex; }

  .main-content {
    padding: 24px;
    padding-bottom: 24px;
    padding-top: calc(var(--topbar-h) + 24px);
  }

  .bottom-nav { display: none; }

  .alert-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .cat-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }

  .view-header h2 { font-size: 26px; }

  .form-row { grid-template-columns: 1fr 1fr; }
}

/* === Dark mode (basic) === */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1c1917;
    --color-surface: #292524;
    --color-text: #fafaf9;
    --color-text-muted: #a8a29e;
    --color-border: #44403c;
    --color-primary-light: #431407;
  }

  .stage-btn { background: var(--color-surface); }
}

/* === Utility === */
.hidden { display: none !important; }
