/* Text Line: graphite, steel and paper; hairlines, square corners, poster type. */
:root {
  --bg: #2b2b2a;
  --surface: #f5f4f0;
  --surface-2: #d6d6d2;
  --field: #f5f4f0;
  --bar: #1b1b1b;
  --disc: #f5f4f0;
  --ink: #1b1b1b;
  --ink-2: #4a4a48;
  --ink-3: #8a8a86;
  --line: #1b1b1b;
  --accent: #1b1b1b;
  --danger: #8f2219;
  --on-dark: #f2f1ec;
  --radius: 0px;
  --radius-sm: 0px;
  --border-w: 1px;
  --desk: #d9d9d5;
  --paper: #f5f4f0;
  --graphite: #1b1b1b;
  --steel: #c9c9c5;
}

/* a canvas page: the browser never takes a touch for panning or zooming the page itself. Every element says it
   (not only the root): a box with overflow set (the frame, the bars) cuts the chain to its parents in some browsers,
   and a finger that lands on a control would then be taken by the browser as a one-axis scroll and cancelled */
html,
body,
#app,
#app * {
  touch-action: none;
}

#app {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
}

.desk {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg);
}

.frame {
  position: absolute;
  display: flex;
  flex-direction: column;
  background-color: var(--desk);
  background-size: 240px 240px;
  overflow: hidden;
}

/* ---------- title band ---------- */
.head {
  position: relative;
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: calc(var(--u) * 13);
  min-height: 46px;
}

.head .plate {
  grid-column: 2;
}

.plate {
  position: relative;
  margin: 0;
  padding: calc(var(--u) * 1.8) calc(var(--u) * 4.4) calc(var(--u) * 1.8) calc(var(--u) * 4.4 + 0.42em);
  background: #161616;
  color: var(--on-dark);
  font-size: calc(var(--u) * 5.2);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.42em;
  white-space: nowrap;
  box-shadow: inset 0 0 0 calc(var(--u) * 0.7) #161616, inset 0 0 0 calc(var(--u) * 0.7 + 1px) #6a6a67;
}

html[lang="en"] .plate {
  padding-left: calc(var(--u) * 3.8 + 0.18em);
  padding-right: calc(var(--u) * 3.8);
  letter-spacing: 0.18em;
}

/* one two-way switch: a single outer rule, no gap in the middle, the chosen half filled */
.lang-seg {
  grid-column: 3;
  justify-self: end;
  display: flex;
  margin-right: calc(var(--u) * 2.4);
  border: 1px solid var(--graphite);
  background: var(--paper);
}

.lang-opt {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: calc(var(--u) * 8);
  height: calc(var(--u) * 5.6);
  padding: 0 calc(var(--u) * 1.8);
  color: var(--graphite);
  font-size: calc(var(--u) * 2.9);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.06em;
}

.lang-opt::after {
  content: '';
  position: absolute;
  top: -12px;
  bottom: -12px;
  left: 0;
  right: 0;
}

.lang-opt:first-child::after {
  left: -6px;
}

.lang-opt:last-child::after {
  right: -6px;
}

.lang-opt.is-on {
  background: var(--graphite);
  color: var(--on-dark);
}

.head .toast {
  top: calc(100% + 6px);
  z-index: 4;
}

.is-land .bottom {
  display: none;
}

.is-port .right {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}

/* ---------- middle band: round buttons | sheet | pen ---------- */
.middle {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.left {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: none;
}

.tools {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tool {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tool, calc(var(--u) * 11));
  height: var(--tool, calc(var(--u) * 11));
  margin-bottom: calc(var(--tool, calc(var(--u) * 11)) * 0.2);
  padding: 0;
  border: 1px solid var(--graphite);
  border-radius: 50%;
  background: var(--paper);
  color: var(--graphite);
}

.tool:last-child {
  margin-bottom: 0;
}

.tool:active {
  background: var(--graphite);
  color: var(--on-dark);
}

.tool .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50%;
  height: 50%;
}

