:root {
  --clr-white: #fff;
  --clr-gray1: #f7f7f7;
  --clr-gray2: #efefef;
  --clr-gray3: #363d44;
  --clr-gray4: #1e1e1e;
  --clr-black: #000;
  --brand: #43753d;
  --brand-soft: #d8e8d6;
  --brand-mid: #2a8451;
  --brand-bright: #58c473;
  --border: #e5e5e5;
  --border-soft: #e9eaeb;
  --muted: #888;
  --shadow: 0 4px 24px #0000000a;
  --sidebar-w: 260px;
  --editor-unselected-color: #5f6368;
  --editor-bg: #fff;
  --editor-text: #1c1b1f;
  --toolbar-bg: #fff;
  --card-bg: #efefef;
  --card-inner: #fff;
}

body.dark {
  --clr-gray1: #121212;
  --clr-gray2: #1e1e1e;
  --clr-gray3: #c5c5c5;
  --clr-black: #f1f1f1;
  --border: #333;
  --border-soft: #2a2a2a;
  --muted: #9a9a9a;
  --editor-bg: #1e1e1e;
  --editor-text: #f1f1f1;
  --toolbar-bg: #1a1a1a;
  --card-bg: #1e1e1e;
  --card-inner: #2a2a2a;
  --shadow: 0 4px 24px #00000040;
  background: #121212;
  color: #f1f1f1;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: Roboto, "Noto Sans Devanagari", sans-serif;
  background: var(--clr-gray1);
  color: var(--clr-black);
  font-size: 0.875rem;
  min-height: 100svh;
  overflow-x: hidden;
}

button,
textarea,
select {
  font: inherit;
  border: none;
  background: none;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--brand);
}

.app {
  display: flex;
  min-height: 100svh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--editor-bg);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transform: translateX(0);
  transition: transform 0.25s ease;
}

.sidebar.collapsed {
  transform: translateX(-100%);
}

.sidebar-top {
  padding: 1rem;
  border-bottom: 1px solid var(--border-soft);
}

.new-file-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
}

.new-file-btn:hover {
  filter: brightness(1.05);
}

.sidebar-note {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.draft-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.draft-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  text-align: left;
  width: 100%;
}

.draft-item:hover {
  background: var(--clr-gray2);
}

.draft-item.active {
  background: var(--brand-soft);
  border-color: #c3d9c0;
}

body.dark .draft-item.active {
  background: #243528;
  border-color: #3a5a40;
}

.draft-title {
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.draft-meta {
  font-size: 0.7rem;
  color: var(--muted);
}

.draft-item .delete-draft {
  align-self: flex-end;
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0;
}

.draft-item:hover .delete-draft {
  opacity: 1;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-soft);
}

.sidebar-link {
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}

.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

.sidebar.collapsed + .main-wrap {
  margin-left: 0;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--clr-black);
  font-weight: 600;
  font-size: 1.125rem;
}

.brand img {
  border-radius: 8px;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}

.text-btn {
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 500;
}

.text-btn:hover {
  background: var(--clr-gray2);
  color: var(--clr-black);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--editor-unselected-color);
}

.icon-btn:hover,
.icon-btn.active {
  background: var(--clr-gray2);
  color: var(--clr-black);
}

/* Editor */
.editor-shell {
  background: var(--editor-bg);
  border-bottom: 1px solid var(--border-soft);
  min-height: 70vh;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  background: var(--toolbar-bg);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding-right: 0.5rem;
  border-right: 1px solid var(--border-soft);
}

.toolbar-group:last-child {
  border-right: none;
}

.toolbar-group.push-end {
  margin-left: auto;
  border-right: none;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.toolbar-select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--editor-bg);
  min-width: 90px;
}

.toolbar-select.size {
  min-width: 56px;
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.8rem;
}

.lang-toggle.english #langLabel {
  color: var(--muted);
  font-weight: 400;
}

.lang-toggle.english .lang-muted {
  color: var(--clr-black);
  font-weight: 600;
}

.lang-muted {
  color: var(--muted);
  font-weight: 400;
}

.lang-switch-icon {
  color: var(--brand);
}

.action-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.action-btn:hover {
  background: var(--clr-gray2);
}

.action-btn.voice.listening {
  background: #ffe8e8;
  border-color: #eb3131;
  color: #eb3131;
  animation: pulse 1.2s infinite;
}

body.dark .action-btn.voice.listening {
  background: #3a1a1a;
}

.action-btn.copy {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.action-btn.copy:hover {
  filter: brightness(1.05);
  background: var(--brand);
}

@keyframes pulse {
  50% {
    opacity: 0.75;
  }
}

.editor-area {
  position: relative;
  flex: 1;
  min-height: 420px;
}

.editor {
  min-height: 420px;
  height: 100%;
  padding: 1.5rem 1.75rem;
  outline: none;
  font-size: 16px;
  line-height: 1.7;
  color: var(--editor-text);
  font-family: "Noto Sans Devanagari", Roboto, sans-serif;
  white-space: pre-wrap;
  word-break: break-word;
}

.editor:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
}

