/* Page layout: title bar with language switch, tool row, machine stage with two side buttons, card dock. */
:root {
  --bg: #f2d27f;
  --outside: #3a2a1c;
  --bar: #2b2018;
  --surface: #fdf3d6;
  --surface-2: #ecd9a2;
  --field: #fffaea;
  --ink: #2b2018;
  --ink-2: #5a4630;
  --ink-3: #9a8460;
  --line: #2b2018;
  --accent: #b5651d;
  --on-dark: #fdf3d6;
  --panel: #fbeec4;
  --title-ink: #2b2018;
  --disc: #2b2018;
  --disc-ink: #fbeec4;
  --seg: #f3e2ac;
  --seg-on: #2b2018;
}

html,
body {
  background: var(--outside);
}

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

.frame {
  position: absolute;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
}

.top {
  position: relative;
  z-index: 4;
  flex: none;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.top > * {
  pointer-events: auto;
}

.page-boil {
  filter: url(#page-boil);
}

.page-boil-soft {
  filter: url(#page-boil-soft);
}

.titlebar {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  height: calc(var(--u) * 14);
  min-height: 58px;
  margin: calc(var(--u) * 2.5 + 4px) calc(var(--u) * 3 + 4px) 0;
  padding: 0 calc(var(--u) * 2.4) 0 calc(var(--u) * 3);
  background-color: var(--panel);
}

.title {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  color: var(--title-ink);
  font-weight: var(--title-weight);
  font-size: calc(var(--u) * 7.4);
  line-height: 1.1;
  letter-spacing: calc(var(--u) * 0.6);
  white-space: nowrap;
  text-align: center;
}

.lang-seg {
  flex: none;
  display: flex;
  margin-left: calc(var(--u) * 2);
  padding: 3px;
  background: var(--seg);
}

.lang-opt {
  min-width: 44px;
  min-height: 44px;
  padding: 0 calc(var(--u) * 2.4);
  color: var(--seg-on);
  font-size: calc(var(--u) * 3.8);
  font-weight: var(--title-weight);
  white-space: nowrap;
}

.lang-opt.is-on {
  background: var(--seg-on);
  color: var(--seg);
  box-shadow: inset 0 -4px 0 var(--accent);
  border-radius: calc(var(--u) * 2.6) calc(var(--u) * 1.4) calc(var(--u) * 2.8) calc(var(--u) * 1.6);
}

.toolbar {
  flex: none;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 calc(var(--u) * 3 + 4px);
  padding: calc(var(--u) * 2) 0 calc(var(--u) * 1);
}

.toolbar .tool {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: calc(var(--u) * 11);
  height: calc(var(--u) * 11);
  min-width: 44px;
  min-height: 44px;
  margin: 0 calc(var(--u) * 1.4);
  background: var(--disc);
  color: var(--disc-ink);
}

.toolbar .tool .icon {
  width: 56%;
  height: 56%;
}

.toolbar .tool .icon svg {
  width: 100%;
  height: 100%;
}

.toolbar .tool[disabled] {
  opacity: 0.45;
  cursor: default;
}

.stage {
  position: relative;
  z-index: 3;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
}

.scene-cell {
  position: relative;
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
}

.stage > * {
  pointer-events: auto;
}

.scene {
  position: absolute;
  z-index: 1;
  left: 0;
  top: 0;
  touch-action: none;
}

/* 挤面糊的瓶子：盖在整个页面上，不挡任何点击，跟着指针飞过按钮、标题栏和屏幕边缘。 */
.bottle-fly {
  position: fixed;
  z-index: var(--z-float);
  left: 0;
  top: 0;
  display: none;
  pointer-events: none;
}

.side {
  position: relative;
  flex: none;
  margin-left: calc(var(--u) * 3 + 4px);
  display: flex;
  flex-direction: column;
}

.side-btn {
  display: block;
  width: calc(var(--u) * 13);
  height: calc(var(--u) * 13);
  min-width: 44px;
  min-height: 44px;
  margin-bottom: calc(var(--u) * 2.5);
}

.side-btn[disabled] {
  opacity: 0.5;
  cursor: default;
}

.side-btn .face {
  width: 100%;
  height: 100%;
}

.dock {
  position: relative;
  z-index: 4;
  flex: none;
  margin: 0 calc(var(--u) * 3 + 4px) calc(var(--u) * 3 + 4px);
  display: flex;
  align-items: center;
  height: calc(var(--u) * 28);
  min-height: 70px;
  padding: 0 calc(var(--u) * 1);
  background-color: var(--panel);
}

.dock-arrow {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--u) * 7);
  min-width: 44px;
  min-height: 44px;
  color: var(--ink);
}

.dock-arrow .chev,
.dock-arrow svg {
  display: block;
  width: calc(var(--u) * 6);
  height: calc(var(--u) * 6);
  min-width: 22px;
  min-height: 22px;
}

.dock-list {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 100%;
}

.card {
  flex: none;
  display: block;
  width: calc(var(--u) * 15);
  height: calc(var(--u) * 20);
  min-width: 44px;
  min-height: 58px;
  margin-right: calc(var(--u) * 1.6);
}

.card:last-child {
  margin-right: 0;
}

.card-face {
  display: block;
  width: 100%;
  height: 100%;
}

.card .card-face-on,
.card.is-on .card-face {
  display: none;
}

.card.is-on .card-face-on {
  display: block;
}

.dock-text {
  flex: 1 1 auto;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--ink);
  font-size: calc(var(--u) * 6.4);
  letter-spacing: calc(var(--u) * 0.5);
  white-space: nowrap;
}

