:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --surface-strong: #ffffff;
  --text: #172033;
  --muted: #637083;
  --line: #dbe1ea;
  --blue: #2f6fed;
  --blue-soft: #edf4ff;
  --blue-ink: #204a98;
  --green: #159a62;
  --green-soft: #eef8f2;
  --green-line: #c9ead7;
  --amber: #c77700;
  --amber-soft: #fff7df;
  --amber-line: #efd08a;
  --red: #b42318;
  --red-soft: #fff2f0;
  --control-hover: #eef3fb;
  --topbar-bg: rgba(255, 255, 255, 0.94);
  --heading-bg: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  --backdrop: rgba(23, 32, 51, 0.45);
  --shadow: 0 14px 34px rgba(32, 42, 68, 0.08);
}

:root[data-theme="dark"] {
  --bg: #0f1724;
  --surface: #151f2d;
  --surface-soft: #101826;
  --surface-strong: #1b2838;
  --text: #eef4fb;
  --muted: #9aa8bb;
  --line: #2b3a4d;
  --blue: #7aa7ff;
  --blue-soft: #172a49;
  --blue-ink: #c8dcff;
  --green: #6bd39a;
  --green-soft: #123221;
  --green-line: #24543a;
  --amber: #ffd074;
  --amber-soft: #352817;
  --amber-line: #6a5020;
  --red: #ff8d82;
  --red-soft: #3a1d1b;
  --control-hover: #202d3f;
  --topbar-bg: rgba(15, 23, 36, 0.94);
  --heading-bg: linear-gradient(180deg, #192535 0%, #151f2d 100%);
  --backdrop: rgba(0, 0, 0, 0.62);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

button,
a,
input,
select,
textarea {
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, color 160ms ease, opacity 160ms ease;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 40%, transparent);
  outline-offset: 2px;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  min-height: 70px;
  padding: 14px 22px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
}

.brand-symbol {
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.brand-name {
  font-size: 25px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.brand-ai {
  color: var(--blue);
}

.brand-tagline {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.15;
  white-space: nowrap;
}

.brand-crop {
  position: relative;
  display: block;
  flex: 0 0 auto;
  overflow: hidden;
}

.brand-crop img {
  position: absolute;
  display: block;
  max-width: none;
  height: auto;
}

.brand-mark {
  width: 36px;
  height: 36px;
}

.brand-mark img {
  top: -17px;
  left: -15px;
  width: 147px;
}

.brand-word {
  width: 116px;
  height: 22px;
}

.brand-word img {
  top: -41px;
  left: -82px;
  width: 210px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

.field textarea {
  min-height: 126px;
  line-height: 1.5;
  resize: vertical;
}

.field input[type="file"] {
  padding: 5px;
  color: var(--muted);
}

.field input[type="file"]::file-selector-button {
  min-height: 32px;
  margin-right: 10px;
  border: 0;
  border-radius: 7px;
  padding: 0 12px;
  background: var(--blue-soft);
  color: var(--blue-ink);
  font-weight: 750;
  cursor: pointer;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
}

.primary-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--blue);
  color: #fff;
  font-weight: 750;
}

.primary-button:hover {
  background: #245ac1;
}

.ghost-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface-strong);
  color: var(--text);
  font-weight: 700;
}

.ghost-button:hover {
  background: var(--control-hover);
}

.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.account-actions,
.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.balance-button,
.premium-button,
.theme-button {
  min-height: 38px;
  border-radius: 8px;
  font-weight: 800;
}

.theme-button {
  width: 42px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}

.theme-button:hover {
  background: var(--control-hover);
}

.balance-button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  border: 1px solid var(--line);
  padding: 0 10px;
  background: var(--blue-soft);
  color: var(--blue-ink);
}

.balance-button strong {
  min-width: 26px;
  border-radius: 6px;
  padding: 2px 6px;
  background: var(--surface-strong);
  text-align: center;
}

.premium-button {
  border: 1px solid var(--amber-line);
  padding: 0 12px;
  background: var(--amber-soft);
  color: var(--amber);
}

.premium-button.active {
  border-color: var(--green-line);
  background: var(--green-soft);
  color: var(--green);
}

.layout {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 328px;
  gap: 18px;
  align-items: start;
}

