/* ==========================================================================
   Notes.SubhanSaeed.Site — public notes UI
   The original notesapp.tsx palette, spacing and rounded card language.
   ========================================================================== */

:root {
  --bg: #0f172a;
  --bg-deep: #0b1120;
  --nav-bg: rgba(15, 23, 42, 0.72);
  --panel: rgba(30, 41, 59, 0.5);
  --panel-strong: #1e293b;
  --panel-soft: rgba(30, 41, 59, 0.3);
  --panel-faint: rgba(30, 41, 59, 0.18);
  --border: #334155;
  --border-strong: #64748b;
  --border-soft: rgba(51, 65, 85, 0.5);
  --border-faint: rgba(51, 65, 85, 0.3);
  --text: #e2e8f0;
  --text-strong: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --indigo: #818cf8;
  --indigo-strong: #6366f1;
  --indigo-bg: rgba(99, 102, 241, 0.16);
  --emerald: #34d399;
  --emerald-bg: rgba(16, 185, 129, 0.14);
  --blue: #60a5fa;
  --amber: #fbbf24;
  --danger: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --content-width: 72rem;
  --font-ui: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-urdu: 'Noori Nastaleeq', 'Noto Nastaliq Urdu', serif;
  --font-code: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(58rem 36rem at 82% -12%, rgba(99, 102, 241, 0.12), transparent 62%),
    radial-gradient(40rem 26rem at 8% 108%, rgba(16, 185, 129, 0.05), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection {
  background: rgba(99, 102, 241, 0.32);
  color: #fff;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  inset-block-start: -100px;
  inset-inline-start: 16px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--indigo-strong);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: inset-block-start 0.2s ease;
}

.skip-link:focus {
  inset-block-start: 16px;
}

/* --------------------------------------------------------------------------
   Top navigation
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 30;
  border-block-end: 1px solid rgba(30, 41, 59, 0.9);
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar-inner {
  width: 100%;
  max-width: var(--content-width);
  height: 4rem;
  margin-inline: auto;
  padding-inline: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  border-radius: 10px;
  min-width: 0;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: var(--indigo-strong);
  color: #fff;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.28);
}

.brand-icon svg {
  width: 23px;
  height: 23px;
}

.brand-name {
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-ui);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.nav-btn svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.nav-btn:hover {
  background: rgba(30, 41, 59, 0.75);
  border-color: rgba(51, 65, 85, 0.7);
  color: var(--text-strong);
}

.nav-admin {
  color: var(--text);
  border-color: var(--border);
  background: rgba(30, 41, 59, 0.45);
}

.lang-toggle {
  min-width: 74px;
}

.lang-toggle span {
  font-family: var(--font-ui);
}

/* --------------------------------------------------------------------------
   Layout and page header
   -------------------------------------------------------------------------- */

.app-main {
  width: 100%;
  max-width: var(--content-width);
  margin-inline: auto;
  padding: 32px 24px 64px;
  outline: none;
}

.view {
  animation: viewIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 24px;
  margin-block-end: 24px;
  border-block-end: 1px solid var(--border-soft);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.page-title {
  margin: 0;
  color: #fff;
  font-size: clamp(1.45rem, 3.5vw, 1.875rem);
  line-height: 1.22;
  font-weight: 700;
  letter-spacing: -0.022em;
  overflow-wrap: anywhere;
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 500;
}

.back-btn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.back-btn:hover {
  background: var(--panel-strong);
  color: #fff;
}

.back-btn svg {
  width: 22px;
  height: 22px;
  transition: transform 0.2s ease;
}

html[dir='rtl'] .back-btn svg,
html[dir='rtl'] .chevron-icon {
  transform: scaleX(-1);
}

/* --------------------------------------------------------------------------
   Home cards
   -------------------------------------------------------------------------- */

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

.home-card {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  inline-size: 100%;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  color: inherit;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.home-card:hover {
  background: var(--panel-strong);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(2, 6, 23, 0.26);
}

.home-card-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-block-end: 16px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.55);
  transition: transform 0.2s ease;
}

.home-card:hover .home-card-icon {
  transform: scale(1.08);
}

.home-card-icon svg {
  width: 27px;
  height: 27px;
}

.accent-indigo { color: var(--indigo); }
.accent-emerald { color: var(--emerald); }
.accent-slate { color: #94a3b8; }
.accent-blue { color: var(--blue); }

.home-card h2 {
  margin: 0 0 8px;
  color: #f1f5f9;
  font-size: 1.2rem;
  line-height: 1.35;
  font-weight: 600;
}

.home-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Feedback section (public)
   -------------------------------------------------------------------------- */

.feedback-section {
  margin-block-start: 40px;
  scroll-margin-block-start: 96px;
}

.feedback-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 34px;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(30, 41, 59, 0.56), rgba(30, 41, 59, 0.3));
}

