*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1b12;
  --bg2: #111f16;
  --card: rgba(255,255,255,0.06);
  --card-hover: rgba(255,255,255,0.10);
  --border: rgba(255,255,255,0.08);
  --green: #2ea84d;
  --green-light: #4ccd6a;
  --red: #e53e3e;
  --text: #e8f5e9;
  --text2: #9ab89e;
  --header-h: 64px;
  --tab-h: 48px;
  --bottom-h: 68px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

/* ── HOA RƠI ── */
.petal {
  position: fixed;
  top: -40px;
  pointer-events: none;
  z-index: 9999;
  animation: petalFall linear forwards;
  will-change: transform, opacity;
  user-select: none;
}

@keyframes petalFall {
  0% {
    transform: translateX(0) rotate(0deg);
    opacity: 0;
  }
  5% { opacity: 1; }
  50% {
    transform: translateX(var(--swing)) rotate(calc(var(--rot) * 0.5));
    opacity: 1;
  }
  85% { opacity: 1; }
  100% {
    transform: translateX(0) translateY(110vh) rotate(var(--rot));
    opacity: 0;
  }
}

/* ── HEADER ── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: linear-gradient(135deg, #0a1f10 0%, #0d2b16 100%);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-avatar {
  position: relative;
  flex-shrink: 0;
}

.header-avatar img,
.avatar-fallback {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--green);
}

.avatar-fallback {
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.header-status {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #4ccd6a;
  border-radius: 50%;
  border: 2px solid var(--bg);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.15); }
}

.header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.header-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.header-username {
  font-size: 11px;
  color: var(--green-light);
  letter-spacing: 0.3px;
}

.header-badge {
  background: rgba(46,168,77,0.2);
  border: 1px solid rgba(46,168,77,0.4);
  color: var(--green-light);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  flex-shrink: 0;
}

/* ── TAB BAR ── */
.tab-bar {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  height: var(--tab-h);
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  z-index: 99;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  letter-spacing: 0.2px;
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--green);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transition: transform 0.2s;
}

.tab-btn.active {
  color: var(--green-light);
}

.tab-btn.active::after {
  transform: scaleX(1);
}

/* ── TAB CONTENT ── */
.tab-content {
  display: none;
  position: fixed;
  top: calc(var(--header-h) + var(--tab-h));
  bottom: var(--bottom-h);
  left: 0; right: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-content.active {
  display: block;
}

/* ── SEARCH ── */
.search-wrap {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 14px 8px;
  padding: 0 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 12px;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.search-icon { font-size: 14px; opacity: 0.6; }

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  padding: 10px 0;
  font-family: inherit;
}

.search-input::placeholder { color: var(--text2); }

.search-clear {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 13px;
  padding: 4px;
}

/* ── MODULE LIST ── */
.module-list {
  padding: 0 14px 12px;
}

.category-block {
  margin-bottom: 8px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.category-header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  background: rgba(46,168,77,0.1);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.category-header:active { background: rgba(46,168,77,0.18); }

.cat-icon { font-size: 17px; }

.cat-name {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: var(--green-light);
}

.cat-count {
  background: rgba(46,168,77,0.25);
  color: var(--green-light);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}

.cat-arrow {
  font-size: 14px;
  color: var(--text2);
  transition: transform 0.25s;
  display: inline-block;
}

.category-header.collapsed .cat-arrow { transform: rotate(-90deg); }

.category-items {
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.category-items.collapsed { max-height: 0; }

.module-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  transition: background 0.15s;
  cursor: pointer;
}

.module-card:active { background: var(--card-hover); }

.card-chevron {
  font-size: 20px;
  color: var(--text2);
  flex-shrink: 0;
  opacity: 0.5;
  line-height: 1;
  margin-left: auto;
}

/* ── FEATURE MODAL ── */
.feat-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  backdrop-filter: blur(2px);
}
.feat-overlay.show { display: block; }

.feat-modal {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #122018;
  border-radius: 20px 20px 0 0;
  z-index: 201;
  padding: 0 0 env(safe-area-inset-bottom, 12px);
  transform: translateY(110%);
  transition: transform 0.28s cubic-bezier(.4,0,.2,1);
  max-height: 70vh;
  overflow-y: auto;
}
.feat-modal.show { transform: translateY(0); }

.feat-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #122018;
  z-index: 1;
}

.feat-modal-icon { font-size: 26px; flex-shrink: 0; }

.feat-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.feat-modal-close {
  background: rgba(255,255,255,0.08);
  border: none;
  color: var(--text2);
  font-size: 14px;
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.feat-modal-body { padding: 16px 18px 20px; }

.fm-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 8px;
  margin-top: 16px;
}
.fm-section-label:first-child { margin-top: 0; }

.fm-cmds {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fm-cmd-chip {
  background: rgba(46,168,77,0.12);
  border: 1px solid rgba(46,168,77,0.3);
  color: #4ccd6a;
  font-size: 12px;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.fm-usage {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.65;
  white-space: pre-line;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
}

.module-icon {
  font-size: 20px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
  margin-top: 1px;
}

.module-body { flex: 1; min-width: 0; }

.module-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.module-desc {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.no-results {
  text-align: center;
  padding: 48px 24px;
  color: var(--text2);
  font-size: 14px;
}

.no-results-icon { font-size: 40px; margin-bottom: 10px; }

/* ── INFO TAB ── */
#tab-info {
  padding: 16px 14px calc(var(--bottom-h) + 16px);
}

/* ── USER PROFILE CARD ── */
.user-profile-card {
  background: linear-gradient(135deg, rgba(46,168,77,0.12) 0%, rgba(13,27,18,0.5) 100%);
  border: 1px solid rgba(46,168,77,0.3);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
}

.user-profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.user-avatar-wrap {
  flex-shrink: 0;
  position: relative;
  width: 64px;
  height: 64px;
}

.user-avatar-wrap img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--green);
  object-fit: cover;
}

