/* Theme tokens */
:root {
  --bg-main: #050814;
  --bg-elevated: #0b0f1f;
  --bg-elevated-soft: #101426;
  --accent: #316bff;
  --accent-strong: #4f46e5;
  --accent-soft: rgba(49, 107, 255, 0.18);
  --text-primary: #f9fbff;
  --text-secondary: #9ca3b5;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-soft: 0 24px 60px rgba(0, 0, 0, 0.65);
  --shadow-card: 0 18px 40px rgba(0, 0, 0, 0.4);
  --sidebar-bg: linear-gradient(160deg, rgba(8, 11, 26, 0.95), rgba(4, 6, 16, 0.95));
  --main-card-gradient: linear-gradient(145deg, rgba(17, 24, 64, 0.98), rgba(6, 10, 30, 0.98));
  --panel-gradient: linear-gradient(145deg, rgba(13, 17, 32, 0.92), rgba(13, 17, 32, 0.98));
}

.light-theme {
  --bg-main: #eef2ff;
  --bg-elevated: #ffffff;
  --bg-elevated-soft: #f5f7ff;
  --accent: #2f5eff;
  --accent-strong: #3446ff;
  --accent-soft: rgba(47, 94, 255, 0.16);
  --text-primary: #0b1020;
  --text-secondary: #5b6170;
  --border-subtle: rgba(0, 9, 43, 0.08);
  --shadow-soft: 0 18px 38px rgba(15, 23, 42, 0.12);
  --shadow-card: 0 14px 30px rgba(15, 23, 42, 0.1);
  --sidebar-bg: linear-gradient(160deg, #ffffff, #eef2ff);
  --main-card-gradient: linear-gradient(145deg, #ffffff, #f3f4ff);
  --panel-gradient: linear-gradient(145deg, #f9faff, #eef2ff);
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #0d1028 0, #050814 55%, #02040b 100%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

body.light-theme {
  background: linear-gradient(135deg, #e8ecff 0%, #f7f8fb 50%, #eef2ff 100%);
}

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

.app-shell {
  display: flex;
  width: 100%;
  min-height: 100vh;
  flex: 1;
}

.mobile-nav {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 14px;
  background: var(--bg-elevated);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.35);
  z-index: 1200;
  gap: 8px;
  justify-content: space-between;
}

.mobile-nav__link {
  flex: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: 14px;
  color: var(--text-secondary);
  font-size: 12px;
  border: 1px solid transparent;
  transition: background 0.16s ease, color 0.16s ease, border 0.16s ease, box-shadow 0.16s ease;
  position: relative;
}

.mobile-nav__link i {
  font-size: 16px;
}

.mobile-nav__link.active {
  background: rgba(49, 107, 255, 0.14);
  color: var(--text-primary);
  border-color: rgba(148, 163, 184, 0.25);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
}

.mobile-nav__link.active::after {
  content: "";
  position: absolute;
  bottom: 6px;
  width: 34px;
  height: 3px;
  background: linear-gradient(90deg, #4f46e5, #316bff);
  border-radius: 999px;
  opacity: 0.9;
}

/* Sidebar */
.sidebar {
  width: 260px;
  padding: 24px 22px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-subtle);
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.sidebar__logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.sidebar__logo span {
  font-weight: 400;
  opacity: 0.9;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, transform 0.12s ease;
}

.nav-item__icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
}

.nav-item--active,
.nav-item:hover {
  background: var(--accent-soft);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.nav-item--active .nav-item__icon,
.nav-item:hover .nav-item__icon {
  background: var(--accent-soft);
}

.sidebar__footer {
  margin-top: auto;
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.85;
}

/* Main area */
.main {
  flex: 1;
  padding: 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.main__topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 68px;
  height: 34px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  padding: 4px;
  cursor: pointer;
  transition: background 0.18s ease, border 0.18s ease;
}

.theme-toggle__knob {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #f9fbff, #dbeafe);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.4), 0 8px 22px rgba(15, 23, 42, 0.95);
  transform: translateX(0);
  transition: transform 0.2s ease;
}

.theme-toggle--on {
  background: rgba(55, 65, 194, 0.92);
  border-color: rgba(129, 140, 248, 0.8);
  justify-content: flex-end;
}

.theme-toggle--on .theme-toggle__knob {
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.35), 0 10px 24px rgba(37, 99, 235, 0.9);
  transform: translateX(0);
}

.main__content-outer {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.blog-section {
  margin-top: 26px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 22px;
}

.blog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.blog-header h2 {
  font-size: 20px;
  margin: 4px 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--text-secondary);
}

.blog-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.blog-card {
  background: var(--bg-elevated-soft);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 14px 12px;
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 8px;
}

.blog-card h3 {
  font-size: 15px;
}

.blog-card p {
  color: var(--text-secondary);
  font-size: 13px;
}

.blog-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.main-card {
  width: 100%;
  max-width: 900px;
  background: radial-gradient(circle at 0 0, var(--accent-soft), transparent 55%),
              var(--main-card-gradient);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: var(--shadow-soft);
  padding: 32px 34px 28px;
  position: relative;
}

.main-card::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: calc(var(--radius-lg) - 1px);
  border: 1px solid rgba(15, 23, 42, 0.85);
  pointer-events: none;
}

.main-card__header {
  margin-bottom: 18px;
}

.main-card__title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.main-card__subtitle {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-secondary);
}

.generator-card {
  margin-top: 12px;
  background: var(--panel-gradient);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
}

.generator-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(140deg, rgba(148, 163, 184, 0.12), transparent 40%, transparent 100%);
  mix-blend-mode: soft-light;
  opacity: 0.6;
  pointer-events: none;
}

/* Tabs */
.tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}

