@font-face {
  font-family: Yekan;
  src: url("/font/BYekan.ttf");
  font-display: swap;
}

:root {
  --primary: #ac0017;
  --accent: #ff4466;
  --scaffold: #212a33;
  --card: #27333d;
  --card-alt: #2d3a44;
  --border: #364650;
  --muted: #8a97a0;
  --up: #34d399;
  --down: #f87171;
  --up-hl: rgba(52, 211, 153, 0.2);
  --down-hl: rgba(248, 113, 113, 0.2);
}

* { box-sizing: border-box; }

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--scaffold);
  color: #e0e0e0;
  font-family: Yekan, Tahoma, sans-serif;
  direction: rtl;
}

body {
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: var(--scaffold);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 24px rgba(0,0,0,0.5);
}

a { color: inherit; text-decoration: none; }

/* ---------- header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--primary);
}
.app-header-row {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 10px;
}
.app-header-row img.logo { height: 36px; }
.app-header-row .spacer { flex: 1; }
.icon-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  padding: 8px;
  cursor: pointer;
}
.app-datetime {
  height: 26px;
  background: rgba(0,0,0,0.25);
  color: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- content ---------- */
.app-content {
  flex: 1;
  padding-bottom: 64px; /* clears bottom nav */
  overflow-y: auto;
}
.view { display: none; padding: 10px 12px; }
.view.active { display: block; }

/* sub-views (history/article/about/contact) get their own app-bar */
.subview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--primary);
  position: sticky;
  top: 0;
  z-index: 30;
}
.subview-bar .back-btn {
  background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; padding: 4px 8px;
}
.subview-bar h2 { margin: 0; font-size: 16px; color: #fff; }

.center-msg {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
}
.retry-btn {
  margin-top: 10px;
  background: transparent;
  border: 1px solid var(--border);
  color: #ddd;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
}

/* ---------- rates ---------- */
.tab-bar {
  display: flex;
  overflow-x: auto;
  gap: 4px;
  padding: 8px 8px 0;
  background: var(--scaffold);
  position: sticky;
  top: 0;
  z-index: 20;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13.5px;
  padding: 10px 12px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.rate-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  margin: 8px 0;
  cursor: pointer;
}
.rate-row.recent-up { background: var(--up-hl); }
.rate-row.recent-down { background: var(--down-hl); }
.rate-row .row1 { display: flex; align-items: center; }
.rate-row .ico {
  font-size: 15px; line-height: 1; width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-left: 9px; overflow: hidden;
}
.rate-row .name {
  flex: 1; font-weight: 600; font-size: 14.5px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rate-row .ago { font-size: 10px; font-style: italic; color: var(--muted); margin-left: 5px; }
.rate-row .price { font-weight: bold; font-size: 18px; color: #fff; }
.rate-row .row2 { display: flex; align-items: center; margin-top: 4px; padding-right: 29px; }
.rate-row .range { flex: 1; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rate-row .badge {
  font-size: 12.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px; display: flex; align-items: center; gap: 2px;
}
.badge.up { color: var(--up); background: rgba(52,211,153,0.15); }
.badge.down { color: var(--down); background: rgba(248,113,113,0.15); }
.badge.flat { color: var(--muted); background: rgba(138,151,160,0.12); }

/* ---------- chart / history ---------- */
.chart-box {
  background: var(--card);
  border-radius: 8px;
  border-top: 4px solid var(--primary);
  padding: 14px;
  margin-top: 4px;
}
.chart-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.chart-hdr .title { color: var(--accent); font-weight: bold; font-size: 15px; }
.chart-ranges { display: flex; gap: 5px; overflow-x: auto; margin-bottom: 10px; }
.chart-ranges::-webkit-scrollbar { display: none; }
.crb {
  flex: 0 0 auto; background: var(--card-alt); border: 1px solid var(--border);
  color: #ccc; font-size: 12px; padding: 5px 10px; border-radius: 14px; cursor: pointer; font-family: inherit;
}
.crb.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chart-wrap { position: relative; }
.chart-tip {
  position: absolute; display: none; top: 8px; background: rgba(0,0,0,0.6);
  border-radius: 6px; padding: 4px 8px; pointer-events: none; color: #fff;
}
.chart-minmax { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* ---------- news ---------- */
.news-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 12px;
  cursor: pointer;
}
.news-card img { width: 100%; height: 150px; object-fit: cover; display: block; }
.news-card .body { padding: 12px; }
.news-badge {
  display: inline-block; background: var(--primary); color: #fff; font-size: 11px;
  padding: 2px 8px; border-radius: 4px; margin-bottom: 6px;
}
.news-card h3 { margin: 0 0 6px; font-size: 15.5px; color: #fff; }
.news-card p.summary {
  margin: 0 0 8px; color: #ccc; font-size: 13.5px; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.news-meta { font-size: 11px; color: var(--muted); }
.news-tags { margin-top: 6px; }
.news-tags span { font-size: 11px; color: var(--accent); margin-left: 6px; }

.article-body { padding: 4px 2px 30px; }
.article-body img { max-width: 100%; border-radius: 10px; margin: 8px 0; }
.article-body h1 { font-size: 19px; line-height: 1.5; margin: 0 0 8px; }
.article-body .meta { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.article-body .content { font-size: 15px; line-height: 1.9; color: #ddd; }
.article-body .content p { margin: 0 0 12px; }
.article-body .source-link {
  display: inline-block; margin-top: 18px; border: 1px solid var(--border); background: var(--card);
  color: #ddd; padding: 8px 14px; border-radius: 6px; font-size: 12.5px;
}

/* ---------- static pages ---------- */
.static-body { padding: 4px 2px 30px; line-height: 1.8; }
.static-body h3 { color: #fff; font-size: 15px; margin: 18px 0 8px; }
.static-body .ltr { direction: ltr; text-align: left; }
.contact-list a {
  display: flex; gap: 12px; align-items: center; padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.contact-list .ico { font-size: 17px; line-height: 1; width: 22px; display: inline-flex; align-items: center; justify-content: center; }
.contact-list .lbl { color: #fff; font-size: 14px; }
.contact-list .val { color: var(--muted); font-size: 12.5px; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 40;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  padding: 9px 0 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font-family: inherit;
}
.nav-btn .ico { font-size: 17px; line-height: 1; }
.nav-btn.active { color: var(--accent); }

/* ---------- menu sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 50; display: none;
}
.sheet-backdrop.open { display: block; }
.sheet {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: var(--card-alt);
  border-radius: 14px 14px 0 0; padding: 8px 0 20px; z-index: 51;
}
.sheet button {
  display: block; width: 100%; background: none; border: none; color: #fff;
  font-size: 15px; padding: 14px 20px; text-align: right; cursor: pointer; font-family: inherit;
}
.sheet button:active { background: rgba(255,255,255,0.06); }

.beta-ribbon {
  text-align: center; font-size: 11px; color: var(--muted); padding: 6px 0 2px;
}
