html {
  --ae-font-size-m: 1rem;
  --ae-font-size-s: 0.875rem;
}

.ae-page {
  margin: 0 auto;
  padding: 0 0.5rem;
  max-width: 52rem;
  min-height: 100vh;

  overflow-y: scroll;

  display: grid;
  grid-template-rows: auto 1fr auto;

  font-size: var(--ae-font-size-m);
}

.ae-page-header {
  margin: 1rem 0 0;

  display: grid;
  align-items: baseline;
  grid-template-columns: 1fr auto;
}

.ae-page-sidebar {
  display: none;
}

@media (width > 60rem) {
  .ae-page-sidebar {
    display: block;
    width: min(6rem, calc((100vw - 54rem) / 2));
    height: 100%;

    position: fixed;
    left: 0;
    top: 0;

    opacity: 0;
  }

  .ae-page-sidebar:hover {
    opacity: 1;
  }
}

.ae-sidebar-link {
  height: 100%;
  display: block;
  padding: 1rem 0;

  font-size: var(--ae-font-size-s);

  text-align: center;
  text-decoration: none;
}

.ae-page-main {
  min-width: 0;
}

.ae-page-footer {
  margin: 0 0 1rem;

  font-size: var(--ae-font-size-s);
  text-align: center;
}

.header-link {
  font-weight: 600;
}

.ae-hr {
  margin: 1rem 0;
}

.ae-banner {
  display: block;
  width: 300px;
  height: 100px;

  margin: 1rem auto;

  border-radius: 0.125rem;
}

.ae-mode-bar {
  margin: 0.125rem 0;
  padding: 0.125rem;
  border-radius: 0.125rem;

  text-align: center;
}

@media (width > 52rem) {
  .ae-mode-bar {
    margin: 0.25rem 0;
  }
}

.ae-form {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.125rem;
}

@media (width > 52rem) {
  .ae-form {
    gap: 0.25rem;
  }
}

.ae-form.is-compact {
  margin: 1rem 1.5rem;
}

.ae-field {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
}

.ae-field-label {
  padding: 0.25rem;
  border-radius: 0.125rem;

  font-size: var(--ae-font-size-s);
}

@media (width > 52rem) {
  .ae-field-label {
    font-size: var(--ae-font-size-m);
  }
}

.ae-field-input,
.ae-field-textarea,
.ae-field-select,
.ae-field-button {
  padding: 0.25rem;
  box-sizing: border-box;

  border-radius: 2px;
}

.ae-field-input,
.ae-field-textarea,
.ae-field-select {
  border: solid 1px;
}

.ae-field-input,
.ae-field-textarea {
  font-family: monospace;
  font-size: var(--ae-font-size-m);
}

.ae-field-textarea {
  resize: vertical;
}

.ae-field-button {
  min-height: 1.75rem;
  border: solid 1px;
}

.ae-field-button:disabled,
.ae-field-button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.ae-field-group {
  display: flex;
  gap: 0.25rem;
  flex-direction: row;
  align-items: center;
}

.ae-field-group .ae-field-input {
  width: 100%;
}

.ae-field.is-misc {
  align-items: center;
}

.ae-field.is-misc .ae-field-label {
  background-color: transparent;
}

.ae-actions {
  margin-top: 0.75rem;

  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.ae-actions-label {
  font-size: var(--ae-font-size-s);
}

.ae-thread-status {
  margin: 1rem 12px;

  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;

  font-size: var(--ae-font-size-s);
}

@media (width > 52rem) {
  .ae-thread-status {
    margin: 1rem 30px;
  }
}

.ae-post.is-reply,
.ae-post.is-thread {
  display: block;
  max-width: fit-content;
  margin: 0.125rem 0;
  padding: 0.25rem 0.25rem 0.5rem;

  overflow: auto;
}

@media (width > 52rem) {
  .ae-post.is-reply,
  .ae-post.is-thread {
    margin: 0.25rem 0;
  }
}

.ae-post.is-reply {
  padding-bottom: 0.75rem;
}

#posts.is-catalog {
  display: grid;
  grid-template-columns: auto 1fr auto;
  column-gap: 0.5rem;
  row-gap: 0.75rem;

  margin-top: 0.75rem;
}