.tool .icon svg {
  width: 100%;
  height: 100%;
  stroke-width: 2.6;
}

.tool.is-on {
  background: var(--graphite);
  color: var(--on-dark);
}

.tool-select .icon {
  width: 62%;
  height: 62%;
}

.obj-select .sel-frame {
  stroke: currentColor;
}

.obj-select .sel-arrow {
  fill: var(--paper);
  stroke: currentColor;
}

.tool-select.is-on .sel-arrow {
  fill: var(--graphite);
}

.tool[disabled] {
  border-color: #a9a9a5;
  background: transparent;
  color: #a9a9a5;
  cursor: default;
}

.stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--desk);
  touch-action: none;
  cursor: crosshair;
}

/* every control floats above the desk; only the controls themselves take pointer input */
.ui {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.ui button,
.ui input,
.ui .bar,
.ui .sel-bar,
.ui .lang-seg,
.ui .plate,
.ui .toast {
  pointer-events: auto;
}

.ui .toast:not(.is-shown) {
  pointer-events: none;
}

.hole {
  flex: 1 1 auto;
  min-width: 0;
}

.stage.is-select {
  cursor: default;
}

.stage.is-panning {
  cursor: move;
}

.sheet-box {
  position: absolute;
  -webkit-transform-origin: 0 0;
  transform-origin: 0 0;
  box-shadow: 0 0 0 1px var(--graphite);
  background: var(--paper);
}

.sheet,
.sheet-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.sheet-overlay {
  pointer-events: none;
}

.right {
  position: relative;
  flex: none;
}

/* portrait: the pen stands at the foot of the right column, barrel up to the right, nib to the lower left */
.is-port .pen-btn {
  flex: none;
  width: calc(var(--u) * 12);
  height: calc(var(--u) * 42);
  min-width: 44px;
  max-height: 70%;
  padding: 0;
}

.pen-btn .obj {
  width: 100%;
  height: 100%;
}

/* ---------- bottom band ---------- */
.bottom {
  flex: none;
  padding: 0 calc(var(--u) * 2.4) calc(var(--u) * 2.4);
}

.row-a {
  display: flex;
  align-items: flex-end;
  padding: calc(var(--u) * 1.8) 0 calc(var(--u) * 1.6);
}

.sel-bar {
  display: none;
  margin-left: calc(var(--u) * 1.6);
  border: 1px solid var(--graphite);
}

.sel-bar.is-shown {
  display: flex;
}

.sel-btn {
  min-height: 44px;
  padding: 0 12px;
  background: var(--paper);
  font-size: 13px;
  white-space: nowrap;
}

.sel-btn + .sel-btn {
  border-left: 1px solid var(--graphite);
}

.sel-btn[disabled] {
  color: #9a9a96;
}

.sel-danger {
  color: var(--danger);
}

/* speech bubble with the start of the brush text; its tail points up at the pen nib */
.bubble {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 46px;
  max-width: calc(var(--u) * 52);
  margin-left: auto;
  padding: 0 calc(var(--u) * 3.6) 0 calc(var(--u) * 3);
  border: 1px solid var(--graphite);
  background: var(--paper);
}

.bubble::before {
  content: '';
  position: absolute;
  right: var(--tail, 24px);
  top: -7px;
  width: 12px;
  height: 12px;
  border-left: 1px solid var(--graphite);
  border-top: 1px solid var(--graphite);
  background: var(--paper);
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
}

.bubble-text {
  display: block;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  white-space: nowrap;
}

/* adjustment bar: one row of category tabs, one row of the chosen category's controls. In portrait the row never
   wraps and never scrolls (everything shrinks to fit the width); only the font list is a list of any length. */
.bar {
  flex: none;
  min-width: 0;
}

.bar-top {
  display: flex;
  align-items: flex-end;
}

.tabs {
  display: flex;
  flex: none;
}

.tab {
  display: flex;
  align-items: flex-end;
  flex: none;
  min-height: 36px;
  min-width: 0;
  padding: 0;
}

.tab span {
  display: block;
  padding: 5px calc(var(--u) * 1.8) 4px;
  border: 1px solid var(--graphite);
  border-bottom: 0;
  background: var(--paper);
  font-size: calc(var(--u) * 2.9);
  letter-spacing: 0.06em;
  line-height: 1.2;
  white-space: nowrap;
}

.tab + .tab span {
  border-left: 0;
}

.tab.is-on span {
  background: var(--graphite);
  color: var(--on-dark);
}

.slot {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 52px;
  padding: 0 calc(var(--u) * 1.4);
  border: 1px solid var(--graphite);
  background: var(--paper);
}

.slot > * {
  flex: none;
  min-width: 0;
}

.slot > * + * {
  margin-left: calc(var(--u) * 1.6);
}

.slot-size > .slider,
.slot-brush > .slider {
  flex: 1 1 0;
}

.slot-brush > .slider {
  min-width: calc(var(--u) * 18);
}

.slot-fx > .fx-chip,
.slot-color > .swatch {
  flex: 1 1 0;
  margin-left: 0;
}

.slot.slot-fx {
  padding: 0;
}

.slot-color > .swatch {
  max-width: 36px;
}

.slot-font > .font-row {
  flex: 1 1 auto;
}

.seg {
  display: flex;
  flex: none;
  border: 1px solid var(--graphite);
  background: var(--paper);
}

.seg-opt {
  min-height: 34px;
  padding: 0 calc(var(--u) * 1.6);
  font-size: calc(var(--u) * 3.1);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.seg-opt + .seg-opt {
  border-left: 1px solid #b4b4b0;
}

.seg-opt.is-on {
  background: var(--graphite);
  color: var(--on-dark);
}

.seg-opt.is-on + .seg-opt {
  border-left-color: var(--graphite);
}

.seg.is-off,
.slider.is-off {
  opacity: 0.4;
}

/* a slider: its name and number above a hairline groove with a square block */
.slider {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.slider-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  min-width: 0;
  padding: 0 2px;
  font-size: calc(var(--u) * 2.7);
  line-height: 1.5;
  white-space: nowrap;
}

.slider-label {
  color: var(--ink-2);
}

.slider-num {
  font-variant-numeric: tabular-nums;
}

.sl-track {
  position: relative;
  display: block;
  height: 26px;
  touch-action: none;
  cursor: pointer;
}

.sl-groove {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 50%;
  height: 1px;
  background: var(--graphite);
}

.sl-fill {
  position: absolute;
  left: 0;
  top: -1px;
  height: 3px;
  background: var(--graphite);
}

.sl-mid {
  position: absolute;
  left: 50%;
  top: -5px;
  width: 1px;
  height: 11px;
  background: var(--ink-3);
}

.sl-thumb {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 20px;
  margin: -10px 0 0 -6px;
  border: 1px solid var(--graphite);
  background: var(--paper);
}

.sl-track:focus {
  outline: none;
}

.sl-track:focus .sl-thumb {
  background: var(--steel);
}

.font-row {
  display: flex;
  align-items: center;
  min-width: 0;
}

.font-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 36px;
  min-height: 36px;
  margin-left: -1px;
  padding: 0 10px;
  border: 1px solid #9a9a96;
  background: var(--paper);
  font-size: 12px;
  white-space: nowrap;
}

.font-sample {
  font-size: 14px;
  font-weight: 400;
}

.font-chip.is-on {
  position: relative;
  z-index: 1;
  border-color: var(--graphite);
  background: var(--graphite);
  color: var(--on-dark);
}

.font-pair {
  display: inline-flex;
  flex: none;
}

.font-x {
  min-width: 34px;
  padding: 0;
}

.font-add {
  font-size: 16px;
}

.swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  height: 36px;
  min-width: 0;
  border: 1px solid transparent;
}

