/* Right sidebar theme customizer */

:root {
  --theme-sidebar-width: 22rem;
  --theme-editor-bg: #0d1117;
  --theme-editor-fg: #e6edf3;
  --theme-editor-border: #30363d;
  --theme-sidebar-bg: #161b22;
  --theme-sidebar-border: #30363d;
  --theme-accent: #edc230;
}

body.has-theme-sidebar:not(.theme-preview) {
  margin-inline-end: var(--theme-sidebar-width);
}

body.theme-preview {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: #100f0f;
}

body.theme-preview .theme-preview-main {
  height: 100vh;
  margin-inline-end: var(--theme-sidebar-width);
}

.theme-preview-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.theme-preview-panes {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
}

.theme-preview-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  border-inline-end: 1px solid var(--theme-sidebar-border);
}

.theme-preview-pane:last-child {
  border-inline-end: none;
}

.theme-preview-pane-label {
  margin: 0;
  padding: 0.35rem 0.75rem;
  font-family: system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  color: #9aa3b0;
  background: var(--theme-sidebar-bg);
  border-block-end: 1px solid var(--theme-sidebar-border);
}

.theme-preview-pane iframe {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

.theme-preview-pane iframe.theme-preview-fixed {
  flex: 0 0 auto;
  width: var(--preview-width);
  height: var(--preview-height);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  margin: 1rem auto;
}

.theme-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-block-end: 1px solid var(--theme-sidebar-border);
  background: var(--theme-sidebar-bg);
  color: #e6e7e8;
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
}

.theme-preview-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #9aa3b0;
}

.theme-preview-toolbar select {
  border: 1px solid var(--theme-sidebar-border);
  background: #0d1117;
  color: #e6edf3;
  border-radius: 8px;
  padding: 0.25rem 0.4rem;
}

.theme-preview-seg {
  display: inline-flex;
  border: 1px solid var(--theme-sidebar-border);
  border-radius: 8px;
  overflow: hidden;
}

.theme-preview-seg button {
  border: 0;
  border-inline-end: 1px solid var(--theme-sidebar-border);
  border-radius: 0;
  background: #0d1117;
  color: #e6edf3;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

.theme-preview-seg button:last-child {
  border-inline-end: 0;
}

.theme-preview-seg button[aria-pressed="true"] {
  background: rgba(237, 194, 48, 0.14);
}

@media (max-width: 52rem) {
  .theme-preview-panes {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .theme-preview-pane {
    border-inline-end: none;
    border-block-end: 1px solid var(--theme-sidebar-border);
  }
}

@media (max-width: 48rem) {
  :root {
    --theme-sidebar-width: min(100vw, 22rem);
  }
}

#theme-sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  z-index: 9999;
  width: var(--theme-sidebar-width);
  display: flex;
  flex-direction: column;
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
  color: #e6e7e8;
  background: var(--theme-sidebar-bg);
  border-inline-start: 1px solid var(--theme-sidebar-border);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

#theme-sidebar.theme-sidebar-hidden {
  display: none;
}

.theme-sidebar-head {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.65rem;
  border-block-end: 1px solid var(--theme-sidebar-border);
}

.theme-sidebar-head h2 {
  flex: 1 1 100%;
  margin: 0 0 0.15rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--theme-accent);
}

.theme-sidebar-head button,
.theme-sidebar-head a {
  padding-block: 0.22em;
  padding-inline: 0.5em;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
}

.theme-sidebar-copy,
.theme-sidebar-copy-compress,
.theme-sidebar-share-link,
.theme-preview-copy-link {
  color: #1a2030;
  background: var(--theme-accent);
  border: 1px solid var(--theme-accent);
}

.theme-sidebar-copy:hover,
.theme-sidebar-copy-compress:hover,
.theme-sidebar-share-link:hover,
.theme-preview-copy-link:hover {
  filter: brightness(1.05);
}

.theme-preview-copy-link {
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
  border-radius: 8px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

.theme-sidebar-hide,
.theme-sidebar-revert {
  color: #9aa3b0;
  background: transparent;
  border: 1px solid #4a5568;
}

.theme-sidebar-ios-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding-inline: 0.25rem 0.1rem;
  color: #9aa3b0;
  user-select: none;
}