.is-pressing .toolbar {
  pointer-events: none;
  opacity: 0.6;
}

.range-choices .btn {
  white-space: normal;
  min-height: 56px;
  line-height: 1.3;
}

.credit-wrap {
  display: flex;
  flex-direction: column;
}

.credits-line {
  margin: 0;
}

.credits-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink-2);
  font-size: calc(var(--u) * 3);
  text-decoration: underline;
}

@media (max-height: 520px) {
  .titlebar {
    height: calc(var(--u) * 11);
    margin-top: calc(var(--u) * 1.5 + 4px);
  }
  .title {
    font-size: calc(var(--u) * 6);
  }
  .toolbar {
    padding: calc(var(--u) * 1) 0;
  }
  .dock {
    height: calc(var(--u) * 21);
    margin-bottom: calc(var(--u) * 1.5 + 4px);
  }
  .card {
    width: calc(var(--u) * 12);
    height: calc(var(--u) * 16);
  }
}

/* Dialogs: cream paper with a hand-cut edge (mask set in script), no hairlines, ink blocks for buttons. */
.modal-overlay {
  background: rgba(43, 32, 24, 0.5);
}

.modal {
  background-color: var(--surface);
  border-radius: 0;
}

.modal-head,
.modal-foot,
.credit {
  border: 0;
}

.modal-head {
  padding: calc(var(--u) * 4) calc(var(--u) * 3) 0 calc(var(--u) * 5);
}

.modal-title {
  font-weight: var(--title-weight);
}

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

.modal-foot {
  padding: 0 calc(var(--u) * 5) calc(var(--u) * 5);
}

.modal .btn {
  border: 0;
  border-radius: 0;
  background: #f0dc9c;
  color: var(--ink);
  font-weight: var(--title-weight);
}

.modal .btn-primary {
  background: var(--ink);
  color: var(--on-dark);
}

.modal .btn-danger {
  background: #8f3416;
  color: #fff4dc;
}

.crop-view {
  border: 0;
  border-radius: 0;
}

.range,
.num {
  border: 0;
  background: #f0dc9c;
}

.export-range {
  display: flex;
  align-self: center;
  padding: 3px;
  background: var(--seg);
}

.export-range .lang-opt {
  min-width: calc(var(--u) * 20);
  font-size: calc(var(--u) * 4.2);
}

.export-formats .btn {
  min-height: 56px;
}

.side-right {
  margin-left: 0;
  margin-right: calc(var(--u) * 3 + 4px);
}

/* Dialogs use the same surfaces as the page: cream panel with grain and hand-cut edge, ink blocks for buttons. */
.modal {
  background-color: var(--panel);
}

.modal .btn,
.modal .btn-primary,
.modal .btn-danger {
  min-height: 48px;
  background: var(--disc);
  color: var(--disc-ink);
}

.modal .btn[disabled] {
  opacity: 0.45;
}

.import-modes {
  display: flex;
}

.import-mode {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: calc(var(--u) * 1);
  color: var(--ink);
  font-weight: var(--title-weight);
}

.import-mode + .import-mode {
  margin-left: calc(var(--u) * 2);
}

.import-mode.is-on span {
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 5px;
}

.import-mode img {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: calc(var(--u) * 1.5);
}

.edge-row {
  display: flex;
  align-items: center;
  justify-content: center;
}

.edge-label {
  margin-right: calc(var(--u) * 3);
  font-weight: var(--title-weight);
}

.image-menu .btn {
  min-height: 56px;
}

.modal-stack > .credits-line {
  align-self: flex-start;
  margin: -10px 0;
}

.modal-stack > .credits-line + * {
  margin-top: calc(var(--u) * 1);
}

.confirm-text {
  padding-top: calc(var(--u) * 2);
  font-size: calc(var(--u) * 4.4);
  text-align: center;
}

.side > .side-btn {
  margin-bottom: 0;
}


/* Dialog close: a small ink x laid over the top-right corner (44px touch area), inside the paper so it moves with it.
   The first row of an untitled dialog keeps the corner free on both sides so centred content stays centred. */
.modal {
  position: relative;
}

.modal.no-title .modal-body > :first-child,
.modal.no-title .modal-stack > :first-child {
  margin-left: calc(var(--u) * 7);
  margin-right: calc(var(--u) * 7);
}

.modal.no-title .modal-stack > .modal-preview:first-child {
  width: calc(100% - var(--u) * 14);
}

.modal.no-title .modal-body > .modal-stack:first-child {
  margin-left: 0;
  margin-right: 0;
}

.modal.has-title .modal-head {
  padding-right: calc(var(--u) * 13);
}

.modal-x {
  position: absolute;
  z-index: 1;
  top: 2px;
  right: 2px;
  width: 44px;
  height: 44px;
}

.modal-x-a,
.modal-x-b {
  position: absolute;
  left: 50%;
  top: 50%;
  height: 3px;
  margin-top: -1.5px;
  border-radius: 1.5px;
  background: var(--ink);
}

.modal-x-a {
  width: 16px;
  margin-left: -8px;
  -webkit-transform: rotate(44deg);
  transform: rotate(44deg);
}

.modal-x-b {
  width: 15px;
  margin-left: -7.5px;
  -webkit-transform: rotate(-47deg) translateY(0.5px);
  transform: rotate(-47deg) translateY(0.5px);
}
