:root {
  color-scheme: light;
  --page: #d7d2c5;
  --panel: #f4f1e8;
  --panel-2: #e7e0d2;
  --input: #fffdf6;
  --line: #8c8578;
  --line-soft: #c3bbac;
  --text: #191816;
  --muted: #5f5a51;
  --link: #064f8f;
  --link-hover: #8b1e16;
  --button: #d1d9df;
  --button-line: #657581;
  --active: #fff1b9;
  --active-line: #9c7d25;
  --topbar: #4d5961;
  --topbar-line: #2f363b;
  --topbar-text: #fff;
  --prefbar: #c9d5de;
  --prefbar-line: #7f8f9b;
  --prefbar-label: #37434c;
  --thumb-bg: #c8c2b6;
  --tile-missing: #ddd5cd;
  --moderated-bg: #e5ddd2;
  --moderated-text: #4d332e;
  --media-bg: #1a1917;
  --media-line: #000;
  --inline-tag-bg: #eef3f5;
  --inline-tag-line: #a7b3bb;
  --source-bg: #fffbf2;
  --notice-bg: #fff7cf;
  --notice-line: #b39b4b;
  --danger-bg: #e8c0bb;
  --danger-line: #95493f;
  --error-bg: #f8d6d2;
  --error-line: #a24b41;
  --shadow: rgba(25, 24, 22, 0.25);
  --overlay-bg: rgba(25, 24, 22, 0.58);
  --overlay-line: rgba(255, 255, 255, 0.58);
  --overlay-icon: rgba(255, 255, 255, 0.92);
  --overlay-shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  --thumb-min: 150px;
  --thumb-min-height: 190px;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 13px/1.35 Verdana, Arial, sans-serif;
}

body.theme-yotsuba {
  --page: #ffffee;
  --panel: #f0e0d6;
  --panel-2: #ead6c8;
  --input: #fffaf0;
  --line: #d9bfb7;
  --line-soft: #e6cfc5;
  --text: #800000;
  --muted: #8f5a4a;
  --link: #0000ee;
  --link-hover: #dd0000;
  --button: #eeaa88;
  --button-line: #800000;
  --active: #f8e5b6;
  --active-line: #800000;
  --topbar: #d9bfb7;
  --topbar-line: #c7a89f;
  --topbar-text: #800000;
  --prefbar: #f0e0d6;
  --prefbar-line: #d9bfb7;
  --prefbar-label: #800000;
  --thumb-bg: #ead6c8;
  --tile-missing: #ead6c8;
  --moderated-bg: #ead6c8;
  --moderated-text: #800000;
  --inline-tag-bg: #fff2df;
  --inline-tag-line: #d9bfb7;
  --source-bg: #fff7e1;
  --notice-bg: #fff2c6;
  --notice-line: #d8a35f;
  --danger-bg: #f0c6bc;
  --danger-line: #a64b3d;
  --error-bg: #f5d0c8;
  --error-line: #a64b3d;
}

body.theme-yotsuba-blue {
  --page: #eef2ff;
  --panel: #d6daf0;
  --panel-2: #c8cfee;
  --input: #f7f8ff;
  --line: #b7c5d9;
  --line-soft: #c9d3e6;
  --text: #000000;
  --muted: #667788;
  --link: #34345c;
  --link-hover: #dd0000;
  --button: #9988ee;
  --button-line: #000000;
  --active: #cdd5fb;
  --active-line: #34345c;
  --topbar: #d6daf0;
  --topbar-line: #b7c5d9;
  --topbar-text: #000000;
  --prefbar: #d6daf0;
  --prefbar-line: #b7c5d9;
  --prefbar-label: #000000;
  --thumb-bg: #c8cfee;
  --tile-missing: #c8cfee;
  --moderated-bg: #c8cfee;
  --moderated-text: #34345c;
  --inline-tag-bg: #eef2ff;
  --inline-tag-line: #b7c5d9;
  --source-bg: #f7f8ff;
  --notice-bg: #fff2c6;
  --notice-line: #b7a15e;
  --danger-bg: #f0c6d0;
  --danger-line: #96364a;
  --error-bg: #f5d0d8;
  --error-line: #96364a;
}

