/* the easl editor — shares the docs site's palette tokens */

:root {
  --bg: #fdfcfa;
  --bg-raised: #f4f1ec;
  --text: #26282e;
  --text-dim: #6d6f78;
  --accent: #7048c8;
  --accent-soft: #ede7fa;
  --border: #e3dfd7;
  --code-bg: #f0ebdf;
  --error: #c0392b;
  --ok: #2f7a4d;
  --warn: #a35b1e;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --editor-fraction: 0.5;
  --console-fraction: 0.3;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171c;
    --bg-raised: #1e2027;
    --text: #d7dae2;
    --text-dim: #8a8e99;
    --accent: #a98cf0;
    --accent-soft: #2a2440;
    --border: #2a2d36;
    --code-bg: #232733;
    --error: #ff7b72;
    --ok: #7fc79a;
    --warn: #e0a06a;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
}

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

a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

button.primary:hover:not(:disabled) {
  filter: brightness(1.1);
}

button.small {
  padding: 0.1rem 0.5rem;
  font-size: 0.8rem;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---- the bar ---- */

.bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.wordmark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

.page-name {
  color: var(--text-dim);
  margin-left: -0.5rem;
}

/* ---- icons: shapes masked from inline SVG, drawn in the text color ---- */

.tree-icon,
.run-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.tree-icon.file, .run-icon.file {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 1.5h5l3 3V14.5H4z' fill='none' stroke='black' stroke-width='1.3' stroke-linejoin='round'/%3E%3Cpath d='M9 1.5v3h3' fill='none' stroke='black' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.tree-icon.folder, .run-icon.folder {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 3.5h4.5l1.5 1.5h7v8.5h-13z' fill='none' stroke='black' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.tree-icon.new-file, .run-icon.new-file {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 1.5h5l3 3V8M3 1.5V14.5h5' fill='none' stroke='black' stroke-width='1.3' stroke-linejoin='round'/%3E%3Cpath d='M12 10v5M9.5 12.5h5' stroke='black' stroke-width='1.4'/%3E%3C/svg%3E");
}

.tree-icon.new-folder, .run-icon.new-folder {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 3h4.5l1.5 1.5h7V8M1.5 3v10.5h7' fill='none' stroke='black' stroke-width='1.3' stroke-linejoin='round'/%3E%3Cpath d='M12 9.5v5M9.5 12h5' stroke='black' stroke-width='1.4'/%3E%3C/svg%3E");
}

.tree-icon.rename, .run-icon.rename {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.5 13.5l1-3.5 7.5-7.5 2.5 2.5-7.5 7.5z' fill='none' stroke='black' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.tree-icon.delete, .run-icon.delete {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.5 4h11M6 4V2.5h4V4M4 4l.8 10h6.4L12 4' fill='none' stroke='black' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.tree-icon.sidebar, .run-icon.sidebar {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect x='1.5' y='2.5' width='13' height='11' rx='1.5' fill='none' stroke='black' stroke-width='1.3'/%3E%3Cpath d='M6 2.5v11' stroke='black' stroke-width='1.3'/%3E%3C/svg%3E");
}

.tree-icon.play, .run-icon.play, #pause.resume .run-icon {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 2.5l9.5 5.5L4 13.5z' fill='black'/%3E%3C/svg%3E");
}

.tree-icon.pause, .run-icon.pause {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 2.5h3v11h-3zM9.5 2.5h3v11h-3z' fill='black'/%3E%3C/svg%3E");
}

.tree-icon.stop, .run-icon.stop {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect x='3' y='3' width='10' height='10' rx='1' fill='black'/%3E%3C/svg%3E");
}

.run-icon.volume-high {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 6h3l4-3.5v11l-4-3.5h-3z' fill='black'/%3E%3Cpath d='M10.5 5.5c.9.7 1.4 1.5 1.4 2.5s-.5 1.8-1.4 2.5M12.3 3.4c1.5 1.1 2.4 2.7 2.4 4.6s-.9 3.5-2.4 4.6' fill='none' stroke='black' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E");
}

.run-icon.volume-low {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 6h3l4-3.5v11l-4-3.5h-3z' fill='black'/%3E%3Cpath d='M10.5 5.5c.9.7 1.4 1.5 1.4 2.5s-.5 1.8-1.4 2.5' fill='none' stroke='black' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E");
}

.run-icon.volume-muted {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 6h3l4-3.5v11l-4-3.5h-3z' fill='black'/%3E%3Cpath d='M10.5 5.5l4 5M14.5 5.5l-4 5' stroke='black' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E");
}

.run-icon.fullscreen {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 6V2h4M10 2h4v4M14 10v4h-4M6 14H2v-4' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.run-icon.fullscreen-exit {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 2v4H2M14 6h-4V2M10 14v-4h4M2 10h4v4' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.icon-button {
  display: inline-grid;
  place-items: center;
  padding: 0.3rem;
  border: none;
  background: none;
  color: var(--text-dim);
  border-radius: 5px;
}

.icon-button:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg-raised);
}

/* ---- the sketch's title, author, likes, and playlists ---- */

.sketch-heading {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
}

.sketch-title {
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  margin-left: -0.35rem;
  border: 1px solid transparent;
  background: none;
  color: var(--text);
  max-width: 26rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sketch-title:disabled {
  opacity: 1;
  cursor: default;
}

.sketch-title:not(:disabled):hover {
  border-color: var(--border);
}

/* Publish, for the owner's unpublished changes, with a menu (the
   published version) behind its caret. */
.split-button {
  display: flex;
}

.split-button > #publish {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.split-toggle {
  display: grid;
  place-items: center;
  padding: 0.3rem 0.45rem;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 1px solid rgb(0 0 0 / 0.22);
}

.split-toggle:hover:not(:disabled) {
  border-left-color: rgb(0 0 0 / 0.22);
}

.caret {
  width: 0;
  height: 0;
  border-left: 0.25rem solid transparent;
  border-right: 0.25rem solid transparent;
  border-top: 0.3rem solid currentColor;
}

.popover.menu {
  width: max-content;
  min-width: 0;
  padding: 0.3rem;
}

.popover.menu > button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.35rem 0.6rem;
  border: none;
  background: none;
  text-align: left;
  white-space: nowrap;
}

