/* Naem Coder Hub — design tokens mirror the Android app (ds_colors.xml); dark by default, light via data-theme */
:root {
  --bg: #0E1621;
  --surface: #17212B;
  --surface-2: #1E2A36;
  --surface-3: #253343;
  --stroke: #26354A;
  --primary: #6C63FF;
  --secondary: #3EBFFF;
  --accent: #FF5C8A;
  --success: #2ED47A;
  --text: #F2F5F9;
  --text-2: #A9B6C6;
  --text-3: #8696AB;
  --radius: 18px;
  --radius-sm: 12px;
  --gradient: linear-gradient(135deg, #6C63FF 0%, #4F7BFF 50%, #3EBFFF 100%);
  --shadow: 0 18px 40px rgba(3, 8, 20, .45);
  --glass: rgba(14, 22, 33, .82);
  --glass-card: rgba(23, 33, 43, .85);
  --glow-1: rgba(108, 99, 255, .18);
  --glow-2: rgba(62, 191, 255, .12);
  --font: "Hind Siliguri", system-ui, -apple-system, "Segoe UI", sans-serif;
}

[data-theme="light"] {
  --bg: #F3F5FA;
  --surface: #FFFFFF;
  --surface-2: #F1F4F9;
  --surface-3: #E5EAF3;
  --stroke: #DDE3EE;
  --text: #131B2C;
  --text-2: #4B5870;
  --text-3: #75839A;
  --shadow: 0 16px 36px rgba(32, 48, 92, .13);
  --glass: rgba(255, 255, 255, .82);
  --glass-card: rgba(255, 255, 255, .92);
  --glow-1: rgba(108, 99, 255, .12);
  --glow-2: rgba(62, 191, 255, .10);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at -10% -10%, var(--glow-1), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, var(--glow-2), transparent 60%),
              var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
.muted { color: var(--text-2); margin: 0; }
button, input { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
:focus-visible { outline: 2px solid var(--secondary); outline-offset: 2px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border: 0; border-radius: 14px;
  font-weight: 600; cursor: pointer; transition: transform .15s ease, filter .15s ease, background .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 8px 22px rgba(108, 99, 255, .35); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--stroke); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--accent); color: #fff; }
.btn-danger-ghost { background: transparent; border: 1px solid rgba(255, 92, 138, .5); color: var(--accent); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; pointer-events: none; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; flex: none;
  border: 1px solid var(--stroke); border-radius: 50%; background: var(--surface-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); }

/* fields */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 14px; color: var(--text-2); font-weight: 500; }
.field input, .image-inputs input[type=url] {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--stroke); background: var(--surface-2); outline: none; transition: border-color .15s;
}
.field input:focus, .image-inputs input:focus { border-color: var(--primary); }
.field input.is-invalid { border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row .field { margin-bottom: 0; }
.hint { font-size: 13px; color: var(--text-3); margin: 6px 0 14px; }
.hint.is-error { color: var(--accent); }
.hint.is-ok { color: var(--success); }
.form-error { min-height: 22px; margin: 0 0 8px; color: var(--accent); font-size: 14px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(400px, 100%); padding: 32px 28px; text-align: center;
  background: var(--glass-card); border: 1px solid var(--stroke); border-radius: 28px;
  box-shadow: var(--shadow); backdrop-filter: blur(12px);
}
.login-card .field { text-align: left; }
.login-logo { border-radius: 20px; margin-bottom: 14px; box-shadow: 0 10px 30px rgba(108, 99, 255, .4); }
.login-card h1 { font-size: 26px; }
.login-card > .muted { margin-bottom: 24px; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; padding: 14px max(16px, 4vw);
  background: var(--glass); backdrop-filter: blur(14px); border-bottom: 1px solid var(--stroke);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand img { border-radius: 10px; }
.search {
  flex: 1; max-width: 520px; margin-left: auto; display: flex; align-items: center; gap: 8px;
  padding: 0 14px; min-height: 44px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--stroke);
}
.search svg { color: var(--text-3); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; }

/* content */
.content { padding: 24px max(16px, 4vw) 48px; max-width: 1280px; margin: 0 auto; }
.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 24px; border-radius: 24px; background: var(--gradient); box-shadow: var(--shadow);
}
.hero h2 { font-size: 26px; color: #fff; }
.hero .muted { color: rgba(255, 255, 255, .88); }
.hero .btn-primary { background: #fff; color: #3B33D6; box-shadow: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0 24px; }
.stat {
  padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--stroke);
  display: grid; gap: 2px; min-width: 0;
}
.stat strong { font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat span { font-size: 13px; color: var(--text-2); }

/* app grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }
.card {
  --card: var(--primary);
  position: relative; display: flex; flex-direction: column; min-width: 0;
  border-radius: 22px; background: var(--surface); border: 1px solid var(--stroke);
  cursor: pointer; overflow: hidden; isolation: isolate;
  transition: transform .22s cubic-bezier(.2, .8, .2, 1), border-color .2s, box-shadow .22s;
  animation: rise .4s ease both;
}
.card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--card) 50%, var(--stroke)); box-shadow: 0 20px 44px color-mix(in srgb, var(--card) 22%, transparent); }
.card:focus-visible { outline-offset: 3px; }
/* coloured cover with soft light blobs and a dot pattern */
.card-cover {
  position: relative; height: 92px; overflow: hidden;
  background:
    radial-gradient(120px 90px at 88% -10%, rgba(255, 255, 255, .35), transparent 70%),
    radial-gradient(160px 120px at 0% 120%, color-mix(in srgb, var(--card) 40%, #000) , transparent 70%),
    linear-gradient(135deg, var(--card), color-mix(in srgb, var(--card) 55%, #3EBFFF));
}
.card-cover::before {
  content: ""; position: absolute; inset: 0; opacity: .22;
  background-image: radial-gradient(rgba(255, 255, 255, .9) 1px, transparent 1.4px); background-size: 14px 14px;
  mask-image: linear-gradient(110deg, transparent 25%, #000 90%);
}
.card-cover::after {
  content: ""; position: absolute; width: 150px; height: 150px; right: -40px; bottom: -90px; border-radius: 50%;
  border: 18px solid rgba(255, 255, 255, .12); transition: transform .5s ease;
}
.card:hover .card-cover::after { transform: scale(1.15) rotate(20deg); }
.card-actions { position: absolute; top: 10px; right: 10px; z-index: 2; display: flex; gap: 6px; }
.card-actions .icon-btn {
  width: 36px; height: 36px; border-radius: 12px; color: #fff;
  background: rgba(10, 14, 24, .22); border: 1px solid rgba(255, 255, 255, .22); backdrop-filter: blur(8px);
}
.card-actions .icon-btn svg { width: 18px; height: 18px; }
.card-actions .icon-btn:hover { background: rgba(10, 14, 24, .4); }
.fav.is-on { color: #FFD166; background: rgba(10, 14, 24, .35); }
.card-badges { position: absolute; top: 12px; left: 14px; z-index: 2; display: flex; gap: 6px; flex-wrap: wrap; max-width: calc(100% - 110px); }
.card-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; color: #fff;
  background: rgba(10, 14, 24, .25); border: 1px solid rgba(255, 255, 255, .2); backdrop-filter: blur(8px);
}
.card-icon {
  position: relative; z-index: 2; width: 68px; height: 68px; margin: -38px 0 0 16px; border-radius: 20px; flex: none;
  display: grid; place-items: center; overflow: hidden; font-size: 28px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--card), color-mix(in srgb, var(--card) 60%, #000));
  border: 4px solid var(--surface); box-shadow: 0 10px 24px color-mix(in srgb, var(--card) 35%, transparent);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}
.card:hover .card-icon { transform: translateY(-3px) rotate(-4deg) scale(1.04); }
.card-icon img { width: 100%; height: 100%; object-fit: cover; }
.card-body { display: grid; gap: 8px; padding: 10px 16px 0; min-width: 0; }
.card-body h3 { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; line-height: 1.35; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; justify-self: start; max-width: 100%; padding: 3px 10px; border-radius: 9px;
  background: color-mix(in srgb, var(--card) 10%, var(--surface-2)); color: var(--text-2);
  border: 1px solid color-mix(in srgb, var(--card) 18%, var(--stroke));
  font-size: 12px; font-family: ui-monospace, Consolas, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip svg { width: 14px; height: 14px; flex: none; color: var(--card); }
.chip span { overflow: hidden; text-overflow: ellipsis; }
.card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px 16px 0; }
.card-stats div { padding: 8px 10px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.card-stats b { display: block; font-size: 15px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-stats span { font-size: 11.5px; color: var(--text-3); }
.card-foot { padding: 14px 16px 16px; margin-top: auto; }
.open-link {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 42px; border-radius: 13px;
  font-weight: 600; font-size: 14px; color: color-mix(in srgb, var(--card) 75%, var(--text));
  background: color-mix(in srgb, var(--card) 12%, transparent); border: 1px solid color-mix(in srgb, var(--card) 30%, transparent);
  transition: background .2s, color .2s;
}
.open-link svg { width: 16px; height: 16px; transition: transform .2s; }
.card:hover .open-link { background: var(--card); color: #fff; border-color: transparent; }
.card:hover .open-link svg { transform: translate(2px, -2px); }
.skeleton { cursor: default; animation: pulse 1.2s ease-in-out infinite alternate; }
.skeleton .card-cover { background: var(--surface-2); }
.skeleton .card-icon, .skeleton .bar { background: var(--surface-3); box-shadow: none; }
.bar { height: 14px; border-radius: 8px; }
@keyframes pulse { from { opacity: .55; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* empty states */
.empty { text-align: center; padding: 48px 16px; display: grid; justify-items: center; gap: 8px; }
.empty-art { font-size: 48px; }
.empty .btn { margin-top: 10px; }

/* sheets (modal on desktop, bottom sheet on phone) */
.sheet { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(5, 9, 16, .7); backdrop-filter: blur(4px); animation: fade .2s ease; }
.sheet-panel {
  position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  padding: 22px; border-radius: 24px; background: var(--surface); border: 1px solid var(--stroke);
  box-shadow: var(--shadow); animation: pop .22s ease;
}
.sheet-small .sheet-panel { width: min(420px, 100%); }
.sheet-small h2 { margin-bottom: 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-head h2 { font-size: 21px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.section-title { font-size: 16px; margin: 18px 0 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.98); } }

.image-row { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.image-preview {
  width: 76px; height: 76px; border-radius: 20px; flex: none; overflow: hidden; display: grid; place-items: center;
  background: var(--surface-3); font-size: 30px; font-weight: 700; color: var(--text-2);
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-inputs { flex: 1; display: grid; gap: 8px; min-width: 0; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); justify-self: start; }
.seg-btn { min-height: 36px; padding: 0 12px; border: 0; border-radius: 10px; background: none; cursor: pointer; color: var(--text-2); font-size: 14px; }
.seg-btn.is-active { background: var(--surface-3); color: var(--text); }
.file-pick {
  display: flex; align-items: center; min-height: 46px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px dashed var(--stroke); background: var(--surface-2); cursor: pointer; color: var(--text-2); font-size: 14px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.file-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-pick:focus-within { border-color: var(--primary); }

.toggle { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle-ui {
  width: 46px; height: 26px; border-radius: 999px; background: var(--surface-3); position: relative; flex: none; transition: background .2s;
}
.toggle-ui::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s;
}
.toggle input:checked + .toggle-ui { background: var(--primary); }
.toggle input:checked + .toggle-ui::after { transform: translateX(20px); }
.toggle input:focus-visible + .toggle-ui { outline: 2px solid var(--secondary); outline-offset: 2px; }

/* card menu */
.menu {
  position: fixed; z-index: 60; min-width: 200px; padding: 6px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--stroke); box-shadow: var(--shadow); animation: fade .12s ease;
}
.menu button, .menu-color {
  width: 100%; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 10px; background: none; cursor: pointer; text-align: left; font-size: 15px;
}
.menu button:hover, .menu-color:hover { background: var(--surface-3); }
.menu .danger { color: var(--accent); }
.menu-color input { margin-left: auto; width: 32px; height: 28px; border: 0; background: none; padding: 0; cursor: pointer; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 70; transform: translateX(-50%);
  max-width: min(520px, calc(100% - 32px)); padding: 12px 18px; border-radius: 14px;
  background: var(--surface-3); border: 1px solid var(--stroke); box-shadow: var(--shadow); animation: pop .2s ease;
}
.toast.is-error { border-color: rgba(255, 92, 138, .6); }
.toast.is-ok { border-color: rgba(46, 212, 122, .6); }

@media (max-width: 640px) {
  .brand span { display: none; }
  .topbar { gap: 10px; }
  .hero { padding: 20px; }
  .hero h2 { font-size: 22px; }
  .hero .btn { width: 100%; }
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .stat strong { font-size: 18px; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .field-row .field { margin-bottom: 14px; }
  .sheet { place-items: end stretch; padding: 0; }
  .sheet-panel { width: 100%; max-height: 92vh; border-radius: 24px 24px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .sheet-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* theme toggle: show the sun in dark mode (switch to light) and the moon in light mode */
.theme-btn .i-moon, [data-theme="light"] .theme-btn .i-sun { display: none; }
[data-theme="light"] .theme-btn .i-moon { display: block; }
.theme-btn svg { transition: transform .4s ease; }
.theme-btn:hover svg { transform: rotate(25deg); }
html { transition: background-color .3s; }
[data-theme="light"] .open-link { color: color-mix(in srgb, var(--card) 62%, #000); }
[data-theme="light"] .chip svg { color: color-mix(in srgb, var(--card) 80%, #000); }

/* cover made from the app's Google Play screenshots */
.card-cover.has-banner { height: 128px; background: #0E1621; }
.cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2, .8, .2, 1); }
.card:hover .cover-img { transform: scale(1.06); }
.card-cover.has-banner::before {
  opacity: 1; z-index: 1; background-image: none; mask-image: none;
  background: linear-gradient(180deg, rgba(8, 12, 20, .35) 0%, transparent 40%, color-mix(in srgb, var(--card) 45%, transparent) 100%);
}
.card-cover.has-banner::after { display: none; }
.card-badge svg { width: 12px; height: 12px; }
.card-badge.play { background: rgba(8, 12, 20, .55); }