.swatch span {
  display: block;
  width: 70%;
  max-width: 24px;
  height: 24px;
  border: 1px solid rgba(0, 0, 0, 0.18);
}

.swatch.is-on {
  border-color: var(--graphite);
}

.bar-btn {
  flex: none;
  min-height: 34px;
  padding: 0 calc(var(--u) * 2);
  border: 1px solid var(--graphite);
  background: var(--paper);
  font-size: calc(var(--u) * 3.1);
  white-space: nowrap;
}

.bar-danger {
  border-color: var(--danger);
  color: var(--danger);
}

/* an effect: the button is its own percentage. It fills from the bottom with black like a level; the name and the
   number are drawn twice, dark on the paper part and light on the black part, clipped by the level. */
.fx-chip {
  position: relative;
  display: block;
  height: 50px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid #9a9a96;
  background: var(--paper);
  overflow: hidden;
  touch-action: none;
}

.fx-chip:first-child {
  border-left: 0;
}

.fx-face {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  color: var(--graphite);
  pointer-events: none;
}

.fx-name {
  font-size: calc(var(--u) * 3);
  line-height: 1.3;
  white-space: nowrap;
}

.fx-pct {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  font-size: calc(var(--u) * 2.5);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
}

.fx-level {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  background: var(--graphite);
  overflow: hidden;
  pointer-events: none;
}

