body {
  --bg-color: var(--tg-theme-bg-color);
  color-scheme: var(--tg-color-scheme);
  max-width: 90%;
  margin: auto;
  padding: 2em;
  background: white;
  color: #333;
  font: 100% / 1.33 Serif;
  text-align: justify;
}

.button.icon-button {
  background: none;
  border: none;
  color: inherit;
  min-width: auto;
  padding: 0.2em 0.4em;
}

a {
  color: #000;
  transition: COLOR 0.2s ease-in 0s;
  -webkit-transition: COLOR 0.2s ease-in 0s;
  -moz-transition: COLOR 0.2s ease-in 0s;
  -o-transition: COLOR 0.2s ease-in 0s;
  transition-timing-function: linear;
  text-decoration-thickness: 0.3px;
  -webkit-text-decoration-thickness: 0.3px;
  text-underline-offset: 3px;
  -webkit-text-underline-offset: 3px;
}

a:hover {
  color: #c00;
}

@media screen and (max-width: 720px) {
  body {
    padding: 0.5em;
    font-size: 120%;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    text-align: left;
  }

  /* A thumb needs a 44px target; the action a row exists for stands out
     and the destructive one keeps its distance. */
  .button.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 44px;
    min-height: 44px;
    margin-left: 8px;
    padding: 0;
    text-decoration: none;
  }

  td:has(> .button.icon-button) {
    white-space: nowrap;
    text-align: right;
    vertical-align: middle;
  }

  .button.icon-button.primary-action {
    min-width: 72px;
    border-radius: 8px;
    background-color: #4caf50;
    color: white;
  }

  .button.icon-button.danger-action {
    margin-left: 0.8em;
  }

  table {
    border-spacing: 0;
  }

  td,
  th {
    padding: 4px 2px;
  }

  table:has(.button.icon-button) th {
    font-size: 0.85em;
  }

  td > .button.icon-button:first-child {
    margin-left: 0;
  }

  .optional-col {
    display: none;
  }

  .filter-input {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    font-size: inherit;
  }
}

@media (prefers-color-scheme: dark) {
  body {
    background: #1a1a1a;
    color: #e0e0e0;
  }
  a {
    color: #bbb;
  }
  a:hover {
    color: #ff6666;
  }
  hr {
    border-bottom: 1px solid #404040;
  }
  h1,
  h2,
  h3,
  h4 {
    color: #e0e0e0;
  }
}

h1 {
  margin: 0.5em 0;
  font-size: 200%;
}

p {
  margin: 0.5em 0;
}

hr {
  border: none;
  border-bottom: 1px solid silver;
}

#viewport {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: var(--tg-viewport-stable-height, 100vh);
  pointer-events: none;
  transition: all 0.2s ease;
}
#viewport:after {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  border-width: 4px;
  border-style: solid;
  border-image: linear-gradient(
      45deg,
      rgba(64, 224, 208, 0.5),
      rgba(173, 255, 47, 0.5)
    )
    1;
}

#viewport-params-size,
#viewport-params-expand {
  content: attr(text);
  position: absolute;
  display: inline-block;
  background: var(--tg-theme-link-color, rgb(64, 224, 208));
  right: 4px;
  left: auto;
  font-size: 8px;
  padding: 4px;
  vertical-align: top;
}
#viewport-params-size {
  top: 4px;
}
#viewport-params-expand {
  top: 30px;
}

.error-alert {
  margin: 0.6em 0;
  padding: 0.6em 0.8em;
  border: 1px solid #d9534f;
  border-radius: 0.25em;
  background-color: #fdf0ef;
  color: #a94442;
}

@media (prefers-color-scheme: dark) {
  .error-alert {
    border-color: #a94442;
    background-color: #3a2020;
    color: #f2b8b5;
  }
}