.feedback-card::before {
  content: '';
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(129, 140, 248, 0.7), transparent);
}

.feedback-intro {
  align-self: start;
  padding-block-start: 4px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-block-end: 14px;
  color: var(--indigo);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: '';
  width: 18px;
  height: 1px;
  background: currentColor;
}

.feedback-intro h2 {
  margin: 0 0 10px;
  color: #fff;
  font-size: clamp(1.2rem, 2.6vw, 1.55rem);
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.feedback-intro p {
  margin: 0;
  max-width: 34ch;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.7;
}

.feedback-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-block-start: 20px;
  color: var(--text-dim);
  font-size: 0.76rem;
  line-height: 1.55;
}

.feedback-note svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-block-start: 2px;
}

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-width: 0;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.field > span:first-child,
.field legend {
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.optional {
  color: var(--text-dim);
  font-weight: 400;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
  color: var(--text-strong);
  font-size: 0.875rem;
  padding: 10px 12px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.input {
  min-height: 42px;
}

.textarea {
  min-height: 108px;
  resize: vertical;
  line-height: 1.6;
}

.input::placeholder,
.textarea::placeholder {
  color: #64748b;
}

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
  background: rgba(15, 23, 42, 0.85);
}

.rating-field {
  margin: 0;
  padding: 0;
  border: 0;
}

.rating-field legend {
  padding: 0;
  margin-block-end: 7px;
}

.stars {
  display: flex;
  align-items: center;
  gap: 2px;
}

.star {
  display: grid;
  place-items: center;
  width: 36px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #475569;
  cursor: pointer;
  transition: color 0.14s ease, transform 0.14s ease, background-color 0.14s ease;
}

.star svg {
  width: 22px;
  height: 22px;
  fill: transparent;
  stroke: currentColor;
  stroke-width: 1.8;
  transition: fill 0.14s ease;
}

.star:hover {
  background: rgba(251, 191, 36, 0.08);
  color: #fcd34d;
  transform: translateY(-1px);
}

.star.is-active {
  color: var(--amber);
}

.star.is-active svg {
  fill: currentColor;
}

.rating-value {
  margin-inline-start: 6px;
  color: var(--text-dim);
  font-size: 0.75rem;
}

.feedback-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.form-status {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.form-status.is-error {
  color: var(--danger);
}

.form-status.is-success {
  color: var(--emerald);
}

.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
}

.btn-primary {
  background: var(--indigo-strong);
  color: #fff;
  box-shadow: 0 8px 22px rgba(79, 70, 229, 0.22);
}

.btn-primary:hover {
  background: #4f46e5;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.btn-primary svg,
.btn-secondary svg,
.btn-danger svg {
  width: 16px;
  height: 16px;
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.7);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--panel-strong);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--danger-bg);
  border-color: rgba(248, 113, 113, 0.25);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* --------------------------------------------------------------------------
   Notes lists
   -------------------------------------------------------------------------- */

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 56rem;
}

.list-item {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  inline-size: 100%;
  padding: 19px 20px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--panel-soft);
  color: inherit;
  text-align: start;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.list-item:hover {
  background: var(--panel-strong);
  border-color: rgba(100, 116, 139, 0.55);
}