.suggestions {
  position: absolute;
  z-index: 20;
  background: var(--editor-bg);
  border: 1px solid #0000001a;
  border-radius: 8px;
  padding: 8px;
  box-shadow: var(--shadow);
  max-width: min(320px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.suggestions.hidden {
  display: none;
}

.suggestion-item {
  padding: 8px 12px;
  border-radius: 6px;
  text-align: left;
  font-weight: 600;
  font-size: 1rem;
  font-family: "Noto Sans Devanagari", Roboto, sans-serif;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: #0000000d;
}

body.dark .suggestion-item:hover,
body.dark .suggestion-item.active {
  background: #ffffff14;
}

/* Marketing */
.marketing {
  width: min(1100px, 92%);
  margin: 0 auto;
  padding: 3rem 0 4rem;
}

.hero-copy {
  text-align: center;
  margin-bottom: 2.5rem;
}

.hero-copy h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.lead {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 36rem;
  margin: 0 auto;
  line-height: 1.6;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.feature-card {
  background: var(--card-bg);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 280px;
}

.feature-art {
  height: 140px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(180deg, transparent, #00000005);
}

.feature-body {
  background: var(--card-inner);
  border-top: 1px solid var(--border);
  padding: 1rem 1.1rem 1.25rem;
  flex: 1;
  border-radius: 0 0 16px 16px;
}

.feature-body h3 {
  font-size: 1.05rem;
  margin-bottom: 0.4rem;
}

.feature-body p {
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}

.pill-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.pill {
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-inner);
  font-size: 0.8rem;
}

.pill.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.demo-line {
  background: var(--card-inner);
  padding: 0.6rem 1rem;
  border-radius: 10px 10px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  font-size: 0.9rem;
}

.demo-voice {
  background: #ffe8e8;
  color: #eb3131;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-inner);
  margin: 0 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.chip.success {
  color: var(--brand-mid);
  font-weight: 700;
}

.mini-draft {
  background: var(--card-inner);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  width: 85%;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
}

.mini-draft.muted {
  color: var(--muted);
  width: 70%;
}

.tool {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: var(--card-inner);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0 0.2rem 0.5rem;
  font-weight: 700;
}

.tool:last-child {
  width: auto;
  padding: 0 0.75rem;
}

.theme-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 90%;
  padding: 0.4rem 0.85rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  background: #fff;
  color: #000;
}

.theme-preview.night {
  background: #212121;
  color: #fff;
}

.switch {
  width: 44px;
  height: 26px;
  border-radius: 15px;
  background: #979899;
  position: relative;
}

.switch::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
}

.switch.on {
  background: var(--brand-bright);
}

.switch.on::after {
  left: auto;
  right: 3px;
}

.fonts-cta,
.app-promo,
.languages,
.faq {
  margin-top: 3.5rem;
}

.fonts-cta,
.app-promo {
  text-align: center;
  background: var(--brand-soft);
  border-radius: 16px;
  padding: 2.5rem 1.5rem;
}

body.dark .fonts-cta,
body.dark .app-promo {
  background: #1a2a1c;
}

.fonts-cta h2,
.app-promo h2,
.languages h2,
.faq h2 {
  font-size: clamp(1.35rem, 3vw, 2rem);
  margin-bottom: 0.5rem;
}

.fonts-cta p,
.app-promo p {
  color: var(--clr-gray3);
  margin-bottom: 1.25rem;
}

.cta-btn,
.store-links a {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
}

.store-links {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.store-links a:last-child {
  background: var(--clr-gray4);
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.lang-grid a {
  display: block;
  text-align: center;
  padding: 0.85rem 0.5rem;
  background: var(--editor-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--clr-black);
  font-weight: 500;
}

.lang-grid a:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.faq details {
  background: var(--editor-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
}

.faq summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

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

.faq details p {
  margin-top: 0.65rem;
  color: var(--muted);
  line-height: 1.55;
}

.site-footer {
  background: var(--clr-gray4);
  color: #fff;
  margin-top: auto;
}

.footer-inner {
  width: min(1100px, 90%);
  margin: 0 auto;
  padding: 2rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}

.site-footer a {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.footer-links {
  display: flex;
  gap: 1rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: #00000050;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal-card {
  background: var(--editor-bg);
  border-radius: 12px;
  padding: 1.25rem;
  width: min(400px, 100%);
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  font-weight: 600;
}

.toggle {
  width: 50px;
  height: 30px;
  border-radius: 15px;
  background: #979899;
  padding: 0.2rem 0.3rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.toggle[aria-checked="true"] {
  background: var(--brand-bright);
  justify-content: flex-end;
}

.toggle .knob {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
}

.setting-hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--editor-bg);
  border: 1px solid var(--border);
  padding: 0.85rem 1.1rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 110;
  font-weight: 500;
}

.toast.hidden {
  display: none;
}

.back-to-top {
  position: fixed;
  bottom: 120px;
  right: 40px;
  background: #fff;
  color: var(--brand);
  border: 1px solid #c3c3c3;
  padding: 0.85rem 1.1rem;
  border-radius: 30px;
  font-weight: 600;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 0.25s ease;
}

body.dark .back-to-top {
  background: #2a2a2a;
  border-color: #444;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 8px 0 24px #00000020;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-wrap {
    margin-left: 0;
  }

  .toolbar-group.push-end {
    margin-left: 0;
    width: 100%;
    padding-top: 0.35rem;
  }
}

@media (min-width: 1024px) {
  body {
    font-size: 1rem;
  }
}

@media print {
  .sidebar,
  .topbar,
  .toolbar,
  .marketing,
  .site-footer,
  .back-to-top,
  .modal,
  .toast {
    display: none !important;
  }

  .main-wrap {
    margin: 0;
  }

  .editor {
    min-height: auto;
  }
}
