body {
  margin: 0;
  padding: 0 .5em;
  min-height: 100dvh;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  width: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  justify-content: safe center;
  align-items: stretch;
}

header {
  z-index: 2;
  margin: 1em 0 .5em;
}

header h1 {
  margin: 0;
  font-size: 1.5em;
  text-align: center;
}
header h1 a {
  text-decoration: none;
}
header h1 a:visited {
  color: #666;
}

.view {
  z-index: 2;
  height: 75vh;
  cursor: pointer;
  background-color: #f5f5f5;
  border: 3px dashed #666;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.dropover {
  background-color: #f5f5f5 !important;
  border: 3px dashed #666 !important;
}

.after-render {
  position: relative;
  overflow: hidden;
  cursor: default;
  background-color: #fff;
  border: 0px;
}

#guide p {
  font-size: 1.25em;
  font-weight: bold;
  color: #333;
  padding: 15px;
}

.status-message {
  z-index: 2;
  margin: .5em 0 0;
  min-height: 1.4em;
  color: #333;
  font-size: .9rem;
  line-height: 1.4;
  text-align: center;
}

.status-message.error {
  color: #b42318;
  font-weight: bold;
}

.face-debug-status {
  z-index: 2;
  width: min(100%, 560px);
  margin: .25em auto 0;
  padding: 6px 8px;
  box-sizing: border-box;
  border: 1px solid #a9bed3;
  border-radius: 6px;
  color: #27435f;
  background: #eef5fb;
  font: .7rem/1.5 ui-monospace, monospace;
  overflow-wrap: anywhere;
}

.buttons {
  z-index: 2;
  width: min(100%, 560px);
  margin-top: .65em;
  align-self: center;
  box-sizing: border-box;
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  border: 1px solid #d8e0e9;
  border-radius: 12px;
  background: #f4f7fa;
  box-shadow: 0 5px 14px rgba(34, 54, 83, .08);
}

#reselect-button {
  display: contents;
}

.action-button {
  cursor: pointer;
  min-width: 0;
  min-height: 44px;
  border: 1px solid #c7d3df;
  border-radius: 8px;
  padding: 7px 8px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 5px;
  color: #223653;
  background: #fff;
  box-shadow: 0 1px 2px rgba(34, 54, 83, .08);
  transition: transform .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.button-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button-icon .icon-fill {
  fill: currentColor;
  stroke: none;
}

.button-label {
  font: 700 .68rem/1 system-ui, sans-serif;
  letter-spacing: .04em;
}

.action-button--primary {
  border-color: #d5ae4c;
  color: #223653;
  background: #f0cf78;
  box-shadow: 0 1px 2px rgba(102, 76, 20, .12);
}

.action-button:disabled {
  cursor: not-allowed;
  border-color: #d8e0e8;
  color: #8795a5;
  background: #edf1f5;
  box-shadow: none;
}

.action-button--primary:disabled {
  border-color: #e0d4bb;
  color: #8d816a;
  background: #f3ead7;
}

@media (hover: hover) {
  .action-button:not(:disabled):hover {
    border-color: #91a8bf;
    background: #edf3f8;
    box-shadow: 0 3px 8px rgba(34, 54, 83, .12);
    transform: translateY(-1px);
  }

  .action-button--primary:not(:disabled):hover {
    border-color: #c89c32;
    background: #f4d98f;
  }
}

.action-button:not(:disabled):active {
  transform: translateY(1px);
}

.view:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid #1668c7;
  outline-offset: 3px;
}

.action-button.active {
  border-color: #7898b8;
  color: #1f4168;
  background: #e4edf6;
}

.face-style-wrapper {
  z-index: 2;
  width: min(100%, 560px);
  margin: .5em 0 1em;
  padding: 8px 10px;
  align-self: center;
  box-sizing: border-box;
  border: 1px solid #d8e0e9;
  border-radius: 10px;
  background: #f4f7fa;
}

.control-label {
  color: #60738b;
  font: 700 .6rem/1 system-ui, sans-serif;
  letter-spacing: .1em;
}

.control-hint {
  min-height: 1em;
  color: #60738b;
  font: 500 .58rem/1.2 system-ui, sans-serif;
}

.face-style {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 1.3fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.control-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-field select {
  width: 100%;
  height: 30px;
  border: 1px solid #bcc9d7;
  border-radius: 6px;
  padding: 0 7px;
  color: #223653;
  font-size: .8rem;
  background: #fff;
}

.range-row {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 6px;
}

#face-alpha-range {
  width: 100%;
  margin: 0;
  accent-color: #315f91;
}

.face-alpha-val {
  min-width: 2.5em;
  color: #223653;
  font: 700 .72rem/1 ui-monospace, monospace;
  text-align: right;
}

@media (max-width: 414px) {
  .buttons {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
    padding: 6px;
  }

  .action-button {
    min-height: 48px;
    padding: 4px 2px;
    flex-direction: column;
    gap: 3px;
  }

  .face-style {
    grid-template-columns: minmax(0, 1fr) minmax(110px, 1.2fr) minmax(0, 1fr);
    gap: 6px;
  }

  .face-style-wrapper {
    padding: 7px 8px;
  }

  .control-field select {
    padding: 0 4px;
    font-size: .7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .action-button {
    transition: none;
  }
}

#wrapper {
  position: relative;
  max-width: 100%;
  align-self: center;
}

/* 顔追跡だけに使う映像レイヤーは操作画面に露出させない */
#video,
#canvas {
  top: 0;
  left: 0;
  opacity: 0;
  pointer-events: none;
}

#img-canvas {
  position: absolute;
  inset: 0;
}

#face-canvas {
  position: absolute;
  z-index: 1;
  cursor: grab;
  touch-action: none;
  outline: none;
}

#face-canvas:focus-visible {
  outline: 2px solid #4f5862;
  outline-offset: 2px;
}

#face-canvas.is-dragging {
  outline: 2px solid #737b84;
  outline-offset: 2px;
  cursor: grabbing;
}

@media (hover: hover) {
  #face-canvas:hover {
    outline: 1px dashed #7898b8;
    outline-offset: 2px;
  }
}

.disp-none {
  display: none;
}

.hidden {
  visibility: hidden;
}

#overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  width: 100vw;
  height: 100vh;
  background-color: rgba(255, 255, 255, 1);
}
