:root {
  color-scheme: light;
  --bg: #e9f6f5;
  --surface: #ffffff;
  --surface-2: #f5f8fb;
  --text: #15202b;
  --muted: #667085;
  --line: #d7e4e8;
  --primary: #0f8f8a;
  --primary-2: #146c94;
  --accent: #e85d4f;
  --gold: #f2a93b;
  --shadow: 0 20px 50px rgba(25, 74, 92, 0.15);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 143, 138, 0.12), transparent 38%),
    linear-gradient(315deg, rgba(232, 93, 79, 0.10), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.dark {
  color-scheme: dark;
  --bg: #111827;
  --surface: #182230;
  --surface-2: #202c3c;
  --text: #eef4f6;
  --muted: #aab7c4;
  --line: #34475b;
  --primary: #35c2b7;
  --primary-2: #64a9d9;
  --accent: #ff7b6d;
  --gold: #f7c266;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.24);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  min-height: 58px;
  padding: 10px clamp(18px, 4vw, 48px);
  background: #071113;
  color: #f8fafc;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: white;
  font-size: 21px;
  font-weight: 900;
}

.font-help {
  margin: 0;
  color: #78f2e7;
  font-weight: 700;
  text-align: center;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--gold);
  font-weight: 800;
  padding: 0;
}

.auth-button {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  color: white;
  padding: 0 14px;
  font-weight: 750;
}

.shell {
  width: min(1280px, calc(100% - 32px));
  margin: 28px auto 56px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.hero h1 {
  max-width: 760px;
  margin: 4px 0 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.42);
}

body.dark .tabs {
  background: rgba(24, 34, 48, 0.55);
}

.tab {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 16px;
  font-weight: 800;
  white-space: nowrap;
}

.tab.active {
  background: var(--surface);
  color: var(--primary-2);
  border-color: var(--line);
  box-shadow: 0 10px 24px rgba(20, 108, 148, 0.12);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-top: 16px;
}

.workspace,
.sidebar {
  min-width: 0;
}

.panel,
.profile-card,
.discover,
.mini-stats {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  display: none;
  min-height: 700px;
  padding: clamp(18px, 3vw, 28px);
}

.panel.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.1;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 0 12px;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.notice {
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 12px 14px;
  color: var(--muted);
  font-weight: 720;
}

.inline-example {
  border: 0;
  border-bottom: 1px dashed currentColor;
  background: transparent;
  color: var(--primary-2);
  padding: 0;
  font-weight: 900;
}

.toolbar,
.search-row,
.controls-grid,
.button-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  padding: 0 16px;
  font-weight: 850;
}

.tool-button.primary {
  border-color: color-mix(in srgb, var(--primary) 60%, var(--line));
  background: var(--primary);
  color: white;
}

.tool-button.full {
  width: 100%;
}

textarea {
  width: 100%;
  min-height: 500px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  padding: 18px;
  font-family: "Noto Sans Devanagari", "Mangal", "Segoe UI", sans-serif;
  font-size: 24px;
  line-height: 1.65;
  outline: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent);
}

.editor-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 760;
}

.search-row {
  align-items: stretch;
}

input,
select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  padding: 0 13px;
  outline: none;
}

.search-row input {
  flex: 1 1 320px;
}

.result-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.result-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 14px;
}

.result-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--primary-2);
  font-size: 1.1rem;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
}

.search-card {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 900;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.controls-grid label,
.auth-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 850;
}

input[type="color"] {
  width: 100%;
  padding: 4px;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--primary);
}

canvas {
  width: 100%;
  max-height: 500px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.font-sample {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 22px;
  font-family: "Noto Sans Devanagari", "Mangal", sans-serif;
  font-size: 26px;
  line-height: 1.8;
}

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

.guide-grid article {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 16px;
}

.guide-grid span,
details p {
  color: var(--muted);
  line-height: 1.6;
}

details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 14px 16px;
  margin-top: 10px;
}

summary {
  cursor: pointer;
  font-weight: 900;
}

.sidebar {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 82px;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.profile-card p {
  margin: 2px 0 0;
  color: var(--muted);
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #21b66f;
  box-shadow: 0 0 0 6px rgba(33, 182, 111, 0.14);
}

.discover {
  overflow: hidden;
}

.discover h3 {
  margin: 0;
  padding: 18px;
  background: var(--surface-2);
  font-size: 1.35rem;
}

.discover button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 70px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 0 18px;
  text-align: left;
  font-size: 1rem;
  font-weight: 760;
}

.discover span {
  color: var(--muted);
  font-size: 1.8rem;
}

.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.mini-stats div {
  display: grid;
  gap: 2px;
  padding: 16px;
}

.mini-stats div + div {
  border-left: 1px solid var(--line);
}

.mini-stats strong {
  font-size: 1.8rem;
}

.mini-stats span {
  color: var(--muted);
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  max-width: 330px;
  transform: translateY(20px);
  opacity: 0;
  border-radius: var(--radius);
  background: #071113;
  color: white;
  padding: 12px 14px;
  font-weight: 800;
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

dialog {
  width: min(420px, calc(100% - 28px));
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  padding: 0;
}

dialog::backdrop {
  background: rgba(7, 17, 19, 0.58);
}

.auth-card {
  display: grid;
  gap: 14px;
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 24px;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0;
}

.close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

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

  .font-help {
    display: none;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    grid-template-columns: 1fr;
  }

  .button-grid,
  .controls-grid,
  .guide-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 10px 14px;
  }

  .brand span:last-child {
    display: none;
  }

  .shell {
    width: min(100% - 20px, 1280px);
    margin-top: 18px;
  }

  .hero,
  .section-head,
  .editor-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .hero h1 {
    font-size: 34px;
  }

  .button-grid,
  .controls-grid,
  .guide-grid,
  .mini-stats {
    grid-template-columns: 1fr;
  }

  .mini-stats div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  textarea {
    min-height: 390px;
    font-size: 22px;
  }
}
