@font-face {
  font-family: "Naowh";
  src: url("./fonts/Naowh.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "GothamNU";
  src: url("./fonts/GothamNarrowUltra.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}


:root {
  --bg: #000000;
  --surface: #000000;
  --surface-2: #0d0d0d;

  --text: #ffffff;
  --muted: #9d9d9d;
  --faint: #5e5e5e;

  --line: #353535;
  --line-strong: #ffffff;

  --active-bg: #ffffff;
  --active-text: #000000;

  --danger: #ffffff;
  --success: #ffffff;

  --bottom-h: 78px;
}


html[data-theme="light"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f3f3;

  --text: #000000;
  --muted: #666666;
  --faint: #a5a5a5;

  --line: #cfcfcf;
  --line-strong: #000000;

  --active-bg: #000000;
  --active-text: #ffffff;

  --danger: #000000;
  --success: #000000;
}


* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}


html {
  min-height: 100%;
  background: var(--bg);
}


body {
  margin: 0;
  min-height: 100vh;

  background: var(--bg);
  color: var(--text);

  font-family:
    "Naowh",
    Arial,
    sans-serif;

  font-size: 16px;
  line-height: 1.25;

  transition:
    background-color 140ms ease,
    color 140ms ease;
}


button,
input,
select,
textarea {
  font: inherit;
}


button {
  color: inherit;
}


.app {
  width: 100%;
  max-width: 820px;

  margin: 0 auto;

  padding:
    18px
    16px
    calc(var(--bottom-h) + 38px);
}


.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;

  gap: 20px;

  margin-bottom: 18px;
}


.brand {
  font-family:
    "GothamNU",
    "Naowh",
    sans-serif;

  font-size: clamp(27px, 7vw, 42px);
  line-height: .92;

  letter-spacing: .015em;

  text-transform: uppercase;
}


.telegram-status {
  margin-top: 8px;

  font-size: 11px;
  letter-spacing: .1em;

  color: var(--muted);
}


.telegram-status.connected {
  color: var(--text);
}


.icon-btn {
  flex: 0 0 auto;

  height: 38px;

  padding: 0 13px;

  border: 1px solid var(--line-strong);
  border-radius: 0;

  background: transparent;
  color: var(--text);

  font-size: 12px;
  letter-spacing: .08em;

  cursor: pointer;
}


.icon-btn:active {
  background: var(--active-bg);
  color: var(--active-text);
}


.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));

  margin-bottom: 18px;

  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}


.tab {
  min-width: 0;
  min-height: 48px;

  padding: 8px 6px;

  border: 0;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;

  background: transparent;
  color: var(--text);

  cursor: pointer;

  text-transform: uppercase;
  letter-spacing: .035em;
}


.tab.active {
  background: var(--active-bg);
  color: var(--active-text);
}


.toolbar-block {
  margin-bottom: 22px;
}


.section-kicker {
  margin-bottom: 8px;

  color: var(--muted);

  font-size: 11px;
  letter-spacing: .12em;

  text-transform: uppercase;
}


.segmented {
  display: grid;

  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}


.segmented-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}


.segmented button {
  min-height: 42px;

  padding: 7px 5px;

  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;

  background: transparent;
  color: var(--text);

  cursor: pointer;

  font-size: 13px;
}


.segmented button.active {
  background: var(--active-bg);
  color: var(--active-text);
}


.copy-tools {
  display: none;

  margin-bottom: 18px;
}


.copy-tools.visible {
  display: block;
}


.copy-btn {
  width: 100%;
  min-height: 42px;

  padding: 8px 12px;

  border: 1px solid var(--line);
  border-radius: 0;

  background: transparent;
  color: var(--text);

  text-align: left;
  cursor: pointer;
}


.copy-btn:active {
  border-color: var(--line-strong);
}


.form-section {
  margin-bottom: 25px;
}


.form-section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;

  gap: 16px;

  margin-bottom: 8px;

  color: var(--muted);

  font-size: 11px;
  letter-spacing: .12em;

  text-transform: uppercase;
}


.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));

  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}


.field {
  position: relative;

  min-width: 0;

  padding: 10px;

  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}


.field.full {
  grid-column: 1 / -1;
}


.field-label {
  display: block;

  margin-bottom: 6px;

  color: var(--muted);

  font-size: 11px;
  line-height: 1.2;

  letter-spacing: .045em;

  text-transform: uppercase;
}


.field-required::after {
  content: " *";
  color: var(--text);
}


.field input,
.field select,
.field textarea {
  display: block;

  width: 100%;
  min-width: 0;

  margin: 0;
  padding: 4px 0;

  border: 0;
  border-radius: 0;
  outline: none;

  background: transparent;
  color: var(--text);

  font-size: 18px;
  line-height: 1.2;
}


.field textarea {
  min-height: 58px;
  resize: vertical;
}


.field select {
  appearance: none;
  -webkit-appearance: none;

  cursor: pointer;
}