.theme-sidebar-ios-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-sidebar-ios-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #252b36;
  border: 1px solid #3a4455;
  box-sizing: border-box;
}

.theme-sidebar-ios-track::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e6e7e8;
  transition: transform 0.15s ease, background 0.15s ease;
}

.theme-sidebar-ios-input:checked + .theme-sidebar-ios-track {
  background: var(--theme-accent);
  border-color: var(--theme-accent);
}

.theme-sidebar-ios-input:checked + .theme-sidebar-ios-track::after {
  transform: translateX(14px);
  background: #1a2030;
}

.theme-sidebar-ios-input:focus-visible + .theme-sidebar-ios-track {
  outline: 2px solid rgba(237, 194, 48, 0.55);
  outline-offset: 2px;
}

.theme-sidebar-ios-label {
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.2;
}

.theme-sidebar-section-title {
  display: none;
  margin: 0.4rem 0 0.3rem;
  font-size: 0.7rem;
  font-weight: 800;
  color: #9aa3b0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.theme-sidebar-section-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.55rem;
  margin-block: 0.15rem 0.45rem;
  padding-block: 0.1rem;
  min-height: 1.75rem;
}

.theme-sidebar-section-bar-title {
  font-size: 0.7rem;
  font-weight: 800;
  color: #9aa3b0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
}

.theme-sidebar-code-bg,
.theme-sidebar-footer-small,
.theme-sidebar-editor-toggle {
  flex-shrink: 0;
  align-items: center;
  margin-inline-start: 0.15rem;
}

.theme-sidebar--ios .theme-sidebar-tabs {
  display: none;
}

.theme-sidebar--ios .theme-sidebar-section-title {
  display: block;
}

.theme-sidebar--ios .theme-sidebar-section {
  display: block !important;
  margin-block-start: 0.7rem;
  padding-block-start: 0.55rem;
  border-block-start: 1px solid var(--theme-sidebar-border);
}

.theme-sidebar--ios .theme-sidebar-sections > .theme-sidebar-section:first-child {
  margin-block-start: 0;
  padding-block-start: 0;
  border-block-start: none;
}

.theme-sidebar--ios .theme-sidebar-section .theme-sidebar-choices {
  margin-block-end: 0.1rem;
}

.theme-sidebar-hide:hover,
.theme-sidebar-revert:hover {
  color: #e6e7e8;
  border-color: #6b7a94;
}

.theme-sidebar-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  width: 100%;
  margin-block-start: 0.1rem;
}

.theme-sidebar-links a {
  color: #8cc2dd;
  font-weight: 500;
  padding: 0;
  border: none;
}

.theme-sidebar-controls {
  flex-shrink: 0;
  max-height: 38vh;
  overflow: auto;
  padding: 0.45rem 0.65rem;
  border-block-end: 1px solid var(--theme-sidebar-border);
  scrollbar-width: thin;
}

#theme-sidebar.theme-sidebar-editor-collapsed .theme-sidebar-controls {
  flex: 1;
  min-height: 0;
  max-height: none;
  border-block-end: none;
}

#theme-sidebar.theme-sidebar-editor-collapsed .theme-sidebar-editor {
  display: none;
}

.theme-sidebar-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-block-end: 0.4rem;
}

.theme-sidebar-tab {
  padding-block: 0.15em;
  padding-inline: 0.45em;
  font: inherit;
  font-size: 0.65rem;
  font-weight: 600;
  color: #9aa3b0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
}

.theme-sidebar-tab:hover {
  color: #e6e7e8;
  background: #252b36;
}

.theme-sidebar-tab[aria-selected="true"] {
  color: #1a2030;
  background: var(--theme-accent);
  border-color: var(--theme-accent);
}

.theme-sidebar-section[hidden] {
  display: none !important;
}

.theme-sidebar-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-block-end: 0.1rem;
}