body.theme-tomorrow {
  color-scheme: dark;
  --page: #1d1f21;
  --panel: #282a2e;
  --panel-2: #2d3035;
  --input: #282a2e;
  --line: #575a60;
  --line-soft: #44474d;
  --text: #c5c8c6;
  --muted: #969896;
  --link: #81a2be;
  --link-hover: #5f89ac;
  --button: #373b41;
  --button-line: #575a60;
  --active: #373f4a;
  --active-line: #81a2be;
  --topbar: #282a2e;
  --topbar-line: #111111;
  --topbar-text: #c5c8c6;
  --prefbar: #282a2e;
  --prefbar-line: #575a60;
  --prefbar-label: #b5bd68;
  --thumb-bg: #1d1f21;
  --tile-missing: #2d3035;
  --moderated-bg: #2d3035;
  --moderated-text: #de935f;
  --media-bg: #111111;
  --media-line: #000000;
  --inline-tag-bg: #2d3035;
  --inline-tag-line: #575a60;
  --source-bg: #2d3035;
  --notice-bg: #35321f;
  --notice-line: #8a7d3b;
  --danger-bg: #4a2f2f;
  --danger-line: #a54242;
  --error-bg: #4a2f2f;
  --error-line: #a54242;
  --shadow: rgba(0, 0, 0, 0.55);
}

body.theme-photon {
  --page: #eeeeee;
  --panel: #dddddd;
  --panel-2: #d2d2d2;
  --input: #ffffff;
  --line: #cccccc;
  --line-soft: #d9d9d9;
  --text: #333333;
  --muted: #666666;
  --link: #ff6600;
  --link-hover: #ff3300;
  --button: #dddddd;
  --button-line: #aaaaaa;
  --active: #ffe0c2;
  --active-line: #ff6600;
  --topbar: #dddddd;
  --topbar-line: #cccccc;
  --topbar-text: #333333;
  --prefbar: #dddddd;
  --prefbar-line: #cccccc;
  --prefbar-label: #333333;
  --thumb-bg: #d2d2d2;
  --tile-missing: #d2d2d2;
  --moderated-bg: #d2d2d2;
  --moderated-text: #333333;
  --inline-tag-bg: #eeeeee;
  --inline-tag-line: #cccccc;
  --source-bg: #f7f7f7;
  --notice-bg: #fff0dc;
  --notice-line: #ffbb80;
  --danger-bg: #f2d0d0;
  --danger-line: #aa6666;
  --error-bg: #f2d0d0;
  --error-line: #aa6666;
}

body.thumb-small {
  --thumb-min: 112px;
  --thumb-min-height: 150px;
}

body.thumb-large {
  --thumb-min: 205px;
  --thumb-min-height: 245px;
}

body.thumb-huge {
  --thumb-min: 280px;
  --thumb-min-height: 325px;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  background: var(--button);
  border: 1px solid var(--button-line);
  color: var(--text);
  cursor: pointer;
  min-height: 26px;
}

.button-link {
  background: var(--button);
  border: 1px solid var(--button-line);
  color: var(--text);
  display: inline-block;
  min-height: 26px;
  padding: 4px 8px;
}

.button-link:hover {
  color: var(--text);
}

button.active {
  background: var(--active);
  border-color: var(--active-line);
}

input,
select,
textarea {
  background: var(--input);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 5px 6px;
}

textarea {
  resize: vertical;
}

.topbar {
  align-items: center;
  background: var(--topbar);
  border-bottom: 2px solid var(--topbar-line);
  color: var(--topbar-text);
  display: grid;
  gap: 12px;
  grid-template-columns: auto auto 1fr;
  min-height: 42px;
  padding: 6px 10px;
}

.topbar a {
  color: var(--topbar-text);
}

.brand {
  font-size: 18px;
  font-weight: 700;
}

.topbar nav {
  align-items: center;
  display: flex;
  gap: 10px;
}

.nav-form {
  display: inline;
  margin: 0;
}

.nav-form button {
  min-height: 22px;
  padding: 1px 6px;
}

.top-search {
  display: flex;
  gap: 5px;
  justify-content: end;
  position: relative;
}

.top-search input {
  max-width: 620px;
  width: min(52vw, 620px);
}

.stack-form {
  position: relative;
}

.autocomplete-wrap {
  display: block;
  min-width: 0;
  position: relative;
}

.autocomplete-wrap > input {
  width: 100%;
}

.top-search .autocomplete-wrap {
  max-width: 620px;
  width: min(52vw, 620px);
}