.field select option {
  background: var(--bg);
  color: var(--text);
}


.field input::placeholder,
.field textarea::placeholder {
  color: var(--faint);
  opacity: 1;
}


.field:focus-within {
  box-shadow:
    inset 0 0 0 1px var(--line-strong);
}


.field.error {
  box-shadow:
    inset 0 0 0 1px var(--line-strong);
}


.field-error {
  display: none;

  margin-top: 6px;

  font-size: 11px;
  color: var(--text);
}


.field.error .field-error {
  display: block;
}


.field-hint {
  margin-top: 6px;

  color: var(--muted);

  font-size: 11px;
  line-height: 1.25;
}


.preview-root {
  margin-top: 6px;
}


.preview {
  margin-top: 22px;

  border: 1px solid var(--line-strong);
}


.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;

  gap: 12px;

  min-height: 42px;

  padding: 8px 10px;

  border-bottom: 1px solid var(--line-strong);
}


.preview-title {
  font-size: 12px;
  letter-spacing: .1em;

  text-transform: uppercase;
}


.preview-state {
  color: var(--muted);

  font-size: 11px;
  text-align: right;
}


.preview-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;

  gap: 20px;

  padding: 8px 10px;

  border-bottom: 1px solid var(--line);
}


.preview-row:last-child {
  border-bottom: 0;
}


.preview-row.total {
  background: var(--active-bg);
  color: var(--active-text);

  border-bottom-color: var(--active-bg);
}


.preview-label {
  color: inherit;
  opacity: .72;

  font-size: 13px;
}


.preview-value {
  min-width: 0;

  text-align: right;
  white-space: nowrap;

  font-size: 15px;
}


.preview-note {
  padding: 10px;

  color: var(--muted);

  font-size: 11px;
  line-height: 1.35;

  border-top: 1px solid var(--line);
}


.status {
  min-height: 22px;

  margin-top: 20px;

  color: var(--muted);

  font-size: 13px;
}


.status.error,
.status.success {
  color: var(--text);
}


.bottom-spacer {
  height: 20px;
}


.bottom-bar {
  position: fixed;

  left: 0;
  right: 0;
  bottom: 0;

  z-index: 50;

  padding:
    9px
    max(10px, env(safe-area-inset-left))
    calc(9px + env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-right));

  border-top: 1px solid var(--line-strong);

  background: var(--bg);
}


.bottom-bar-inner {
  display: grid;
  grid-template-columns: .75fr 1.6fr .75fr;

  width: 100%;
  max-width: 820px;

  margin: 0 auto;

  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}


.action {
  min-height: 48px;

  padding: 8px;

  border: 0;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;

  cursor: pointer;

  font-size: 12px;
  letter-spacing: .04em;

  text-transform: uppercase;
}


.action.primary {
  background: var(--active-bg);
  color: var(--active-text);
}


.action.secondary {
  background: var(--bg);
  color: var(--text);
}


.action:disabled {
  opacity: .4;
  cursor: default;
}


.busy {
  position: fixed;
  inset: 0;

  z-index: 100;

  display: none;
  align-items: center;
  justify-content: center;

  padding: 24px;

  background: rgba(0, 0, 0, .82);
}


html[data-theme="light"] .busy {
  background: rgba(255, 255, 255, .84);
}


.busy.visible {
  display: flex;
}


.busy-box {
  width: min(100%, 340px);

  padding: 18px;

  border: 1px solid var(--line-strong);

  background: var(--bg);
  color: var(--text);

  text-align: center;

  font-size: 13px;
  letter-spacing: .1em;
}


.busy-line {
  width: 100%;
  height: 2px;

  margin-bottom: 14px;

  background:
    linear-gradient(
      90deg,
      var(--text) 0 30%,
      transparent 30% 100%
    );

  background-size: 220% 100%;

  animation: busy 900ms linear infinite;
}


@keyframes busy {
  from {
    background-position: 100% 0;
  }

  to {
    background-position: -100% 0;
  }
}


@media (max-width: 600px) {

  .app {
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 13px;
  }

  .topbar {
    margin-bottom: 13px;
  }

  .brand {
    font-size: 29px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field.full {
    grid-column: auto;
  }

  .field input,
  .field select,
  .field textarea {
    font-size: 17px;
  }

  .preview-row {
    gap: 10px;
  }

  .preview-label {
    font-size: 12px;
  }

  .preview-value {
    font-size: 14px;
  }

  .bottom-bar-inner {
    grid-template-columns: .72fr 1.5fr .72fr;
  }

  .action {
    padding-left: 4px;
    padding-right: 4px;

    font-size: 11px;
  }
}


@media (max-width: 370px) {

  .brand {
    font-size: 25px;
  }

  .icon-btn {
    height: 34px;
    padding: 0 9px;
  }

  .tab {
    font-size: 13px;
  }

  .segmented button {
    font-size: 12px;
  }
}