.tabs__left {
  display: inline-flex;
  padding: 4px;
  background: var(--bg-elevated);
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.tab-btn--active {
  background: linear-gradient(135deg, #316bff, #527dff);
  color: #f9fbff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.75);
}

.tabs__actions {
  display: inline-flex;
  gap: 8px;
}

.icon-pill {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.icon-pill:hover {
  background: rgba(30, 64, 175, 0.8);
  color: #e5edff;
  transform: translateY(-1px);
}

/* Form */
.form {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form__group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form__label {
  font-size: 13px;
  color: var(--text-secondary);
}

.textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 13px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.9);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.textarea:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.8), 0 0 0 1px rgba(15, 23, 42, 1);
  background: var(--bg-elevated-soft);
}

.form__row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.input {
  width: 100%;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.input:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.8);
  background: var(--bg-elevated-soft);
}

.form__col {
  flex: 1 1 160px;
}

.btn-primary,
.btn-secondary {
  border: none;
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.btn-primary {
  width: 100%;
  margin-top: 6px;
  background: linear-gradient(135deg, #316bff, #4f46e5);
  color: #f9fbff;
  box-shadow: 0 18px 40px rgba(37, 99, 235, 0.75);
}

.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 22px 48px rgba(37, 99, 235, 0.9);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 14px 32px rgba(30, 64, 175, 0.95);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid rgba(148, 163, 184, 0.45);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  padding-inline: 18px;
}

.btn-secondary:hover {
  background: var(--accent-soft);
  border-color: rgba(49, 107, 255, 0.35);
}

.helper-text {
  margin-top: 2px;
  font-size: 11px;
  color: rgba(148, 163, 184, 0.85);
}

.results {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.round {
  background: var(--bg-elevated-soft);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px 12px;
  box-shadow: var(--shadow-card);
}

.round h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.round p {
  color: var(--text-secondary);
  line-height: 1.5;
  font-size: 14px;
}

.export-container {
  display: none;
  text-align: center;
  margin-top: 14px;
}

/* Toast */
#toast {
  visibility: hidden;
  min-width: 240px;
  background-color: rgba(9, 12, 20, 0.95);
  color: #fff;
  text-align: center;
  border-radius: 12px;
  padding: 12px 14px;
  position: fixed;
  z-index: 10000;
  left: 50%;
  bottom: 30px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.4s, bottom 0.4s;
  transform: translateX(-50%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

#toast.show {
  visibility: visible;
  opacity: 1;
  bottom: 50px;
}

/* Offline install banner */
.install-banner {
  position: fixed;
  top: 18px;
  right: 18px;
  width: min(440px, calc(100% - 36px));
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 14px 14px 16px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  z-index: 12000;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.install-banner::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, #4f46e5, #316bff);
  border-radius: 16px 0 0 16px;
  opacity: 0.9;
}

.install-banner--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.install-banner__icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.install-banner__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.install-banner__title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.install-banner__text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.install-banner__close {
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 12px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.install-banner__close:hover {
  background: var(--accent-soft);
  color: var(--text-primary);
  border-color: rgba(99, 102, 241, 0.35);
}

/* Cookie banner */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 14px 18px;
  text-align: center;
  font-size: 14px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 9999;
  box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.35);
  border-top: 1px solid var(--border-subtle);
}

.cookie-banner a {
  color: var(--accent);
  text-decoration: underline;
}

.cookie-buttons {
  display: flex;
  gap: 8px;
}

.cookie-buttons button {
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 13px;
}

#accept-cookies {
  background: #22c55e;
  color: #0b1020;
}

