:root {
    --color-window: #FFFAD9;
    --color-leaf: #BAFCDE;
    --color-branch: #C9DCFF;
    --color-root: #FFD1D1;
    --color-leaf-saturated: #00D7A1;
    --color-branch-saturated: #6EA8FF;
    --color-root-saturated: #FF8888;
    --color-black: #000000;
    --color-grey: #E8E8E8;
    --color-cancel: red;
    --color-highlight: yellow;
    --color-hovered: #C9DCFF;
    --color-menu: #F1FCFF;
    --color-error: pink;
    --color-info: lightblue;
    --color-submit: green;
    --color-text: black;
    --color-textbox: white;
    --color-grab: rgb(230,230,230);
    --color-action: rgb(240,240,240);
    --color-selected: lightgreen;
    --color-selected-text: rgb(150,150,150);
    --color-toolbar: rgb(180,180,180);
    --thickness: 3.5pt;
    --resize: 0.7rem;
}
html, body {
    margin: 0;
    padding: 0;
    font-family: "Instrument Sans", sans-serif;
}
* {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
body {
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}
input[type="text"] { padding: 0; border: none; outline: none; font-size: inherit; } /* from https://stackoverflow.com/a/6520729 */
input[type="text"]:hover { outline: none; }
#body, #body > div {
    position: absolute;
    top: 0;
    left: 0;
    height: 100vh;
    width: 100vw;
}
button.noDefault {
    border: 0;
    padding: 0;
    margin: 0;
    overflow: visible;
    background: none;
    box-shadow: none;
}
#inputPane {
    display: flex;
    flex-direction: row;
    padding: 0;
    box-sizing: border-box;
    pointer-events: none;
}
#leftPane {
    flex-grow: 1;
    flex-shrink: 1;
    position: relative;
    overflow: none;
    pointer-events: auto;
}
#leftPane.closed {
    pointer-events: none;
}
#leftPane > * {
    pointer-events: auto;
}
#rightPane {
    display: block;
    position: relative;
    background-color: var(--color-menu);
    pointer-events: auto;
    overflow: hidden;
    max-width: min(100%, 25rem);
    transition: max-width 0.5s ease-out;
}
span.space {
    display: inline-block;
    width: 0.5rem;
}
.submitable {
    color: var(--color-submit);
}
.cancelable {
    color: var(--color-cancel);
}
.helpable {
    color: var(--color-menu);
}
.reminder {
    text-decoration: underline;
}
.clickable {
    cursor: pointer;
}
.clickable:hover {
    color: var(--color-hovered);
}
.clickableNoHover {
    cursor: pointer;
}
.clickableNoCursor:hover {
    color: var(--color-hovered)
}
/* Text bar */
.input {
    font-size: 3rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translateX(-50%) translateY(-50%);
    width: 70dvw;
    max-height: 75dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-items: center;
    border: var(--color-black) var(--thickness) solid;
    background-color: var(--color-window);
    border-radius: 2rem;
}
.textbar {
    min-width: 0;
    flex-shrink: 0;
    flex-grow: 0;
    padding: 0 1rem;
    min-height: 1em;
    gap: 0.2em;
    display: flex;
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: start;
    overflow: hidden;
}
.textbar::before, .textbar::after {
    display: block;
    width: 0.4rem;
    content: ""
}
.textbar > svg {
    flex-grow: 1;
    flex-shrink: 1;
    max-height: 1.5em;
    width: 1.5em;
}
.textbar .submit {
    border-radius: 1rem;
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
    flex-grow: 1;
    flex-shrink: 1;
    font-size: 2rem;
    min-width: 0;
    border: var(--thickness) var(--color-black) solid;
    color: var(--color-black);
    background-color: var(--color-grey);
    cursor: pointer;
}
.textbar .submit:hover {
    color: var(--color-hovered);
}
.inputSeparator {
    display: block;
    content: "";
    height: var(--thickness);
    flex-shrink: 0;
    flex-grow: 0;
    width: 90%;
    margin: 0 auto;
    border-radius: var(--thickness);
    background-color: var(--color-black);
}
.suggestions {
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.suggestions ul {
    position: relative;
    list-style: none;
    overflow-y: scroll;
    min-height: 0;
    flex-shrink: 1;
    flex-grow: 1;
    width: 100%;
    padding: 1rem;
    padding-top: 0;
    margin: 0;
    box-sizing: border-box;
    color: var(--color-branch-saturated);
}
.suggestions ul > li {
    position: relative;
    text-wrap: nowrap;
    height: 1em;
    margin: 1rem 0;
    align-content: center;
}
.suggestions > ul svg {
    height: 1em;
}
.suggestions > ul a {
    margin-left: 1rem;
}
.textbar .mathInput {
    flex-grow: 10;
    flex-shrink: 10;
    min-width: 0;
    border: none;
}
.mathInput {
    width: 100%;
    font-size: 2em;
    padding: 0.5rem;
    position: relative;
    box-sizing: border-box;
    display: block;
    border: var(--thickness) var(--color-text) solid;
    border-radius: 0.3em;
}
.mathInput > input {
    display: block;
    box-sizing: border-box;
    background-color: transparent;
    height: 1em;
    width: 100%;
    caret-color: transparent;
}
.mathInput > .placeholder {
    position: absolute;
    top: 0.5rem; /* padding of mathinput */
    left: 0.5rem;
    height: 2.5em;
    line-height: 2.5em;
    font-size: 0.4em;
    color: lightgrey;
    vertical-align: middle;
    pointer-events: none;
}
.mathInput > svg {
    display: block;
    position: absolute;
    box-sizing: border-box;
    margin: 0;
    padding: 0.1em;
    top: 0.5rem;
    left: 0.5rem;
    height: 1em;
    max-width: calc(100% - 1rem);
}
.mathHint {
    font-size: 0.2em;
    padding: 0;
    text-align: center;
    margin: 0;
    height: 1.5em;
    overflow: hidden;
}
.mathPopup {
    width: 100%;
    box-sizing: border-box;
    height: 1em;
    font-size: 0.8em;
    min-width: 0;
    display: block;
    position: relative;
    overflow: hidden;
}
.mathPopup > .holder {
    display: flex;
    flex-direction: row;
    width: calc(100% - 2px);  /* this prevents the .scrollMask from showing 1 pixel on each end */
    gap: 0.5rem;
    margin-left: 1px;
    margin-right: 1px;
    align-items: center;
    justify-items: center;
    overflow-x: scroll;
    overflow-y: hidden;
}
.holder .space, .actions .space {
    display: block;
    flex-shrink: 0;
    flex-grow: 0;
    width: 10%;
}
.textbar .mathPopup .scrollMask {
    background-image: linear-gradient(to right, transparent 90%, var(--color-window));
    height: 1em;
}
.mathPopup svg {
    display: block;
    margin: 0;
    padding: 0;
    height: 1em;
}
/* Menu */
#logo {
    position: absolute;
    top: 1rem;
    left: 1rem;
    height: 2.5rem;
}
#menuToggle {
    position: absolute;
    height: 2rem;
    top: 0.9rem;
    right: 0.9rem;
}
#rightPane.closed {
    max-width: 0;
    transition: max-width 0.5s ease-out;
}
#closeMenu {
    height: 2rem;
    margin: 1rem;
}
#menu {
    position: relative;
    display: block;
    max-height: 100%;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    box-sizing: border-box;
    overflow-x: clip;
    overflow-y: scroll;
}
#menu ul {
    display: flex;
    width: min(100%, 25rem);
    flex-direction: column;
    box-sizing: border-box;
    margin: 0;
    padding: 0 0 0 1.5rem;
}
#menu * {
    margin: 0;
    padding: 0;
}
#menu p {
    vertical-align: middle;
    height: 1rem;
}
#menu li {
    list-style: none;
    overflow-x: scroll;
    white-space: nowrap;
}
#menu svg {
    height: 100%;
}
.menuTitle {
    width: 100%;
    display: flex;
    flex-direction: row;
    height: 2rem;
    vertical-align: middle;
    margin: 0;
}
.menuTitle > h1 {
    text-decoration: underline;
    text-wrap: nowrap;
    font-weight: normal;
}
.menuTitle > h1::before {
    content: "";
    background-image: url(../img/arrow.svg);
    display: inline-block;
    vertical-align: middle;
    height: 1rem;
    width: 1rem;
    margin: 0.5rem;
    rotate: 0;
    transition: rotate 0.5s linear;
}
.menuTitle.shown > h1::before {
    rotate: 90deg;
    transition: rotate 0.5s linear;
}
#menu .menuAction {
    margin-right: 1rem;
    margin-left: auto;
    justify-self: end;
    font-size: 1.5rem;
    height: 2rem;
}
.subMenu {
    padding-left: 1rem;
    box-sizing: border-box;
    height: 0;
    overflow: hidden;
    transition: height 0.5s ease-out;
}
.subMenu.shown {
    height: auto;
    height: calc-size(auto); /* Only a few limited browsers support this for now */
    transition: height 0.5s ease-out;
}
.equationMenu * {
    height: 100%;
    white-space: nowrap;
}
#menu li.equationMenu {
    height: 1rem;
    width: 100%;
    display: flex;
    flex-direction: row;
    overflow-x: scroll;
}
/* Notifications */
#notification {
    height: 100%;
    display: flex;
    pointer-events: none;
    flex-direction: column;
    align-items: center;
}
.notificationMessage {
    position: relative;
    display: block;
    width: 80vw;
    overflow-y: scroll;
    text-align: center;
    margin: 0.2rem 0;
    padding: 0 0.2rem;
    border-radius: 0.5rem;
    pointer-events: auto;
}
.notificationMessage * {
    -webkit-user-select: text;
    user-select: text;
}
.notificationError {
    background-color: var(--color-error);
}
.notificationError svg {
    color: var(--color-cancel);
}
.notificationInfo {
    background-color: var(--color-info);
}
.notificationInfo svg {
    color: var(--color-menu);
}
.notificationMessage > svg {
    float: right;
    padding: auto 0;
    width: 1rem;
    height: 100%;
}
.notificationMessage >pre {
    float: left;
    margin: 0.2rem 0;
    max-width: 90%;
    text-wrap: wrap;
    padding: 0;
    vertical-align: center;
}
/* Dialog*/
dialog {
    position: absolute;
    top: 50vh ;
    left: 50vw;
    margin: 0;
    transform: translateY(-50%) translateX(-50%);
    overflow-y: scroll;
    max-height: 90vh;
    max-width: 80vw;
}
dialog > form {
    display: flex;
    flex-direction: column;
}
dialog .mathInput {
    font-size: 4em;
}
dialog span > svg {
    height: 2rem;
}
.radioSelection {
    display: flex;
    flex-direction: column;
}
.radioOptions {
    display: flex;
    flex-direction: row;
}
.dialogLatex {
    padding-left: 1rem;
    height: 3rem;
}
.dialogLatex > svg {
    height: 100%;
}
span.centered {
    display: block;
    text-align: center;
    margin: 0 auto;
}
.buttonHolder {
    display: flex;
    margin-top: 1rem;
    align-self: center;
    width: 50%;
    flex-direction: row;
}
.buttonHolder * {
    flex-grow: 1;
    flex-shrink: 1;
    height: 2rem;
    margin: 0.5rem auto;
}
.radioSelection * {
    vertical-align: middle;
}
/* Draggable */
.draggable {
    box-sizing: border-box;
    border-radius: 2rem;
    border: var(--thickness) solid var(--color-text);
    background-color: var(--color-window);
    padding: var(--resize);
    overflow: hidden;
}
.border {
    position: absolute;
    display: block;
    background-color: transparent;
}
.border.top { top: 0; left: 0; width: 100%; height: var(--resize); cursor: ns-resize;}
.border.left { top: 0; left: 0; width: var(--resize); height: 100%; cursor: ew-resize;}
.border.bottom { bottom: 0; left: 0; width: 100%; height: var(--resize); cursor: ns-resize;}
.border.right { top: 0; right: 0; width: var(--resize); height: 100%; cursor: ew-resize;}
.border.topLeft { top: 0; left: 0; width: var(--resize); height: var(--resize); cursor: nwse-resize;}
.border.topRight { top: 0; right: 0; width: var(--resize); height: var(--resize); cursor: nesw-resize;}
.border.bottomLeft { bottom: 0; left: 0; width: var(--resize); height: var(--resize); cursor: nesw-resize;}
.border.bottomRight { bottom: 0; right: 0; width: var(--resize); height: var(--resize); cursor: nwse-resize;}
.mover {
    cursor: move;
}
/* Equation */
.equationHolder {
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr fit-content(33%);
    grid-template-rows: auto 1fr auto auto;
}
.equation {
    grid-column: 1;
    grid-row: 1/3;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    flex-shrink: 1;
    justify-content: space-evenly;
    gap: 1rem;
}
.actionToolbar {
    position: relative;
    grid-column: 1/3;
    grid-row: 4;
    display: flex;
    flex-direction: column;
    background-color: var(--color-window);
}
.actionSubtoolbar {
    position: relative;
    grid-column: 1/3;
    grid-row: 3;
    display: flex;
    flex-direction: column;
    background-color: var(--color-window);
}
.actionToolbar .scrollMask, .actionSubtoolbar .scrollMask {
    background-image: linear-gradient(to right, transparent 90%, var(--color-window));
}
.actions {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow: scroll;
}
.hideScrollbar {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* Internet Explorer 10+ */
}
.hideScrollbar::-webkit-scrollbar { /* WebKit */
    width: 0;
    height: 0;
}
.scrollMask {
    display: block;
    position: absolute;
    right: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.action {
    display: flex;
    font-size: 1.5rem;
}
.actionButton {
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
    margin-top: 0.2rem;
    margin-bottom: 0.2rem;
    margin-left: 0.1rem;
    margin-right: 0.1rem;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
    background-color: var(--color-action);
    border-radius: 1rem;
    border-width: 0.2rem;
    border-style: solid;
    border-color: black;
}
.actionIcon {
    width: 1.5rem;
}
.actionIcon > svg {
    height: 100%;
}

/* only for undo and redo */
.actionDisabled {
    pointer-events: none;
    color: var(--color-grey);
}

.actionLatex > div > span {
    height: 2.3rem;
}
.actionLatex > div > span > svg {
    height: 1.6rem;
    margin-top: 0.3rem;
}
.actionLatex > div > span > svg > path {
    stroke-width: 0.15rem;
}
.brickRect {
    stroke: var(--color-black);
}
.brickText {
    text-anchor: middle;
    dominant-baseline: central;
    fill: none;
    stroke: var(--color-black);
    stroke-width: 0.05;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}
.brick.leaf   > .brickRect { fill: var(--color-leaf) }
.brick.branch > .brickRect { fill: var(--color-branch) }
.brick.root   > .brickRect { fill: var(--color-root) }

.brick.leaf:hover   > .brickText { stroke: var(--color-leaf-saturated); }
.brick.branch:hover > .brickText { stroke: var(--color-branch-saturated); }
.brick.root:hover   > .brickText { stroke: var(--color-root-saturated); }
.brick.leaf:hover   > .brickRect { fill: white; }
.brick.branch:hover > .brickRect { fill: white; }
.brick.root:hover   > .brickRect { fill: white; }

.brick.leaf.selected   > .brickRect { fill: var(--color-leaf-saturated); }
.brick.branch.selected > .brickRect { fill: var(--color-branch-saturated); }
.brick.root.selected   > .brickRect { fill: var(--color-root-saturated); }
.brick.leaf.selected   > .brickText { stroke: var(--color-black); }
.brick.branch.selected > .brickText { stroke: var(--color-black); }
.brick.root.selected   > .brickText { stroke: var(--color-black); }

.brick.leaf.selected:hover   > .brickRect { fill: var(--color-leaf-saturated); }
.brick.branch.selected:hover > .brickRect { fill: var(--color-branch-saturated); }
.brick.root.selected:hover   > .brickRect { fill: var(--color-root-saturated); }
.brick.leaf.selected:hover   > .brickText { stroke: white; }
.brick.branch.selected:hover > .brickText { stroke: white; }
.brick.root.selected:hover   > .brickText { stroke: white; }

.brick.leaf.grabbed   > .brickRect { fill: var(--color-leaf-saturated); }
.brick.branch.grabbed > .brickRect { fill: var(--color-branch-saturated); }
.brick.root.grabbed   > .brickRect { fill: var(--color-root-saturated); }
.brick.leaf.grabbed   > .brickText { stroke: var(--color-leaf); }
.brick.branch.grabbed > .brickText { stroke: var(--color-branch); }
.brick.root.grabbed   > .brickText { stroke: var(--color-root); }

.brick.staged > .brickRect {
    fill-opacity: 0.75;
}
.brick.commutable > .brickRect {
    cursor: move;
}
.mathStroke {
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}
.mathStroke.stroke {
    stroke: var(--color-black);
}
.stroke:not(.selected):hover {
    stroke: var(--color-selected-text);
}
.stroke.selected {
    stroke: var(--color-selected-text);
}
.controls {
    width: 2rem;
    display: flex;
    flex-direction: column;
    height: fit-content;
    margin-left: auto;
}
.controls * {
    width: 100%;
}
.historyHolder {
    display: flex;
    flex-direction: row;
    grid-column: 2;
    grid-row: 2;
    min-width: 0rem;
    max-width: 100%;
    margin: 0.5rem;
    margin-left: auto;
    overflow: scroll;
    transition: linear 0.5s max-width;
}
.historyHolder.closed {
    max-width: 0;
    transition: linear 0.5s max-width;
}
.historyHolder > svg {
    width: 1em;
}
/* History */
.history {
    display: flex;
    font-size: 2rem;
    flex-direction: column;
    position: relative;
    overflow: scroll;
}
.history a {
    position: relative;
    display: block;
    padding-left: 1.1em;
    height: 1em;
}
.history div {
    position: relative;
    display: block;
    padding-left: 0.5em;
}
.history a > svg {
    height: 100%;
}
.history a::before, .history div::before {
    position: absolute;
    top: 0;
    left: 0;
    width: 1em;
    height: 100%;
    overflow: hidden;
    content: "";
    background-image: url("../img/history_middle.svg");
    background-repeat: no-repeat;
    background-size: cover;
}
.history a:first-child:before, .history div:first-child:before {
    background-image: url("../img/history_top.svg");
}
.history a:last-child:before {
    background-image: url("../img/history_bottom.svg");
}
.history a:first-child:last-child:before, .history div:first-child:last-child:before {
    background-image: url("../img/history.svg");
}
.history .selected, .history .selected::before {
    color: var(--color-selected-text);
}