.popover.menu > button:hover:not(:disabled) {
  background: var(--accent-soft);
}

/* Format, and the switch beside it turning Format on save on (up) and off
   (down). */
.format-group {
  display: flex;
}

.format-group > #format {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.format-switch {
  display: grid;
  place-items: center;
  width: 1.45rem;
  padding: 0;
  border-left: none;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.format-switch::before {
  content: "";
  grid-area: 1 / 1;
  box-sizing: border-box;
  width: 0.6rem;
  height: 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--text-dim);
  transition: border-color 0.12s, background 0.12s;
}

.format-switch-knob {
  grid-area: 1 / 1;
  width: 0.36rem;
  height: 0.36rem;
  border-radius: 50%;
  background: var(--text-dim);
  transform: translateY(0.25rem);
  transition: transform 0.12s, background 0.12s;
}

.format-switch[aria-checked="true"]::before {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.format-switch[aria-checked="true"] .format-switch-knob {
  background: var(--accent);
  transform: translateY(-0.25rem);
}

/* The published version, read-only: nothing to change files with. */
body.read-only .explorer-head .icon-button,
body.read-only .tree-actions {
  display: none !important;
}

body.read-only .editor-area::after {
  content: "Published version · read-only";
  position: absolute;
  right: 1.2rem;
  bottom: 0.8rem;
  z-index: 5;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  pointer-events: none;
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.social-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.popover-anchor {
  position: relative;
}

.popover {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 30;
  min-width: 15rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
}

.popover-title {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ---- the byline and likes ---- */

.byline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  min-width: 0;
}

.byline:empty {
  display: none;
}

.author {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text);
  font-weight: 600;
}

.avatar {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  flex: none;
  background: var(--bg-raised);
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.badge.private {
  color: var(--warn);
  border-color: currentColor;
}

.badge.public {
  color: var(--ok);
  border-color: currentColor;
}

.badge-button {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: none;
  cursor: pointer;
}

.badge-button:hover {
  background: var(--bg-raised);
}

.badge-caret {
  font-size: 0.65rem;
}

.visibility-menu {
  min-width: 17rem;
  padding: 0.45rem;
}

.visibility-menu .popover-title {
  margin: 0.15rem 0.35rem 0.35rem;
}

.visibility-choice {
  display: grid;
  width: 100%;
  gap: 0.1rem;
  padding: 0.4rem 0.5rem;
  border: none;
  border-radius: 6px;
  background: none;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
}

.visibility-choice:hover {
  background: var(--accent-soft);
}

.visibility-choice .visibility-help {
  grid-column: 1;
}

.visibility-choice.current .visibility-name::after {
  content: " ✓";
  color: var(--accent);
}

.like,
.playlist-button {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
}

.like-count {
  color: var(--text-dim);
  padding-left: 0.3rem;
  border-left: 1px solid var(--border);
}

.like.liked {
  border-color: #e2457a;
  color: #e2457a;
}

.like .like-heart {
  color: var(--text-dim);
  transition: transform 0.15s;
}

.like.liked .like-heart {
  color: #e2457a;
}

.like:active .like-heart {
  transform: scale(1.3);
}

/* ---- the account ---- */

.account {
  position: relative;
}

.account-button {
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: none;
  display: grid;
}

.account-button .avatar {
  width: 1.9rem;
  height: 1.9rem;
}

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

.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 30;
  min-width: 10rem;
  display: flex;
  flex-direction: column;
  padding: 0.25rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
}

.account-menu[hidden] {
  display: none;
}

.account-menu a,
.account-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.6rem;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text);
  font-size: 0.9rem;
}