.ae-post.is-catalog {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
}

.post-summary {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.post-replies {
  text-align: right;
}

.ae-post-header {
  margin: 0 0.25rem;
}

.post-checkbox {
  width: 14px;
  height: 14px;

  margin: 3px 2px 3px 0px;
  vertical-align: baseline;
}

.post-subject {
  font-weight: 600;
}

.post-name {
  font-weight: 600;
}

.post-id {
  color: inherit !important;
  text-decoration: none;
}

.post-message {
  line-height: 1.25;
}

.post-subject,
.post-name,
.post-message {
  overflow-wrap: anywhere;
  word-break: normal;

  line-height: 1.25;
}

.post-truncated,
.post-backlinks,
.post-omitted {
  font-size: var(--ae-font-size-s);
}

.post-truncated {
  text-decoration: dashed underline 0.6px;

  cursor: default;
}

.post-message,
.post-truncated,
.post-backlinks,
.post-omitted {
  margin: 0.875rem 0.375rem 0;
}

@media (width > 52rem) {
  .post-message,
  .post-truncated,
  .post-backlinks,
  .post-omitted {
    margin: 0.875rem 25px 0;
  }
}

.markup-link {
  word-break: break-all;
}

.markup-spoiler:hover {
  color: inherit !important;
  background-color: inherit !important;
}

.markup-bold {
  font-weight: 600;
}

.markup-italic {
  font-style: italic;
}

.markup-monospace {
  font-family: monospace;
}

.markup-strikethrough {
  text-decoration: line-through;
}

.markup-blocklink {
  max-width: 100%;

  display: inline-flex;
  align-items: center;
  gap: 0.25rem;

  text-decoration: none;
}

.blocklink-marker {
  font-size: var(--ae-font-size-s);

  white-space: nowrap;
}

.blocklink-title {
  min-width: 0;

  white-space: nowrap;
  overflow-x: hidden;
  text-overflow: ellipsis;

  text-decoration: solid 0.5px underline;
}

.markup-banmessage {
  font-weight: 600;
}

.pages {
  padding: 0 1.5rem;
}

.pages-toggle {
  margin: 1rem 0;

  display: flex;
  justify-content: space-between;
}

.pages-list {
  margin: 0.5rem 0;

  letter-spacing: 0.125rem;
  text-align: justify;
}

.js-loading {
  animation: loading 0.5s infinite;
}

@keyframes loading {
  50% {
    opacity: 0;
  }
}

.js-floater {
  max-width: 52rem;
  box-shadow: 0.5rem 0.5rem 0 0 #00000010;
  position: fixed;

  background-color: lightgray;
  border-radius: 0.125rem;

  border: solid 1px #ababb5;
}

.js-floater .ae-post {
  margin: 0;
}

.js-hide,
.js-show {
  border: none;
  background: none;
  padding: 0;

  display: inline-block;

  color: inherit;
  letter-spacing: 0.125rem;
}

.ae-post.is-thread .js-show {
  display: none;
}

.ae-post.is-thread.is-hidden {
  margin: -0.8rem 0;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
}

.ae-post.is-thread.is-hidden .js-show {
  display: unset;
}

.ae-post.is-thread.is-hidden .js-hide {
  display: none;
}

.ae-post.is-thread.is-hidden .ae-post-header {
  filter: grayscale(1) opacity(0.5);
}

.ae-post.is-thread.is-hidden .ae-post-content,
.ae-post.is-reply.is-hidden {
  display: none;
}

.js-hidden {
  display: none;
}

#img-gd-captcha {
  cursor: pointer;
}