.top-search .autocomplete-wrap > input {
  max-width: none;
  width: 100%;
}

.autocomplete-menu {
  background: var(--input);
  border: 1px solid var(--line);
  box-shadow: 2px 2px 0 var(--shadow);
  left: 0;
  max-height: 220px;
  min-width: 100%;
  overflow-y: auto;
  position: absolute;
  top: calc(100% + 1px);
  z-index: 20;
}

.top-search .autocomplete-menu {
  width: 100%;
}

.autocomplete-item {
  align-items: baseline;
  background: var(--input);
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-height: 24px;
  padding: 4px 6px;
  text-align: left;
  width: 100%;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--active);
}

.autocomplete-item small {
  color: var(--muted);
  white-space: nowrap;
}

.prefbar {
  align-items: center;
  background: var(--prefbar);
  border-bottom: 1px solid var(--prefbar-line);
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 5px 10px;
}

.prefbar fieldset {
  align-items: center;
  border: 0;
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.prefbar legend {
  color: var(--prefbar-label);
  float: left;
  font-weight: 700;
  margin-right: 2px;
}

.prefbar label {
  align-items: center;
  display: inline-flex;
  gap: 3px;
  white-space: nowrap;
}

.prefbar input {
  margin: 0;
}

.prefbar select {
  height: 20px;
  min-height: 0;
  padding: 0 5px;
}

.prefbar .prefbar-theme {
  margin-left: auto;
}

.prefbar .prefbar-theme select {
  min-width: 112px;
}

.shell {
  display: grid;
  gap: 10px;
  grid-template-columns: 240px minmax(0, 1fr);
  padding: 10px;
}

.post-shell {
  grid-template-columns: 240px minmax(0, 1fr);
}

.post-shell > .viewer {
  grid-column: 2;
  grid-row: 1;
}

.post-sidebar {
  grid-column: 1;
  grid-row: 1;
}

.post-shell.viewer-wide,
.post-shell.viewer-original {
  grid-template-columns: minmax(0, 1fr);
}

.post-shell.viewer-wide .viewer,
.post-shell.viewer-wide .post-sidebar,
.post-shell.viewer-original .viewer,
.post-shell.viewer-original .post-sidebar {
  grid-column: 1;
  grid-row: auto;
}

.post-shell.viewer-wide .post-sidebar,
.post-shell.viewer-original .post-sidebar {
  width: 100%;
}

.sidebar,
.post-sidebar,
.content,
.viewer,
.narrow {
  min-width: 0;
}

.sidebar-section,
.post-sidebar section,
.comments,
.post-tabs,
.panel-form,
.listing {
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 10px;
  padding: 8px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 20px;
  margin-bottom: 3px;
}

h2 {
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
  margin-bottom: 8px;
  padding-bottom: 3px;
}

h3 {
  color: var(--muted);
  font-size: 12px;
  margin: 8px 0 4px;
  text-transform: uppercase;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

.sidebar-section > summary {
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 8px;
  padding-bottom: 3px;
}

.sidebar-section > summary h2 {
  border: 0;
  display: inline;
  margin: 0;
  padding: 0;
}

.post-sidebar .sidebar-section > summary h1 {
  border: 0;
  display: inline;
  font-size: 15px;
  margin: 0;
  padding: 0;
}

.tag-list {
  list-style: none;
  margin: 4px 0 10px;
  padding: 0;
}

.tag-list li {
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 1px 0;
}

.tag-list span {
  color: var(--muted);
}

.tag-list .tag-label {
  color: var(--text);
  min-width: 0;
}

.tag-list .tag-source {
  color: var(--muted);
  font-size: 11px;
}

.tag-list a.active {
  color: var(--link-hover);
  font-weight: 700;
}

.tag-more {
  color: var(--muted);
  font-size: 11px;
  margin: -6px 0 10px;
}

.flash {
  background: var(--notice-bg);
  border-bottom: 1px solid var(--notice-line);
  padding: 6px 10px;
}

.flash p {
  margin: 0;
}

.section-head {
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 8px;
}

.section-head p {
  color: var(--muted);
  margin: 0;
}

.section-actions {
  align-items: center;
  display: flex;
  gap: 6px;
}

.pager {
  align-items: center;
  display: flex;
  gap: 8px;
}

.pager-large {
  font-size: 15px;
  font-weight: 700;
}

.pager-large a,
.pager-large span {
  background: var(--button);
  border: 1px solid var(--button-line);
  color: var(--text);
  display: inline-block;
  min-width: 34px;
  padding: 4px 8px;
  text-align: center;
}

.pager-large span {
  background: var(--panel-2);
}

.bottom-pager {
  justify-content: end;
  margin-top: 10px;
}

.post-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(var(--thumb-min), 1fr));
}

