/* ==========================================================
   Story Life — "Deep Midnight & Gold" theme
   A premium, OTT/audiobook-app-inspired palette: a near-black
   charcoal-navy base with a warm gold accent (coins + brand),
   an emerald for success states, and a restrained crimson for
   danger — built to read as advanced/professional in a native
   Android WebView (Kodular) as well as in a browser.
   ========================================================== */
:root {
  --bg-dark: #0b0e14;
  --bg-darker: #05070b;
  --bg-mid: #141a24;
  --primary: #e0b256;         /* warm gold — brand + primary actions */
  --primary-2: #a9781f;       /* deep amber gold — gradient partner */
  --primary-soft: #f4d999;    /* light gold for text-on-dark highlights */
  --accent: #f0a93a;          /* coin / price emphasis (same family, brighter) */
  --text: #f3efe6;            /* warm off-white */
  --text-dim: #9a9488;        /* warm gray */
  --card-bg: rgba(255,255,255,0.045);
  --card-border: rgba(224,178,86,0.14);
  --card-border-strong: rgba(224,178,86,0.32);
  --radius: 18px;
  --success: #34d399;
  --danger: #f0596b;
  --shadow-gold: rgba(224,178,86,0.28);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { overscroll-behavior-y: none; }

body {
  margin: 0;
  font-family: 'Poppins', 'Segoe UI', sans-serif;
  background: radial-gradient(circle at 18% 0%, #1b2130 0%, var(--bg-dark) 45%, var(--bg-darker) 100%);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 84px;
  overscroll-behavior-y: none;
  -webkit-user-select: none;
  user-select: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }

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

.container { max-width: 480px; margin: 0 auto; padding: 16px; }

/* ---- Top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: rgba(11,14,20,0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-border);
}
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; letter-spacing: 0.2px; }
.topbar .brand .logo-emoji {
  font-size: 1.3rem; width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 4px 14px var(--shadow-gold);
  animation: floaty 3s ease-in-out infinite;
}
.topbar .wallet-pill {
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #1a1305;
  padding: 6px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 700;
  box-shadow: 0 4px 14px var(--shadow-gold);
}

@keyframes floaty { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-3px)} }

/* ---- Search ---- */
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 999px; padding: 10px 16px; margin: 14px 0;
}
.search-box input {
  background: transparent; border: none; outline: none; color: var(--text);
  width: 100%; font-size: 0.95rem;
}
.search-box i { color: var(--primary); }

.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; }
.chip {
  white-space: nowrap; padding: 7px 14px; border-radius: 999px;
  background: var(--card-bg); border: 1px solid var(--card-border);
  font-size: 0.82rem; color: var(--text-dim); transition: all .2s;
}
.chip.active, .chip:hover { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #1a1305; border-color: transparent; font-weight: 600; }

/* ---- Story grid ---- */
.story-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
.story-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius);
  overflow: hidden; transition: transform .25s, box-shadow .25s, border-color .25s;
  animation: fadeUp .5s ease both;
}
.story-card:hover, .story-card:active { transform: translateY(-4px); box-shadow: 0 10px 30px rgba(224,178,86,0.18); border-color: var(--card-border-strong); }
.story-card img { width: 100%; height: 130px; object-fit: cover; display: block; background: var(--bg-mid); }
.story-card .info { padding: 10px 12px 14px; }
.story-card .title { font-size: 0.92rem; font-weight: 600; margin: 0 0 4px; line-height: 1.3; }
.story-card .meta { font-size: 0.72rem; color: var(--text-dim); display: flex; justify-content: space-between; }
.badge {
  display: inline-block; font-size: 0.65rem; padding: 2px 8px; border-radius: 999px;
  background: rgba(224,178,86,0.16); color: var(--primary-soft); margin-bottom: 6px;
  border: 1px solid rgba(224,178,86,0.25);
}

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

/* ---- Story detail ---- */
.story-hero { border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; position: relative; }
.story-hero img { width: 100%; height: 220px; object-fit: cover; display: block; }
.story-hero .overlay {
  position: absolute; inset: 0; background: linear-gradient(to top, rgba(5,7,11,0.96), transparent 60%);
  display: flex; align-items: flex-end; padding: 16px;
}
.story-hero h1 { margin: 0; font-size: 1.3rem; }

