:root {
  --bg: #f6f7fb;
  --text: #222;
  --muted: #666;
  --primary: #2e7d32;
  --primary-weak: #e6f3e7;
  --border: #e5e7eb;
  --card: #ffffff;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app { display: flex; flex-direction: column; height: 100%; }

.device-stage { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.device.phone { position: relative; width: 390px; max-width: 100%; height: 780px; border: 12px solid #111; border-bottom-width: 18px; border-top-width: 18px; border-radius: 34px; background: #111; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.device.phone::before { content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%); width: 120px; height: 5px; background: #111; border-radius: 0 0 10px 10px; }
.device.phone > #app { position: absolute; inset: 0; background: var(--bg); border-radius: 22px; overflow: hidden; display: flex; flex-direction: column; }

#app { display: flex; flex-direction: column; height: 100%; }

.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.app-title { font-weight: 600; }

.nav-back { 
  position: absolute; 
  left: 16px; 
  top: 50%; 
  transform: translateY(-50%);
  background: transparent; 
  border: 0; 
  color: var(--primary); 
  font: inherit; 
  padding: 6px 8px; 
  cursor: pointer; 
  font-size: 16px;
}

.view-container { flex: 1; overflow-y: auto; padding: 12px; padding-bottom: 72px; }

.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border);
  background: #fff;
}
.tab-item {
  padding: 8px 6px; background: transparent; border: 0; font: inherit; color: var(--muted); display:grid; place-items:center; gap:2px;
}
.tab-item .tab-icon { font-size: 16px; line-height: 1; }
.tab-item .tab-text { font-size: 12px; }
.tab-item.is-active { color: var(--primary); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.section-title { margin: 12px 0 8px; font-weight: 600; }
.muted { color: var(--muted); }

.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { width: 100%; display: flex; justify-content: center; }

.upload {
  display: grid; gap: 8px; align-items: center;
}
.preview {
  width: 100%; aspect-ratio: 16/10; background: var(--primary-weak); border: 1px dashed var(--primary); border-radius: 10px; display: grid; place-items: center; overflow: hidden; cursor: pointer; transition: all 0.2s ease;
}
.preview:hover {
  background: var(--primary); color: white;
}
.preview:hover .muted {
  color: white;
}
.preview img { width: 100%; height: 100%; object-fit: cover; }

.list { display: grid; gap: 8px; }
.list-item { display: flex; gap: 10px; align-items: center; padding: 10px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.list-item + .list-item { margin-top: 8px; }
.list-item img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; }
.list-item .meta { flex: 1; }
.list-item .title { font-weight: 600; }
.list-item .sub { color: var(--muted); font-size: 12px; }

/* profile stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px; text-align: center; }
.stat .num { font-weight: 700; font-size: 18px; }
.stat .label { color: var(--muted); font-size: 12px; }

/* profile card */
.profile-card { display: flex; align-items: center; gap: 12px; padding: 12px; background: linear-gradient(180deg, #f0fdf4, #ffffff); border: 1px solid var(--border); border-radius: 12px; }
.profile-card img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.profile-card .name { font-weight: 700; }
.profile-card .sub { color: var(--muted); font-size: 12px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--primary-weak); color: var(--primary); font-size: 12px; }
.chip { display:inline-block; padding:4px 10px; border:1px solid var(--border); border-radius:999px; background:#fff; font-size:12px; color:var(--muted); }
.chip.ongoing { border-color:#c8e6c9; color:#2e7d32; background:#e8f5e9; }
.chip.finished { border-color:#ffe0b2; color:#e65100; background:#fff3e0; }

.act-card { display:grid; gap:8px; padding:10px; background:var(--card); border:1px solid var(--border); border-radius:12px; }
.act-card img { width:100%; height:140px; object-fit:cover; border-radius:8px; }
.act-card .meta { }
.act-card .row { display:flex; gap:8px; align-items:center; justify-content: space-between; flex-wrap:wrap; }
.act-card .title { font-weight:600; }
.act-card .sub { color:var(--muted); font-size:12px; }

.hint { background: #fff8e1; border: 1px solid #ffe082; color: #a67c00; padding: 10px; border-radius: 10px; }

.empty { text-align: center; color: var(--muted); padding: 24px 0; }

.tabs { display: grid; grid-auto-flow: column; gap: 8px; margin-bottom: 8px; }
.tabs .tab { padding: 8px 10px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--muted); }
.tabs .tab.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }

.video-link { color: var(--primary); text-decoration: none; }

/* in-device modal */
.modal-overlay { 
  position: absolute; 
  inset: 0; 
  background: rgba(0,0,0,.35); 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  padding: 20px; 
  z-index: 30; 
}
.modal { 
  width: 100%; 
  max-width: 100%; 
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.modal-overlay.full { align-items: stretch; padding: 0; }
.modal-page { background:#fff; height: 100%; overflow: auto; padding: 12px; border-radius: 0; }

/* spacing refinement inside cards */
.card .list { gap: 10px; }
.card .list .list-item { margin-top: 0; }
.card .list .list-item + .list-item { margin-top: 10px; }

/* form fields */
.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 4px; font-weight: 600; color: var(--text); }
.field input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.field input:focus { outline: none; border-color: var(--primary); }

/* ranking page styles */
.ranking-banner {
  background: linear-gradient(135deg, var(--primary), #4caf50);
  color: white;
  padding: 20px 16px;
  margin: -12px -12px 0 -12px;
  border-radius: 0 0 16px 16px;
  position: relative;
  overflow: hidden;
}

.ranking-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="plants" patternUnits="userSpaceOnUse" width="20" height="20"><circle cx="10" cy="10" r="2" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23plants)"/></svg>');
  opacity: 0.3;
}

.banner-content {
  position: relative;
  z-index: 1;
}

.banner-content h2 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 700;
}

.banner-content p {
  margin: 0;
  font-size: 14px;
  opacity: 0.9;
}

.category-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.category-tag {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-tag:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.category-tag.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.ranking-list {
  display: grid;
  gap: 12px;
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ranking-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(46, 125, 50, 0.1);
}

.rank-number {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  min-width: 24px;
}

.plant-thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
}

.plant-info {
  flex: 1;
}

.plant-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.scientific-name {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 2px;
}

.plant-family {
  font-size: 12px;
  color: var(--muted);
}

.popularity-score {
  text-align: right;
}

.score-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}

.score-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

/* plant detail modal styles */
.plant-details {
  margin-top: 12px;
}

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

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

.detail-label {
  font-weight: 600;
  color: var(--text);
}

.detail-value {
  color: var(--muted);
  text-align: right;
  flex: 1;
  margin-left: 12px;
}

.plant-description {
  margin-top: 16px;
}

.description-text {
  color: var(--text);
  line-height: 1.6;
  margin: 8px 0 0 0;
  text-align: justify;
}


