:root {
  --bg: #0b0b0f;
  --card: #111118;
  --accent: #6cf;
  --accent2: #a66cff;
  --text: #ffffff;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: Inter, Arial, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
}

/* layout */
.app {
  display: flex;
  min-height: 100vh;
}

/* sidebar */
.sidebar {
  position: fixed;
  left: -240px;
  top: 0;
  width: 220px;
  height: 100%;
  background: #09090c;
  border-right: 1px solid #1a1a22;
  padding: 20px;
  transition: .3s;
  z-index: 1000;
}

.sidebar.active {
  left: 0;
  box-shadow: 0 0 30px rgba(108, 204, 255, .2);
}

.logo {
  font-weight: 700;
  font-size: 20px;
  color: var(--accent);
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  text-decoration: none;
  color: #aaa;
  margin-top: 5px;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.nav-label {
  line-height: 1.2;
}

.nav a:hover,
.nav a.active {
  background: linear-gradient(90deg, rgba(108, 204, 255, .2), rgba(166, 108, 255, .2));
  color: white;
}

.sidebar-lang {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid #1f2432;
}

.sidebar-lang-title {
  color: #93a0bd;
  font-size: 12px;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.lang-switch {
  display: flex;
  gap: 6px;
  align-items: center;
}

.lang-form {
  margin: 0;
}

.lang-btn {
  border: 1px solid #3b445d;
  background: #171c28;
  color: #cfd8ee;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.lang-btn:hover,
.lang-btn.active {
  border-color: var(--accent);
  color: #fff;
  background: linear-gradient(90deg, rgba(108, 204, 255, .18), rgba(166, 108, 255, .18));
}

/* overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  z-index: 900;
}

.overlay.active {
  display: block;
}

/* top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 40px;
  margin-bottom: 20px;
}

.menu-btn {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border: none;
  color: black;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.topbar-actions {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-lang-switch {
  display: none;
  align-items: center;
  gap: 6px;
}

.wallet-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #1b1f2a;
  border: 1px solid #343f5a;
}

.wallet-label {
  color: #9fb0d4;
  font-size: 12px;
}

.wallet-value {
  color: #8fdfff;
  font-weight: 700;
  font-size: 12px;
}

.account-menu {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.account-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #434b62;
  background: #1b1f2a;
  color: #fff;
  padding: 7px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.account-toggle:hover {
  border-color: var(--accent);
}

.account-avatar {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #27314a;
}

.account-name {
  font-size: 13px;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-caret {
  color: #b7c4e3;
  font-size: 12px;
}

.account-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #3a4358;
  background: #171b27;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
  display: none;
  z-index: 1200;
}

.account-menu.is-open .account-dropdown {
  display: block;
}

.account-email {
  color: #c6d0e6;
  font-size: 13px;
  margin-bottom: 10px;
  word-break: break-word;
}

.logout-form {
  margin: 0;
}

.dropdown-link-btn {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  border: 1px solid #434b62;
  background: #1b1f2a;
  color: #fff;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.dropdown-link-btn:hover {
  border-color: var(--accent);
}

.logout-btn {
  width: 100%;
  border: 1px solid #434b62;
  background: #1b1f2a;
  color: #fff;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
}

.logout-btn:hover {
  border-color: var(--accent);
}

.edit-subtitle {
  color: #aeb8ce;
  margin-top: 8px;
}

.edit-success {
  margin-top: 12px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #2e5d44;
  background: #173425;
  color: #9ce4b8;
}

.account-edit-form {
  margin-top: 14px;
  max-width: 460px;
  text-align: left;
}

.account-edit-form input {
  width: 100%;
  background: #fff;
  color: #000;
  border: 1px solid #2a2a36;
  border-radius: 10px;
  padding: 11px 12px;
  margin-top: 10px;
}

/* content */
.content {
  flex: 1;
  padding: 20px;
  text-align: center;
}

.content>h1,
.content>h2,
.content>h3,
.content>p,
.content>ol,
.content>ul,
.content>div {
  margin-left: auto;
  margin-right: auto;
}

/* cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 240px));
  gap: 15px;
  max-width: 980px;
  margin-top: 16px;
  justify-content: center;
  justify-items: stretch;
}

.card {
  background: #575764;
  border-radius: 16px;
  padding: 10px;
  transition: .3s;
  border: 1px solid #1c1c28;
  width: 100%;
  max-width: 240px;
  text-align: center;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 0 20px rgba(108, 204, 255, .3);
}

.card img {
  width: 100%;
  border-radius: 10px;
}

.card h3 {
  font-size: 14px;
  margin-top: 8px;
}

.store-card.is-disabled {
  opacity: 0.6;
  filter: grayscale(0.2);
}

.btn-disabled {
  pointer-events: none;
  opacity: 0.7;
}

.btn-danger {
  background: linear-gradient(90deg, #f7797d, #f44f5a);
  color: #fff;
  border: none;
}

.btn-danger[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.price {
  color: var(--accent);
  margin-top: 5px;
}

.card-controls {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.qty-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #394056;
  border-radius: 9px;
  background: #181d2a;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.qty-btn:hover {
  border-color: var(--accent);
}

.qty-value {
  min-width: 26px;
  text-align: center;
  font-weight: 700;
}

.token-price {
  font-weight: 700;
  color: #8fdfff;
}

/* buttons */
.btn {
  display: inline-block;
  padding: 10px 15px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: black;
  font-weight: 600;
  text-decoration: none;
  margin-top: 10px;
}

.btn-group {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.info-list {
  margin-top: 16px;
  line-height: 2;
  list-style-position: inside;
}

.page-shell,
.store-shell {
  width: 66.6667%;
  max-width: 980px;
  margin: 14px auto 0;
  padding: 14px;
  border-radius: 14px;
  background: #2e2e35;
  border: solid #4e4e56 2px;
}

.history-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-filters {
  margin-top: 12px;
  text-align: left;
}

.history-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.history-filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #b7c4e0;
  font-size: 13px;
}

.history-filter-search {
  grid-column: span 1;
}

.history-filter-actions {
  justify-content: flex-start;
}

.history-reset {
  background: #2a3246;
  color: #dbe5fb;
}

.history-messages {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-message {
  border-radius: 10px;
  padding: 10px;
  border: 1px solid #38425c;
  background: #1a202d;
}

.history-message.error {
  border-color: #6f3037;
  background: #37161a;
  color: #ffc7cd;
}

.history-message.success {
  border-color: #2e5d44;
  background: #173425;
  color: #9ce4b8;
}

.history-row-expand {
  background: #1e1e24;
  border: 1px solid #34343d;
  border-radius: 10px;
}

.history-card {
  background: #1f2432;
  border: 1px solid #3a4358;
  border-radius: 14px;
  padding: 12px;
}

.history-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.history-card-title-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  flex: 1;
}

.history-name-input {
  width: 100%;
  max-width: 360px;
  background: #111827;
  color: #e8eefc;
  border: 1px solid #35415c;
  border-radius: 10px;
  padding: 9px 10px;
  font-weight: 700;
}

.apk-state {
  font-size: 12px;
  color: #9bb1db;
  border: 1px solid #3b4662;
  border-radius: 999px;
  padding: 3px 8px;
}

.history-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.history-card-body {
  margin-top: 10px;
  text-align: left;
}

.history-notes-input {
  width: 100%;
  margin-top: 6px;
  background: #111827;
  color: #e8eefc;
  border: 1px solid #35415c;
  border-radius: 10px;
  padding: 10px;
  resize: vertical;
}

.history-save-status {
  margin-top: 6px;
  min-height: 16px;
  font-size: 12px;
  color: #a0acbf;
}

.history-card-footer {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-delete-form {
  margin-left: auto;
}

.history-row-summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
}

.history-row-summary::-webkit-details-marker {
  display: none;
}

.history-row-main {
  text-align: left;
}

.history-status {
  margin-top: 4px;
  display: inline-block;
  font-size: 12px;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid #3f4a62;
  color: #cbd6ef;
}

.history-status.active {
  border-color: #2f7753;
  color: #9ee6bd;
}

.history-status.inactive {
  border-color: #7a6a36;
  color: #f0dc9f;
}

.history-status.deleted {
  border-color: #77394a;
  color: #f0b9cb;
}

.history-download-btn {
  margin-top: 0;
}

.history-row-details {
  border-top: 1px solid #34343d;
  padding: 12px;
  text-align: left;
  display: grid;
  gap: 10px;
}

.history-detail-label {
  font-size: 12px;
  color: #a0acbf;
}

.history-detail-value {
  margin-top: 2px;
  color: #dce4f7;
  word-break: break-word;
}

.history-detail-actions {
  display: flex;
  justify-content: flex-start;
}

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-radius: 10px;
  background: #1e1e24;
  border: 1px solid #34343d;
}

.history-main {
  text-align: left;
}

.history-name {
  font-weight: 700;
}

.history-date {
  margin-top: 3px;
  font-size: 12px;
  color: #9f9fab;
}

.history-meta {
  text-align: right;
}

.history-qty {
  color: #b8b8c7;
}

.history-tokens {
  margin-top: 3px;
  color: #8fdfff;
  font-weight: 700;
}

.history-empty {
  padding: 18px;
  border-radius: 10px;
  background: #1e1e24;
  color: #a6a6b3;
}

.token-subtitle {
  margin-top: 10px;
  color: #b6bed2;
}

.token-balance {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #38425c;
  background: #1a202d;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.token-balance-label {
  color: #a8b5d2;
}

.token-balance-value {
  color: #8fdfff;
  font-weight: 700;
}

.token-pack-list {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.token-pack {
  border: 1px solid #3e4863;
  background: #1b2230;
  color: #d9e1f2;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
}

.token-pack.active,
.token-pack:hover {
  border-color: var(--accent);
  background: linear-gradient(90deg, rgba(108, 204, 255, .18), rgba(166, 108, 255, .18));
}

.token-buy-form {
  margin: 14px auto 0;
  max-width: 460px;
  text-align: left;
}

.token-label {
  display: block;
  color: #b7c4e0;
}

.token-input {
  width: 100%;
  margin-top: 8px;
  background: #111827;
  color: #e8eefc;
  border: 1px solid #35415c;
  border-radius: 10px;
  padding: 11px 12px;
}

.token-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108, 204, 255, 0.18);
}

.token-result {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #36415a;
  background: #1a202d;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.token-result-value {
  font-weight: 700;
  color: #8fdfff;
}

.token-note {
  margin-top: 12px;
  color: #a0acbf;
  font-size: 13px;
}

.edit-subtitle {
  color: #aeb8ce;
  margin-top: 8px;
}

.edit-success {
  margin-top: 12px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #2e5d44;
  background: #173425;
  color: #9ce4b8;
}

.account-edit-form {
  margin: 14px auto 0;
  max-width: 460px;
  text-align: left;
}

.account-edit-form input,
.auth-box input {
  width: 100%;
  background: #111827;
  color: #e8eefc;
  border: 1px solid #35415c;
  border-radius: 10px;
  padding: 11px 12px;
  margin-top: 10px;
}

.account-edit-form input::placeholder,
.auth-box input::placeholder {
  color: #8ea0c7;
}

.account-edit-form input:focus,
.auth-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108, 204, 255, 0.18);
}