.episode-list { display: flex; flex-direction: column; gap: 10px; }
.episode-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px;
  padding: 12px 14px; cursor: pointer; transition: background .2s, border-color .2s;
}
.episode-item:hover, .episode-item:active { background: rgba(224,178,86,0.06); border-color: var(--card-border-strong); }
.episode-item .ep-icon {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #1a1305; flex-shrink: 0;
}
.episode-item .ep-info { flex: 1; min-width: 0; }
.episode-item .ep-title { font-weight: 600; font-size: 0.9rem; margin: 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.episode-item .ep-meta { font-size: 0.75rem; color: var(--text-dim); }
.coin-tag {
  display: flex; align-items: center; gap: 4px; font-size: 0.78rem; font-weight: 700;
  background: rgba(240,169,58,0.16); color: var(--accent); padding: 4px 10px; border-radius: 999px;
}
.coin-tag.unlocked { background: rgba(52,211,153,0.16); color: var(--success); }

/* ---- Player modal ---- */
.player-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.78); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.player-overlay.open { display: flex; animation: fadeIn .2s ease; }
.player-box {
  background: linear-gradient(160deg, #1a2029, #0a0d13); border: 1px solid var(--card-border-strong);
  border-radius: 20px; padding: 22px; max-width: 420px; width: 100%; text-align: center;
  animation: popIn .3s ease; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes popIn { from{opacity:0; transform: scale(.9);} to{opacity:1; transform: scale(1);} }

.drive-embed-wrap { position: relative; margin: 14px 0; }
.drive-embed-wrap iframe { width: 100%; height: 200px; border-radius: 12px; border: none; display: block; }
.drive-embed-close-overlay {
  position: absolute; top: 0; right: 0; z-index: 10;
  width: 64px; height: 56px; border: none;
  border-radius: 0 12px 0 14px;
  background: rgba(5,7,11,0.95); color: #fff; font-size: 1.2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5); transition: background .15s;
}
.drive-embed-close-overlay:hover { background: rgba(240,89,107,0.9); }

.player-ctrl-btn {
  position: relative; width: 46px; height: 46px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.07); color: #fff; font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background .15s, transform .15s;
}
.player-ctrl-btn:hover:not(:disabled) { background: rgba(224,178,86,0.22); transform: scale(1.05); }
.player-ctrl-btn:disabled { cursor: not-allowed; }

.download-episode-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 14px; padding: 12px 18px; border-radius: 12px;
  background: rgba(224,178,86,0.1); border: 1px solid var(--card-border-strong);
  color: var(--primary-soft); font-weight: 600; font-size: 0.88rem; cursor: pointer;
  transition: background .2s, transform .15s;
}
.download-episode-btn:hover { background: rgba(224,178,86,0.18); transform: translateY(-1px); }
.download-episode-btn i { font-size: 0.95rem; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 12px; border: none; font-weight: 700; font-size: 0.92rem;
  cursor: pointer; transition: transform .15s, box-shadow .15s; width: 100%;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #1a1305; box-shadow: 0 6px 20px var(--shadow-gold); }
.btn-primary:hover { transform: translateY(-2px); }
.btn-outline { background: transparent; border: 1px solid var(--card-border-strong); color: var(--text); }
.btn-danger { background: rgba(240,89,107,0.15); color: var(--danger); border: 1px solid rgba(240,89,107,0.3); }
.btn-success { background: rgba(52,211,153,0.15); color: var(--success); border: 1px solid rgba(52,211,153,0.3); }
.btn-sm { padding: 8px 14px; font-size: 0.8rem; width: auto; }

/* ---- Forms ---- */
.form-group { margin-bottom: 14px; text-align: left; }
.form-group label { display: block; font-size: 0.82rem; color: var(--text-dim); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.04); color: var(--text); font-size: 0.92rem; outline: none;
  transition: border .2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }

.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 24px;
  padding: 32px 26px; max-width: 380px; width: 100%; animation: fadeUp .5s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.auth-card .emoji-hero {
  width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center; font-size: 1.8rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 30px var(--shadow-gold);
}
.auth-card h1 { text-align: center; font-size: 1.4rem; margin: 0 0 4px; }
.auth-card p.sub { text-align: center; color: var(--text-dim); font-size: 0.85rem; margin-bottom: 22px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 0.85rem; color: var(--text-dim); }
.auth-switch a { color: var(--primary); font-weight: 700; }
.error-box {
  background: rgba(240,89,107,0.14); border: 1px solid rgba(240,89,107,0.3); color: #ffc4cc;
  padding: 10px 14px; border-radius: 10px; font-size: 0.82rem; margin-bottom: 16px;
}
.success-box {
  background: rgba(52,211,153,0.14); border: 1px solid rgba(52,211,153,0.3); color: #b7f5da;
  padding: 10px 14px; border-radius: 10px; font-size: 0.82rem; margin-bottom: 16px;
}