.compact-grid {
  grid-template-columns: repeat(auto-fill, minmax(var(--thumb-min), 1fr));
}

.thumb {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  display: block;
  min-height: var(--thumb-min-height);
  overflow: hidden;
  padding: 5px;
}

.thumb:hover {
  color: var(--text);
  text-decoration: none;
}

.thumb img {
  aspect-ratio: 1 / 1;
  background: var(--thumb-bg);
  display: block;
  object-fit: contain;
  width: 100%;
}

.thumb-caption,
.thumb-type {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb-type {
  color: var(--muted);
  font-weight: 700;
  margin-top: 1px;
}

.thumb-media {
  aspect-ratio: 1 / 1;
  background: var(--thumb-bg);
  position: relative;
}

.thumb-media img {
  height: 100%;
}

.play-overlay {
  background: var(--overlay-bg);
  border: 1px solid var(--overlay-line);
  border-radius: 50%;
  box-shadow: 0 1px 7px var(--overlay-shadow);
  height: 46px;
  left: 50%;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 46px;
}

.play-overlay::before {
  border-bottom: 11px solid transparent;
  border-left: 17px solid var(--overlay-icon);
  border-top: 11px solid transparent;
  content: "";
  left: 18px;
  position: absolute;
  top: 11px;
}

.file-tile {
  align-items: center;
  aspect-ratio: 1 / 1;
  background: var(--panel-2);
  border: 1px dashed var(--line);
  color: var(--muted);
  display: flex;
  justify-content: center;
  text-align: center;
  text-transform: uppercase;
}

.file-tile.missing {
  background: var(--tile-missing);
}

.text-tile {
  align-items: stretch;
  color: var(--text);
  justify-content: stretch;
  padding: 7px;
  text-align: left;
  text-decoration: none;
  text-transform: none;
}

.text-tile pre {
  color: var(--text);
  font: 11px/1.25 Menlo, Consolas, "Liberation Mono", monospace;
  margin: 0;
  max-height: 100%;
  text-decoration: none;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}

.thumb:hover .text-tile,
.thumb:hover .text-tile pre {
  color: var(--text);
  text-decoration: none;
}

.thumb.moderated {
  border-style: dashed;
}

.thumb.deleted {
  opacity: 0.86;
}

.moderated-tile {
  background: var(--moderated-bg);
  color: var(--moderated-text);
  font-weight: 700;
}

.media-frame {
  background: var(--media-bg);
  border: 1px solid var(--media-line);
  min-height: 280px;
  overflow: auto;
  padding: 10px;
  text-align: center;
}

.media-frame img,
.media-frame video,
.media-frame object {
  max-height: calc(100vh - 90px);
  max-width: 100%;
}

.media-frame .cycle-media {
  cursor: zoom-in;
}

.media-frame.media-wide img {
  height: auto;
  max-height: none;
  max-width: none;
  width: 100%;
}

.media-frame.media-original {
  overflow: visible;
  text-align: left;
  width: 100%;
}

.media-frame.media-original img {
  height: auto;
  max-height: none;
  max-width: none;
  width: auto;
}

.media-frame.media-original .cycle-media {
  cursor: zoom-out;
}

.file-message {
  background: var(--panel);
  border: 1px solid var(--line);
  display: inline-block;
  margin: 40px auto;
  padding: 12px;
}

.document-frame {
  background: var(--input);
  border: 0;
  display: block;
  min-height: min(76vh, 900px);
  width: 100%;
}

.text-document {
  background: var(--input);
  border: 1px solid var(--line);
  color: var(--text);
  font: 12px/1.4 Menlo, Consolas, "Liberation Mono", monospace;
  margin: 0;
  max-height: 76vh;
  overflow: auto;
  padding: 10px;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

.meta {
  display: grid;
  gap: 3px 8px;
  grid-template-columns: auto minmax(0, 1fr);
  margin: 0;
}

.meta dt {
  color: var(--muted);
  font-weight: 700;
}

.meta dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  gap: 5px;
  margin-top: 8px;
}

.inline-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
}