/* Keep dark theme for browser autofill (Chrome/Safari) */
.account-edit-form input:-webkit-autofill,
.account-edit-form input:-webkit-autofill:hover,
.account-edit-form input:-webkit-autofill:focus,
.auth-box input:-webkit-autofill,
.auth-box input:-webkit-autofill:hover,
.auth-box input:-webkit-autofill:focus {
  -webkit-text-fill-color: #e8eefc;
  box-shadow: 0 0 0 1000px #111827 inset;
  -webkit-box-shadow: 0 0 0 1000px #111827 inset;
  transition: background-color 9999s ease-in-out 0s;
  border: 1px solid #35415c;
}

/* auth pages */
.section {
  display: none;
  width: 100%;
  max-width: 420px;
}

.section.active {
  display: block;
}

.auth-box {
  background: var(--card);
  border: 1px solid #1c1c28;
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 0 20px rgba(108, 204, 255, .12);
}

.auth-box h2 {
  margin-bottom: 14px;
  color: white;
}

/* input styles are shared with .account-edit-form input above */

.auth-form {
  text-align: left;
}

.form-error {
  color: #ff8f8f;
  margin-top: 8px;
  font-size: 13px;
}

.full {
  width: 100%;
}

.auth-switch {
  margin-top: 14px;
  color: #aaa;
}