/* ---- Bottom nav (native app-style, Material-inspired) ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(11,14,20,0.94); backdrop-filter: blur(16px);
  border-top: 1px solid var(--card-border);
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(0,0,0,0.35);
}
.bottom-nav a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 0.66rem; font-weight: 600; color: var(--text-dim);
  padding: 6px 14px; border-radius: 14px; min-width: 60px;
  transition: color .2s, background .2s;
}
.bottom-nav a i { font-size: 1.2rem; transition: transform .2s; }
.bottom-nav a.active { color: var(--primary-soft); background: rgba(224,178,86,0.12); }
.bottom-nav a.active i { transform: translateY(-1px); }
.bottom-nav a.active::after {
  content: ''; position: absolute; top: 2px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--primary);
}

/* ---- Wallet ---- */
.wallet-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #1a1305;
  border-radius: 22px; padding: 24px; text-align: center; margin-bottom: 20px;
  box-shadow: 0 15px 40px var(--shadow-gold);
}
.wallet-card .big-num { font-size: 2.4rem; font-weight: 800; margin: 6px 0; }
.qr-box { background: #fff; border-radius: 16px; padding: 16px; text-align: center; margin: 16px 0; }
.qr-box img { width: 220px; height: 220px; }

.history-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; font-size: 0.85rem;
}
.status-pill { font-size: 0.7rem; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.status-pending { background: rgba(240,169,58,0.2); color: var(--accent); }
.status-approved { background: rgba(52,211,153,0.2); color: var(--success); }
.status-rejected { background: rgba(240,89,107,0.2); color: var(--danger); }
.status-cancelled { background: rgba(148,163,184,0.2); color: #94a3b8; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-dim); }
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.5; }

.contact-fabs {
  position: fixed; right: 16px; bottom: 96px; z-index: 25;
  display: flex; flex-direction: column; gap: 12px;
}
.contact-fabs a {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: #fff;
  animation: floaty 3s ease-in-out infinite;
}
.telegram-fab { background: #0088cc; box-shadow: 0 8px 24px rgba(0,136,204,0.4); }
.instagram-fab {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  box-shadow: 0 8px 24px rgba(220,39,67,0.4);
}

/* ---- Profile ---- */
.profile-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 20px;
  padding: 20px; margin-bottom: 18px;
}
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #1a1305;
}
.profile-name { font-size: 1.1rem; font-weight: 700; margin: 0 0 2px; }
.profile-phone { font-size: 0.82rem; color: var(--text-dim); }
.profile-menu { display: flex; flex-direction: column; gap: 10px; }
.profile-menu a, .profile-menu button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px;
  padding: 14px 16px; font-size: 0.9rem; font-weight: 600; color: var(--text);
  cursor: pointer; text-align: left; transition: background .2s, border-color .2s;
}
.profile-menu a:hover, .profile-menu button:hover { background: rgba(224,178,86,0.08); border-color: var(--card-border-strong); }
.profile-menu i:first-child { color: var(--primary); width: 18px; text-align: center; }
.profile-menu .chevron { margin-left: auto; color: var(--text-dim); font-size: 0.8rem; }

/* ---- Admin ---- */
.admin-body { background: #070911; min-height: 100vh; padding-bottom: 40px; }
.admin-wrap { max-width: 1100px; margin: 0 auto; padding: 20px; }
.admin-nav {
  display: flex; gap: 6px; overflow-x: auto; padding: 12px 20px; background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--card-border); position: sticky; top: 0; z-index: 10;
}
.admin-nav a {
  padding: 8px 14px; border-radius: 10px; font-size: 0.85rem; color: var(--text-dim); white-space: nowrap;
}
.admin-nav a.active, .admin-nav a:hover { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #1a1305; font-weight: 600; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 14px; margin: 20px 0; }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px; padding: 18px;
}
.stat-card .num { font-size: 1.6rem; font-weight: 800; color: var(--primary-soft); }
.stat-card .lbl { font-size: 0.78rem; color: var(--text-dim); }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table th, table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--card-border); }
table th { color: var(--text-dim); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }
.table-wrap { overflow-x: auto; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px; padding: 4px; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.flex-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-title { font-size: 1.4rem; font-weight: 700; margin: 4px 0 18px; }
.card-panel { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 18px; padding: 22px; margin-bottom: 20px; }

@media (min-width: 640px) {
  .container { max-width: 720px; }
  .story-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .container { max-width: 960px; }
  .story-grid { grid-template-columns: repeat(4, 1fr); }
}
