:root {
  --text-color: #3d3a35;
  --qr-width: 400px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
      display: flex;
      flex-direction: column;
      min-height: 100vh;
      max-width: 800px;
      margin: 0 auto;
      padding: 1rem;
      background: #f7f5f0;
      color: var(--text-color);
      font-family: "Courier New", Courier, monospace;
    }

    main {
      flex: 1;
    }

    h1 {
      font-size: 3rem;
      letter-spacing: 0.05em;
      margin: 0 0 1rem;
      font-weight: bolder;
    }

    header a {
      color: inherit;
      text-decoration: none;
    }

    .subtitle {
      font-size: 1.5rem;
      font-weight: bold;
    }

    p {
      font-size: 1rem;
      letter-spacing: 0.05em;
      margin: 0.5rem 0;
    }

    .dumb-joke {
      font-size: 0.75rem;
    }

    .dumb-joke a,
    .dumb-joke a:visited {
      color: #6b665e;
      text-decoration: none;
      cursor: pointer;
      font-style: italic;
    }

    .error {
      color: #a8402a;
      font-weight: bolder;
    }

    #qr {
      padding-top: 1rem;
      max-width: var(--qr-width);
      aspect-ratio: 1 / 1;
    }

    #pairUrl {
      overflow-wrap: anywhere;
      user-select: all;
      color: color-mix(in srgb, var(--text-color) 65%, transparent);
    }

    #qr svg {
      width: 100%;
      height: auto;
      max-width: var(--qr-width);
    }

    #sessionName {
      display: block;
      width: 100%;
      max-width: var(--qr-width);
      margin: 0.5rem 0;
      font-weight: bolder;
      text-align: justify;
      text-align-last: justify;
    }

    body.wide {
      max-width: 1600px;
    }

    .layout {
      display: flex;
      align-items: flex-start;
      gap: 1.5rem;
      flex: 1;
    }

    .layout .sidebar {
      flex: 0 1 auto;
      max-width: 30%;
      min-width: 0;
    }

    .layout main {
      flex: 1;
      min-width: 0;
    }

    footer {
      margin-top: 2rem;
      padding-top: 1rem;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
    }

    .footer-links {
      display: flex;
      gap: 1.5rem;
      list-style: none;
      margin: 0;
      padding: 0;
    }

    .footer-links a {
      display: inline-flex;
      align-items: center;
      gap: 0.4rem;
      color: var(--text-color);
      text-decoration: none;
    }

    .footer-links a:hover {
      color: #a8402a;
    }

    .footer-links svg {
      width: 1.1em;
      height: 1.1em;
    }

    @media (max-width: 800px) {
      .layout {
        flex-direction: column-reverse;
      }

      .layout .sidebar {
        flex-basis: auto;
        width: 100%;
      }

      .messages-layout {
        flex-direction: column;
      }

      .thread-column {
        flex-basis: auto;
        max-height: 30vh;
        border-right: none;
        padding-right: 0;
        padding-bottom: 1rem;
        border-bottom: 1px solid color-mix(in srgb, var(--text-color) 15%, transparent);
      }
    }

    .card {
      border: 2px solid #3d3a35;
      border-radius: 4px;
      padding: 1rem 1.25rem;
      margin: 1rem 0;
      background: #fffdf8;
    }

    .btn {
      display: block;
      padding: 0.6rem 1.2rem;
      font-family: inherit;
      font-size: 0.9rem;
      font-weight: bolder;
      letter-spacing: 0.05em;
      text-transform: uppercase;
      color: #f7f5f0;
      cursor: pointer;
      border: 2px solid #3d3a35;
      border-radius: 4px;
    }

    .btn:active {
      transform: translateY(1px);
    }

    .id-row {
      display: flex;
      min-width: 0;
    }

    .id,
    .thread-preview {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .id {
      flex: 1;
      min-width: 0;
    }

    .card hr {
      border: none;
      border-top: 1px solid #3d3a35;
      opacity: 0.3;
      margin: 1rem 0;
    }

    .messages-layout {
      display: flex;
      gap: 1.25rem;
    }

    .thread-column {
      flex: 0 0 220px;
      min-width: 0;
      max-height: calc(100vh - 21rem);
      display: flex;
      flex-direction: column;
      gap: 1rem;
      border-right: 1px solid color-mix(in srgb, var(--text-color) 15%, transparent);
      padding-right: 1.25rem;
    }

    .thread-list {
      margin: 0;
      padding: 0;
      min-width: 0;
      flex: 1;
      min-height: 0;
      overflow-y: auto;
    }

    .message-column {
      flex: 1;
      min-width: 0;
      max-height: calc(100vh - 21rem);
      display: flex;
      flex-direction: column;
    }

    #messageList {
      list-style: none;
      margin: 0;
      padding: 0;
      flex: 1;
      min-height: 0;
      overflow-y: auto;
    }

    .thread-row {
      cursor: pointer;
      padding: 0.5rem 0;
      border-bottom: 1px solid color-mix(in srgb, var(--text-color) 15%, transparent);
    }

    .thread-row:last-child {
      border-bottom: none;
    }

    .thread-row.selected {
      background: color-mix(in srgb, var(--text-color) 8%, transparent);
    }

    .thread-name {
      font-weight: bolder;
    }

    .thread-preview {
      font-size: 0.85rem;
      opacity: 0.7;
    }

    .message-row {
      max-width: 75%;
      margin: 0.5rem 0;
      padding: 0.5rem 0.75rem;
      border-radius: 4px;
      background: color-mix(in srgb, var(--text-color) 6%, transparent);
      overflow-wrap: anywhere;
    }

    .message-body {
      white-space: pre-wrap;
    }

    .message-row.out {
      margin-left: auto;
      background: color-mix(in srgb, var(--text-color) 14%, transparent);
    }

    .message-row.sending {
      opacity: 0.6;
    }

    .message-row.failed {
      background: color-mix(in srgb, #a8402a 25%, transparent);
    }

    .message-row.failed .message-meta {
      color: #a8402a;
      opacity: 1;
    }

    .sendUI {
      margin-bottom: 0;
      display: flex;
      align-items: flex-end;
      gap: 0.75rem;
    }

    #smsBody {
      flex: 1;
      min-width: 0;
      field-sizing: content;
      min-height: 2.25rem;
      max-height: 8rem;
      padding: 0.4rem 0;
      border: none;
      border-radius: 0;
      border-bottom: 1px solid color-mix(in srgb, var(--text-color) 30%, transparent);
      background: transparent;
      appearance: none;
      font-family: inherit;
      font-size: 1rem;
      color: var(--text-color);
      resize: none;
      overflow-y: auto;
      outline: none;
    }

    #smsBody:focus {
      border-bottom-color: var(--text-color);
    }

    #clipboardText {
      width: 100%;
      min-height: 4rem;
      resize: vertical;
      padding: 0.4rem;
      border: 1px solid color-mix(in srgb, var(--text-color) 30%, transparent);
      border-radius: 4px;
      background: transparent;
      font-family: inherit;
      font-size: 0.9rem;
      color: var(--text-color);
    }

    .clipboard-actions {
      display: flex;
      gap: 0.5rem;
      margin-top: 0.5rem;
    }

    .message-meta {
      margin-top: 0.25rem;
      font-size: 0.75rem;
      opacity: 0.6;
    }

    .toggle {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      cursor: pointer;
    }

    #clearBtn {
      margin-top: 1.5rem;
      background: #a8402a;
    }

    #clearBtn::before {
      content: "⚠ ";
    }

    #clearBtn:hover {
      background: #8f331f;
    }

    .dialog-actions {
      display: flex;
      align-items: center;
      gap: 1rem;
      margin-top: 1rem;
    }

    .dialog-actions #clearBtn {
      margin-top: 0;
    }

    .btn-accent {
      background: #3f6b4a;
    }

    .btn-accent:hover {
      background: #335a3d;
    }

    .btn-info {
      background: #3a5a78;
    }

    .btn-info:hover {
      background: #2c4760;
    }

    .btn-danger {
      background: #a8402a;
    }

    .btn-danger:hover {
      background: #8f331f;
    }