.account-menu a:hover,
.account-menu button:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

.account-menu form {
  margin: 0;
}

.status {
  font-size: 0.85rem;
  border-color: transparent;
  background: none;
  color: var(--text-dim);
}

.status[data-kind="ok"] {
  color: var(--ok);
}

.status[data-kind="errors"] {
  color: var(--error);
}

.status[data-kind="failure"] {
  color: var(--warn);
}

.status::before {
  content: "●";
  margin-right: 0.35rem;
  font-size: 0.7em;
  vertical-align: 0.1em;
}

.links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

button.icon {
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  border-radius: 50%;
  font-weight: 700;
}

/* ---- the panes ---- */

.panes {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns:
    minmax(0, calc(var(--editor-fraction) * 100%))
    6px
    minmax(0, 1fr);
}

/* The file explorer beside the editor (collapsible), and the editor's
   column: the open files' tabs above the editor. */
.editor-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  /* Until the visitor drags it, the explorer is as narrow as its names
     allow, up to a limit. */
  grid-template-columns:
    var(--explorer-width, fit-content(13rem))
    6px
    minmax(0, 1fr);
}

body.explorer-closed .editor-pane {
  grid-template-columns: minmax(0, 1fr);
}

body.explorer-closed .explorer,
body.explorer-closed #explorer-splitter {
  display: none;
}

/* A collapsed explorer slides out over the editor while the pointer is at
   the window's left edge (the zone), and goes away when it leaves. */
.explorer-peek-zone {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 10px;
  z-index: 15;
}

body.explorer-closed .explorer-peek-zone {
  display: block;
}

body.explorer-closed.explorer-peeking .explorer {
  display: block;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 16;
  width: var(--explorer-width, max-content);
  max-width: var(--explorer-width, 13rem);
  box-shadow: 4px 0 18px rgb(0 0 0 / 0.25);
  animation: explorer-slide 0.12s ease-out;
}

@keyframes explorer-slide {
  from {
    transform: translateX(-30%);
    opacity: 0;
  }
}

.editor-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.editor-area {
  position: relative;
  min-height: 0;
}

.editor {
  position: absolute;
  inset: 0;
  color: var(--text-dim);
}

.editor-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--text-dim);
  background: var(--bg);
}

/* ---- the file explorer ---- */

.explorer {
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--border);
  background: var(--bg-raised);
  font-size: 0.85rem;
}

.explorer-head {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  padding: 0.25rem 0.15rem 0.25rem 0.45rem;
  position: sticky;
  top: 0;
  background: var(--bg-raised);
}

