:root {
  --app-bg: #06101c;
  --app-panel: #091523;
  --app-panel-deep: #020813;
  --app-line: rgba(148, 163, 184, .18);
  --app-line-strong: rgba(148, 163, 184, .3);
  --app-accent: #6366f1;
  --app-accent-light: #818cf8;
  --app-mint: #34d399;
  --app-sky: #38bdf8;
  --app-text: #f8fafc;
  --app-muted: #94a3b8;
}

.app-page {
  min-height: 100%;
  margin: 0;
  overflow-x: clip;
  color: var(--app-text);
  background:
    radial-gradient(circle at 12% -5%, rgba(99, 102, 241, .22), transparent 32rem),
    radial-gradient(circle at 94% 92%, rgba(14, 165, 233, .12), transparent 30rem),
    linear-gradient(155deg, #081421 0%, var(--app-bg) 58%, #040a12 100%);
}

.app-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .22;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, .035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

.app-page .app-shell {
  position: relative;
  width: 100%;
  max-width: none;
  min-width: 0;
  padding-inline: clamp(16px, 3.2vw, 64px) !important;
}

.app-page .app-shell::before,
.app-page .app-shell::after {
  display: none;
}

.app-header {
  min-width: 0;
}

.app-header h1 {
  max-width: 760px;
  color: #fff;
  font-size: clamp(1.75rem, 4vw, 2.65rem);
  line-height: 1.08;
  letter-spacing: -.035em;
}

.app-header #subtitle {
  max-width: 900px;
  color: #aebdd0;
  line-height: 1.65;
}

.subtitle-main,
.subtitle-hint {
  display: block;
}

.subtitle-main {
  color: #cbd5e1;
}

.source-link {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin: 2px 3px;
  padding: 2px 9px;
  border: 1px solid rgba(129, 140, 248, .32);
  border-radius: 9px;
  color: #c7d2fe;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .82em;
  text-decoration: none;
  background: rgba(99, 102, 241, .09);
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}

.source-link::before {
  content: "";
  width: 5px;
  height: 5px;
  margin-right: 7px;
  border-radius: 50%;
  background: #34d399;
}

.source-link:hover {
  border-color: rgba(129, 140, 248, .68);
  color: #eef2ff;
  background: rgba(99, 102, 241, .17);
}

.subtitle-hint {
  position: relative;
  margin-top: 7px;
  padding-left: 17px;
  color: #7f91a8;
  font-size: .9em;
}

.subtitle-hint::before {
  content: "↳";
  position: absolute;
  left: 0;
  color: #6366f1;
}

.app-header .inline-flex.rounded-full {
  border-color: rgba(129, 140, 248, .34);
  background: rgba(99, 102, 241, .1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}

.header-actions {
  flex: 0 0 auto;
}

.language-switch {
  min-height: 48px;
  padding: 4px;
  border-color: rgba(148, 163, 184, .18);
  background: rgba(2, 8, 19, .68);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
}

.language-switch button {
  min-width: 68px;
  min-height: 38px;
  border-radius: 10px;
}

.header-buttons > * {
  min-height: 48px;
  border-radius: 14px;
  transition: transform .18s ease, border-color .18s ease,
    background-color .18s ease, filter .18s ease, box-shadow .18s ease;
}

#btnAbout {
  border-color: rgba(148, 163, 184, .22);
  background: rgba(15, 28, 45, .76);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
}

#btnAbout:hover {
  border-color: rgba(129, 140, 248, .55);
  background: rgba(30, 41, 59, .92);
  transform: translateY(-1px);
}

#btnBuy {
  border: 1px solid rgba(165, 180, 252, .2);
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow:
    0 14px 30px rgba(79, 70, 229, .28),
    inset 0 1px 0 rgba(255, 255, 255, .18);
}

#btnBuy:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow:
    0 18px 34px rgba(79, 70, 229, .34),
    inset 0 1px 0 rgba(255, 255, 255, .18);
}

.workspace-grid {
  align-items: stretch;
  min-width: 0;
}

.app-page .workspace-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--app-line);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(15, 29, 47, .96), rgba(7, 16, 29, .98));
  box-shadow:
    0 24px 64px rgba(0, 0, 0, .32),
    inset 0 1px 0 rgba(255, 255, 255, .045);
  backdrop-filter: none;
}

.app-page .output-card {
  background:
    radial-gradient(circle at 100% 0%, rgba(56, 189, 248, .07), transparent 20rem),
    linear-gradient(145deg, rgba(15, 29, 47, .96), rgba(7, 16, 29, .98));
}