.fx-level .fx-face {
  top: auto;
  bottom: 0;
  color: var(--on-dark);
}

/* the pen's sheet: the brush text and the list of brushes (presets and pinned first, then recent) */
.pen-sheet {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pen-sheet .tl-edit {
  height: calc(var(--u) * 24);
  min-height: 90px;
  resize: none;
}

.brush-list {
  height: calc(var(--u) * 44);
  min-height: 132px;
  margin-top: calc(var(--u) * 2);
  border: 1px solid var(--graphite);
  background: var(--paper);
  overscroll-behavior: contain;
}

.brush-row {
  position: relative;
  display: flex;
  align-items: center;
  height: 44px;
  border-bottom: 1px solid #d2d2ce;
}

.brush-row.is-on {
  background: #e7e7e3;
}

.pin {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  color: #a9a9a5;
}

.pin.is-on {
  color: var(--graphite);
}

.pin[disabled] {
  cursor: default;
}

.pin .obj-pin {
  width: 22px;
  height: 22px;
}

.pin .pin-head {
  fill: currentColor;
  stroke: currentColor;
}

.pin .pin-needle {
  stroke: currentColor;
}

.brush-text {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 4px;
  text-align: left;
}

.brush-sample {
  display: block;
  overflow: hidden;
  font-size: 17px;
  font-weight: 400;
  line-height: 44px;
  white-space: nowrap;
}

/* a small x laid over the card's top right corner: out of the layout, so the text and the pin never give way to it */
.brush-x {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  width: 28px;
  height: 28px;
  padding: 3px 5px 0 0;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1;
}

/* the field that takes the typing on an item: a dot at the item, never seen */
.type-field {
  position: absolute;
  z-index: 1;
  width: 2px;
  height: 2px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  font-size: 16px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  resize: none;
}

/* ---------- landscape: left column | sheet | right column ---------- */
.is-land .head {
  height: calc(var(--u) * 11);
  min-height: 40px;
}

.is-land .left {
  width: calc(var(--u) * 19);
  min-width: 70px;
}

.is-land .right {
  display: flex;
  flex-direction: column;
  width: calc(var(--u) * 72);
  max-width: 380px;
  padding: calc(var(--u) * 1.2) calc(var(--u) * 2.4) calc(var(--u) * 2.4) 0;
}

.is-land .writer {
  display: flex;
  align-items: flex-end;
  flex: none;
  padding-bottom: calc(var(--u) * 1.8);
}

.is-land .writer .bubble {
  flex: 1 1 auto;
  margin-left: 0;
  max-width: none;
}

.is-land .writer .pen-btn {
  flex: none;
  width: calc(var(--u) * 7);
  height: calc(var(--u) * 24);
  min-width: 34px;
  padding: 0;
}

/* the right column has room to grow downwards, so a row of controls may wrap there */
.is-land .slot {
  flex-wrap: wrap;
  height: auto;
  min-height: 52px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.is-land .slot > * {
  margin-top: 3px;
  margin-bottom: 3px;
}

.is-land .slot-fx > .fx-chip,
.is-land .slot-color > .swatch {
  margin-top: 0;
  margin-bottom: 0;
}

.is-land .slot.slot-fx {
  height: 52px;
  padding: 0;
}

.is-land .slot-brush > .slider,
.is-land .slot-size > .slider {
  flex: 1 1 100%;
}

.is-land .slot-size > .slider {
  flex-basis: 30%;
}

.is-land .sel-bar {
  margin: 0 0 calc(var(--u) * 1.4);
}

/* ---------- dialogs, panels, toast: same paper, graphite rules and square corners as the page ---------- */
.modal-overlay {
  background: rgba(22, 22, 22, 0.55);
}

.modal {
  border: 1px solid var(--graphite);
  background: var(--paper);
}

.modal-head {
  border-bottom: 1px solid var(--graphite);
}

.modal-title {
  font-weight: 900;
  letter-spacing: 0.08em;
}

.modal-close {
  background: var(--paper);
  color: var(--graphite);
  font-size: 16px;
  font-weight: 400;
}

.modal-body {
  padding: calc(var(--u) * 4);
}

.btn {
  min-height: 44px;
  border: 1px solid var(--graphite);
  background: var(--paper);
  color: var(--graphite);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.btn-primary,
.modal-choices .btn {
  background: var(--graphite);
  border-color: var(--graphite);
  color: var(--on-dark);
}

.btn-danger {
  background: var(--paper);
  border-color: var(--danger);
  color: var(--danger);
}

.modal-choices .btn {
  font-size: 15px;
  letter-spacing: 0.2em;
  min-height: 48px;
}

.modal-foot {
  border-top: 1px solid #b4b4b0;
}

.export-sources {
  color: var(--ink-2);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-decoration: underline;
}

.modal-preview {
  border: 1px solid var(--graphite);
  background: var(--desk);
}

.modal-progress {
  height: 4px;
  border: 0;
  background: #d6d6d2;
  -webkit-appearance: none;
  appearance: none;
}

.modal-progress::-webkit-progress-bar {
  background: #d6d6d2;
}

.modal-progress::-webkit-progress-value {
  background: var(--graphite);
}

.modal-progress::-moz-progress-bar {
  background: var(--graphite);
}

.credit {
  border-top: 1px solid #b4b4b0;
}

.credit-avatar {
  border: 1px solid var(--graphite);
}

.popover {
  border: 1px solid var(--graphite);
  background: var(--paper);
}

.popover .popover-body {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.popover-grip span {
  height: 2px;
  background: var(--graphite);
}

.toast {
  border-radius: 0;
  background: var(--graphite);
  color: var(--on-dark);
  font-size: 14px;
  letter-spacing: 0.04em;
}

.toast-action {
  border-radius: 0;
}

.color-button {
  border-radius: 0;
}

.tl-edit {
  font-weight: 400;
  font-size: 16px;
}

/* a short wide screen: the brush text and the brush list sit side by side, both as tall as fits (no scrolling of the page) */
@media (orientation: landscape) and (max-height: 520px) {
  .pen-sheet {
    flex-direction: row;
  }

  .pen-sheet .tl-edit,
  .brush-list {
    flex: 1 1 0;
    height: calc(var(--u) * 44);
    min-height: 132px;
  }

  .brush-list {
    margin-top: 0;
    margin-left: calc(var(--u) * 2);
  }
}