.theme-sidebar-choices button {
  padding-block: 0.15em;
  padding-inline: 0.4em;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  color: #c8cdd4;
  background: #252b36;
  border: 1px solid #3a4455;
  border-radius: 3px;
  cursor: pointer;
}

.theme-sidebar-choices button[aria-pressed="true"] {
  color: #1a2030;
  background: var(--theme-accent);
  border-color: var(--theme-accent);
}

.theme-sidebar-font-fields {
  display: grid;
  gap: 0.3rem;
  margin-block-end: 0.35rem;
}

.theme-sidebar-font-fields label {
  display: grid;
  gap: 0.1rem;
  font-size: 0.62rem;
  font-weight: 600;
  color: #9aa3b0;
}

.theme-sidebar-font-fields input {
  padding: 0.2em 0.4em;
  font: inherit;
  font-size: 0.68rem;
  color: #e6e7e8;
  background: #252b36;
  border: 1px solid #3a4455;
  border-radius: 3px;
}

.theme-sidebar-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0.45rem 0.65rem 0.65rem;
  color-scheme: dark;
}

.theme-sidebar-editor.theme-editor-light {
  color-scheme: light;
}

.theme-sidebar-editor-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-block-end: 0.35rem;
  min-width: 0;
}

.theme-sidebar-editor-head .theme-editor-label {
  font-size: 0.62rem;
  color: #6e7681;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-editor-scheme {
  display: flex;
  gap: 0.15rem;
}

.theme-editor-scheme button {
  padding: 0.1em 0.35em;
  font: inherit;
  font-size: 0.6rem;
  color: #9aa3b0;
  background: #252b36;
  border: 1px solid #3a4455;
  border-radius: 3px;
  cursor: pointer;
}

.theme-editor-scheme button[aria-pressed="true"] {
  color: #1a2030;
  background: var(--theme-accent);
  border-color: var(--theme-accent);
}

.theme-editor-wrap {
  position: relative;
  flex: 1;
  min-height: 8rem;
  overflow: hidden;
  border: 1px solid var(--theme-editor-border);
  border-radius: 4px;
  background: var(--theme-editor-bg);
}

.theme-editor-wrap pre,
.theme-editor-wrap textarea {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0.5rem;
  overflow: auto;
  font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
  font-size: 0.68rem;
  line-height: 1.45;
  tab-size: 2;
  white-space: pre;
  word-wrap: normal;
}

.theme-editor-wrap pre {
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  color: var(--theme-editor-fg);
}

.theme-editor-wrap pre code {
  display: block;
  min-height: 100%;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  white-space: pre;
  transform: translate(0, 0);
  will-change: transform;
}

.theme-editor-wrap pre code.hljs {
  background: transparent !important;
  padding: 0;
}

.theme-editor-wrap textarea {
  z-index: 1;
  resize: none;
  border: none;
  color: var(--theme-editor-fg);
  caret-color: var(--theme-editor-fg);
  background: transparent;
}

.theme-editor-wrap textarea.theme-editor--highlighted {
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.theme-editor-wrap textarea:focus {
  outline: none;
}

.theme-editor-wrap textarea::selection {
  background: rgba(237, 194, 48, 0.35);
}

.theme-editor-light .theme-editor-wrap {
  --theme-editor-bg: #ffffff;
  --theme-editor-fg: #24292f;
  --theme-editor-border: #d0d7de;
}

#theme-sidebar-fab {
  position: fixed;
  inset-block-start: 50%;
  inset-inline-end: 0;
  z-index: 9998;
  transform: translateY(-50%);
  padding-block: 0.5em;
  padding-inline: 0.35em 0.25em;
  writing-mode: vertical-rl;
  font-family: system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  color: #e6e7e8;
  background: #2a3140;
  border: 1px solid #4a5568;
  border-inline-end: none;
  border-start-start-radius: 4px;
  border-end-start-radius: 4px;
  cursor: pointer;
  box-shadow: -2px 0 12px rgba(0, 0, 0, 0.2);
}

#theme-sidebar-fab:hover {
  background: #343d4f;
  color: var(--theme-accent);
}

#theme-sidebar-fab[hidden] {
  display: none;
}

