body {
  font-family: monospace;
  font-size: 1rem;
  line-height: 1.2;
  margin: 0;
  overflow: hidden;
}

:root {
  --padding: 0.5rem;
  --text-bg-color: cornflowerblue;
  --text-color: black;
  --diagram-bg-color: whitesmoke;
  --diagram-text-color: black;
  --table-bg-color: white;
  --table-text-color: black;
}

header {
  padding: var(--padding);
  background-color: steelblue;
  .more {
    pointer-events: none;
    transition: all 0.2s ease-in-out;
    height: 0;
    opacity: 0;
    z-index: 1;
    background-color: steelblue;
    position: absolute;
    margin-bottom: 1rem;
  }
}
.more-group {
  margin: 0.25rem;
}
header:hover,
header.hover {
  .more {
    opacity: 1;
    height: initial;
    pointer-events: initial;
  }
}

button {
  font-size: 1em;
  margin: 0;
  padding: 0.25em;
  line-height: 1em;
}
.color-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.deprecated {
  opacity: 0.5;
}

label {
  text-transform: capitalize;
}

button kbd {
  text-decoration: underline;
  font-family: inherit;
}

.controls {
  position: absolute;
  font-size: 1rem;
  top: calc(var(--padding) * 2);
  right: calc(var(--padding) * 2);
  user-select: none;
  .buttons {
    position: fixed;
    width: max-content;
    transform: translateX(-100%);
  }
  button {
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
  }
}

main {
  height: calc(100vh - 1.5em - 1em);
  display: flex;
  background-color: whitesmoke;
  width: 100vw;
}

#editor {
  width: max-content;
  // flex-shrink: 1;
  overflow: hidden;
  background-color: var(--text-bg-color);
  textarea {
    color: var(--text-color);
    overflow: auto;
    background-color: transparent;
    resize: horizontal;
    font-family: monospace;
    font-size: 1rem;
    line-height: 1.2;
    padding: var(--padding);
    border: 0;
    width: calc(100% - var(--padding) * 2);
    --scroll-bar: 1em;
    &::-webkit-scrollbar {
      height: var(--scroll-bar);
      width: var(--scroll-bar);
    }
    &::-webkit-scrollbar-track-piece {
      background-color: lightgray;
    }
    &::-webkit-scrollbar-thumb {
      background-color: gray;
      border-radius: 1em;
    }
    &::-webkit-scrollbar-button {
      background-color: lightskyblue;
    }
    &::-webkit-scrollbar-corner {
      background-color: crimson;
    }
    height: calc(100% - var(--padding) * 2 - var(--scroll-bar));
    margin: 0;
    margin-bottom: var(--scroll-bar);
    white-space: pre;
    // outline: none; // to normalize chrome behavior when :focus-visible
  }
  position: relative;
  .erd-controls,
  .output-controls {
    position: absolute;
    top: calc(var(--padding));
    right: calc(var(--padding));
    background-color: var(--text-bg-color);
  }
  legend,
  label {
    color: var(--text-color);
  }
}
#diagram {
  padding: var(--padding);
  background-color: var(--diagram-bg-color);
  // width: 70%;
  flex-grow: 1;
  overflow: auto;
  position: relative;
  #tables-container {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    display: block;
    outline: 1px solid lightgrey;
    z-index: 1;
  }
  svg {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 0;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    pointer-events: none;
  }
  path {
    stroke: var(--diagram-text-color);
  }
}
#font-size {
  color: var(--diagram-text-color);
}

dialog[open] {
  position: absolute;
  top: 25%;
  background-color: #ffffffd0;
}

.confirm {
  background-color: green;
  color: white;
}
.danger {
  background-color: red;
  color: white;
}
.cancel {
  background-color: black;
  color: white;
}

[data-table] {
  outline: 1px solid black;
  background-color: var(--table-bg-color);
  color: var(--table-text-color);
  display: inline-block;
  user-select: none;
  position: absolute;
  z-index: 1;
  table {
    border-collapse: collapse;
    min-width: 100%;
  }
}
[data-table-field] td {
  padding: 0.25em;
}
.table-header {
  background-color: var(--text-bg-color);
  color: var(--table-bg-color);
  padding: 0.5em;
  font-weight: bold;
  font-size: 1.1em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.table-name {
  flex-grow: 1;
  text-align: center;
}
.table-color-container {
  display: none;
}
[data-table]:hover .table-header {
  padding: 0.35em;
}
[data-table]:hover .table-color-container {
  display: unset;
}
[data-table]:hover input[type="color"] {
  height: 2em;
}
.table-field-name {
  text-align: start;
  padding: 0 !important;
}
.table-field-name label {
  text-transform: initial;
  padding: 0.25em;
  display: block;
}
.table-field-name input {
  margin-top: 0;
  margin-bottom: 0;
}
[data-mode="schema"] .table-field-name input {
  display: none;
}
.table-field-type {
  text-align: start;
}
.table-field-tag {
  border-right: 1px solid;
}
.table-field-type {
  border-left: 1px solid;
}
.table-footer {
  display: none;
}
[data-table]:hover .table-footer {
  border-top: 1px solid;
  display: flex;
  justify-content: center;
}
.table-footer button {
  margin: 0.25rem;
  padding: 0.3rem 2rem;
}
.table-footer button.message-mode {
  background: none;
  border: 0;
  opacity: 0.5;
}

.erd-controls {
  text-align: end;
}
.server-mode {
  margin-bottom: 0.5rem;
  display: none;
}

[data-mode="schema"] #queryInput,
[data-mode="schema"] .output-controls {
  display: none;
}
[data-mode="query"] #erdInput,
[data-mode="query"] .erd-controls {
  display: none;
}

[data-table="_stub_"] {
  display: none;
}

.icon {
  width: 1em;
  height: 1em;
}

.share-url {
  display: block;
  width: 100%;
}

#nightowl-switcher-default {
  left: calc(100vw - 80px) !important;
  top: 6.5rem !important;
}

@media screen and (max-width: 800px) {
  #nightowl-switcher-default {
    top: 9rem !important;
  }
}