/***************************************************************************
 * Management Panel styles
 *
 * @todo: Should be moved into a separate CSS file
 */

.ae-manage-actions-row {
  margin: 1rem 0;

  display: flex;
  flex-wrap: wrap;

  gap: 0.5rem;
}

/***************************************************************************
 * Futaba Theme
 */

[data-theme='futaba'] {
  a {
    color: #0000ee;
  }

  a:hover {
    color: #dd0000;
  }

  .ae-page {
    color: #800000;
    background-color: #ffffee;

    font-family: serif;
  }

  .ae-sidebar-link {
    background-color: #f0e0d666;
  }

  .ae-hr {
    height: 0.125rem;

    border: none;
    border-radius: 0.125rem;

    background-color: #f0e0d6;
  }

  .ae-mode-bar.is-regular {
    color: #ffffff;
    background-color: #e04000;
  }

  .ae-mode-bar.is-success {
    color: #ffffff;
    background-color: #00b930;
  }

  .ae-field-label {
    color: #800000;
    background-color: #eeaa88;

    font-weight: 600;
  }

  .ae-field-input,
  .ae-field-select,
  .ae-field-textarea {
    color: #000000;
    background-color: #ffffff;
  }

  .ae-field-button {
    color: #000000;
    background-color: #f0f0f0;
  }

  .post-subject {
    color: #cc1105;
  }

  .post-name {
    color: #117743;
  }

  .post-tripcode {
    color: #228854;
  }

  .markup-quote {
    color: #789922;
  }

  .markup-reply {
    color: #8766dd;
  }

  .markup-spoiler {
    border-radius: 0.125rem;

    color: #800000;
    background-color: #800000;
  }

  .markup-banmessage {
    color: #ff0000;
  }

  .post-backlinks,
  .post-truncated,
  .post-omitted {
    color: #707070;
    font-style: italic;
  }

  .ae-post.is-thread {
    background-color: #ffffee;
  }

  .ae-post.is-reply {
    background-color: #f0e0d6;
    border-radius: 0.125rem;
  }

  .post-capcode.is-admin {
    color: #ff0000;
  }

  .post-capcode.is-mod {
    color: #800080;
  }

  .js-floater {
    background-color: #ffffee;
  }
}

/***************************************************************************
 * Burichan Theme
 */

[data-theme='burichan'] {
  a {
    color: #34345c;
  }

  a:hover {
    color: #dd0000;
  }

  .ae-page {
    color: #000000;
    background-color: #eef2ff;

    font-family: serif;
  }

  .ae-sidebar-link {
    background-color: #d6daf066;
  }

  .ae-hr {
    height: 0.125rem;

    border: none;
    border-radius: 0.125rem;

    background-color: #d6daf0;
  }

  .ae-mode-bar.is-regular {
    color: #ffffff;
    background-color: #0010e0;
  }

  .ae-mode-bar.is-success {
    color: #ffffff;
    background-color: #00b930;
  }

  .ae-field-label {
    color: #000000;
    background-color: #9988ee;

    font-weight: 600;
  }

  .ae-field-input,
  .ae-field-select,
  .ae-field-textarea {
    color: #000000;
    background-color: #ffffff;
  }

  .ae-field-button {
    color: #000000;
    background-color: #f0f0f0;
  }

  .post-subject {
    color: #0f0c5d;
  }

  .post-name {
    color: #117743;
  }

  .markup-quote {
    color: #789922;
  }

  .markup-reply {
    color: #8766dd;
  }

  .markup-spoiler {
    border-radius: 0.125rem;

    color: #000000;
    background-color: #000000;
  }

  .markup-banmessage {
    color: #ff0000;
  }

  .post-backlinks,
  .post-truncated,
  .post-omitted {
    color: #707070;
    font-style: italic;
  }

  .ae-post.is-thread {
    background-color: #eef2ff;
  }

  .ae-post.is-reply {
    background-color: #d6daf0;
    border-radius: 0.125rem;
  }

  .post-capcode.is-admin {
    color: #ff0000;
  }

  .post-capcode.is-mod {
    color: #800080;
  }

  .js-floater {
    background-color: #eef2ff;
  }
}