.explorer-title {
  margin-right: auto;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.tree {
  list-style: none;
  margin: 0;
  padding: 0 0 0.6rem;
}

/* Rows are compact: a folder's chevron is all that comes before a name,
   and the row's buttons (shown on hover) lie over its end rather than
   taking room from the name. */
.tree-row {
  --row-bg: var(--bg-raised);
  position: relative;
  display: flex;
  align-items: center;
  padding-left: calc(0.15rem + var(--depth) * 0.7rem);
  background: var(--row-bg);
}

.tree-row:hover {
  --row-bg: color-mix(in srgb, var(--text) 7%, var(--bg-raised));
}

.tree-row.active {
  --row-bg: var(--accent-soft);
}

.tree-name {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.3rem 0.2rem 0;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
  text-align: left;
  white-space: nowrap;
}

.tree-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-row.active .tree-name {
  color: var(--accent);
  font-weight: 600;
}

.tree-row.has-problems .tree-name::after {
  content: "●";
  color: var(--error);
  font-size: 0.55rem;
}

/* Dragging rows: where a dropped row would go. */
.tree-row.dragging {
  opacity: 0.45;
}

.tree-row.drop-before {
  box-shadow: inset 0 2px 0 var(--accent);
}

.tree-row.drop-after {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.tree-row.drop-into {
  --row-bg: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.tree.drop-end {
  box-shadow: 0 2px 0 var(--accent);
}

.tree-row.folder .tree-label {
  color: var(--text-dim);
}

.tree-chevron {
  width: 0.65rem;
  flex: none;
  color: var(--text-dim);
  font-size: 0.6rem;
  text-align: center;
}

.tree.flat .tree-chevron.none {
  width: 0.2rem;
}

.tree-chevron::before {
  content: "▸";
}

.tree-chevron.open::before {
  content: "▾";
}

.tree-chevron.none::before {
  content: "";
}

.tree-entry {
  color: var(--ok);
  font-size: 0.55rem;
}

.tree-actions {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  padding: 0 0.15rem 0 0.9rem;
  background: linear-gradient(to right, transparent, var(--row-bg) 0.8rem);
}

.tree-actions .icon-button {
  padding: 0.2rem;
  font-size: 0.75rem;
}

.tree-row:hover .tree-actions,
.tree-actions:focus-within {
  display: flex;
}

.tab-strip {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  min-height: 2rem;
}

.explorer-toggle {
  flex: none;
  padding: 0 0.6rem;
  border-radius: 0;
  border-right: 1px solid var(--border);
}

body:not(.explorer-closed) .explorer-toggle {
  color: var(--accent);
}

/* ---- file tabs ---- */

.file-tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  scrollbar-width: thin;
}

.file-tab {
  display: flex;
  align-items: center;
  border-right: 1px solid var(--border);
  color: var(--text-dim);
  flex: none;
}

.file-tab.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.file-select {
  border: none;
  background: none;
  border-radius: 0;
  padding: 0.35rem 0.4rem 0.35rem 0.8rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: inherit;
}

.file-tab:only-of-type .file-select {
  padding-right: 0.8rem;
}

.file-dir {
  color: var(--text-dim);
}

.file-tab.has-problems .file-name::after {
  content: "●";
  color: var(--error);
  font-size: 0.6rem;
  margin-left: 0.35rem;
  vertical-align: 0.15em;
}

.file-close {
  border: none;
  background: none;
  padding: 0 0.5rem 0 0.2rem;
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1;
  opacity: 0;
}

.file-tab:hover .file-close,
.file-tab.active .file-close,
.file-close:focus-visible {
  opacity: 1;
}

.file-close:hover {
  color: var(--error);
}

.file-add {
  border: none;
  background: none;
  border-radius: 0;
  padding: 0.3rem 0.8rem;
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1;
}

.file-add:hover {
  color: var(--accent);
}

/* The ▶ in the editor's gutter beside each @cpu entry point. */
.entry-glyph {
  cursor: pointer;
}

.entry-glyph::before {
  content: "▶";
  display: block;
  font-size: 0.7rem;
  line-height: 20px;
  text-align: center;
  color: var(--text-dim);
  opacity: 0.75;
}

.entry-glyph.current::before,
.entry-glyph:hover::before {
  color: var(--ok);
  opacity: 1;
}

.splitter {
  cursor: col-resize;
  background: var(--border);
  touch-action: none;
}

.splitter:hover,
.splitter.active {
  background: var(--accent);
}

.splitter.horizontal {
  cursor: row-resize;
}

/* iframes swallow the pointer while dragging */
.dragging iframe {
  pointer-events: none;
}

/* The output: the playlist and entry point bars, the canvas, and the
   panels under it (with their splitter and tabs), which take
   --console-fraction of the pane (dragging can collapse them to their
   tabs). */
.output-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.stage:fullscreen {
  width: 100vw;
  height: 100vh;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
}

.output-pane > .splitter {
  flex: 0 0 6px;
}

.panels {
  flex: 0 0 calc(var(--console-fraction) * 100%);
  min-height: 0;
  position: relative;
}

.panel {
  position: absolute;
  inset: 0;
  overflow: auto;
}

/* ---- the run bar: run, pause, stop; the entry points ---- */

.run-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  min-height: 2.25rem;
  box-sizing: border-box;
}

.run-controls {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: none;
}

.run-controls .icon-button {
  font-size: 0.85rem;
  padding: 0.35rem 0.45rem;
}

.run-divider {
  width: 1px;
  height: 1rem;
  margin: 0 0.25rem;
  background: var(--border);
}

/* The volume: the speaker mutes and unmutes, and hovering it shows a
   vertical slider below it. */
.volume {
  position: relative;
  display: flex;
}

.volume-popover {
  position: absolute;
  top: 100%;
  left: 50%;
  z-index: 25;
  display: none;
  padding: 0.6rem 0.45rem 0.5rem;
  transform: translateX(-50%);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
}

/* The gap between the icon and the popover is part of the popover, so the
   pointer can cross it without the popover closing. */
.volume-popover::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 0.4rem;
}