/* LOADER */
.loader {
  --size: 1.7px;

  width: calc(8 * var(--size));
  height: calc(48 * var(--size));
  display: block;
  margin: 1rem auto;
  border-radius: calc(4 * var(--size));
  color: var(--text-color);
  animation: animloader 1.5s linear infinite;
  transform: translateX(calc(-40 * var(--size)));
}

@keyframes animloader {
  0% {
    box-shadow:
      calc(20 * var(--size)) calc(-10 * var(--size)),
      calc(40 * var(--size)) calc(10 * var(--size)),
      calc(60 * var(--size)) 0;
  }
  25% {
    box-shadow:
      calc(20 * var(--size)) 0,
      calc(40 * var(--size)) 0,
      calc(60 * var(--size)) calc(10 * var(--size));
  }
  50% {
    box-shadow:
      calc(20 * var(--size)) calc(10 * var(--size)),
      calc(40 * var(--size)) calc(-10 * var(--size)),
      calc(60 * var(--size)) 0;
  }
  75% {
    box-shadow:
      calc(20 * var(--size)) 0,
      calc(40 * var(--size)) 0,
      calc(60 * var(--size)) calc(-10 * var(--size));
  }
  100% {
    box-shadow:
      calc(20 * var(--size)) calc(-10 * var(--size)),
      calc(40 * var(--size)) calc(10 * var(--size)),
      calc(60 * var(--size)) 0;
  }
}
/* END LOADER */
.dots::after {
  content: '';
  animation: dots 1.5s steps(1) infinite;
}

@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

summary {
  cursor: pointer;
}
