:root {
  --webishell-wave-opacity: 0.16;
}

[hidden] {
  display: none !important;
}

#wasp {
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    visibility 180ms linear;
}

.prompt-line {
  width: max-content;
  max-width: 100%;
  padding: 0.25rem 0;
  border: 0;
  border-radius: 0;
  cursor: text;
  text-align: left;
}

body.is-webishell {
  height: auto;
  min-height: 100dvh;
  padding-top: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

body.is-webishell #wasp {
  position: fixed;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.5rem);
  pointer-events: none;
}

body .ascii-wave {
  transition: opacity 180ms ease;
}

body.is-webishell .ascii-wave {
  opacity: 0;
}

body.is-webishell.webishell-wave-on .ascii-wave {
  opacity: var(--webishell-wave-opacity);
}

.webishell-terminal {
  position: relative;
  z-index: 3;
  width: min(calc(100vw - 2rem), 118ch);
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(0.85rem, 3vh, 1.75rem) 0 2rem;
  color: var(--text);
  font: inherit;
  opacity: 0;
  transform: translateY(0.6rem);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  text-shadow:
    0 1px 14px rgba(0, 0, 0, 0.95),
    0 0 16px rgba(0, 0, 0, 0.78);
}

.webishell-terminal.is-active {
  opacity: 1;
  transform: none;
}

.webishell-output {
  display: grid;
  gap: 0.36rem;
}

.webishell-command,
.webishell-input-line {
  display: flex;
  align-items: baseline;
  min-width: 0;
}