.volume:hover .volume-popover,
.volume:focus-within .volume-popover {
  display: block;
}

.volume-slider {
  display: block;
  writing-mode: vertical-lr;
  direction: rtl;
  width: 1.1rem;
  height: 6rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.run-button {
  color: var(--ok) !important;
}

.run-button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ok) 15%, transparent) !important;
}

.entries {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.3rem;
  overflow-x: auto;
  font-size: 0.8rem;
}

.entry-select-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-dim);
}

.entry-select {
  font: inherit;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
  max-width: 16rem;
}

.entry {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.78rem;
  background: none;
}

.entry.current {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.entry-play {
  font-size: 0.6rem;
}

.entry-file {
  color: var(--text-dim);
  font-weight: normal;
}

.entries-empty {
  color: var(--text-dim);
  padding: 0 0.3rem;
}

/* ---- playlists ---- */

.playlist-nav {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--accent-soft);
}

.playlist-nav[hidden] {
  display: none;
}

.playlist-name {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-position {
  color: var(--text-dim);
  margin-right: auto;
}

.playlist-nav .disabled {
  color: var(--text-dim);
  opacity: 0.5;
}

/* ---- the notice ---- */

.notice {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
}

.notice[hidden] {
  display: none;
}

.notice span {
  margin-right: auto;
}

.stage iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.stage-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  color: #8a8e99;
}

.stage-message p {
  display: none;
  max-width: 28rem;
  margin: 0;
}

body[data-run="stopped"] .idle-message,
body[data-run="finished"] .idle-message,
body[data-run="checking"] .checking-message,
body.no-webgpu .no-webgpu-message {
  display: block;
}

body.no-webgpu .idle-message {
  display: none;
}

.panel-bar {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0 0.5rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-dim);
  flex: none;
  min-height: 2.1rem;
}

.panel-tab {
  white-space: nowrap;
  border: none;
  border-radius: 0;
  background: none;
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  box-shadow: inset 0 -2px 0 transparent;
}

.panel-tab.active {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.panel-tab .count:not(:empty) {
  margin-left: 0.2rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--bg-raised);
  font-weight: normal;
}