.panel-heading h2 {
  color: #f8fafc;
  font-weight: 650;
  letter-spacing: -.01em;
}

.panel-badge {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 10px;
  line-height: 1;
  letter-spacing: -.03em;
  white-space: nowrap;
}

.panel-heading > div:first-child > div {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

.panel-actions button,
.panel-actions label,
.panel-footer button {
  min-height: 40px;
  border-radius: 11px;
  border-color: rgba(148, 163, 184, .2);
  background: rgba(2, 8, 19, .62);
  transition: border-color .18s ease, background-color .18s ease,
    transform .18s ease, filter .18s ease;
}

.panel-actions button:hover,
.panel-actions label:hover,
.panel-footer button:hover {
  border-color: rgba(129, 140, 248, .45);
  background: rgba(15, 29, 47, .96);
  transform: translateY(-1px);
}

#btnFormat {
  border: 1px solid rgba(165, 180, 252, .2);
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 10px 24px rgba(79, 70, 229, .22);
}

#btnFormat:hover {
  filter: brightness(1.08);
}

#input,
#outputView {
  border-color: rgba(148, 163, 184, .2);
  background: var(--app-panel-deep);
  box-shadow: none;
  transition: none;
  contain: none;
  will-change: auto;
}

#input:focus,
#outputView:focus {
  outline: none;
  border-color: var(--app-accent-light);
  box-shadow: none;
}

#supportLine {
  color: var(--app-muted);
  line-height: 1.55;
}

.mirrors-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 9px 12px;
  margin-top: 18px;
  color: #7f91a8;
  font-size: 12px;
  text-align: right;
}

.mirrors-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.mirrors-list a {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid rgba(148, 163, 184, .17);
  border-radius: 9px;
  color: #a5b4fc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  text-decoration: none;
  background: rgba(2, 8, 19, .5);
  transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}

.mirrors-list a:hover {
  color: #eef2ff;
  border-color: rgba(129, 140, 248, .5);
  background: rgba(99, 102, 241, .12);
}

#warn {
  border-color: rgba(251, 191, 36, .38);
  background: #241806;
}

#aboutBackdrop {
  background: rgba(1, 5, 12, .86);
}

#aboutModal .card-glass {
  max-height: min(92dvh, 900px);
  overflow-y: auto;
  border-color: rgba(129, 140, 248, .28);
  background: linear-gradient(145deg, #102038, #07111f);
  box-shadow: 0 32px 90px rgba(0, 0, 0, .6);
}

#aboutBody > div > div {
  border-color: rgba(148, 163, 184, .16);
  background: #06101c;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
}

#aboutClose,
#aboutOk {
  min-height: 44px;
}

#aboutOk {
  border: 1px solid rgba(165, 180, 252, .2);
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 12px 26px rgba(79, 70, 229, .24);
}

@media (min-width: 1024px) {
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .app-page .app-shell {
    max-width: 100%;
    padding: 20px 14px 30px !important;
  }

  .app-header {
    align-items: stretch;
    margin-bottom: 20px !important;
  }

  .header-copy,
  .header-actions,
  .header-buttons {
    width: 100%;
    max-width: 100%;
  }

  .header-actions {
    align-items: stretch !important;
  }

  .language-switch {
    align-self: flex-end;
  }

  .header-buttons {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  }

  .workspace-grid {
    gap: 16px !important;
  }

  .mirrors-footer,
  .mirrors-list {
    justify-content: flex-start;
    text-align: left;
  }

  .app-page .workspace-card {
    padding: 17px !important;
    border-radius: 19px;
  }

  .panel-heading {
    display: block;
  }

  .panel-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    margin-top: 12px;
  }

  .panel-actions > * {
    width: 100%;
    min-width: 0;
    justify-content: center;
    text-align: center;
  }

  #input,
  #outputView {
    height: min(52dvh, 430px) !important;
    min-height: 320px;
    margin-top: 14px !important;
  }
}

@media (max-width: 520px) {
  .app-header h1 {
    font-size: clamp(1.7rem, 8vw, 2.15rem);
  }

  .header-buttons {
    gap: 8px;
  }

  .header-buttons > * {
    min-height: 46px;
    padding-inline: 10px !important;
    font-size: 13px;
  }

  .panel-actions label {
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .panel-footer {
    align-items: stretch;
  }

  .panel-footer > div {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  #aboutModal > div:last-child {
    align-items: flex-end;
    padding: 0;
  }

  #aboutModal .card-glass {
    width: 100%;
    max-height: 90dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 22px 22px 0 0 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-page *,
  .app-page *::before,
  .app-page *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