.auth-switch a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* bottom nav (mobile) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 68px;
  background: rgba(9, 9, 12, 0.92);
  border-top: 1px solid #232433;
  backdrop-filter: blur(10px);
  display: none;
  justify-content: space-evenly;
  align-items: center;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  z-index: 1100;
}

.bottom-nav a {
  color: #aeb5c8;
  text-decoration: none;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  min-width: 68px;
}

.bottom-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  line-height: 1;
  transition: .2s;
}

.bottom-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}

.bottom-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.bottom-label {
  font-size: 11px;
  letter-spacing: 0.2px;
}

.bottom-nav a.active {
  color: #dff5ff;
  background: linear-gradient(90deg, rgba(108, 204, 255, .22), rgba(166, 108, 255, .22));
  border: 1px solid rgba(108, 204, 255, .35);
  box-shadow: 0 0 16px rgba(108, 204, 255, .2);
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
  }

  .content {
    padding: 12px;
    padding-bottom: 88px;
  }

  .topbar {
    min-height: 36px;
    margin-bottom: 14px;
  }


  .menu-btn {
    display: none;
  }

  .topbar-actions {
    position: static;
    transform: none;
    width: auto;
    justify-content: center;
    align-items: center;
    margin-top: 8px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .mobile-lang-switch {
    display: flex;
  }

  .topbar {
    flex-direction: column;
    gap: 6px;
    min-height: auto;
  }

  .account-dropdown {
    position: absolute;
    margin-top: 8px;
    width: auto;
    min-width: 220px;
    right: 0;
    top: calc(100% + 6px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
  }

  .account-menu {
    align-items: flex-end;
  }

  .account-toggle {
    width: auto;
    justify-content: center;
  }

  .account-name {
    max-width: calc(100vw - 140px);
  }

  .wallet-pill {
    width: auto;
    justify-content: center;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
  }

  .page-shell,
  .store-shell {
    width: 100%;
    padding: 12px;
  }

  .card {
    max-width: none;
  }

  .history-filter-grid {
    grid-template-columns: 1fr;
  }

  .history-row-summary {
    align-items: flex-start;
  }

  .history-card-head {
    flex-direction: column;
    align-items: stretch;
  }

  .history-card-actions {
    justify-content: flex-start;
  }

  .history-name-input {
    max-width: 100%;
  }

  .history-delete-form {
    margin-left: 0;
  }

  .history-download-btn {
    padding: 8px 11px;
    font-size: 12px;
  }

  .token-pack-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .token-balance,
  .token-result {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .section {
    max-width: 100%;
  }

  .auth-box {
    padding: 14px;
  }
}

@media (max-width: 420px) {
  .grid {
    grid-template-columns: 1fr;
  }
}