.list-item-main {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.list-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: rgba(51, 65, 85, 0.5);
  color: var(--indigo);
}

.list-icon svg {
  width: 22px;
  height: 22px;
}

.list-title {
  display: block;
  color: #e2e8f0;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.4;
  overflow-wrap: anywhere;
  transition: color 0.18s ease;
}

.list-item:hover .list-title {
  color: #fff;
}

.list-meta {
  display: block;
  margin-block-start: 2px;
  color: var(--text-dim);
  font-size: 0.76rem;
}

.list-tail {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  color: #64748b;
}

.list-count {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: #94a3b8;
  background: rgba(51, 65, 85, 0.5);
  border: 1px solid rgba(51, 65, 85, 0.6);
  border-radius: 999px;
  padding: 2px 8px;
}

.chevron-icon {
  width: 20px;
  height: 20px;
  transition: color 0.18s ease, transform 0.18s ease;
}

.list-item:hover .chevron-icon {
  color: var(--indigo);
}

.list-item.is-placeholder {
  background: rgba(30, 41, 59, 0.1);
  border: 1px dashed var(--border-faint);
  opacity: 0.55;
  cursor: not-allowed;
}

.list-item.is-placeholder .list-icon {
  background: var(--panel-strong);
  color: var(--text-dim);
}

.list-item.is-placeholder .list-title {
  color: #94a3b8;
}

.empty-state {
  padding: 40px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  text-align: center;
  font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   Chapter content and Q&A
   -------------------------------------------------------------------------- */

.content-wrap {
  max-width: 62rem;
}

.content-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-block-end: 20px;
  flex-wrap: wrap;
}

.content-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-dim);
  font-size: 0.78rem;
  flex-wrap: wrap;
}

.subject-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(129, 140, 248, 0.2);
  background: rgba(99, 102, 241, 0.1);
  color: #a5b4fc;
  font-size: 0.72rem;
  font-weight: 600;
}

.filter-tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.45);
}

.filter-tab {
  appearance: none;
  min-height: 30px;
  padding: 4px 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease;
  white-space: nowrap;
}

.filter-tab:hover {
  color: var(--text);
}

.filter-tab.is-active {
  background: rgba(51, 65, 85, 0.8);
  color: #fff;
  box-shadow: 0 1px 2px rgba(2, 6, 23, 0.3);
}