#decline-cookies {
  background: #ef4444;
  color: #fff;
}

/* Footer */
footer {
  text-align: center;
  padding: 18px;
  font-size: 13px;
  color: var(--text-secondary);
  background: transparent;
}

footer a {
  color: var(--accent);
}

/* Bug button */
#bugReportContainer {
  position: fixed;
  bottom: 20px;
  left: 0;
  z-index: 99999;
  pointer-events: none;
}

#bugReportBtn {
  transition: width 0.3s ease, background-color 0.3s ease, opacity 0.3s ease;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background-color: #4caf50;
  color: white;
  font-size: 20px;
  border-radius: 0 30px 30px 0;
  cursor: pointer;
  width: 62px;
  height: 56px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  padding-left: 14px;
  overflow: hidden;
  white-space: nowrap;
}

#bugReportBtn i {
  flex-shrink: 0;
}

#bugReportBtn .label {
  margin-left: 10px;
  opacity: 0;
  font-size: 14px;
  transition: opacity 0.25s ease;
}

#bugReportBtn.open {
  width: 210px;
  background-color: #43a047;
}

#bugReportBtn.open .label {
  opacity: 1;
}

#bugReportBtn:hover {
  background-color: #45b14a;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

#bugReportBtn.blinking {
  animation: blink 0.6s ease-in-out 3;
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    display: none;
  }

  .mobile-nav {
    display: inline-flex;
  }

  body {
    padding-bottom: 96px;
  }

  .main {
    padding: 20px 16px 24px;
  }

  .main__content-outer {
    align-items: stretch;
  }

  .main-card {
    max-width: 100%;
    padding: 22px 18px 20px;
  }

  .install-banner {
    top: 14px;
    right: 12px;
    width: calc(100% - 24px);
    max-width: none;
  }

  #bugReportContainer {
    left: auto;
    right: 18px;
    bottom: 108px;
  }

  #bugReportBtn {
    border-radius: 18px;
  }
}

@media (max-width: 640px) {
  body {
    padding-bottom: 90px;
  }

  .blog-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .tabs {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .tabs__actions {
    width: 100%;
  }

  .form__row {
    flex-direction: column;
    gap: 4px;
  }

  .form {
    gap: 8px;
  }

  .form__group {
    gap: 4px;
  }

  .generator-card {
    padding: 14px 14px 12px;
  }

  .btn-primary {
    margin-top: 2px;
  }

  .cookie-banner {
    padding: 12px;
  }

  #bugReportContainer {
    left: auto;
    right: 16px;
    bottom: 110px;
  }

  #bugReportBtn {
    width: 52px;
    height: 52px;
    font-size: 18px;
    border-radius: 16px;
    padding-left: 0;
    justify-content: center;
  }

  #bugReportBtn .label {
    display: none;
  }

  #bugReportBtn.open {
    width: 190px;
    justify-content: flex-start;
    padding-left: 14px;
  }

  #bugReportBtn.open .label {
    display: inline;
    opacity: 1;
  }

  .install-banner {
    top: 12px;
    right: 12px;
    left: 12px;
    width: auto;
    gap: 10px;
  }

  .install-banner__text {
    font-size: 12.5px;
  }
}

@media (max-width: 460px) {
  .main-card__title {
    font-size: 22px;
  }
}