.seo-links {
  width: min(1240px, 100%);
  margin: 10px auto 22px;
  padding: 0 18px;
  display: grid;
  gap: 14px;
}

.seo-links h2 {
  margin: 0;
  font-size: 22px;
}

.seo-links-copy,
.seo-links-note {
  max-width: 900px;
  margin: 8px 0 0;
  color: var(--muted);
}

.seo-links-note {
  margin-top: 0;
  font-size: 14px;
}

.seo-links a {
  color: var(--blue);
  font-weight: 750;
  text-decoration: none;
}

.tool-panel,
.context-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-panel {
  min-height: 590px;
  overflow: hidden;
}

.tool-panel.chat-panel {
  display: flex;
  flex-direction: column;
}

.tool-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--heading-bg);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(28px, 3.3vw, 40px);
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
}

.tool-summary {
  margin: 0;
  padding: 16px 24px 0;
  max-width: 780px;
  color: var(--muted);
}

.tool-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 24px 20px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 720;
}

.field.full {
  grid-column: 1 / -1;
}

.auth-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.auth-mode-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.auth-mode-button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 29, 53, 0.12);
}

.registration-consents {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.registration-consents[hidden] {
  display: none;
}

.consent-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.consent-row input {
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  accent-color: var(--blue);
}

.consent-row a,
.legal-note a {
  color: var(--blue);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  grid-column: 1 / -1;
}

.form-actions .primary-button {
  min-width: 118px;
}

.file-preview {
  display: none;
  grid-column: 1 / -1;
  width: min(360px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.file-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.result-section {
  margin: 0 24px 24px;
}

.result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.result-heading h2 {
  font-size: 15px;
}

.result-box {
  min-height: 144px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  overflow: hidden;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 144px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.answer {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.answer-main {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: 8px;
  background: var(--green-soft);
  border: 1px solid var(--green-line);
}

.answer-label {
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0;
}

.answer-value {
  font-size: 28px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.ai-response {
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.65;
  white-space: pre-wrap;
}

.generated-image {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.generated-image img {
  display: block;
  width: min(640px, 100%);
  aspect-ratio: 1;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  object-fit: contain;
}

.generated-image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.generated-image-actions span {
  flex: 1 1 240px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.image-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.tool-form.system-form {
  display: block;
}

.tool-form.chat-form {
  display: grid;
  order: 4;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px 22px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-strong);
}

.chat-panel .result-box {
  order: 3;
  flex: 1 1 auto;
  margin: 16px 22px 0;
}

.chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  justify-content: space-between;
}

.chat-toolbar .field {
  width: min(220px, 100%);
}

.support-toolbar > div {
  display: grid;
  gap: 3px;
}

.support-toolbar span,
.support-ticket > p,
.telegram-bot-item > p {
  color: var(--muted);
  font-size: 13px;
}

.chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.chat-compose textarea {
  width: 100%;
  min-height: 54px;
  max-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  resize: vertical;
  color: var(--text);
  font: inherit;
  outline: none;
}

.chat-compose textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
}

.chat-thread {
  display: grid;
  align-content: start;
  gap: 12px;
  max-height: 520px;
  min-height: 300px;
  padding: 16px;
  overflow-y: auto;
}

.chat-message {
  display: grid;
  gap: 5px;
  width: min(720px, 92%);
}

.chat-message.user {
  justify-self: end;
}

.chat-message.assistant {
  justify-self: start;
}

.chat-message span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chat-message.user span {
  justify-self: end;
}

.chat-message p {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-message.user p {
  border-color: #cfe0ff;
  background: var(--blue-soft);
}

.chat-message.loading p {
  color: var(--muted);
}

.system-page {
  display: grid;
  gap: 18px;
}

.empty-account {
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: center;
  text-align: center;
}

.empty-account h2,
.empty-account p,
.profile-identity h2,
.profile-identity p {
  margin: 0;
}

.empty-account p,
.profile-identity p {
  margin-top: 4px;
  color: var(--muted);
}

.profile-identity {
  display: flex;
  gap: 14px;
  align-items: center;
}

.profile-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: #204a98;
  font-size: 22px;
  font-weight: 850;
}

.profile-avatar.small {
  width: 38px;
  height: 38px;
  font-size: 16px;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  gap: 1px;
}

.admin-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.admin-tabs {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  justify-self: start;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.admin-tab {
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.admin-tab.active {
  color: var(--text);
  background: var(--surface-strong);
  box-shadow: 0 1px 3px rgba(15, 29, 53, 0.12);
}

.version-panel {
  display: grid;
  gap: 16px;
}

.version-panel[hidden] {
  display: none;
}

.version-panel .system-section-head > div {
  display: grid;
  gap: 3px;
}

.version-list {
  border-top: 1px solid var(--line);
}

.version-entry {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.version-entry-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.version-entry-head strong {
  color: var(--blue);
  font-size: 12px;
  text-transform: uppercase;
}

.version-entry h3 {
  margin: 4px 0 0;
  font-size: 17px;
  letter-spacing: 0;
}

.version-entry time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.version-entry ul {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
}

.ticket-conversation {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.ticket-conversation p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.telegram-editor {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-status {
  grid-column: 1 / -1;
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.stat-strip div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 14px;
  background: var(--surface-strong);
}

.stat-strip span,
.system-section-head span,
.admin-user-row span {
  color: var(--muted);
  font-size: 12px;
}

.stat-strip strong {
  overflow-wrap: anywhere;
  font-size: 19px;
}

.system-section {
  display: grid;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.profile-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.plan-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.plan-row div {
  display: grid;
  gap: 3px;
}

.plan-row span {
  color: var(--muted);
  font-size: 13px;
}

.system-actions,
.system-section-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.system-result-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
}

.system-result-head span {
  color: var(--muted);
  font-size: 13px;
}

.account-history {
  display: grid;
  background: var(--surface-strong);
}

.account-history-item {
  display: grid;
  gap: 7px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.account-history-item:last-child {
  border-bottom: 0;
}

.account-history-item div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.account-history-item span,
.account-history-item p {
  color: var(--muted);
  font-size: 12px;
}

.account-history-item p {
  margin: 0;
  overflow-wrap: anywhere;
}

.empty-state.compact {
  min-height: 140px;
}

.service-list {
  display: grid;
}

.service-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.service-list div:last-child {
  border-bottom: 0;
}

.service-ok {
  color: var(--green);
}

.service-error,
.danger-button {
  color: #b42318;
}

.danger-button {
  border-color: #efb8b3;
  background: #fff7f6;
}

.admin-user-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
}

.admin-user-row > div:not(.profile-avatar) {
  display: grid;
  gap: 3px;
}

.site-footer {
  width: min(1440px, calc(100% - 40px));
  margin: 4px auto 0;
  padding: 18px 0 28px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--blue);
}

.loading-state {
  display: grid;
  place-items: center;
  min-height: 210px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
}

.formula {
  padding: 12px;
  border-radius: 7px;
  background: #fff8e8;
  border: 1px solid #f0d69c;
  color: #5e4100;
  font-family: "SFMono-Regular", Consolas, monospace;
  overflow-wrap: anywhere;
}

.context-panel {
  position: sticky;
  top: 88px;
  overflow: hidden;
}

.product-menu {
  display: grid;
}

.product-menu a {
  display: grid;
  gap: 4px;
  min-height: 82px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  scroll-snap-align: start;
}

.product-menu a:last-child {
  border-bottom: 0;
}

.product-menu a:hover,
.product-menu a.active {
  background: #f4f8ff;
}

.product-menu a.active {
  box-shadow: inset 4px 0 0 var(--blue);
  color: #1c55ba;
}

.product-menu strong {
  font-size: 15px;
}

.product-menu span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.document-preview {
  display: grid;
  gap: 14px;
  padding: 20px;
  background: var(--surface-strong);
}

.document-preview h3,
.document-preview p {
  margin: 0;
}

.document-preview p {
  color: #374151;
}

.report-chart {
  display: grid;
  grid-template-columns: repeat(var(--bar-count), minmax(44px, 1fr));
  gap: 12px;
  align-items: end;
  min-height: 250px;
  padding: 18px 14px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  overflow-x: auto;
}

.chart-column {
  display: grid;
  grid-template-rows: 24px minmax(120px, 1fr) auto;
  gap: 7px;
  align-items: end;
  min-width: 44px;
  height: 210px;
  text-align: center;
}

.chart-value,
.chart-label {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-value {
  color: var(--text);
  font-weight: 800;
}

.chart-bar-track {
  display: flex;
  align-items: end;
  width: 100%;
  height: 100%;
  border-radius: 6px 6px 3px 3px;
  background: #edf0f4;
  overflow: hidden;
}

.chart-bar {
  width: 100%;
  min-height: 3px;
  border-radius: 6px 6px 3px 3px;
  background: var(--blue);
}

.chart-label {
  color: var(--muted);
}

.history-dialog {
  width: min(720px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

.app-dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  box-shadow: 0 24px 60px rgba(23, 32, 51, 0.22);
}

.app-dialog::backdrop {
  background: var(--backdrop);
}

.dialog-shell {
  margin: 0;
  background: var(--surface);
}

.dialog-body {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.wide-button {
  width: 100%;
}

.social-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
}

.vk-button {
  background: #2787f5;
}

.yandex-button {
  background: #171717;
}

.or-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.or-divider::before,
.or-divider::after {
  height: 1px;
  background: var(--line);
  content: "";
}

.legal-note,
.panel-copy {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.account-view {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.account-view p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: #204a98;
  font-size: 20px;
  font-weight: 850;
}

.account-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-column: 1 / -1;
  gap: 1px;
  margin: 4px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.account-stats div {
  padding: 12px;
  background: var(--surface-soft);
}

.account-stats dt {
  color: var(--muted);
  font-size: 12px;
}

.account-stats dd {
  margin: 3px 0 0;
  font-weight: 850;
}

.account-view .wide-button {
  grid-column: 1 / -1;
}

.commerce-dialog {
  width: min(640px, calc(100vw - 28px));
}

.commerce-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  margin: 14px 18px 0;
  padding: 4px;
  border-radius: 8px;
  background: #edf0f4;
}

.commerce-tab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.commerce-tab.active {
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(23, 32, 51, 0.09);
}

.premium-status {
  padding: 12px;
  border: 1px solid #cfe0ff;
  border-radius: 8px;
  background: var(--blue-soft);
  color: #204a98;
}

.plan-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.plan-option {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  min-height: 68px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  background: var(--surface-strong);
  color: var(--text);
  text-align: left;
}

.plan-option:last-child {
  border-bottom: 0;
}

.plan-option:hover,
.plan-option.recommended:hover {
  background: #f4f8ff;
}

.plan-option.recommended {
  background: #fffaf0;
}

.plan-option span {
  display: grid;
  gap: 3px;
}

.plan-option small {
  color: var(--muted);
}

.plan-option b {
  white-space: nowrap;
}

.checkout-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.checkout-panel[hidden] {
  display: none;
}

.checkout-panel div {
  display: grid;
  gap: 2px;
}

.checkout-panel span {
  color: var(--muted);
  font-size: 12px;
}

.share-body {
  padding-bottom: 22px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  max-width: min(380px, calc(100vw - 36px));
  padding: 11px 14px;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

:root[data-theme="dark"] .danger-button {
  border-color: #74312d;
  background: var(--red-soft);
  color: var(--red);
}

:root[data-theme="dark"] .formula {
  border-color: var(--amber-line);
  background: var(--amber-soft);
  color: var(--amber);
}

:root[data-theme="dark"] .product-menu a:hover,
:root[data-theme="dark"] .product-menu a.active,
:root[data-theme="dark"] .plan-option:hover,
:root[data-theme="dark"] .plan-option.recommended:hover {
  background: var(--control-hover);
}

:root[data-theme="dark"] .product-menu a.active {
  color: var(--blue);
}

:root[data-theme="dark"] .chart-bar-track,
:root[data-theme="dark"] .commerce-tabs {
  background: var(--surface-soft);
}

:root[data-theme="dark"] .premium-status {
  border-color: #2e4a73;
  background: var(--blue-soft);
  color: var(--blue-ink);
}

:root[data-theme="dark"] .profile-avatar,
:root[data-theme="dark"] .notice {
  border-color: #2e4a73;
  color: var(--blue-ink);
}

:root[data-theme="dark"] .error {
  border-color: #74312d;
}

:root[data-theme="dark"] .plan-option.recommended {
  background: var(--amber-soft);
}

:root[data-theme="dark"] .toast {
  background: #eef4fb;
  color: #101826;
}

.history-dialog::backdrop {
  background: rgba(23, 32, 51, 0.34);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.history-list {
  display: grid;
  gap: 10px;
  max-height: 60vh;
  overflow: auto;
  padding: 16px;
}

.history-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-item strong {
  display: block;
  margin-bottom: 4px;
}

.history-item span {
  color: var(--muted);
  font-size: 13px;
}

.notice {
  padding: 12px;
  border-radius: 7px;
  background: var(--blue-soft);
  border: 1px solid #cfe0ff;
  color: #204a98;
}

.error {
  padding: 12px;
  border-radius: 7px;
  background: var(--red-soft);
  border: 1px solid #ffd2cc;
  color: var(--red);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .context-panel {
    position: static;
  }

  .product-menu {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
  }

  .product-menu a {
    flex: 0 0 250px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .product-menu a:last-child {
    border-right: 0;
  }
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr;
  }

  .account-actions {
    justify-content: stretch;
  }

  .account-actions > button {
    flex: 1 1 auto;
  }

  .layout {
    padding: 12px;
  }

  .seo-links {
    padding: 0 12px;
  }

  .tool-form {
    grid-template-columns: 1fr;
  }

  .chat-toolbar {
    align-items: stretch;
  }

  .chat-toolbar .field,
  .chat-toolbar .ghost-button {
    width: 100%;
  }

  .chat-thread {
    max-height: 460px;
  }

  .chat-compose {
    grid-template-columns: 1fr;
  }

  .chat-message {
    width: 100%;
  }

  .product-menu a {
    min-height: 74px;
  }

  .tool-heading {
    display: grid;
  }

  .empty-account,
  .profile-fields,
  .plan-row {
    grid-template-columns: 1fr;
  }

  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-tabs,
  .telegram-editor {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .topbar {
    gap: 10px;
    padding: 10px 12px 12px;
  }

  .account-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 76px;
    gap: 6px;
  }

  .account-actions > button,
  .theme-button {
    width: 100%;
    min-height: 40px;
  }

  #historyButton {
    grid-column: 1 / 3;
  }

  .account-actions:has(#adminButton:not([hidden])) #historyButton {
    grid-column: 1;
  }

  .account-actions:has(#adminButton:not([hidden])) #adminButton {
    grid-column: 2;
  }

  #accountButton {
    grid-column: 3;
  }

  .brand-symbol {
    width: 38px;
    height: 38px;
  }

  .brand-name {
    font-size: 22px;
  }

  .brand-tagline {
    display: none;
  }

  .layout {
    padding: 10px;
  }

  .tool-panel {
    min-height: 0;
  }

  .tool-heading {
    padding: 18px 20px 14px;
  }

  .tool-heading h1 {
    font-size: 30px;
  }

  .tool-summary {
    padding: 14px 20px 0;
  }

  .tool-form {
    padding: 16px 20px 18px;
  }

  .result-section {
    margin: 0 20px 20px;
  }

  .result-heading {
    align-items: flex-end;
  }

  .result-heading .tool-actions {
    gap: 6px;
  }

  .result-heading .ghost-button {
    min-height: 36px;
    padding: 0 9px;
    font-size: 13px;
  }

  .result-box,
  .empty-state {
    min-height: 120px;
  }

  .form-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .form-actions .primary-button {
    width: 100%;
  }

  .product-menu a {
    flex-basis: min(82vw, 290px);
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .brand-mark img {
    top: -14px;
    left: -12px;
    width: 119px;
  }

  .brand-word {
    width: 94px;
    height: 18px;
  }

  .brand-word img {
    top: -33px;
    left: -66px;
    width: 170px;
  }

  .checkout-panel {
    grid-template-columns: 1fr auto;
  }

  .checkout-panel .primary-button {
    grid-column: 1 / -1;
  }

  .answer-value {
    font-size: 22px;
  }

  .stat-strip,
  .admin-stats {
    grid-template-columns: 1fr;
  }

  .admin-user-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .admin-user-row > b,
  .admin-user-row > span {
    grid-column: 2;
  }
}