/***************************************************************************
 * Courier Theme
 */

[data-theme='courier'] {
  a {
    color: #0000ff;
  }

  a:hover {
    color: #ff0000;
  }

  .ae-page {
    color: #000000;
    background-color: #c1c1c1;

    font-family: serif;
  }

  .ae-sidebar-link {
    background-color: #ffffff66;
  }

  .ae-field-label {
    padding-left: 0;
  }

  .post-subject {
    color: #8b0000;
  }

  .post-name {
    color: #006400;
  }

  .post-tripcode {
    color: #008000;
  }

  .markup-quote {
    color: #008000;
  }

  .markup-spoiler {
    color: #000000;
    background-color: #000000;
  }

  .markup-banmessage {
    color: #ff0000;
  }

  .ae-post.is-thread {
    background-color: #c1c1c1;
  }

  .ae-post.is-reply {
    background-color: #fefefe;
  }

  .post-capcode.is-admin {
    color: #ff0000;
  }

  .post-capcode.is-mod {
    color: #800080;
  }

  .js-floater {
    background-color: #ffffee;
  }
}

/***************************************************************************
 * Nightshift Theme
 */

[data-theme='nightshift'] {
  color-scheme: dark light;

  a {
    color: #d0cdc8;
  }

  a:hover {
    color: #a19b91;
  }

  .ae-page {
    color: #d0cdc8;
    background-color: #212121;

    font-family: 'Tahoma', sans-serif;

    color-scheme: dark light;
  }

  .ae-sidebar-link {
    background-color: #30303066;
  }

  .ae-page-headr {
    font-size: var(--ae-font-size-s);
  }

  .ae-hr {
    height: 1px;

    border: none;
    background-color: #303030;
  }

  .ae-mode-bar.is-regular {
    font-size: var(--ae-font-size-s);
    color: #ffffff;
    background-color: #303030;
  }

  .ae-mode-bar.is-success {
    font-size: var(--ae-font-size-s);
    color: #ffffff;
    background-color: #00a67d;
  }

  .ae-field-label {
    font-size: var(--ae-font-size-s);

    background-color: #303030;
  }

  .ae-field-input,
  .ae-field-select,
  .ae-field-textarea {
    color: #ffffff;
    background-color: #3b3b3b;
    border-color: #858585;
  }

  .ae-field-input:hover,
  .ae-field-select:hover,
  .ae-field-textarea:hover {
    border-color: #acacac;
  }

  .ae-field-button {
    background-color: #6b6b6b;
    border-color: #858585;
  }

  .ae-field-button:hover {
    background-color: #7b7b7b;
    border-color: #acacac;
  }

  .ae-post-header {
    font-size: var(--ae-font-size-s);
  }

  .post-checkbox {
    accent-color: #e5e5e5;
  }

  .post-name {
    font-weight: 400;
  }

  .post-tripcode {
    color: #0ba880;
  }

  .markup-quote {
    color: #0ba880;
  }

  .markup-reply {
    color: #8c81d9;
  }

  .markup-spoiler {
    border-radius: 0.125rem;

    color: #d0cdc8;
    background-color: #d0cdc8;
  }

  .markup-italic {
    font-family: serif;
  }

  .markup-banmessage {
    color: #f22c3d;
  }

  .post-backlinks,
  .post-truncated,
  .post-omitted {
    color: #a19b91;
  }

  .ae-post.is-thread {
    background-color: #212121;
  }

  .ae-post.is-reply {
    background-color: #303030;
    border-radius: 6px;
  }

  .post-capcode.is-admin {
    color: #f22c3d;
  }

  .post-capcode.is-mod {
    color: #c8306f;
  }

  .js-floater {
    background-color: #212121;
    border-color: #212121;

    border-radius: 6px;
  }
}