.user-avatar-fallback {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--green);
  background: rgba(46,168,77,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  color: var(--green-light);
}

.user-profile-info {
  flex: 1;
  min-width: 0;
}

.user-full-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-username {
  font-size: 13px;
  color: var(--green-light);
  margin-bottom: 3px;
}

.user-id-row {
  font-size: 11px;
  color: var(--text2);
  opacity: 0.7;
}

.user-stats-row {
  display: flex;
  align-items: center;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  padding: 12px 14px;
  gap: 0;
}

.user-stat-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-stat-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
  margin: 0 14px;
}

.user-stat-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.user-stat-label {
  font-size: 11px;
  color: var(--text2);
  margin-bottom: 2px;
}

.user-stat-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.info-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 20px;
  background: linear-gradient(160deg, rgba(46,168,77,0.15) 0%, rgba(13,27,18,0) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 14px;
}

.info-avatar img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--green);
  margin-bottom: 10px;
  box-shadow: 0 0 24px rgba(46,168,77,0.3);
}

.info-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 1px;
}

.info-handle {
  font-size: 13px;
  color: var(--green-light);
  margin-top: 2px;
}

.info-badge {
  margin-top: 10px;
  background: rgba(46,168,77,0.15);
  border: 1px solid rgba(46,168,77,0.3);
  color: var(--green-light);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
}

.info-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  text-align: center;
  margin-bottom: 16px;
  padding: 0 4px;
}

.stats-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--green-light);
  line-height: 1.1;
}

.stat-label {
  font-size: 11px;
  color: var(--text2);
  margin-top: 4px;
}

.info-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.link-grid {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.link-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s;
  text-align: center;
}

.link-card:active { background: var(--card-hover); }
.link-icon { font-size: 22px; }

.donate-card {
  background: linear-gradient(135deg, rgba(229,197,0,0.1) 0%, rgba(46,168,77,0.08) 100%);
  border: 1px solid rgba(229,197,0,0.2);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
}

.donate-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: 12px;
}

.btn-donate {
  display: inline-block;
  background: linear-gradient(135deg, #d4a017, #e8c55a);
  color: #1a1000;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 22px;
  border-radius: 20px;
  text-decoration: none;
  transition: opacity 0.15s;
}

.btn-donate:active { opacity: 0.8; }

/* ── RATING CARD ── */
.rating-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
}

.rating-desc {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 14px;
  line-height: 1.4;
}

.star-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 14px;
}

.star {
  font-size: 36px;
  color: rgba(255,255,255,0.15);
  cursor: pointer;
  transition: color 0.15s, transform 0.1s;
  user-select: none;
  line-height: 1;
}

.star.active { color: #f5c518; }
.star:active { transform: scale(0.9); }

.rating-textarea {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  resize: none;
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

.rating-textarea:focus { border-color: var(--green); }
.rating-textarea::placeholder { color: var(--text2); }

.btn-rate {
  width: 100%;
  height: 42px;
  background: linear-gradient(135deg, #1a6b2e, #2ea84d);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
  letter-spacing: 0.2px;
}

.btn-rate:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-rate:not(:disabled):active { opacity: 0.8; }

.rating-msg {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  min-height: 18px;
}

.info-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text2);
  opacity: 0.6;
  padding-top: 4px;
}

/* ── BOTTOM BAR ── */
.bottom-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-h);
  display: flex;
  align-items: center;
  padding: 10px 16px;
  background: linear-gradient(0deg, rgba(10,20,13,0.97) 60%, transparent 100%);
  z-index: 100;
}

.btn-close {
  width: 100%;
  height: 46px;
  background: linear-gradient(135deg, #c0392b, #e53e3e);
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 16px rgba(229,62,62,0.35);
  transition: opacity 0.15s, transform 0.1s;
  font-family: inherit;
}

.btn-close:active {
  opacity: 0.85;
  transform: scale(0.98);
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(46,168,77,0.3); border-radius: 4px; }

/* ── CLOCK + UPTIME CARD ── */
.clock-uptime-card {
  display: flex;
  align-items: stretch;
  background: linear-gradient(135deg, rgba(46,168,77,0.12) 0%, rgba(17,31,22,0.9) 100%);
  border: 1px solid rgba(46,168,77,0.25);
  border-radius: 16px;
  margin: 0 16px 16px;
  overflow: hidden;
}

.clock-uptime-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  gap: 4px;
}

.clock-uptime-divider {
  width: 1px;
  background: rgba(255,255,255,0.08);
  margin: 12px 0;
}

.clock-uptime-label {
  font-size: 11px;
  color: var(--text2);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.clock-uptime-value {
  font-size: 26px;
  font-weight: 700;
  color: #4ccd6a;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  line-height: 1.2;
}

.clock-uptime-sub {
  font-size: 11px;
  color: var(--text2);
  letter-spacing: 0.3px;
}