.qa-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.qa-card {
  padding: 23px 24px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: rgba(30, 41, 59, 0.4);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.qa-card:hover {
  background: rgba(30, 41, 59, 0.6);
  border-color: rgba(51, 65, 85, 0.8);
}

.qa-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.qa-row + .qa-row {
  margin-block-start: 12px;
}

.qa-letter {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.qa-letter.q {
  background: rgba(99, 102, 241, 0.2);
  color: var(--indigo);
}

.qa-letter.a {
  background: rgba(16, 185, 129, 0.2);
  color: var(--emerald);
}

.qa-question {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-block-start: 3px;
}

.qa-question h2 {
  margin: 0;
  color: #f1f5f9;
  font-size: 1.02rem;
  line-height: 1.55;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.type-badge {
  flex: 0 0 auto;
  margin-block-start: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.type-badge.short {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.16);
}

.type-badge.long {
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.18);
}

.qa-answer {
  flex: 1 1 auto;
  min-width: 0;
  padding-block-start: 4px;
  color: #cbd5e1;
  font-size: 0.94rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

html[lang='ur'] .qa-answer,
html[lang='ur'] .list-title,
html[lang='ur'] .qa-question h2,
html[lang='ur'] .feedback-intro p,
html[lang='ur'] .home-card p {
  line-height: 2.05;
}

.qa-answer p {
  margin: 0 0 8px;
}

.qa-answer p:last-child {
  margin-block-end: 0;
}

.qa-answer ul,
.qa-answer ol {
  margin: 6px 0;
  padding-inline-start: 1.35rem;
}

.qa-answer li {
  margin-block: 2px;
}

.qa-answer b,
.qa-answer strong {
  color: #f1f5f9;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Code blocks with press-and-hold output
   -------------------------------------------------------------------------- */

.code-block {
  position: relative;
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0b1120;
  overflow: hidden;
  white-space: normal;
  box-shadow: 0 10px 26px rgba(2, 6, 23, 0.25);
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 13px;
  border-block-end: 1px solid rgba(51, 65, 85, 0.55);
  background: rgba(30, 41, 59, 0.4);
}

.code-lang {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #a5b4fc;
  font-family: var(--font-code);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.code-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.08);
}

.code-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 500;
  transition: color 0.16s ease;
}

.code-hint svg {
  width: 13px;
  height: 13px;
}

.code-block:hover .code-hint {
  color: #a5b4fc;
}

.code-source {
  margin: 0;
  padding: 14px 15px;
  overflow-x: auto;
  color: #e2e8f0;
  font-family: var(--font-code);
  font-size: 0.8rem;
  line-height: 1.7;
  white-space: pre;
  tab-size: 2;
}

.code-block.is-preview {
  border-color: rgba(52, 211, 153, 0.28);
}

.code-block.is-preview .code-head {
  border-block-end-color: rgba(52, 211, 153, 0.2);
}

.code-output {
  margin: 0;
  padding: 15px;
  color: #a7f3d0;
  background: rgba(6, 78, 59, 0.16);
  font-family: var(--font-code);
  font-size: 0.8rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: outputIn 0.16s ease both;
}

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

.code-block .code-output {
  display: none;
}

.code-block.is-preview .code-source {
  display: none;
}

.code-block.is-preview .code-output {
  display: block;
}

.code-block:focus-visible {
  outline: 2px solid var(--emerald);
  outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Loading, toast, modal, footer
   -------------------------------------------------------------------------- */

.loading-view {
  min-height: 48vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 2px solid rgba(129, 140, 248, 0.22);
  border-block-start-color: var(--indigo);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast-region {
  position: fixed;
  inset-block-end: 22px;
  inset-inline-end: 22px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: min(360px, calc(100vw - 32px));
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #1e293b;
  box-shadow: 0 16px 38px rgba(2, 6, 23, 0.45);
  color: var(--text);
  font-size: 0.82rem;
  animation: toastIn 0.24s ease both;
}

.toast.success { border-color: rgba(52, 211, 153, 0.35); }
.toast.error { border-color: rgba(248, 113, 113, 0.35); }

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

.modal-root:empty {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.18s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: min(450px, 100%);
  max-height: min(86vh, 720px);
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #131e33;
  box-shadow: 0 28px 80px rgba(2, 6, 23, 0.6);
  animation: modalIn 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-block-end: 16px;
}

.modal-head h2 {
  margin: 0;
  color: #fff;
  font-size: 1.08rem;
  font-weight: 600;
}

.modal-head p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.55;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: rgba(51, 65, 85, 0.6);
  color: #fff;
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.lang-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(15, 23, 42, 0.45);
  color: var(--text);
  text-align: start;
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.lang-option:hover {
  border-color: var(--border-strong);
  background: rgba(30, 41, 59, 0.6);
}

.lang-option.is-selected {
  border-color: rgba(129, 140, 248, 0.6);
  background: rgba(99, 102, 241, 0.1);
}

.lang-option strong {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
}

.lang-option small {
  display: block;
  margin-block-start: 2px;
  color: var(--text-dim);
  font-size: 0.72rem;
}

.lang-check {
  width: 17px;
  height: 17px;
  color: var(--indigo);
  opacity: 0;
}

.lang-option.is-selected .lang-check {
  opacity: 1;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-block-start: 18px;
}

.noscript {
  position: fixed;
  inset-block-end: 0;
  inset-inline: 0;
  padding: 12px;
  background: #7f1d1d;
  color: #fff;
  text-align: center;
  z-index: 100;
}

/* --------------------------------------------------------------------------
   Urdu typography and RTL
   -------------------------------------------------------------------------- */

html[lang='ur'] body {
  font-family: var(--font-urdu);
  line-height: 1.9;
}

html[lang='ur'] .brand-name,
html[lang='ur'] .nav-btn,
html[lang='ur'] .code-lang,
html[lang='ur'] .code-hint,
html[lang='ur'] .code-source,
html[lang='ur'] .code-output,
html[lang='ur'] .type-badge,
html[lang='ur'] .list-count {
  font-family: var(--font-ui);
}

html[lang='ur'] .page-title,
html[lang='ur'] .home-card h2,
html[lang='ur'] .feedback-intro h2,
html[lang='ur'] .qa-question h2,
html[lang='ur'] .list-title {
  letter-spacing: 0;
  line-height: 1.8;
}

html[lang='ur'] .btn-primary,
html[lang='ur'] .btn-secondary,
html[lang='ur'] .field > span,
html[lang='ur'] .field legend,
html[lang='ur'] .input,
html[lang='ur'] .textarea,
html[lang='ur'] .filter-tab {
  font-family: var(--font-urdu);
  line-height: 2;
}

html[lang='ur'] .eyebrow {
  font-family: var(--font-ui);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 980px) {
  .home-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }

  .home-card {
    padding: 20px;
  }

  .feedback-card {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 26px;
  }

  .feedback-intro p {
    max-width: 60ch;
  }
}

@media (max-width: 760px) {
  .topbar-inner {
    padding-inline: 16px;
    height: 3.75rem;
  }

  .app-main {
    padding: 22px 16px 52px;
  }

  .brand-name {
    font-size: 1rem;
  }

  .nav-btn span[data-nav-label] {
    display: none;
  }

  .nav-btn {
    width: 38px;
    padding: 7px;
  }

  .nav-btn.lang-toggle {
    width: auto;
    min-width: 62px;
    padding-inline: 10px;
  }

  .nav-actions {
    gap: 5px;
  }

  .page-header {
    padding-block: 18px;
    margin-block-end: 20px;
  }

  .home-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .home-card {
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 17px;
  }

  .home-card-icon {
    width: 46px;
    height: 46px;
    margin-block-end: 0;
    flex: 0 0 auto;
  }

  .home-card-icon svg {
    width: 24px;
    height: 24px;
  }

  .home-card h2 {
    margin-block-end: 3px;
    font-size: 1.02rem;
  }

  .home-card p {
    font-size: 0.79rem;
    line-height: 1.5;
  }

  .feedback-section {
    margin-block-start: 28px;
  }

  .feedback-card {
    padding: 20px;
    border-radius: 16px;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .list-item {
    padding: 15px;
  }

  .list-icon {
    width: 38px;
    height: 38px;
  }

  .list-title {
    font-size: 0.96rem;
  }

  .qa-card {
    padding: 18px 16px;
  }

  .qa-row {
    gap: 12px;
  }

  .qa-question {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding-block-start: 2px;
  }

  .qa-question h2 {
    font-size: 0.97rem;
  }

  .type-badge {
    margin-block-start: 0;
  }

  .qa-answer {
    font-size: 0.9rem;
  }

  .content-toolbar {
    align-items: flex-start;
  }

  .code-source,
  .code-output {
    font-size: 0.76rem;
  }
}

@media (max-width: 540px) {
  .brand-name {
    display: none;
  }

  .topbar-inner {
    gap: 8px;
  }

  .nav-admin svg {
    width: 16px;
    height: 16px;
  }

  .feedback-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .feedback-footer .btn-primary {
    width: 100%;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .back-btn {
    width: 36px;
    height: 36px;
  }

  .content-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 11px;
  }

  .filter-tabs {
    align-self: flex-start;
    max-width: 100%;
    overflow-x: auto;
  }

  .qa-letter {
    width: 29px;
    height: 29px;
  }

  .toast-region {
    inset-block-end: 14px;
    inset-inline: 14px;
  }

  .toast {
    max-width: none;
  }
}

@media (max-width: 370px) {
  .app-main {
    padding-inline: 12px;
  }

  .nav-btn.lang-toggle {
    min-width: 54px;
  }

  .home-card p {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
