:root {
  --bg: #ffffff;
  --bg-secondary: #f1f3f5;
  --text: #0a0a0a;
  --hint: #999999;
  --accent: #2ea6ff;
  --accent-text: #ffffff;
  --border: #e5e7eb;
  --card: #ffffff;
  --danger: #e53935;
  --ok: #43a047;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

html[data-scheme="dark"] {
  --bg: #17212b;
  --bg-secondary: #232e3c;
  --text: #f5f5f5;
  --hint: #7d8b99;
  --card: #232e3c;
  --border: #2f3a48;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body { display: flex; flex-direction: column; }

#app {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 76px;
  padding-top: env(safe-area-inset-top);
}

html[dir="rtl"] body { text-align: right; }

/* Header */
#app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 26px; }
.brand h1 { font-size: 18px; font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--hint); }

/* Views */
.view { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card h2 { font-size: 17px; font-weight: 700; }
.center { align-items: center; text-align: center; }
.center-text { color: var(--hint); font-size: 13px; }

.profile-card { flex-direction: row; align-items: center; gap: 14px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--bg-secondary); object-fit: cover; }
.name { font-size: 17px; font-weight: 700; }
.muted { color: var(--hint); font-size: 13px; margin-top: 2px; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-secondary);
  color: var(--hint);
}

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.15s, transform 0.08s;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-wide { width: 100%; }
.btn code { font-size: 12px; opacity: 0.85; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid-btn { flex-direction: column; padding: 14px 6px; font-size: 13px; }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* Inputs */
.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 12px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}
.input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.input-area { resize: vertical; min-height: 80px; }
.input-slim { width: 64px; flex: 0 0 64px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--hint); }

.row { display: flex; gap: 8px; }

/* Lists */
.list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.list li {
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.list li .muted { font-size: 11px; }

/* Premium */
.perks { list-style: none; text-align: right; display: flex; flex-direction: column; gap: 8px; font-size: 14px; margin-top: 4px; width: 100%; }
.gem { font-size: 56px; line-height: 1; }

/* Hint / toast / error */
.hint {
  font-size: 12px;
  color: var(--hint);
  text-align: center;
  padding: 8px;
}
.error { color: var(--danger); font-size: 12px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 50;
  max-width: 88vw;
  text-align: center;
}

html[dir="rtl"] #toast { transform: translateX(50%); }

/* Tab bar */
#tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--hint);
  font-size: 10px;
  font-weight: 600;
  padding: 8px 0 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font-family: inherit;
}
.tab.active { color: var(--accent); }