.webishell-command {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.webishell-command-prompt,
.webishell-input-prompt {
  flex: none;
  color: var(--strong);
  white-space: pre;
}

.webishell-input-line {
  position: relative;
  margin-top: 0.45rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

.webishell-input {
  flex: 1;
  min-width: 1ch;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--strong);
  caret-color: var(--strong);
  font: inherit;
  line-height: inherit;
  text-shadow: inherit;
}

.webishell-input:disabled,
.webishell-input:read-only {
  opacity: 0.7;
}

.webishell-input-cursor {
  display: none;
}

.webishell-result,
.webishell-ascii,
.webishell-fetch-logo,
.webishell-fetch-info {
  max-width: 100%;
  margin: 0;
  color: inherit;
  font: inherit;
  line-height: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.webishell-result-error {
  color: var(--strong);
  border-left: 1px solid var(--faint);
  padding-left: 0.65rem;
}

.webishell-result-warning {
  color: var(--muted);
}

.webishell-ascii-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scrollbar-color: var(--faint) transparent;
}

.webishell-ascii {
  width: max-content;
  max-width: none;
  min-width: max-content;
  line-height: 1;
  white-space: pre;
  overflow-wrap: normal;
}

.webishell-ascii.is-large {
  font-size: inherit;
}

.webishell-fetch {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: start;
  gap: 1.4rem;
  max-width: 100%;
  overflow-x: auto;
}

.webishell-fetch-logo,
.webishell-fetch-info {
  width: max-content;
  max-width: none;
  line-height: 1.05;
  white-space: pre;
  overflow-wrap: normal;
}

.webishell-editor {
  --editor-blue: #00113f;
  --editor-blue-active: #173975;
  --editor-chrome: #a7a9b3;
  position: fixed;
  z-index: 20;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  border: 0;
  background: #050505;
  text-shadow: none;
}

.webishell-editor-title {
  flex: none;
  min-height: 1.75rem;
  padding: 0.2rem 0.65rem;
  overflow: hidden;
  background: #e2e2e2;
  color: #111;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: pre;
}

.webishell-editor[data-frontend="edit"] .webishell-editor-title {
  display: none;
}

.webishell-editor-menu {
  position: relative;
  z-index: 3;
  display: flex;
  flex: none;
  align-items: stretch;
  min-height: 2.5rem;
  overflow: visible;
  background: var(--editor-blue);
  color: var(--editor-chrome);
}

.webishell-editor-menu > button,
.webishell-editor-menu-panel button,
.webishell-editor-shortcuts button,
.webishell-editor-touchbar button,
.webishell-editor-prompt-actions button {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.webishell-editor-menu > button {
  padding: 0.25rem 0.75rem;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.webishell-editor-menu > button:is(:hover, :focus-visible, [aria-expanded="true"]) {
  outline: 0;
  background: #dadada;
  color: #101010;
}

.webishell-editor-menu-panel {
  position: absolute;
  z-index: 6;
  top: 100%;
  left: 0;
  display: grid;
  min-width: 18rem;
  padding: 0.2rem;
  border: 1px solid #eee;
  background: #3f3f3f;
  box-shadow: 0 0.45rem 1.2rem rgba(0, 0, 0, 0.65);
  color: #f4f4f4;
}

.webishell-editor-menu-panel button {
  padding: 0.32rem 0.7rem;
  text-align: left;
  white-space: pre;
}

.webishell-editor-menu-panel button:is(:hover, :focus-visible) {
  outline: 0;
  background: #e5e5e5;
  color: #111;
}

.webishell-editor-workspace {
  display: grid;
  flex: 1;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  background: #050505;
}

.webishell-editor-lines {
  display: none;
  min-width: 4ch;
  height: 100%;
  margin: 0;
  padding: 0.55rem 0.65rem 0.55rem 0.4rem;
  overflow: hidden;
  border-right: 1px solid #2a2a2a;
  color: #777;
  font: inherit;
  line-height: 1.35;
  text-align: right;
  user-select: none;
}

.webishell-editor[data-frontend="edit"] .webishell-editor-lines {
  display: block;
}

.webishell-editor-buffer {
  width: 100%;
  min-height: 0;
  padding: 0.55rem 0.7rem;
  resize: none;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: #050505;
  color: #ececec;
  caret-color: #fff;
  font: inherit;
  line-height: 1.35;
  tab-size: 4;
  white-space: pre;
  overflow: auto;
}

.webishell-editor.is-wrapped .webishell-editor-buffer {
  white-space: pre-wrap;
}

.webishell-editor-message {
  flex: none;
  min-height: 1.65rem;
  padding: 0.15rem 0.65rem;
  overflow: hidden;
  color: #e5e5e5;
  text-align: center;
  text-overflow: ellipsis;
  white-space: pre-wrap;
}

.webishell-editor[data-frontend="edit"] .webishell-editor-message {
  min-height: 0;
  padding-block: 0;
  color: var(--editor-chrome);
}

.webishell-editor-prompt {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.35rem 0.65rem;
  border-top: 1px solid var(--border);
  background: #050505;
  color: #ececec;
}

.webishell-editor-prompt > label {
  flex: none;
  white-space: pre-line;
}

.webishell-editor-search {
  flex: 1;
  min-width: 4ch;
  padding: 0.15rem 0.25rem;
  border: 0;
  border-bottom: 1px solid currentColor;
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.webishell-editor-prompt-actions {
  display: flex;
  flex: none;
  gap: 0.4rem;
}

.webishell-editor-prompt-actions button {
  padding: 0.16rem 0.45rem;
  border: 1px solid currentColor;
}

.webishell-editor-prompt-actions button:is(:hover, :focus-visible) {
  outline: 0;
  background: #e5e5e5;
  color: #111;
}

.webishell-editor[data-frontend="edit"] .webishell-editor-prompt[data-kind="exit"],
.webishell-editor[data-frontend="edit"] .webishell-editor-prompt[data-kind="about"] {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 50%;
  display: grid;
  width: min(90vw, 48rem);
  min-height: 12rem;
  padding: 1.15rem;
  transform: translate(-50%, -50%);
  border: 3px double #f5f5f5;
  background: #444;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.68);
  color: #fff;
  place-content: center;
  text-align: center;
}

.webishell-editor[data-frontend="edit"] .webishell-editor-prompt[data-kind="exit"] .webishell-editor-prompt-actions,
.webishell-editor[data-frontend="edit"] .webishell-editor-prompt[data-kind="about"] .webishell-editor-prompt-actions {
  justify-content: center;
}

.webishell-editor-status {
  display: flex;
  flex: none;
  justify-content: center;
  min-height: 1.7rem;
  padding: 0.18rem 0.65rem;
  overflow: hidden;
  color: #e5e5e5;
  white-space: nowrap;
}

.webishell-editor[data-frontend="edit"] .webishell-editor-status {
  justify-content: space-between;
  background: var(--editor-blue);
  color: var(--editor-chrome);
}

.webishell-editor-status-details,
.webishell-editor-status-filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.webishell-editor-status-filename {
  margin-left: 1rem;
}

.webishell-editor-shortcuts {
  display: grid;
  flex: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 3.3rem;
  padding: 0.2rem 0.35rem;
  background: #050505;
  color: #ececec;
}

.webishell-editor-shortcuts button {
  overflow: hidden;
  padding: 0.06rem 0.25rem;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.webishell-editor-shortcuts button:is(:hover, :focus-visible) {
  outline: 1px solid currentColor;
}

.webishell-editor[data-frontend="edit"] .webishell-editor-shortcuts {
  display: none;
}

.webishell-editor-touchbar {
  display: none;
  flex: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid #3d3d3d;
  background: #111;
  color: #ddd;
}

.webishell-editor-touchbar button {
  min-height: 2.6rem;
  border-right: 1px solid #3d3d3d;
}

@media (max-width: 768px) {
  .webishell-terminal {
    width: calc(100vw - 1.5rem);
    padding-top: 0.75rem;
  }

  .webishell-fetch {
    display: block;
  }

  .webishell-fetch-info {
    margin-top: 0.85rem;
  }

  .webishell-editor {
    height: 100dvh;
    min-height: 0;
  }

  .webishell-editor-prompt {
    flex-wrap: wrap;
  }

  .webishell-editor-shortcuts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .webishell-editor-touchbar {
    display: grid;
  }
}

@media (max-width: 480px) {
  .webishell-terminal {
    width: calc(100vw - 1rem);
    padding-top: 0.5rem;
  }

  .webishell-editor-title,
  .webishell-editor-status,
  .webishell-editor-prompt {
    padding-inline: 0.4rem;
  }

  .webishell-editor-lines {
    min-width: 3ch;
    padding-inline: 0.25rem 0.4rem;
  }

  .webishell-editor-shortcuts {
    display: none;
  }
}

@media (pointer: coarse) {
  .webishell-editor-touchbar {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  #wasp,
  body .ascii-wave,
  .webishell-terminal {
    transition: none;
  }
}