/***************************************************************************
 * Legacy.Day Theme
 */

[data-theme='legacy-day'] {
  a {
    color: hsl(208, 100%, 43%);
  }

  a:hover {
    color: hsl(3, 100%, 61%);
  }

  .ae-page {
    color: #333333;
    background-color: #f6f6f6;

    font-family: 'Tahoma', sans-serif;
  }

  .ae-sidebar-link {
    background-color: #00000008;
  }

  .ae-hr {
    border: none;

    height: 0.125rem;
    background-color: #00000044;
  }

  .ae-mode-bar {
    color: #f6f6f6;
    background-color: #333333;
  }

  .ae-field-input,
  .ae-field-select,
  .ae-field-textarea {
    color: #262626;
    background-color: #f6f6f6;
    border-color: #00000088;
  }

  .ae-field-button {
    background-color: #f6f6f6;
    border-color: #000000bb;
  }

  .post-name {
    font-weight: 400;
  }

  .markup-quote {
    color: rgb(84, 155, 34);
  }

  .markup-reply {
    color: rgb(171, 100, 221);
  }

  .markup-italic {
    font-family: serif;
  }

  .markup-spoiler {
    border-radius: 0.125rem;

    color: #333333;
    background-color: #333333;
  }

  .markup-banmessage {
    color: #ff0000;
  }

  .post-backlinks,
  .post-truncated,
  .post-omitted {
    font-style: italic;
  }

  .ae-post.is-thread {
    background-color: #f6f6f6;
  }

  .ae-post.is-reply {
    background-color: #f6f6f6;

    border: dashed 1px #00000088;
    border-radius: 0.125rem;
  }

  .post-capcode.is-admin {
    color: #ff0000;
  }

  .post-capcode.is-mod {
    color: #800080;
  }

  .js-floater {
    background-color: #ffffee;
  }
}

/***************************************************************************
 * Legacy.Night Theme
 */

[data-theme='legacy-night'] {
  color-scheme: dark light;

  a {
    color: hsl(208, 100%, 43%);
  }

  a:hover {
    color: hsl(3, 100%, 61%);
  }

  .ae-page {
    color: #e8e6e3;
    background-color: #212121;

    font-family: 'Tahoma', sans-serif;
  }

  .ae-sidebar-link {
    background-color: #ffffff08;
  }

  .ae-hr {
    border: none;

    height: 0.125rem;
    background-color: #ffffff44;
  }

  .ae-mode-bar {
    color: #212121;
    background-color: #e8e6e3;
  }

  .ae-field-input,
  .ae-field-select,
  .ae-field-textarea {
    color: #d4d4d4;
    background-color: #212121;
    border-color: #ffffff44;
  }

  .ae-field-button {
    background-color: #212121;
    border-color: #ffffff88;
  }

  .post-checkbox {
    accent-color: #e8e6e3;
  }

  .post-name {
    font-weight: 400;
  }

  .markup-quote {
    color: rgb(84, 155, 34);
  }

  .markup-reply {
    color: rgb(171, 100, 221);
  }

  .markup-italic {
    font-family: serif;
  }

  .markup-spoiler {
    border-radius: 0.125rem;

    color: #e8e6e3;
    background-color: #e8e6e3;
  }

  .markup-banmessage {
    color: #ff0000;
  }

  .post-backlinks,
  .post-truncated,
  .post-omitted {
    font-style: italic;
  }

  .ae-post.is-thread {
    background-color: #212121;
  }

  .ae-post.is-reply {
    background-color: #212121;

    border: dashed 1px #ffffff44;
    border-radius: 0.125rem;
  }

  .post-capcode.is-admin {
    color: #ff0000;
  }

  .post-capcode.is-mod {
    color: #800080;
  }

  .js-floater {
    background-color: #ffffee;
  }
}
