/* ===== global ===== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  font-size: 1.2em;
  line-height: 1.4;
}

a {
  word-break: break-word;
}

/* ===== page layout ===== */

.wrapper {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 12px;
}

.flex-wrap {
  display: block;
}

.tweet {
  width: 100%;
  padding: 16px;
  font-family: sans-serif;
  font-size: 1.2em;
  background-color: #e8e8e8;
  border: 2px solid black;
  border-radius: 16px;
  overflow: hidden; /* prevents descendants from painting outside */
}

/* ===== controls ===== */

#search-input {
  display: block;
  width: 100%;
  font-size: 1.5em;
}

#sorting,
#browse-sort {
  margin-top: 8px;
  line-height: 1.7em;
}

.sort-button,
#browse-sort > button {
  font-size: 1em;
}

#page-num {
  width: 80px;
  font-size: 1em;
}

#paging {
  margin: 8px 0;
}

#tabs {
  margin: -16px 0 0;
}

.tab {
  border: none;
  border-right: 2px solid black;
  padding: 4px 10px;
  font-size: 1.2em;
  cursor: pointer;
  background: transparent;
}

.tab:first-child {
  margin-left: -16px;
  border-top-left-radius: 16px;
}

.tab.active {
  text-decoration: underline;
}

.hr {
  margin: 0 -16px 16px;
}

/* ===== result blocks ===== */

.search_item {
  display: block;
  width: 100%;
  margin: 0 0 12px;
  overflow: hidden;
}

.search_text {
  display: block;
  width: 100%;
  overflow: hidden;
}

.search_time {
  display: block;
  width: 100%;
  margin-top: 6px;
  font-size: 0.7em;
  clear: both;
}

.search_divider {
  display: block;
  margin: 10px 0 0;
  clear: both;
}

/* ===== hard reset for injected tweet/gallery HTML ===== */
/* This is the important part. */

.search_text .gallery,
.search_text .gallery *,
#browse-output .gallery,
#browse-output .gallery *,
#output .gallery,
#output .gallery * {
  float: none !important;
  position: static !important;
  transform: none !important;
}

.search_text .gallery,
#browse-output .gallery,
#output .gallery {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  clear: both !important;
}

.search_text .gallery ul,
#browse-output .gallery ul,
#output .gallery ul {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.search_text .gallery li,
#browse-output .gallery li,
#output .gallery li {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 0 0 8px 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  clear: both !important;
}

.search_text .gallery a,
#browse-output .gallery a,
#output .gallery a {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

.search_text img,
.search_text video,
#browse-output img,
#browse-output video,
#output img,
#output video {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  object-fit: contain !important;
  vertical-align: bottom !important;
}

/* ===== thread cards if present ===== */

.child,
.parent {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 12px 0;
  background-color: white;
}

/* ===== dark mode ===== */

@media (prefers-color-scheme: dark) {
  body {
    background-color: black;
    color: white;
  }

  a {
    color: #33ff00;
    text-decoration: none;
  }

  a:hover {
    color: #33ff00;
    text-decoration: underline;
  }

  .tweet {
    background-color: black;
    border: 1px solid gray;
    border-radius: 5px;
  }

  .child,
  .parent {
    background-color: black;
  }

  button,
  input {
    background-color: black;
    color: white;
  }

  .search_time,
  .tweet .favorite_count,
  .tweet .retweet_count,
  .tweet .created_at {
    color: #33ff00;
  }
}