.inline-tags a {
  background: var(--inline-tag-bg);
  border: 1px solid var(--inline-tag-line);
  display: inline-block;
  padding: 2px 5px;
}

.source-box {
  background: var(--source-bg);
  border: 1px solid var(--line-soft);
  margin-bottom: 7px;
  padding: 6px;
}

.source-json-group {
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 10px;
  padding: 8px;
}

.source-actions {
  margin: 7px 0;
}

.json-document[open] summary {
  margin-bottom: 6px;
}

.json-document-summary {
  line-height: 24px;
}

.json-summary-text {
  display: inline-block;
}

.json-download-link {
  float: right;
  line-height: 18px;
  min-height: 0;
  padding: 1px 6px;
}

.json-view {
  background: var(--input);
  border: 1px solid var(--line-soft);
  color: var(--text);
  font: 12px/1.4 Menlo, Consolas, "Liberation Mono", monospace;
  margin: 0;
  max-height: 76vh;
  overflow: auto;
  padding: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.comments h2 {
  margin-top: 0;
}

.comment {
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 7px;
  padding: 7px;
}

.comment time {
  color: var(--muted);
  font-size: 11px;
}

.comment p {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.tab-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.tab-button {
  background: var(--button);
  border: 1px solid var(--button-line);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 4px 8px;
}

.tab-button:hover {
  color: var(--text);
}

.tab-button.active {
  background: var(--active);
  border-color: var(--active-line);
  font-weight: 700;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.tab-pane-head {
  align-items: end;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tab-pane-head h3 {
  margin-top: 0;
}

.tab-pane-head p {
  color: var(--muted);
  margin: 0;
}

.source-text {
  background: var(--input);
  border: 1px solid var(--line-soft);
  color: var(--text);
  font: inherit;
  margin: 0 0 7px;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.subtle {
  color: var(--muted);
  font-size: 11px;
}

.comment-form,
.stack-form,
.panel-form {
  display: grid;
  gap: 6px;
}

.auth-form label,
.panel-form label {
  display: grid;
  gap: 3px;
}

.dev-link {
  background: var(--notice-bg);
  border: 1px solid var(--notice-line);
  padding: 8px;
}

.danger-form button {
  background: var(--danger-bg);
  border-color: var(--danger-line);
}

.inline-admin-form {
  display: grid;
  gap: 4px;
  margin-bottom: 5px;
}

.admin-tabs {
  display: flex;
  gap: 10px;
}

.users-table input,
.comments-table input {
  max-width: 160px;
  width: 100%;
}

.panel-form.horizontal {
  align-items: center;
  grid-template-columns: 1fr auto;
}

.tag-rule-form {
  margin-bottom: 10px;
}

.tag-rule-section-head {
  align-items: center;
}

.tag-rule-section-head h2 {
  margin: 0;
}

.rating-rule-form {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.alias-rule-form,
.implication-rule-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

.narrow {
  margin: 10px auto;
  max-width: 880px;
}

.narrow.wide {
  max-width: 1200px;
}

.listing {
  border-collapse: collapse;
  padding: 0;
  width: 100%;
}

.listing th,
.listing td {
  border: 1px solid var(--line);
  padding: 5px;
  text-align: left;
  vertical-align: top;
}

.listing th {
  background: var(--panel-2);
}

.comments-table td:nth-child(4) {
  white-space: pre-wrap;
}

.actions-table td:nth-child(5) {
  white-space: pre-wrap;
}

.table-form {
  margin: 0;
}

.table-form button {
  min-height: 22px;
  padding: 1px 6px;
  white-space: nowrap;
}

.muted {
  color: var(--muted);
  opacity: 0.75;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.error {
  background: var(--error-bg);
  border: 1px solid var(--error-line);
  padding: 7px;
}

code {
  font-size: 12px;
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .top-search {
    justify-content: stretch;
  }

  .top-search .autocomplete-wrap,
  .top-search input {
    width: 100%;
  }

  .rating-rule-form,
  .alias-rule-form,
  .implication-rule-form {
    grid-template-columns: 1fr;
  }

  .shell,
  .post-shell {
    grid-template-columns: 1fr;
  }

  .post-shell > .viewer,
  .post-sidebar {
    grid-column: 1;
    grid-row: auto;
  }

  .sidebar {
    order: 2;
  }

  .post-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}