.console-hint {
  font-weight: normal;
  margin: 0 0.5rem 0 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.console-wrap {
  background: var(--code-bg);
}

/* ---- the about panel ---- */

.about-panel,
.comments-panel {
  padding: 0.9rem 1rem 1.2rem;
  font-size: 0.9rem;
}

.about-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.about-title {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
}

.about-meta,
.about-stats {
  margin: 0.45rem 0 0;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.about-description {
  margin: 0.8rem 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.about-note {
  margin: 0.6rem 0 0;
  color: var(--text-dim);
}

.about-note.error {
  color: var(--error);
}

.about-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.9rem;
}

.field-label {
  display: block;
  margin: 0.9rem 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.description-field,
.comment-field {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin-top: 0.35rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  resize: vertical;
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
}

.description-field:focus,
.comment-field:focus {
  outline: none;
  border-color: var(--accent);
}

.field-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.field-status {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.visibility {
  border: none;
  margin: 0;
  padding: 0;
}

.visibility-option {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.5rem;
  align-items: baseline;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.visibility-option:hover {
  background: var(--bg-raised);
}

.visibility-option input {
  accent-color: var(--accent);
  margin: 0;
}

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

.visibility-help {
  grid-column: 2;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.popover > button {
  margin-top: 0.4rem;
}

.playlist-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
}

.playlist-row input {
  accent-color: var(--accent);
}

.playlist-open {
  margin-left: auto;
  font-size: 0.8rem;
}

/* ---- comments ---- */

.comments {
  list-style: none;
  margin: 0;
  padding: 0;
}

.comment {
  display: flex;
  gap: 0.6rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.comment-avatar .avatar {
  width: 1.8rem;
  height: 1.8rem;
}

.comment-main {
  min-width: 0;
  flex: 1;
}

.comment-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.comment-time {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.comment-delete {
  margin-left: auto;
  opacity: 0;
}

.comment:hover .comment-delete,
.comment-delete:focus-visible {
  opacity: 1;
}

.comment-body {
  margin-top: 0.2rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.comments-empty,
.comment-signin {
  color: var(--text-dim);
  padding: 0.6rem 0;
  margin: 0;
}

.comment-form {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  margin-top: 0.8rem;
}

/* ---- toasts ---- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  pointer-events: none;
}

.toast {
  max-width: min(32rem, calc(100vw - 2rem));
  padding: 0.55rem 1rem;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
  transition: opacity 0.4s, transform 0.4s;
}

.toast.error {
  background: var(--error);
  color: #fff;
}

.toast.leaving {
  opacity: 0;
  transform: translateY(0.4rem);
}

.console {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 0.5rem 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.console-empty {
  margin: 0;
  padding: 0.5rem 0.8rem;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.line-link {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}

.console .error {
  color: var(--error);
}

.console .info {
  color: var(--text-dim);
}

/* ---- the help dialog ---- */

.help {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  padding: 1.2rem 1.4rem;
  max-width: 34rem;
}

.help::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.help h2 {
  margin: 0 0 0.8rem;
  font-size: 1.1rem;
}

.help table {
  border-collapse: collapse;
  width: 100%;
}

.help td {
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--border);
}

.help td:last-child {
  text-align: right;
  white-space: nowrap;
}

.help kbd {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.help p {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.help form {
  text-align: right;
}

.prompt {
  width: min(26rem, calc(100vw - 2rem));
  box-sizing: border-box;
}

.prompt form {
  text-align: left;
}

.prompt-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.prompt-error {
  min-height: 1.2em;
  margin: 0.4rem 0 0;
  color: var(--error) !important;
}

.prompt input {
  box-sizing: border-box;
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
}

.prompt input:focus {
  outline: none;
  border-color: var(--accent);
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.9rem;
}

/* ---- small screens: editor above, output below ---- */

@media (max-width: 52rem) {
  .panes {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows:
      minmax(0, calc(var(--editor-fraction) * 100%))
      6px
      minmax(0, 1fr);
  }

  .splitter {
    cursor: row-resize;
  }

  .links {
    margin-left: 0;
  }
}

/* ---- phones: the essentials only ---- */

@media (max-width: 40rem) {
  .bar {
    gap: 0.4rem 0.6rem;
    padding: 0.45rem 0.75rem;
  }

  .format-group,
  .console-hint,
  .byline-by {
    display: none;
  }

  .links {
    gap: 0.6rem;
  }
}

/* ---- tags ---- */

.tag-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.7rem 0 0;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  line-height: 1.5;
  text-decoration: none;
}

.tag-chip a {
  color: inherit;
  text-decoration: none;
}

a.tag-chip:hover,
.tag-chip a:hover {
  text-decoration: underline;
}

.tag-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  box-sizing: border-box;
  width: 100%;
  min-height: 2.1rem;
  padding: 0.25rem 0.35rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: text;
}

.tag-editor:focus-within {
  border-color: var(--accent);
}

.tag-chips {
  display: contents;
}

.tag-editor .tag-chip {
  padding-right: 0.2rem;
}

.tag-remove {
  padding: 0 0.25rem;
  border: none;
  border-radius: 999px;
  background: none;
  color: inherit;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
}

.tag-remove:hover {
  opacity: 1;
  background: none;
}

.tag-field {
  flex: 1;
  min-width: 7rem;
  padding: 0.15rem 0.2rem;
  border: none;
  outline: none;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}

.tag-field[hidden] {
  display: none;
}
