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;
  gap: 1rem;
}

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

.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 {
    animation: sidebar-appearance 0.1s linear 0.2s forwards;
  }

  @keyframes sidebar-appearance {
    to {
      opacity: 1;
    }
  }
}

.ae-sidebar-link {
  display: block;
  padding: 1rem 0;
  box-sizing: border-box;

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

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

.ae-sidebar-link.is-back,
.ae-sidebar-link.is-top {
  height: 70%;
}

.ae-sidebar-link.is-bottom {
  height: 30%;

  display: flex;
  justify-content: center;
  align-items: flex-end;
}

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

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

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

.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 {
  opacity: 0.6;
}

.ae-field-input:focus,
.ae-field-textarea:focus,
.ae-field-select:focus,
.ae-field-button:focus {
  outline: solid 2px;
  outline-offset: 1px;
}

.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:target,
.ae-post.is-thread:target {
  animation: target 1s;
}

@keyframes target {
  0% {
    opacity: 0.5;
  }
}

.ae-post.is-reply {
  border: solid 1px transparent;
}

table.ae-posts {
  margin-top: 0.75rem;

  border-collapse: collapse;
  border-spacing: 0;
}

td.post-link {
  padding: 4px 0;

  vertical-align: top;
}

td.post-replies {
  padding: 4px 0 4px 0.5rem;

  text-align: right;
  vertical-align: top;

  font-weight: 600;
}

@media (width > 52rem) {
  td.post-replies {
    padding: 4px 0 4px 1rem;
  }
}

td.post-summary {
  padding: 4px 0 4px 0.5rem;

  vertical-align: top;

  overflow-wrap: anywhere;
  word-break: normal;
}

@media (width > 52rem) {
  td.post-summary {
    padding: 4px 0 4px 1rem;
  }
}

.ae-post-header {
  margin: 0 0.25rem;
  font-size: var(--ae-font-size-s);
}

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

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

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

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

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

.ae-post-header .post-id {
  color: inherit;
  text-decoration: none;
}

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

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

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

.post-truncated {
  text-decoration: dashed underline;
  text-decoration-skip-ink: auto;

  cursor: pointer;
}

.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 {
  text-decoration: none;
}

.blocklink-marker {
  white-space: nowrap;
}

.blocklink-title {
  text-decoration: solid 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 linear infinite;
}

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

.js-floater {
  position: fixed;

  border-radius: 0.125rem;
}

.js-floater .ae-post {
  margin: 0;
  max-width: 52rem;

  overflow: hidden;
}

.js-floater .post-message {
  display: -webkit-box;

  -webkit-box-orient: vertical;
  -webkit-line-clamp: 10;
  line-clamp: 10;

  overflow: hidden;
}

.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;
}

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

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

  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'] {
  color-scheme: light;

  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'] {
  color-scheme: light;

  a {
    color: #008080;
  }

  a:hover {
    color: #00ffff;
  }

  form[data-autosave='true'] {
    margin: 0 auto;
    max-width: 36rem;
  }

  .ae-page {
    max-width: initial;

    color: #000000;
    background-color: #aaaaaa;

    font-family: serif;
  }

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

  .ae-hr {
    height: 1px;

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

  .ae-banner {
    border-radius: 0;
  }

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

  .ae-field-label {
    background-color: #ffffff;
    border-radius: 0;

    font-weight: 600;
  }

  .ae-field-input,
  .ae-field-textarea,
  .ae-field-select {
    border: inset 2px;
    border-radius: 0;
  }

  .ae-field-button {
    border: outset 2px;
    border-radius: 0;
  }

  .post-subject {
    font-size: 1.2em;

    color: #804000;
  }

  .post-name {
    color: #800000;
  }

  .post-tripcode {
    color: #008000;
  }

  .markup-quote {
    color: #4a8a73;
  }

  .markup-reply {
    color: #7a6fb8;
  }

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

  .markup-banmessage {
    color: #ff0000;
  }

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

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

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

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

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

/***************************************************************************
 * Daydream Theme
 */

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

  a {
    color: #a35e49;
  }

  a:hover {
    color: #894d3b;
  }

  .ae-page {
    color: #322d27;
    background-color: #f4f1ea;

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

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

  .ae-hr {
    height: 1px;

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

  .ae-mode-bar.is-regular {
    color: #544f48;
    background-color: #e9e5de;
  }

  .ae-mode-bar.is-success {
    color: #fcf9f3;
    background-color: #6a9074;
  }

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

    background-color: #e9e5de;
  }

  .ae-field-input,
  .ae-field-select,
  .ae-field-textarea {
    /* color: #544f48; */
    background-color: #fcf9f3;
    border-color: #d8d2c4;
  }

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

  .ae-field-button {
    background-color: #e9e5de;
    border-color: #d8d2c4;
  }

  .ae-field-button:hover {
    background-color: #dad2c6;
    border-color: #a7a094;
  }

  .post-checkbox {
    accent-color: #6d665e;
  }

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

  .post-tripcode {
    color: #4a8a73;
  }

  .markup-quote {
    color: #4a8a73;
  }

  .markup-reply {
    color: #7a6fb8;
  }

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

    color: #544f48;
    background-color: #544f48;
  }

  .markup-banmessage {
    color: #c15b5b;
  }

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

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

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

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

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

  .ae-post-header {
    color: #8d8579;
  }

  .js-floater {
    background-color: #f4f1ea;
    border-color: #d8d2c4;

    border-radius: 6px;
  }
}

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

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

  a {
    color: #b8b5b0;
  }

  a:hover {
    color: #949088;
  }

  .ae-page {
    color: #b8b5b0;
    background-color: #1a1a1a;

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

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

  .ae-hr {
    height: 1px;

    border: none;
    background-color: #2a2a2a;
  }

  .ae-mode-bar.is-regular {
    color: #d4d1cc;
    background-color: #2a2a2a;
  }

  .ae-mode-bar.is-success {
    color: #d4d1cc;
    background-color: #2d7a63;
  }

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

    background-color: #2a2a2a;
  }

  .ae-field-input,
  .ae-field-select,
  .ae-field-textarea {
    /* color: #d4d1cc; */
    background-color: #323232;
    border-color: #5a5a5a;
  }

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

  .ae-field-button {
    background-color: #4a4a4a;
    border-color: #5a5a5a;
  }

  .ae-field-button:hover {
    background-color: #545454;
    border-color: #7a7a7a;
  }

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

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

  .post-tripcode {
    color: #4a8a73;
  }

  .markup-quote {
    color: #4a8a73;
  }

  .markup-reply {
    color: #7a6fb8;
  }

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

    color: #b8b5b0;
    background-color: #b8b5b0;
  }

  .markup-banmessage {
    color: #c45562;
  }

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

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

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

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

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

  .ae-post-header {
    color: #8a8580;
  }

  .js-floater {
    background-color: #1a1a1a;
    border-color: #1a1a1a;

    border-radius: 6px;
  }
}

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

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

  a {
    color: oklch(58% 0.2 240);
  }

  a:hover {
    color: oklch(58% 0.2 30);
  }

  .ae-page {
    color: oklch(35% 0 0);
    background-color: oklch(95% 0 0);

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

  .ae-sidebar-link {
    background-color: oklch(90% 0 0);
  }

  .ae-hr {
    border: none;

    height: 1px;
    background-color: oklch(68% 0 0);
  }

  .ae-mode-bar {
    color: oklch(95% 0 0);
    background-color: oklch(35% 0 0);
  }

  .ae-field-input,
  .ae-field-select,
  .ae-field-textarea,
  .ae-field-button {
    color: oklch(35% 0 0);
    background-color: oklch(95% 0 0);
    border-color: oklch(75% 0 0);
  }

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

  .markup-quote {
    color: oklch(58% 0.2 130);
  }

  .markup-reply {
    color: oklch(58% 0.2 295);
  }

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

    color: oklch(35% 0 0);
    background-color: oklch(35% 0 0);
  }

  .markup-banmessage {
    color: #ff0000;
  }

  .post-backlinks,
  .post-truncated,
  .post-omitted {
    font-style: italic;
    color: oklch(68% 0 0);
  }

  .ae-post.is-thread {
    background-color: oklch(95% 0 0);
  }

  .ae-post.is-reply {
    background-color: oklch(95% 0 0);

    border: dashed 1px oklch(68% 0 0);
    border-radius: 0.125rem;
  }

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

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

  .js-floater {
    border-color: oklch(95% 0 0);
    background-color: oklch(95% 0 0);
  }
}

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

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

  a {
    color: oklch(56% 0.2 240);
  }

  a:hover {
    color: oklch(56% 0.2 30);
  }

  .ae-page {
    color: oklch(84% 0 0);
    background-color: oklch(24% 0 0);

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

  .ae-sidebar-link {
    background-color: oklch(28% 0 0);
  }

  .ae-hr {
    border: none;

    height: 1px;
    background-color: oklch(58% 0 0);
  }

  .ae-mode-bar {
    color: oklch(24% 0 0);
    background-color: oklch(84% 0 0);
  }

  .ae-field-input,
  .ae-field-select,
  .ae-field-textarea,
  .ae-field-button {
    color: oklch(84% 0 0);
    background-color: oklch(24% 0 0);
    border-color: oklch(50% 0 0);
  }

  .post-checkbox {
    accent-color: oklch(84% 0 0);
  }

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

  .markup-quote {
    color: oklch(56% 0.2 130);
  }

  .markup-reply {
    color: oklch(56% 0.2 295);
  }

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

    color: oklch(84% 0 0);
    background-color: oklch(84% 0 0);
  }

  .markup-banmessage {
    color: #ff0000;
  }

  .post-backlinks,
  .post-truncated,
  .post-omitted {
    font-style: italic;
    color: oklch(58% 0 0);
  }

  .ae-post.is-thread {
    background-color: oklch(24% 0 0);
  }

  .ae-post.is-reply {
    background-color: oklch(24% 0 0);

    border: dashed 1px oklch(58% 0 0);
    border-radius: 0.125rem;
  }

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

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

  .js-floater {
    border-color: oklch(24% 0 0);
    background-color: oklch(24% 0 0);
  }
}
